use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class FormAttributeDeleteBulkActionIntegrationTest method testProcessBulkActionByFilter.
@Test
public void testProcessBulkActionByFilter() {
List<IdmFormAttributeDto> attributes = createAttributes(5);
IdmFormAttributeFilter filter = new IdmFormAttributeFilter();
filter.setId(attributes.get(2).getId());
List<IdmFormAttributeDto> checkAttributes = service.find(filter, null).getContent();
Assert.assertEquals(1, checkAttributes.size());
IdmBulkActionDto bulkAction = findBulkAction(IdmFormAttribute.class, FormAttributeDeleteBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
Assert.assertNull(service.get(attributes.get(2)));
Assert.assertNotNull(service.get(attributes.get(1)));
Assert.assertNotNull(service.get(attributes.get(3)));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method otherStuffClenaup.
private void otherStuffClenaup() {
// script cleanup
IdmScriptDto dto = scriptService.getByCode(stringToLocalDateScript);
scriptService.delete(dto);
dto = scriptService.getByCode(getIdentityUuidByPersonalNumScript);
scriptService.delete(dto);
// generator setting removal
IdmGenerateValueFilter generatorFilter = new IdmGenerateValueFilter();
generatorFilter.setDtoType(IdmIdentityDto.class.getCanonicalName());
generatedAttributeService.find(generatorFilter, null).getContent().stream().filter(gen -> IdentityUsernameGenerator.class.getCanonicalName().equals(gen.getGeneratorType())).forEach(gen -> {
generatedAttributeService.delete(gen);
});
generatedAttributeService.find(generatorFilter, null).getContent().stream().filter(gen -> IdentityEmailGenerator.class.getCanonicalName().equals(gen.getGeneratorType())).forEach(gen -> {
generatedAttributeService.delete(gen);
});
// identity EAV
IdmFormAttributeFilter formAttrFilt = new IdmFormAttributeFilter();
formAttrFilt.setCode(eavAutoRoleAttrName);
List<IdmFormAttributeDto> attrs = formAttrService.find(formAttrFilt, null).getContent();
attrs.forEach(attr -> {
// if deleted after identity is deleted, no value remains
formService.deleteAttribute(attr);
});
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method addEavIdentityContractFormDef.
/**
* Creating required contract EAV attribute for the purpose of automatic roles assignment
*/
private void addEavIdentityContractFormDef() {
IdmFormDefinitionFilter filt = new IdmFormDefinitionFilter();
filt.setType(IdmIdentityContract.class.getCanonicalName());
filt.setMain(true);
IdmFormDefinitionDto formDef = formDefService.find(filt, null).getContent().get(0);
IdmFormAttributeFilter formAttrFilt = new IdmFormAttributeFilter();
formAttrFilt.setCode(eavAutoRoleAttrName);
formAttrFilt.setDefinitionId(formDef.getId());
if (formAttrService.count(formAttrFilt) > 0) {
// already created
return;
}
IdmFormAttributeDto formAttr = new IdmFormAttributeDto();
formAttr.setCode(eavAutoRoleAttrName);
formAttr.setName(eavAutoRoleAttrName);
formAttr.setPersistentType(PersistentType.SHORTTEXT);
formAttr.setFormDefinition(formDef.getId());
formAttrService.save(formAttr);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter in project CzechIdMng by bcvsolutions.
the class ComplexHrProcessIntegrationTest method createAutoRoleByAttribute.
/**
* Defines automatic roles assigned based on contract attribute
*/
private void createAutoRoleByAttribute() {
IdmAutomaticRoleAttributeRuleDto attrRule = new IdmAutomaticRoleAttributeRuleDto();
IdmFormAttributeDto formAttr = null;
IdmAutomaticRoleAttributeDto roleAtt = null;
IdmFormAttributeFilter formAttrFilt = new IdmFormAttributeFilter();
formAttrFilt.setCode(eavAutoRoleAttrName);
formAttr = formAttrService.find(formAttrFilt, null).getContent().get(0);
// common part
attrRule.setComparison(AutomaticRoleAttributeRuleComparison.EQUALS);
attrRule.setType(AutomaticRoleAttributeRuleType.CONTRACT_EAV);
attrRule.setAttributeName(formAttr.getName());
attrRule.setFormAttribute(formAttr.getId());
// Consultant autorole
roleAtt = new IdmAutomaticRoleAttributeDto();
roleAtt.setRole(roleService.getByCode(consultantBusinessRole).getId());
roleAtt.setName("Consultant autorole");
roleAtt = autoRoleAttrService.save(roleAtt);
attrRule.setValue(consultantPositionName);
attrRule.setAutomaticRoleAttribute(roleAtt.getId());
attrRule = autoRoleAttrRuleService.save(attrRule);
// concept needs to be set to false after rule's been saved
roleAtt.setConcept(false);
roleAtt = autoRoleAttrService.save(roleAtt);
// Director autorole
roleAtt = new IdmAutomaticRoleAttributeDto();
roleAtt.setRole(roleService.getByCode(adGroupDirectorRole).getId());
roleAtt.setName("Director autorole");
roleAtt = autoRoleAttrService.save(roleAtt);
attrRule.setId(null);
attrRule.setValue(directorPositionName);
attrRule.setAutomaticRoleAttribute(roleAtt.getId());
attrRule = autoRoleAttrRuleService.save(attrRule);
// concept needs to be set to false after rule's been saved
roleAtt.setConcept(false);
roleAtt = autoRoleAttrService.save(roleAtt);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter 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);
}
Aggregations