use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncB_Linked_doEntityUpdate_Filtered.
@Test
public /**
* We will do synchronize with use inner connector synch function.
*/
void doStartSyncB_Linked_doEntityUpdate_Filtered() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
this.getBean().changeResourceData();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
SysSystemMappingDto systemMapping = systemMappingService.get(syncConfigCustom.getSystemMapping());
SysSystemDto system = systemService.get(schemaObjectClassService.get(systemMapping.getObjectClass()).getSystem());
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system.getConnectorInstance());
IdmFormAttributeDto changeLogColumn = savedFormDefinition.getMappedAttributeByCode("changeLogColumn");
formService.saveValues(system, changeLogColumn, ImmutableList.of("modified"));
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setCustomFilter(false);
syncConfigCustom.setReconciliation(false);
// We want do sync for account changed in future
syncConfigCustom.setToken(LocalDateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
// We don`t use custom filter. This option will be not used.
syncConfigCustom.setFilterOperation(IcFilterOperationType.ENDS_WITH);
syncConfigService.save(syncConfigCustom);
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(1, actions.size());
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(1, items.size());
Assert.assertEquals("x" + IDENTITY_USERNAME_TWO, items.get(0).getIdentification());
// Delete log
syncLogService.delete(log);
// We have to change property of connector configuration "changeLogColumn" from "modified" on empty string.
// When is this property set, then custom filter not working. Bug in Table connector !!!
formService.saveValues(system, changeLogColumn, ImmutableList.of(""));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultFormService method createDefinition.
@Override
@Transactional
public IdmFormDefinitionDto createDefinition(String type, String code, List<IdmFormAttributeDto> formAttributes) {
Assert.hasLength(type);
//
// create definition
IdmFormDefinitionDto formDefinition = new IdmFormDefinitionDto();
formDefinition.setType(type);
formDefinition.setCode(code);
formDefinition = formDefinitionService.save(formDefinition);
// and their attributes
if (formAttributes != null) {
Short seq = 0;
for (IdmFormAttributeDto formAttribute : formAttributes) {
// default attribute order
if (formAttribute.getSeq() == null) {
formAttribute.setSeq(seq);
seq++;
}
formAttribute.setFormDefinition(formDefinition.getId());
formAttribute = formAttributeService.save(formAttribute);
formDefinition.addFormAttribute(formAttribute);
}
}
return formDefinition;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultFormService method convertConfigurationToFormDefinition.
/**
* Create instance form definition from the given configuration class
*
* @param configurationClass
* @return
*/
@Override
public IdmFormDefinitionDto convertConfigurationToFormDefinition(Class<? extends ConfigurationClass> configurationClass) {
Assert.notNull(configurationClass, "Class with the configuration is required!");
try {
ConfigurationClass configurationClassInstance = configurationClass.newInstance();
List<IdmFormAttributeDto> properties = new ArrayList<>();
PropertyDescriptor[] descriptors = Introspector.getBeanInfo(configurationClass).getPropertyDescriptors();
Lists.newArrayList(descriptors).stream().forEach(descriptor -> {
Method readMethod = descriptor.getReadMethod();
String propertyName = descriptor.getName();
ConfigurationClassProperty property = readMethod.getAnnotation(ConfigurationClassProperty.class);
if (property != null) {
IdmFormAttributeDto formAttribute = this.convertConfigurationProperty(property);
formAttribute.setCode(propertyName);
// TODO: Better convertors (move from IC and ACC module to the Core)!
initPersistentType(readMethod, formAttribute);
try {
formAttribute.setDefaultValue(this.convertDefaultValue(readMethod.invoke(configurationClassInstance), formAttribute.isMultiple()));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new CoreException("Cannot read value of connector configuration property!", e);
}
properties.add(formAttribute);
}
});
IdmFormDefinitionDto definition = new IdmFormDefinitionDto();
definition.setFormAttributes(properties);
return definition;
} catch (IntrospectionException | InstantiationException | IllegalAccessException e) {
throw new CoreException("Cannot read configuration property!", e);
}
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultFormService method convertConfigurationProperty.
private IdmFormAttributeDto convertConfigurationProperty(ConfigurationClassProperty property) {
if (property == null) {
return null;
}
IdmFormAttributeDto icProperty = new IdmFormAttributeDto();
icProperty.setConfidential(property.confidential());
icProperty.setName(property.displayName());
icProperty.setDescription(property.helpMessage());
icProperty.setRequired(property.required());
icProperty.setSeq((short) property.order());
icProperty.setFaceType(property.face());
return icProperty;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto in project CzechIdMng by bcvsolutions.
the class DefaultFormService method findOwners.
@Override
@Transactional(readOnly = true)
public <O extends BaseDto> Page<O> findOwners(Class<? extends Identifiable> ownerType, String attributeName, Serializable persistentValue, Pageable pageable) {
IdmFormAttributeDto attribute = getAttribute(ownerType, attributeName);
Assert.notNull(attribute, MessageFormat.format("Attribute [{0}] does not exist in default form definition for owner [{1}]", attributeName, ownerType));
//
return findOwners(ownerType, attribute, persistentValue, pageable);
}
Aggregations