use of eu.bcvsolutions.idm.core.eav.api.event.FormDefinitionEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmFormDefinitionService method saveInternal.
/**
* Fill default definition code and name, if no code / name is given.
*/
@Override
@Transactional
public IdmFormDefinitionDto saveInternal(IdmFormDefinitionDto dto) {
if (StringUtils.isEmpty(dto.getCode())) {
dto.setMain(true);
dto.setCode(DEFAULT_DEFINITION_CODE);
}
if (StringUtils.isEmpty(dto.getName())) {
dto.setName(dto.getCode());
}
if (dto.isMain()) {
IdmFormDefinitionDto mainDefinition = findOneByMain(dto.getType());
if (mainDefinition != null && !mainDefinition.getId().equals(dto.getId())) {
mainDefinition.setMain(false);
//
FormDefinitionEvent formDefinitionEvent = new FormDefinitionEvent(FormDefinitionEventType.UPDATE, mainDefinition);
// We don't need validation - main definition is set in the same transaction bellow.
formDefinitionEvent.getProperties().put(FormService.SKIP_EAV_VALIDATION, Boolean.TRUE);
//
publish(formDefinitionEvent);
}
}
//
return super.saveInternal(dto);
}
use of eu.bcvsolutions.idm.core.eav.api.event.FormDefinitionEvent in project CzechIdMng by bcvsolutions.
the class FormDefinitionDeleteBulkAction method processDto.
@Override
protected OperationResult processDto(IdmFormDefinitionDto formDefinition) {
try {
FormDefinitionEvent event = new FormDefinitionEvent(FormDefinitionEventType.DELETE, formDefinition, new ConfigurationMap(getProperties()).toMap());
event.setPriority(PriorityType.HIGH);
service.publish(event);
//
return new OperationResult.Builder(OperationState.EXECUTED).build();
} catch (ResultCodeException ex) {
return new OperationResult.Builder(OperationState.EXCEPTION).setException(ex).build();
} catch (Exception ex) {
Throwable resolvedException = ExceptionUtils.resolveException(ex);
if (resolvedException instanceof ResultCodeException) {
return //
new OperationResult.Builder(OperationState.EXCEPTION).setException(//
(ResultCodeException) resolvedException).build();
}
return new OperationResult.Builder(OperationState.EXCEPTION).setCause(ex).build();
}
}
Aggregations