use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method findOwnerByCriteria.
@Test
public void findOwnerByCriteria() {
IdmRoleDto owner = helper.createRole();
IdmRoleDto ownerTwo = helper.createRole();
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmRole.class);
IdmFormAttributeDto attribute = formDefinition.getFormAttributes().get(0);
//
formService.saveValues(owner.getId(), IdmRole.class, attribute, Lists.newArrayList("test"));
formService.saveValues(ownerTwo.getId(), IdmRole.class, attribute, Lists.newArrayList("test2"));
Specification<IdmRole> criteria = new Specification<IdmRole>() {
public Predicate toPredicate(Root<IdmRole> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
Subquery<IdmRoleFormValue> subquery = query.subquery(IdmRoleFormValue.class);
Root<IdmRoleFormValue> subRoot = subquery.from(IdmRoleFormValue.class);
subquery.select(subRoot);
Predicate predicate = builder.and(builder.equal(subRoot.get(IdmRoleFormValue_.owner), root), builder.equal(subRoot.get(IdmRoleFormValue_.formAttribute).get(IdmFormAttribute_.id), attribute.getId()), builder.equal(subRoot.get(IdmRoleFormValue_.stringValue), "test"));
subquery.where(predicate);
//
return query.where(builder.exists(subquery)).getRestriction();
}
};
List<IdmRole> roles = roleRepository.findAll(criteria, (Pageable) null).getContent();
assertEquals(1, roles.size());
assertEquals(owner.getId(), roles.get(0).getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class AbstractWorkingPositionFilterIntegrationTest method createPosition.
private IdmTreeNodeDto createPosition(IdmTreeTypeDto type, IdmTreeNodeDto parent) {
IdmTreeNodeDto node = helper.createTreeNode(type, parent);
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmTreeNode.class, FormService.DEFAULT_DEFINITION_CODE);
IdmFormAttributeDto attr = formDefinition.getMappedAttributeByCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
if (attr == null) {
attr = new IdmFormAttributeDto();
attr.setName("Parent code");
attr.setCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
attr.setFormDefinition(formDefinition.getId());
attr.setPersistentType(PersistentType.TEXT);
attr.setUnmodifiable(true);
attr = formService.saveAttribute(attr);
}
//
formService.saveValues(node, attr, Lists.newArrayList(parent.getCode()));
//
return node;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class AbstractFormPropertyConverter method toFormAttribute.
@Override
public IdmFormAttributeDto toFormAttribute(IcConfigurationProperty propertyConfiguration) {
Assert.notNull(propertyConfiguration);
//
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
attribute.setCode(propertyConfiguration.getName());
attribute.setName(propertyConfiguration.getDisplayName());
attribute.setDescription(propertyConfiguration.getHelpMessage());
attribute.setPersistentType(getFormPropertyType());
attribute.setConfidential(propertyConfiguration.isConfidential());
attribute.setRequired(propertyConfiguration.isRequired());
attribute.setMultiple(isMultiple());
attribute.setDefaultValue(convertDefaultValue(propertyConfiguration));
attribute.setFaceType(propertyConfiguration.getFace());
return attribute;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method updateExtendedAttributes.
/**
* Update extended attribute for given entity. Entity must be persisted first.
*
* @param mappedAttributes
* @param uid
* @param icAttributes
* @param entity
* @param create
* (is create or update entity situation)
* @param context
* @return
*/
@SuppressWarnings("unchecked")
protected DTO updateExtendedAttributes(List<SysSystemAttributeMappingDto> mappedAttributes, String uid, List<IcAttribute> icAttributes, DTO dto, boolean create, SynchronizationContext context) {
mappedAttributes.stream().filter(attribute -> {
// Skip disabled attributes
// Only for extended attributes
boolean fastResult = !attribute.isDisabledAttribute() && attribute.isExtendedAttribute();
if (!fastResult) {
return false;
}
// Can be value set by attribute strategy?
return this.canSetValue(uid, attribute, dto, create);
}).forEach(attribute -> {
String attributeProperty = attribute.getIdmPropertyName();
Object transformedValue = getValueByMappedAttribute(attribute, icAttributes, context);
// Save to extended attribute
if (!formService.isFormable(dto.getClass())) {
String message = MessageFormat.format("Entity [{0}] is not instance of fromable entity!", dto.getId());
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_ERROR_DURING_SYNC_ITEM, ImmutableMap.of("uid", uid, "message", message));
}
IdmFormAttributeDto defAttribute = formService.getDefinition(dto.getClass()).getMappedAttributeByCode(attributeProperty);
if (defAttribute == null) {
// eav definition could be changed
String message = MessageFormat.format("Form attribute defininion [{0}] was not found!", attributeProperty);
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_ERROR_DURING_SYNC_ITEM, ImmutableMap.of("uid", uid, "message", message));
}
if (transformedValue instanceof List<?>) {
((List<?>) transformedValue).stream().forEach(value -> {
if (value != null && !(value instanceof Serializable)) {
String message = MessageFormat.format("Value is not serializable [{0}] for attribute [{1}] and UID [{2}]!", value, attribute, uid);
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_ERROR_DURING_SYNC_ITEM, ImmutableMap.of("uid", uid, "message", message));
}
});
formService.saveValues(dto, defAttribute, (List<Serializable>) transformedValue);
} else {
formService.saveValues(dto, defAttribute, Lists.newArrayList((Serializable) transformedValue));
}
});
return dto;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultRoleCatalogueProvisioningTest method initData.
private void initData() {
// create test system
system = helper.createSystem("test_tree_resource");
system.setName(SYSTEM_NAME);
system = systemService.save(system);
// key to EAV
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system.getConnectorInstance());
IdmFormAttributeDto attributeKeyColumn = savedFormDefinition.getMappedAttributeByCode("keyColumn");
formService.saveValues(system, attributeKeyColumn, ImmutableList.of("ID"));
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
// Create synchronization mapping
SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
syncSystemMapping.setName("default_" + System.currentTimeMillis());
syncSystemMapping.setEntityType(SystemEntityType.ROLE_CATALOGUE);
syncSystemMapping.setOperationType(SystemOperationType.PROVISIONING);
syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
createMapping(system, syncMapping);
}
Aggregations