Search in sources :

Example 61 with IApsEntity

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;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 62 with IApsEntity

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);
    }
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 63 with IApsEntity

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;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 64 with IApsEntity

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;
}
Also used : UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) Lang(com.agiletec.aps.system.services.lang.Lang) Properties(java.util.Properties)

Example 65 with IApsEntity

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;
}
Also used : HashMap(java.util.HashMap) Element(org.jdom.Element) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Aggregations

IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)70 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)24 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)16 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)12 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)11 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)11 ArrayList (java.util.ArrayList)9 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)6 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)5 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)4 Lang (com.agiletec.aps.system.services.lang.Lang)4 List (java.util.List)4 BeanComparator (org.apache.commons.beanutils.BeanComparator)4 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)3 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)3 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)3 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)3 Widget (com.agiletec.aps.system.services.page.Widget)2 ApsProperties (com.agiletec.aps.util.ApsProperties)2 EntityAttributeConfigAction (com.agiletec.apsadmin.system.entity.type.EntityAttributeConfigAction)2