RED-8762: added endpoint to update flag addToDictionary for given type, dossierTemplateId and dossierId
This commit is contained in:
parent
f870759747
commit
623068e1a1
@ -22,12 +22,10 @@ import org.springframework.web.bind.annotation.RequestPart;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.AccessControlService;
|
|
||||||
import com.knecon.fforesight.keycloakcommons.security.KeycloakSecurity;
|
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.AccessControlService;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.DictionaryService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.DictionaryService;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.AuditPersistenceService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.AuditPersistenceService;
|
||||||
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
|
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.utils.StringEncodingUtils;
|
import com.iqser.red.service.persistence.management.v1.processor.utils.StringEncodingUtils;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.utils.TypeValueMapper;
|
import com.iqser.red.service.persistence.management.v1.processor.utils.TypeValueMapper;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.external.resource.DictionaryResource;
|
import com.iqser.red.service.persistence.service.v1.api.external.resource.DictionaryResource;
|
||||||
@ -41,6 +39,8 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.audit.Audit
|
|||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.Colors;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.Colors;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
|
||||||
|
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
|
||||||
|
import com.knecon.fforesight.keycloakcommons.security.KeycloakSecurity;
|
||||||
|
|
||||||
import feign.FeignException;
|
import feign.FeignException;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@ -322,4 +322,14 @@ public class DictionaryController implements DictionaryResource {
|
|||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeFlags(@PathVariable(TYPE_PARAMETER_NAME) String type,
|
||||||
|
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||||
|
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME) String dossierId,
|
||||||
|
@RequestParam(value = "addToDictionary") boolean addToDictionary) {
|
||||||
|
|
||||||
|
dictionaryService.changeAddToDictionary(type, dossierTemplateId, dossierId, addToDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,8 @@ public interface DictionaryResource {
|
|||||||
String MERGED = "/merged";
|
String MERGED = "/merged";
|
||||||
String DELETE = "/delete";
|
String DELETE = "/delete";
|
||||||
|
|
||||||
|
String UPDATE_FLAG = "/updateFlag";
|
||||||
|
|
||||||
String COLOR_REST_PATH = ExternalApi.BASE_PATH + "/color";
|
String COLOR_REST_PATH = ExternalApi.BASE_PATH + "/color";
|
||||||
|
|
||||||
String DOSSIER_ID_PARAMETER_NAME = "dossierId";
|
String DOSSIER_ID_PARAMETER_NAME = "dossierId";
|
||||||
@ -196,4 +198,14 @@ public interface DictionaryResource {
|
|||||||
@GetMapping(value = COLOR_REST_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = COLOR_REST_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
Colors getColors(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);
|
Colors getColors(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);
|
||||||
|
|
||||||
}
|
|
||||||
|
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||||
|
@PostMapping(value = DICTIONARY_REST_PATH + UPDATE_FLAG + TYPE_PATH_VARIABLE + DOSSIER_TEMPLATE_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@Operation(summary = "Updates flags regarding to selected type, dossier and dossier template.", description = "None")
|
||||||
|
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Successfully updated the flags of the type."), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The entry type is not found.")})
|
||||||
|
void changeFlags(@PathVariable(TYPE_PARAMETER_NAME) String type,
|
||||||
|
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||||
|
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME) String dossierId,
|
||||||
|
@RequestParam(value = "addToDictionary") boolean addToDictionary);
|
||||||
|
|
||||||
|
}
|
||||||
@ -227,7 +227,7 @@ public class DictionaryService {
|
|||||||
accessControlService.verifyUserHasViewPermissions(dossierId);
|
accessControlService.verifyUserHasViewPermissions(dossierId);
|
||||||
dictionaryManagementService.checkDossierMatchesDossierTemplate(dossierId, dossierTemplateId);
|
dictionaryManagementService.checkDossierMatchesDossierTemplate(dossierId, dossierTemplateId);
|
||||||
// for every dossier template type check if a dossier type exists
|
// for every dossier template type check if a dossier type exists
|
||||||
types.forEach(t -> dictionaryManagementService.checkForDossierTypeExistenceAndCreate(toTypeId(t.getType(), t.getDossierTemplateId(), dossierId),includeDeleted));
|
types.forEach(t -> dictionaryManagementService.checkForDossierTypeExistenceAndCreate(toTypeId(t.getType(), t.getDossierTemplateId(), dossierId), includeDeleted));
|
||||||
types.addAll(MagicConverter.convert(dictionaryPersistenceService.getAllTypesForDossier(dossierId, includeDeleted), Type.class));
|
types.addAll(MagicConverter.convert(dictionaryPersistenceService.getAllTypesForDossier(dossierId, includeDeleted), Type.class));
|
||||||
} catch (AccessDeniedException e) {
|
} catch (AccessDeniedException e) {
|
||||||
log.debug(" Don't include the types for the dossier id");
|
log.debug(" Don't include the types for the dossier id");
|
||||||
@ -431,4 +431,15 @@ public class DictionaryService {
|
|||||||
return MagicConverter.convert(colorsService.getColors(dossierTemplateId), Colors.class);
|
return MagicConverter.convert(colorsService.getColors(dossierTemplateId), Colors.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void changeAddToDictionary(String type, String dossierTemplateId, String dossierId, boolean addToDictionary) {
|
||||||
|
|
||||||
|
var typeEntity = dictionaryPersistenceService.getType(toTypeId(type, dossierTemplateId, dossierId));
|
||||||
|
if (typeEntity.isDossierDictionaryOnly()) {
|
||||||
|
typeEntity.setAddToDictionaryAction(addToDictionary);
|
||||||
|
dictionaryPersistenceService.saveType(typeEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -279,6 +279,12 @@ public class DictionaryPersistenceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void saveType(TypeEntity type) {
|
||||||
|
|
||||||
|
typeRepository.saveAndFlush(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public int undeleteType(String typeId) {
|
public int undeleteType(String typeId) {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user