use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class DefaultFormService method getAttributes.
@Override
@Transactional(readOnly = true)
public List<IdmFormAttributeDto> getAttributes(IdmFormDefinitionDto formDefinition, BasePermission... permission) {
Assert.notNull(formDefinition, "Form definition is required.");
//
if (PermissionUtils.isEmpty(permission)) {
IdmFormDefinitionDto cachedDefinition = getCachedDefinition(formDefinition.getId());
if (cachedDefinition != null) {
// sorted already
return cachedDefinition.getFormAttributes();
}
}
//
IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
filter.setDefinitionType(formDefinition.getType());
filter.setDefinitionCode(formDefinition.getCode());
//
return formAttributeService.find(filter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmFormAttribute_.seq.getName())), permission).getContent();
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmFormDefinitionService method toDto.
@Override
protected IdmFormDefinitionDto toDto(IdmFormDefinition entity, IdmFormDefinitionDto dto) {
dto = super.toDto(entity, dto);
if (dto == null) {
return null;
}
//
if (!dto.isTrimmed()) {
// set mapped attributes - required to cache form definition with attributes
IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
filter.setDefinitionId(dto.getId());
dto.setFormAttributes(formAttributeService.find(filter, getPageableAll(Sort.by(IdmFormAttribute_.seq.getName(), IdmFormAttribute_.name.getName()))).getContent());
LOG.trace("Form attributes were loaded for definition [{},{}]", dto.getType(), dto.getCode());
}
//
return dto;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmFormDefinitionService method deleteInternal.
@Override
@Transactional
public void deleteInternal(IdmFormDefinitionDto dto) {
Assert.notNull(dto, "Form definition is required for delete.");
UUID id = dto.getId();
Assert.notNull(id, "Form definition identifier is required for delete.");
//
// delete all attributes in definition
IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
filter.setDefinitionId(id);
formAttributeService.find(filter, null).forEach(formAttribute -> {
formAttributeService.delete(formAttribute);
});
//
IdmRoleFilter roleFilter = new IdmRoleFilter();
roleFilter.setAttributeFormDefinitionId(id);
List<IdmRoleDto> roles = roleService.find(roleFilter, PageRequest.of(0, 1)).getContent();
if (roles.size() > 0) {
throw new ResultCodeException(CoreResultCode.FORM_DEFINITION_DELETE_FAILED_ROLE, ImmutableMap.of("definition", dto.getCode(), "role", roles.get(0).getCode()));
}
super.deleteInternal(dto);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmFormDefinitionService method export.
@Override
public void export(UUID id, IdmExportImportDto batch) {
super.export(id, batch);
// Export form attributes
IdmFormAttributeFilter systemMappingFilter = new IdmFormAttributeFilter();
systemMappingFilter.setDefinitionId(id);
List<IdmFormAttributeDto> attributes = formAttributeService.find(systemMappingFilter, null).getContent();
if (attributes.isEmpty()) {
formAttributeService.export(ExportManager.BLANK_UUID, batch);
}
attributes.forEach(mapping -> {
formAttributeService.export(mapping.getId(), batch);
// Authoritative mode is not set here only parent field could be sets.
ExportDescriptorDto descriptor = getExportManager().getDescriptor(batch, mapping.getClass());
if (descriptor != null) {
descriptor.getParentFields().add(IdmFormAttribute_.formDefinition.getName());
}
});
}
Aggregations