RED-10463: unlock rule file endpoint
This commit is contained in:
parent
aaa87c7a74
commit
ed3ee8b2d2
@ -160,4 +160,11 @@ public class RulesController implements RulesResource {
|
||||
return new ResponseEntity<>(new InputStreamResource(is), httpHeaders, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unlockRules(String dossierTemplateId, RuleFileType ruleFileType) {
|
||||
|
||||
rulesPersistenceService.resetTimeoutDetected(dossierTemplateId, ruleFileType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
@ -105,4 +106,10 @@ public interface RulesResource {
|
||||
@GetMapping(value = RULES_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE + RULE_FILE_TYPE_PATH_VARIABLE + DOWNLOAD_PATH)
|
||||
ResponseEntity<?> downloadFile(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @PathVariable(RULE_FILE_TYPE_PARAMETER_NAME) RuleFileType ruleFileType);
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@Operation(summary = "Resets the timeout detected flag in a Rule file.")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "No content")})
|
||||
@PutMapping(value = RULES_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE + RULE_FILE_TYPE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
void unlockRules(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @PathVariable(RULE_FILE_TYPE_PARAMETER_NAME) RuleFileType ruleFileType);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.RuleSetEntity;
|
||||
@ -20,11 +21,11 @@ public class RulesPersistenceService {
|
||||
|
||||
public static final String DEFAULT_RULES = """
|
||||
package drools
|
||||
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility.anyMatch;
|
||||
import static com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility.exactMatch;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
@ -32,7 +33,7 @@ public class RulesPersistenceService {
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.*;
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.TextRange;
|
||||
import com.iqser.red.service.redaction.v1.server.model.document.entity.*;
|
||||
@ -65,7 +66,7 @@ public class RulesPersistenceService {
|
||||
import com.iqser.red.service.redaction.v1.server.service.document.EntityCreationService;
|
||||
import com.iqser.red.service.redaction.v1.server.service.ManualChangesApplicationService;
|
||||
import com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility;
|
||||
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Engine;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualResizeRedaction;
|
||||
@ -73,20 +74,20 @@ public class RulesPersistenceService {
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRecategorization;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualLegalBasisChange;
|
||||
|
||||
|
||||
global Document document
|
||||
global EntityCreationService entityCreationService
|
||||
global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
|
||||
query "getFileAttributes"
|
||||
$fileAttribute: FileAttribute()
|
||||
end
|
||||
|
||||
|
||||
//------------------------------------ Local dictionary search rules ------------------------------------
|
||||
|
||||
|
||||
// Rule unit: LocalDictionarySearch.0
|
||||
rule "LDS.0.0: run local dictionary search"
|
||||
agenda-group "LOCAL_DICTIONARY_ADDS"
|
||||
@ -140,6 +141,7 @@ public class RulesPersistenceService {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setRules(@NonNull String rules, String dossierTemplateId, RuleFileType ruleFileType, long version, boolean timeoutDetected) {
|
||||
|
||||
@ -147,7 +149,8 @@ public class RulesPersistenceService {
|
||||
ruleSet.setDossierTemplateId(dossierTemplateId);
|
||||
ruleSet.setRuleFileType(ruleFileType.name());
|
||||
ruleSet.setValue(rules);
|
||||
ruleSet.setVersion(ruleSet.getVersion() + 1); // Setting rules version in existing dossier template will break analysis, if there are files with higher versions in entity log. So only increment.
|
||||
// Setting rules version in existing dossier template will break analysis, if there are files with higher versions in entity log. So only increment.
|
||||
ruleSet.setVersion(ruleSet.getVersion() + 1);
|
||||
ruleSet.setTimeoutDetected(timeoutDetected);
|
||||
}, () -> {
|
||||
RuleSetEntity ruleSet = new RuleSetEntity();
|
||||
@ -164,7 +167,14 @@ public class RulesPersistenceService {
|
||||
@Transactional
|
||||
public void setTimeoutDetected(String dossierTemplateId, RuleFileType ruleFileType) {
|
||||
|
||||
ruleSetRepository.updateTimeoutDetected(dossierTemplateId, ruleFileType.name());
|
||||
ruleSetRepository.updateTimeoutDetected(dossierTemplateId, ruleFileType.name(), true);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void resetTimeoutDetected(String dossierTemplateId, RuleFileType ruleFileType) {
|
||||
|
||||
ruleSetRepository.updateTimeoutDetected(dossierTemplateId, ruleFileType.name(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.configur
|
||||
public interface RuleSetRepository extends JpaRepository<RuleSetEntity, RuleSetEntityKey> {
|
||||
|
||||
@Modifying
|
||||
@Query("update RuleSetEntity r set r.timeoutDetected = true where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
|
||||
void updateTimeoutDetected(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType);
|
||||
@Query("update RuleSetEntity r set r.timeoutDetected = :timeoutDetected where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
|
||||
void updateTimeoutDetected(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType, @Param("timeoutDetected") boolean timeoutDetected);
|
||||
|
||||
@Modifying
|
||||
@Query("update RuleSetEntity r set r.version = :version where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
|
||||
@ -27,4 +27,5 @@ public interface RuleSetRepository extends JpaRepository<RuleSetEntity, RuleSetE
|
||||
@Query("select r.version from RuleSetEntity r where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
|
||||
Optional<Long> findVersionByDossierTemplateIdAndRuleFileType(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user