use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method createMapping.
private void createMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
schemaAttributesPage.forEach(schemaAttr -> {
if ("id".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setUid(true);
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
// it is for link and update situation
attributeHandlingName.setIdmPropertyName(IdmIdentityContract_.description.getName());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("name".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("position");
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("owner".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_IDENTITY_FIELD);
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("workposition".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_WORK_POSITION_FIELD);
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("state".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_STATE_FIELD);
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setTransformFromResourceScript("return scriptEvaluator.evaluate(\n" + " scriptEvaluator.newBuilder()\n" + " .setScriptCode('compileIdentityRelationState')\n" + " .addParameter('scriptEvaluator', scriptEvaluator)\n" + " .addParameter('attributeValue', attributeValue)\n" + " .addParameter('icAttributes', icAttributes)\n" + " .addParameter('system', system)\n" + " .build());");
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("leader".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName(ContractSynchronizationExecutor.CONTRACT_GUARANTEES_FIELD);
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("modified".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setEntityAttribute(false);
attributeHandlingName.setExtendedAttribute(false);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("validfrom".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setIdmPropertyName("validFrom");
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setExtendedAttribute(false);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
attributeHandlingName.setTransformFromResourceScript("return attributeValue == null ? null : org.joda.time.LocalDate.parse(attributeValue);");
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("validtill".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setIdmPropertyName("validTill");
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setExtendedAttribute(false);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
attributeHandlingName.setTransformFromResourceScript("return attributeValue == null ? null : org.joda.time.LocalDate.parse(attributeValue);");
schemaAttributeMappingService.save(attributeHandlingName);
} else if ("description".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeHandlingName = new SysSystemAttributeMappingDto();
attributeHandlingName.setIdmPropertyName("description");
attributeHandlingName.setName(schemaAttr.getName());
attributeHandlingName.setEntityAttribute(true);
attributeHandlingName.setSchemaAttribute(schemaAttr.getId());
attributeHandlingName.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeHandlingName);
}
});
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method createMapping.
private void createMapping(SysSystemDto system, final SysSystemMappingDto entityHandlingResult) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
schemaAttributesPage.forEach(schemaAttr -> {
if (ATTRIBUTE_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(true);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName("username");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if ("firstname".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("firstName");
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if ("lastname".equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("lastName");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("email");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(entityHandlingResult.getId());
schemaAttributeMappingService.save(attributeMapping);
}
});
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter in project CzechIdMng by bcvsolutions.
the class PrepareConnectorObjectProcessor method findSchemaAttributes.
/**
* Find list of {@link SysSchemaAttribute} by system and objectClass
*
* @param objectClass
* @param system
* @return
*/
private List<SysSchemaAttributeDto> findSchemaAttributes(SysSystemDto system, SysSchemaObjectClassDto objectClass) {
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
schemaAttributeFilter.setObjectClassId(objectClass.getId());
return schemaAttributeService.find(schemaAttributeFilter, null).getContent();
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountService method getSchemaAttributes.
/**
* Find schema's attributes for the system id and schema name.
*
* @param systemId
* @param schema
* - If is schema name null, then will used default '__ACCOUNT__'.
* @return
*/
private List<SysSchemaAttributeDto> getSchemaAttributes(UUID systemId, String schema) {
SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
schemaFilter.setSystemId(systemId);
schemaFilter.setObjectClassName(schema != null ? schema : IcObjectClassInfo.ACCOUNT);
List<SysSchemaObjectClassDto> schemas = schemaObjectClassService.find(schemaFilter, null).getContent();
if (schemas.size() != 1) {
return null;
}
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setObjectClassId(schemas.get(0).getId());
schemaAttributeFilter.setSystemId(systemId);
return schemaAttributeService.find(schemaAttributeFilter, null).getContent();
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createTestResourceSystem.
@Override
public SysSystemDto createTestResourceSystem(boolean withMapping, String systemName) {
// create test system
SysSystemDto system = createSystem(TestResource.TABLE_NAME, systemName);
//
if (!withMapping) {
return system;
}
//
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
//
SysSystemMappingDto systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setEntityType(SystemEntityType.IDENTITY);
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setObjectClass(objectClasses.get(0).getId());
systemMapping = systemMappingService.save(systemMapping);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
Page<SysSchemaAttributeDto> schemaAttributesPage = schemaAttributeService.find(schemaAttributeFilter, null);
for (SysSchemaAttributeDto schemaAttr : schemaAttributesPage) {
if (ATTRIBUTE_MAPPING_NAME.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(true);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName(IdmIdentity_.username.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_ENABLE.equals(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setUid(false);
attributeMapping.setEntityAttribute(true);
attributeMapping.setIdmPropertyName("disabled");
attributeMapping.setTransformToResourceScript("return String.valueOf(!attributeValue);");
attributeMapping.setTransformFromResourceScript("return !attributeValue;");
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_PASSWORD.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName("password");
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_FIRSTNAME.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.firstName.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_LASTNAME.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.lastName.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
} else if (ATTRIBUTE_MAPPING_EMAIL.equalsIgnoreCase(schemaAttr.getName())) {
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setIdmPropertyName(IdmIdentity_.email.getName());
attributeMapping.setName(schemaAttr.getName());
attributeMapping.setSchemaAttribute(schemaAttr.getId());
attributeMapping.setSystemMapping(systemMapping.getId());
systemAttributeMappingService.save(attributeMapping);
}
}
return system;
}
Aggregations