use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class EntityTypesAction method getEntityPrototypes.
@Override
public List<IApsEntity> getEntityPrototypes() {
List<IApsEntity> entityPrototypes = null;
try {
Map<String, IApsEntity> modelMap = this.getEntityManager().getEntityPrototypes();
entityPrototypes = new ArrayList<IApsEntity>(modelMap.values());
BeanComparator comparator = new BeanComparator("typeDescr");
Collections.sort(entityPrototypes, comparator);
} catch (Throwable t) {
_logger.error("Error on extracting entity prototypes", t);
// ApsSystemUtils.logThrowable(t, this, "getEntityPrototypes");
throw new RuntimeException("Error on extracting entity prototypes", t);
}
return entityPrototypes;
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class ApiEntityTypeInterface method deleteEntityType.
public void deleteEntityType(Properties properties) throws Throwable {
try {
String typeCode = properties.getProperty(this.getTypeCodeParamName());
IApsEntity masterEntityType = this.getEntityManager().getEntityPrototype(typeCode);
if (null == masterEntityType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " with code '" + typeCode + "' doesn't exist");
}
EntitySearchFilter filter = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, typeCode, false);
List<String> entityIds = this.getEntityManager().searchId(new EntitySearchFilter[] { filter });
if (null != entityIds && !entityIds.isEmpty()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " '" + typeCode + "' are used into " + entityIds.size() + " entities");
}
this.checkEntityTypeToDelete(masterEntityType);
((IEntityTypesConfigurer) this.getEntityManager()).removeEntityPrototype(typeCode);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error deleting Entity type", t);
// ApsSystemUtils.logThrowable(t, this, "deleteEntityType");
throw new ApsSystemException("Error deleting Entity type", t);
}
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class ContentListHelper method getConfiguredUserFilters.
@Override
public List<UserFilterOptionBean> getConfiguredUserFilters(IContentListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
List<UserFilterOptionBean> userEntityFilters = null;
try {
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties config = (null != widget) ? widget.getConfig() : null;
if (null == config || null == config.getProperty(WIDGET_PARAM_CONTENT_TYPE)) {
return null;
}
String contentTypeCode = config.getProperty(WIDGET_PARAM_CONTENT_TYPE);
IApsEntity prototype = this.getContentManager().getEntityPrototype(contentTypeCode);
if (null == prototype) {
_logger.error("Null content type by code '{}'", contentTypeCode);
return null;
}
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String userFilters = config.getProperty(WIDGET_PARAM_USER_FILTERS);
if (null != userFilters && userFilters.length() > 0) {
userEntityFilters = FilterUtils.getUserFilters(userFilters, currentFrame, currentLang, prototype, this.getUserFilterDateFormat(), reqCtx.getRequest());
}
} catch (Throwable t) {
_logger.error("Error extracting user filters", t);
throw new ApsSystemException("Error extracting user filters", t);
}
return userEntityFilters;
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class FilterUtils method getUserFilter.
public UserFilterOptionBean getUserFilter(String contentType, IEntityFilterBean bean, IContentManager contentManager, String dateFormat, RequestContext reqCtx) {
UserFilterOptionBean filter = null;
try {
IApsEntity prototype = contentManager.createContentType(contentType);
Properties props = new Properties();
props.setProperty(UserFilterOptionBean.PARAM_KEY, bean.getKey());
props.setProperty(UserFilterOptionBean.PARAM_IS_ATTRIBUTE_FILTER, String.valueOf(bean.isAttributeFilter()));
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
filter = new UserFilterOptionBean(props, prototype, currentFrame, currentLang, dateFormat, reqCtx.getRequest());
} catch (Throwable t) {
_logger.error("Error creating user filter", t);
// ApsSystemUtils.logThrowable(t, FilterUtils.class, "getUserFilter", "Error creating user filter");
}
return filter;
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class EntityTypeDOM method doParsing.
/**
* Parse the XML element and return the map of Entity Types . This method
* must be extended to implement particular operations that apply to the
* specific structure of (an eventually customized) entity class that must
* be handled by the native Entity manager. That class must implement the
* IApsEntity interface.
*
* @param document The DOM document.
* @param entityClass The class that maps the Entity Type.
* @param entityDom L'elemento xml della definizione del singolo tipo di
* entità .
* @return The map of the Entity Types
* @throws ApsSystemException In case of error
*/
protected Map<String, IApsEntity> doParsing(Document document, Class entityClass, IApsEntityDOM entityDom) throws ApsSystemException {
Map<String, IApsEntity> entityTypes = new HashMap<>();
List<Element> contentElements = document.getRootElement().getChildren();
for (int i = 0; i < contentElements.size(); i++) {
Element currentContentElem = contentElements.get(i);
IApsEntity entity = this.doParsing(currentContentElem, entityClass, entityDom);
entityTypes.put(entity.getTypeCode(), entity);
}
return entityTypes;
}
Aggregations