use of eu.bcvsolutions.idm.core.eav.api.event.FormAttributeEvent in project CzechIdMng by bcvsolutions.
the class FormDefinitionDeleteProcessor method process.
@Override
public EventResult<IdmFormDefinitionDto> process(EntityEvent<IdmFormDefinitionDto> event) {
IdmFormDefinitionDto formDefinition = event.getContent();
UUID id = formDefinition.getId();
Assert.notNull(id, "Form definition identifier is required for delete.");
//
boolean forceDelete = getBooleanProperty(PROPERTY_FORCE_DELETE, event.getProperties());
if (forceDelete) {
//
// delete all attributes in definition
IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
filter.setDefinitionId(id);
formAttributeService.find(filter, null).forEach(formAttribute -> {
Map<String, Serializable> properties = new HashMap<>();
// force
properties.put(EntityEventProcessor.PROPERTY_FORCE_DELETE, Boolean.TRUE);
FormAttributeEvent formAttributeEvent = new FormAttributeEvent(FormAttributeEventType.DELETE, formAttribute, properties);
//
formAttributeService.publish(formAttributeEvent, event);
});
}
//
formDefinitionService.deleteInternal(formDefinition);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.eav.api.event.FormAttributeEvent in project CzechIdMng by bcvsolutions.
the class FormAttributeDeleteBulkAction method processDto.
@Override
protected OperationResult processDto(IdmFormAttributeDto formAttribute) {
try {
FormAttributeEvent event = new FormAttributeEvent(FormAttributeEventType.DELETE, formAttribute, 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