Search in sources :

Example 1 with FormAttributeEvent

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);
}
Also used : IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) Serializable(java.io.Serializable) HashMap(java.util.HashMap) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) UUID(java.util.UUID) FormAttributeEvent(eu.bcvsolutions.idm.core.eav.api.event.FormAttributeEvent)

Example 2 with FormAttributeEvent

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();
    }
}
Also used : ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) FormAttributeEvent(eu.bcvsolutions.idm.core.eav.api.event.FormAttributeEvent)

Aggregations

FormAttributeEvent (eu.bcvsolutions.idm.core.eav.api.event.FormAttributeEvent)2 ConfigurationMap (eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)1 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IdmFormAttributeFilter (eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter)1 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1