Merge branch 'RED-10463' into 'master'
RED-10463: unlock rule file endpoint Closes RED-10463 See merge request redactmanager/persistence-service!860
This commit is contained in:
commit
5563c19dca
@ -160,4 +160,11 @@ public class RulesController implements RulesResource {
|
|||||||
return new ResponseEntity<>(new InputStreamResource(is), httpHeaders, HttpStatus.OK);
|
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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
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)
|
@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);
|
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 java.util.Optional;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.RuleSetEntity;
|
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.RuleSetEntity;
|
||||||
@ -140,6 +141,7 @@ public class RulesPersistenceService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void setRules(@NonNull String rules, String dossierTemplateId, RuleFileType ruleFileType, long version, boolean timeoutDetected) {
|
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.setDossierTemplateId(dossierTemplateId);
|
||||||
ruleSet.setRuleFileType(ruleFileType.name());
|
ruleSet.setRuleFileType(ruleFileType.name());
|
||||||
ruleSet.setValue(rules);
|
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);
|
ruleSet.setTimeoutDetected(timeoutDetected);
|
||||||
}, () -> {
|
}, () -> {
|
||||||
RuleSetEntity ruleSet = new RuleSetEntity();
|
RuleSetEntity ruleSet = new RuleSetEntity();
|
||||||
@ -164,7 +167,14 @@ public class RulesPersistenceService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void setTimeoutDetected(String dossierTemplateId, RuleFileType ruleFileType) {
|
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> {
|
public interface RuleSetRepository extends JpaRepository<RuleSetEntity, RuleSetEntityKey> {
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query("update RuleSetEntity r set r.timeoutDetected = true where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :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);
|
void updateTimeoutDetected(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType, @Param("timeoutDetected") boolean timeoutDetected);
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query("update RuleSetEntity r set r.version = :version where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
|
@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")
|
@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);
|
Optional<Long> findVersionByDossierTemplateIdAndRuleFileType(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user