Search in sources :

Example 11 with IEntityManager

use of com.agiletec.aps.system.common.entity.IEntityManager in project entando-core by entando.

the class AbstractBaseEntityAttributeConfigAction method getAttributePrototype.

public AttributeInterface getAttributePrototype(String typeCode) {
    IEntityManager entityManager = this.getEntityManager();
    Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
    return attributeTypes.get(typeCode);
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 12 with IEntityManager

use of com.agiletec.aps.system.common.entity.IEntityManager in project entando-core by entando.

the class CompositeAttributeConfigAction method getAllowedAttributeElementTypes.

public List<AttributeInterface> getAllowedAttributeElementTypes() {
    List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
        while (attributeIter.hasNext()) {
            AttributeInterface attribute = attributeIter.next();
            if (attribute.isSimple()) {
                attributes.add(attribute);
            }
        }
        Collections.sort(attributes, new BeanComparator("type"));
    } catch (Throwable t) {
        _logger.error("Error extracting the allowed types of attribute elements", t);
        // ApsSystemUtils.logThrowable(t, this, "getAllowedAttributeElementTypes");
        throw new RuntimeException("Error extracting the allowed types of attribute elements", t);
    }
    return attributes;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 13 with IEntityManager

use of com.agiletec.aps.system.common.entity.IEntityManager in project entando-core by entando.

the class EntityAttributeConfigAction method getAllowedNestedTypes.

public List<AttributeInterface> getAllowedNestedTypes(AttributeInterface listType) {
    List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
        while (attributeIter.hasNext()) {
            AttributeInterface attribute = attributeIter.next();
            boolean simple = attribute.isSimple();
            boolean multiLanguage = attribute.isMultilingual();
            if ((listType instanceof ListAttribute && simple && !multiLanguage) || (listType instanceof MonoListAttribute && !(attribute instanceof AbstractListAttribute))) {
                attributes.add(attribute);
            }
        }
        Collections.sort(attributes, new BeanComparator("type"));
    } catch (Throwable t) {
        _logger.error("Error while extracting Allowed Nested Types", t);
        // ApsSystemUtils.logThrowable(t, this, "getAllowedNestedTypes");
        throw new RuntimeException("Error while extracting Allowed Nested Types", t);
    }
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Example 14 with IEntityManager

use of com.agiletec.aps.system.common.entity.IEntityManager in project entando-core by entando.

the class EntityTypeConfigAction method addAttribute.

@Override
public String addAttribute() {
    this.updateEntityOnSession();
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        if (null == attributeTypes.get(this.getAttributeTypeCode())) {
            String[] args = { this.getAttributeTypeCode() };
            this.addFieldError("attributeTypeCode", this.getText("error.attribute.not.exists", args));
            return INPUT;
        }
    } catch (Throwable t) {
        _logger.error("error in addAttribute", t);
        // ApsSystemUtils.logThrowable(t, this, "addAttribute");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 15 with IEntityManager

use of com.agiletec.aps.system.common.entity.IEntityManager in project entando-core by entando.

the class EntityTypeInfoTag method getMasterObject.

@Override
protected Object getMasterObject(String keyValue) throws Throwable {
    String managerNameValue = (String) super.findValue(this.getEntityManagerName(), String.class);
    try {
        IEntityManager entityManager = (IEntityManager) ApsWebApplicationUtils.getBean(managerNameValue, this.pageContext);
        if (null != entityManager) {
            return entityManager.getEntityPrototype(keyValue);
        }
    } catch (Throwable t) {
        String message = "Error extracting entity prototype : key '" + keyValue + "' - entity manager '" + managerNameValue + "'";
        _logger.error("Error extracting entity prototype : key '{}' - entity manager '{}'", keyValue, managerNameValue, t);
        // ApsSystemUtils.logThrowable(t, this, "getMasterObject", message);
        throw new ApsSystemException(message, t);
    }
    _logger.debug("Null entity manager : service name '{}'", managerNameValue);
    return null;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Aggregations

IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)25 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)12 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)7 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)7 ArrayList (java.util.ArrayList)7 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)5 BeanComparator (org.apache.commons.beanutils.BeanComparator)5 RestServerError (org.entando.entando.aps.system.exception.RestServerError)3 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)2 EntityAttributeConfigAction (com.agiletec.apsadmin.system.entity.type.EntityAttributeConfigAction)2 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)2 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)2 AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)1 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)1 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)1 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)1 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)1 List (java.util.List)1 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)1 StringListApiResponse (org.entando.entando.aps.system.services.api.model.StringListApiResponse)1