use of com.agiletec.aps.system.common.entity.model.ApsEntity in project entando-core by entando.
the class AbstractEntityService method createEntityType.
protected I createEntityType(IEntityManager entityManager, EntityTypeDtoRequest dto, BindingResult bindingResult) throws Throwable {
Class entityClass = entityManager.getEntityClass();
ApsEntity entityType = (ApsEntity) entityClass.newInstance();
if (StringUtils.isEmpty(dto.getCode()) || dto.getCode().length() != 3) {
this.addError(EntityTypeValidator.ERRCODE_INVALID_TYPE_CODE, bindingResult, new String[] { dto.getCode() }, "entityType.typeCode.invalid");
}
entityType.setTypeCode(dto.getCode());
if (StringUtils.isEmpty(dto.getName())) {
this.addError(EntityTypeValidator.ERRCODE_INVALID_TYPE_DESCR, bindingResult, new String[] {}, "entityType.typeDescription.invalid");
}
entityType.setTypeDescription(dto.getName());
if (bindingResult.hasErrors()) {
return (I) entityType;
}
Map<String, AttributeInterface> attributeMap = entityManager.getEntityAttributePrototypes();
List<EntityAttributeFullDto> attributeDtos = dto.getAttributes();
if (null != attributeDtos) {
for (EntityAttributeFullDto attributeDto : attributeDtos) {
AttributeInterface attribute = this.buildAttribute(dto.getCode(), attributeDto, attributeMap, bindingResult);
if (null != attribute) {
entityType.addAttribute(attribute);
} else {
logger.warn("Create Entity Type - Attribute type {} undefined in manager {}", attributeDto.getType(), entityManager.getName());
}
}
}
return (I) entityType;
}
use of com.agiletec.aps.system.common.entity.model.ApsEntity in project entando-core by entando.
the class ContentFinderAction method restoreEntitySearchState.
@SuppressWarnings("rawtypes")
protected void restoreEntitySearchState(ContentFinderSearchInfo searchInfo) {
if (null != searchInfo.getFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY)) {
EntitySearchFilter filter = searchInfo.getFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY);
this.addFilter(filter);
this.setEntityTypeCode((String) filter.getValue());
EntitySearchFilter[] filters = searchInfo.getFiltersByKeyPrefix(ContentFinderSearchInfo.ATTRIBUTE_FILTER);
if (null != filters && filters.length > 0) {
for (EntitySearchFilter entitySearchFilter : filters) {
this.addFilter(entitySearchFilter);
String attrName = entitySearchFilter.getKey();
ApsEntity proto = (ApsEntity) this.getEntityPrototype();
String[] attributeFilterFieldNames = this.getEntityActionHelper().getAttributeFilterFieldName(proto, attrName);
if (null != attributeFilterFieldNames && attributeFilterFieldNames.length == 1) {
this.getRequest().setAttribute(attributeFilterFieldNames[0], entitySearchFilter.getValue());
} else if (null != attributeFilterFieldNames && attributeFilterFieldNames.length == 2) {
Date start = (Date) entitySearchFilter.getStart();
if (null != start) {
this.getRequest().setAttribute(attributeFilterFieldNames[0], DateConverter.getFormattedDate(start, EntitySearchFilter.DATE_PATTERN));
}
Date end = (Date) entitySearchFilter.getEnd();
if (null != end) {
this.getRequest().setAttribute(attributeFilterFieldNames[1], DateConverter.getFormattedDate(end, EntitySearchFilter.DATE_PATTERN));
}
}
}
}
}
}
Aggregations