use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.
the class DefaultFormService method getFormInstance.
@Override
@Transactional(readOnly = true)
public IdmFormInstanceDto getFormInstance(Identifiable owner, IdmFormDefinitionDto formDefinition) {
Assert.notNull(owner, "Form values owner is required!");
Assert.notNull(owner.getId(), "Owner id is required!");
FormableEntity ownerEntity = getOwnerEntity(owner);
formDefinition = checkDefaultDefinition(owner.getClass(), formDefinition);
//
FormValueService<FormableEntity> formValueService = getFormValueService(owner);
//
return new IdmFormInstanceDto(ownerEntity, formDefinition, formValueService.getValues(ownerEntity, formDefinition));
}
use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.
the class DefaultFormService method deleteValues.
@Override
@Transactional
public void deleteValues(Identifiable owner, IdmFormDefinitionDto formDefinition) {
Assert.notNull(owner, "Form values owner is required!");
Assert.notNull(owner.getId(), "Owner id is required!");
FormableEntity ownerEntity = getOwnerEntity(owner);
//
FormValueService<FormableEntity> formValueService = getFormValueService(ownerEntity);
formValueService.deleteValues(ownerEntity, formDefinition);
}
use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.
the class DefaultFormService method deleteValues.
@Override
@Transactional
public void deleteValues(Identifiable owner, IdmFormAttributeDto attribute) {
Assert.notNull(owner, "Form values owner is required!");
Assert.notNull(owner.getId(), "Owner id is required!");
Assert.notNull(attribute, "Form attribute definition is required!");
//
FormableEntity ownerEntity = getOwnerEntity(owner);
FormValueService<FormableEntity> formValueService = getFormValueService(ownerEntity);
formValueService.deleteValues(ownerEntity, attribute);
}
use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testMultipleValues.
/**
* Test multi values order and removal
*/
@Test
public void testMultipleValues() {
FormableEntity owner = createTestOwner("test3");
//
// create definition with multi parameter
IdmFormAttributeDto multiAttribite = new IdmFormAttributeDto();
String multiAttributeName = "name_" + System.currentTimeMillis();
multiAttribite.setCode(multiAttributeName);
multiAttribite.setName(multiAttribite.getCode());
multiAttribite.setPersistentType(PersistentType.TEXT);
multiAttribite.setMultiple(true);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), "t_v3", Lists.newArrayList(multiAttribite));
multiAttribite = formDefinitionOne.getMappedAttributeByCode(multiAttribite.getCode());
//
// fill values
IdmFormValueDto value1 = new IdmFormValueDto(multiAttribite);
value1.setValue(FORM_VALUE_ONE);
value1.setSeq((short) 0);
IdmFormValueDto value2 = new IdmFormValueDto(multiAttribite);
value2.setValue(FORM_VALUE_TWO);
value2.setSeq((short) 1);
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1, value2));
Map<String, List<IdmFormValueDto>> m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
// check order
assertEquals(2, m.get(multiAttributeName).size());
assertEquals(FORM_VALUE_ONE, (m.get(multiAttributeName).get(0)).getValue());
assertEquals(FORM_VALUE_TWO, (m.get(multiAttributeName).get(1)).getValue());
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value1));
// check delete unsaved multiple values
m = formService.getFormInstance(owner, formDefinitionOne).toValueMap();
assertEquals(1, m.get(multiAttributeName).size());
assertEquals(FORM_VALUE_ONE, m.get(multiAttributeName).get(0).getValue());
// checks value map
Map<String, ? extends List<Serializable>> v = formService.getFormInstance(owner, formDefinitionOne).toPersistentValueMap();
assertEquals(1, v.get(multiAttributeName).size());
assertEquals(FORM_VALUE_ONE, v.get(multiAttributeName).get(0));
//
identityService.deleteById(owner.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceItegrationTest method testOwnerWithoutId.
@Test(expected = IllegalArgumentException.class)
public void testOwnerWithoutId() {
// unpersisted identity
FormableEntity owner = new IdmIdentity();
formService.getValues(owner);
}
Aggregations