use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class CodeListSaveProcessor method process.
@Override
public EventResult<IdmCodeListDto> process(EntityEvent<IdmCodeListDto> event) {
IdmCodeListDto codeList = event.getContent();
//
// prevent to change underlying form definition
IdmCodeListDto originalSource = event.getOriginalSource();
if (originalSource == null) {
if (codeList.getFormDefinition() != null) {
throw new ResultCodeException(CoreResultCode.UNMODIFIABLE_ATTRIBUTE_CHANGE, ImmutableMap.of("name", "formDefinition", "class", codeList.getClass().getSimpleName()));
}
} else {
if (!codeList.getFormDefinition().equals(originalSource.getFormDefinition())) {
throw new ResultCodeException(CoreResultCode.UNMODIFIABLE_ATTRIBUTE_CHANGE, ImmutableMap.of("name", "formDefinition", "class", codeList.getClass().getSimpleName()));
}
}
codeList = service.saveInternal(codeList);
event.setContent(codeList);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class IdmCodeListControllerRestTest method prepareDto.
@Override
protected IdmCodeListDto prepareDto() {
IdmCodeListDto dto = new IdmCodeListDto();
dto.setName(getHelper().createName());
dto.setCode(getHelper().createName());
//
return dto;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmCodeListItemService method toDto.
@Override
protected IdmCodeListItemDto toDto(IdmCodeListItem entity, IdmCodeListItemDto dto) {
dto = super.toDto(entity, dto);
if (dto == null) {
return null;
}
// load eav attributes
// TODO: trimmed only?
IdmCodeListDto codeList = DtoUtils.getEmbedded(dto, IdmCodeListItem_.codeList);
dto.getEavs().add(formService.getFormInstance(dto, codeList.getFormDefinition()));
//
return dto;
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class DefaultCodeListManager method createItem.
@Override
@Transactional
public IdmCodeListItemDto createItem(Serializable codeListIdentifier, String code, String name, BasePermission... permission) {
Assert.notNull(codeListIdentifier, "CodeList identifier is required.");
Assert.notNull(code, "Item code is required.");
Assert.notNull(name, "Item name is required.");
//
IdmCodeListDto codeList = get(codeListIdentifier);
Assert.notNull(codeList, "CodeList is required.");
//
IdmCodeListItemDto item = new IdmCodeListItemDto();
item.setCodeList(codeList.getId());
item.setCode(code);
item.setName(name);
//
return saveItem(item, permission);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class DefaultCodeListManager method getItem.
@Override
public IdmCodeListItemDto getItem(Serializable codeListIdentifier, String itemCode, BasePermission... permission) {
Assert.notNull(codeListIdentifier, "CodeList identifier is required.");
Assert.notNull(itemCode, "Item code is required.");
//
IdmCodeListDto codeList = get(codeListIdentifier);
if (codeList == null) {
return null;
}
//
return codeListItemService.getItem(codeList.getId(), itemCode, permission);
}
Aggregations