use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.
the class IdmContractSliceController method getFormValues.
/**
* Returns entity's filled form values
*
* @param backendId
* @return
*/
@ResponseBody
@RequestMapping(value = "/{backendId}/form-values", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.CONTRACTSLICE_READ + "')")
@ApiOperation(value = "Contract slice form definition - read values", nickname = "getIdentityContractFormValues", tags = { IdmContractSliceController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.CONTRACTSLICE_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.CONTRACTSLICE_READ, description = "") }) })
public Resource<?> getFormValues(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Code of form definition (default will be used if no code is given).", required = false, defaultValue = FormService.DEFAULT_DEFINITION_CODE) @RequestParam(name = "definitionCode", required = false) String definitionCode) {
IdmContractSliceDto dto = getDto(backendId);
if (dto == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
//
checkAccess(dto, IdmBasePermission.READ);
//
IdmFormDefinitionDto formDefinition = formDefinitionController.getDefinition(IdmIdentityContract.class, definitionCode);
//
return formDefinitionController.getFormValues(dto, formDefinition);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.
the class IdmContractSliceController method saveFormValue.
/**
* Save entity's form value
*
* @param backendId
* @param formValues
* @return
* @since 9.4.0
*/
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.CONTRACTSLICE_UPDATE + "')")
@RequestMapping(value = "/{backendId}/form-value", method = { RequestMethod.POST })
@ApiOperation(value = "Role form definition - save value", nickname = "postRoleFormValue", tags = { IdmContractSliceController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.CONTRACTSLICE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.CONTRACTSLICE_UPDATE, description = "") }) })
public Resource<?> saveFormValue(@ApiParam(value = "Slice's uuid identifier.", required = true) @PathVariable @NotNull String backendId, @RequestBody @Valid IdmFormValueDto formValue) {
IdmContractSliceDto dto = getDto(backendId);
if (dto == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
checkAccess(dto, IdmBasePermission.UPDATE);
//
return formDefinitionController.saveFormValue(dto, formValue);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.
the class IdmContractSliceController method saveFormValues.
/**
* Saves entity's form values
*
* @param backendId
* @param formValues
* @return
*/
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.CONTRACTSLICE_UPDATE + "')")
@RequestMapping(value = "/{backendId}/form-values", method = { RequestMethod.POST, RequestMethod.PATCH })
@ApiOperation(value = "Contract slice form definition - save values", nickname = "postIdentityContractFormValues", tags = { IdmContractSliceController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.CONTRACTSLICE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.CONTRACTSLICE_UPDATE, description = "") }) })
public Resource<?> saveFormValues(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Code of form definition (default will be used if no code is given).", required = false, defaultValue = FormService.DEFAULT_DEFINITION_CODE) @RequestParam(name = "definitionCode", required = false) String definitionCode, @ApiParam(value = "Filled form data.", required = true) @RequestBody @Valid List<IdmFormValueDto> formValues) {
IdmContractSliceDto dto = getDto(backendId);
if (dto == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
//
checkAccess(dto, IdmBasePermission.UPDATE);
//
IdmFormDefinitionDto formDefinition = formDefinitionController.getDefinition(IdmIdentityContract.class, definitionCode);
//
return formDefinitionController.saveFormValues(dto, formDefinition, formValues);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.
the class ClearDirtyStateForContractSliceTaskExecutor method processItem.
/**
* Process one dirty state for contract slice
*
* @param dirtyState
*/
private void processItem(IdmEntityStateDto dirtyState) {
try {
if (dirtyState.getOwnerType() == null || !dirtyState.getOwnerType().equals(IdmContractSlice.class.getName())) {
this.logItemProcessed(dirtyState, new OperationResult.Builder(OperationState.NOT_EXECUTED).build());
return;
}
IdmContractSliceDto contractSliceDto = (IdmContractSliceDto) dirtyState.getEmbedded().get(CURRENT_SLICE);
if (contractSliceDto == null) {
contractSliceDto = contractSliceService.get(dirtyState.getOwnerId());
}
if (contractSliceDto == null) {
DefaultResultModel model = new DefaultResultModel(CoreResultCode.NOT_FOUND, ImmutableMap.of("ownerId", dirtyState.getOwnerId()));
this.logItemProcessed(dirtyState, new OperationResult.Builder(OperationState.NOT_EXECUTED).setModel(model).build());
return;
}
ResultModel resultModel = dirtyState.getResult().getModel();
Map<String, Object> parameters = new HashMap<>();
if (resultModel != null) {
parameters = resultModel.getParameters();
}
IdmContractSliceDto originalSlice = null;
Object originalSliceAsObject = parameters.get(ORIGINAL_SLICE);
if (originalSliceAsObject instanceof IdmContractSliceDto) {
originalSlice = (IdmContractSliceDto) originalSliceAsObject;
}
// Transform saved parameters into map string and serializable value
Map<String, Serializable> transformedParameters = transformParameters(parameters);
// Current using flag was sets to FALSE (during making as dirty), we want to force recalculate
transformedParameters.put(IdmContractSliceService.FORCE_RECALCULATE_CURRENT_USING_SLICE, Boolean.TRUE);
// Provisioning skip have to by removed. We need to make a provisioning in this phase.
// Workaround - skip provisioning is from the ACC module, but work with slices and dirty states is only in core. So this is safe way how remove a skip property.
transformedParameters.put(SKIP_PROVISIONING, Boolean.FALSE);
contractSliceManager.recalculateContractSlice(contractSliceDto, originalSlice, transformedParameters);
this.logItemProcessed(contractSliceDto, new OperationResult.Builder(OperationState.EXECUTED).build());
entityStateManager.deleteState(dirtyState);
} catch (Exception e) {
this.logItemProcessed(dirtyState, new OperationResult.Builder(OperationState.EXCEPTION).setCause(e).build());
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto in project CzechIdMng by bcvsolutions.
the class SelectCurrentContractSliceTaskExecutor method process.
@Override
@Transactional
public OperationResult process() {
// Found all unvalid slices
List<IdmContractSliceDto> unvalidSlices = contractSliceManager.findUnvalidSlices(null).getContent();
boolean canContinue = true;
//
this.counter = 0L;
this.count = Long.valueOf(unvalidSlices.size());
StringBuilder duplicitiesMessage = null;
List<UUID> invalidContracts = new ArrayList<>();
for (IdmContractSliceDto slice : unvalidSlices) {
// Start recalculation
List<IdmContractSliceDto> duplicatedSlices = //
unvalidSlices.stream().filter(//
s -> s.getParentContract() != null && s.getParentContract().equals(slice.getParentContract())).collect(Collectors.toList());
if (duplicatedSlices.size() > 1) {
String errorMsg = MessageFormat.format("We found more then once slice [{1}] which should be use as contract. This is not allowed. None from this slices will be used as contract. It means contract [{0}] is in incorrect state now!", slice.getParentContract(), duplicatedSlices.size());
LOG.warn(errorMsg);
if (duplicitiesMessage == null) {
duplicitiesMessage = new StringBuilder();
}
if (!invalidContracts.contains(slice.getParentContract())) {
duplicitiesMessage.append(slice.getParentContract()).append(',');
invalidContracts.add(slice.getParentContract());
}
} else {
contractSliceManager.setSliceAsCurrentlyUsing(slice, null);
//
counter++;
}
canContinue = updateState();
if (!canContinue) {
break;
}
}
if (duplicitiesMessage != null) {
return new OperationResult.Builder(OperationState.EXCEPTION).setException(new ResultCodeException(CoreResultCode.CONTRACT_SLICE_DUPLICATE_CANDIDATES, ImmutableMap.of("contracts", duplicitiesMessage.toString()))).build();
}
return new OperationResult.Builder(OperationState.EXECUTED).build();
}
Aggregations