Search in sources :

Example 96 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class ResourceAttributeActionHelper method joinResource.

/**
 * Associa la risorsa all'attributo del contenuto o all'elemento dell'attributo lista
 * o all'elemento dell'attributo Composito (sia semplice che in lista).
 */
private static void joinResource(AttributeInterface attribute, ResourceInterface resource, HttpSession session) {
    if (attribute instanceof CompositeAttribute) {
        String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
        AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
        joinResource(includedAttribute, resource, session);
    } else if (attribute instanceof ResourceAttributeInterface) {
        String langCode = (String) session.getAttribute(RESOURCE_LANG_CODE_SESSION_PARAM);
        langCode = (langCode != null && !"".equals(langCode)) ? langCode : null;
        ((ResourceAttributeInterface) attribute).setResource(resource, langCode);
        ((AbstractResourceAttribute) attribute).setText(resource.getDescription(), langCode);
    } else if (attribute instanceof MonoListAttribute) {
        int elementIndex = ((Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM)).intValue();
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex);
        joinResource(attributeElement, resource, session);
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 97 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class ContentModelAction method getAllowedAttributeMethods.

public List<String> getAllowedAttributeMethods(Content prototype, String attributeName) {
    List<String> methods = new ArrayList<String>();
    try {
        AttributeInterface attribute = (AttributeInterface) prototype.getAttribute(attributeName);
        if (null == attribute) {
            throw new ApsSystemException("Null Attribute '" + attributeName + "' for Content Type '" + prototype.getTypeCode() + "' - '" + prototype.getTypeDescr());
        }
        String methodsString = this.getAllowedPublicAttributeMethods().getProperty(attribute.getType());
        if (null != methodsString) {
            String[] methodsArray = methodsString.split(";");
            methods = Arrays.asList(methodsArray);
        } else {
            BeanInfo beanInfo = Introspector.getBeanInfo(attribute.getClass(), AbstractAttribute.class);
            PropertyDescriptor[] prDescrs = beanInfo.getPropertyDescriptors();
            for (int i = 0; i < prDescrs.length; i++) {
                PropertyDescriptor propertyDescriptor = prDescrs[i];
                if (null != propertyDescriptor.getReadMethod()) {
                    methods.add(propertyDescriptor.getDisplayName());
                }
            }
        }
    } catch (Throwable t) {
        _logger.error("error in getAllowedAttributeMethods", t);
    // ApsSystemUtils.logThrowable(t, this, "getAllowedAttributeMethods");
    }
    return methods;
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 98 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class BaseFilterAction method setFilterType.

@Override
public String setFilterType() {
    try {
        Content prototype = this.getContentManager().createContentType(this.getContentType());
        String key = this.getFilterKey();
        int attrFilterType = -1;
        AttributeInterface attribute = (AttributeInterface) prototype.getAttribute(key);
        if (null != attribute) {
            if (attribute instanceof ITextAttribute) {
                attrFilterType = TEXT_ATTRIBUTE_FILTER_TYPE;
            } else if (attribute instanceof NumberAttribute) {
                attrFilterType = NUMBER_ATTRIBUTE_FILTER_TYPE;
            } else if (attribute instanceof BooleanAttribute) {
                attrFilterType = BOOLEAN_ATTRIBUTE_FILTER_TYPE;
            } else if (attribute instanceof DateAttribute) {
                attrFilterType = DATE_ATTRIBUTE_FILTER_TYPE;
            }
        } else if ((METADATA_KEY_PREFIX + IContentManager.CONTENT_CREATION_DATE_FILTER_KEY).equals(key) || (METADATA_KEY_PREFIX + IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY).equals(key)) {
            key = key.substring(METADATA_KEY_PREFIX.length());
            this.setFilterKey(key);
            attrFilterType = METADATA_FILTER_TYPE;
        }
        this.setFilterTypeId(attrFilterType);
        if (this.getFilterTypeId() < 0) {
            this.setFilterKey(null);
        }
    } catch (Throwable t) {
        _logger.error("error in setFilterType", t);
        // ApsSystemUtils.logThrowable(t, this, "setFilterType");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 99 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class BaseFilterAction method getFilterTypes.

/**
 * Restituisce la lista di filtri possibili per il tipo di contenuto specificato.
 * La lista comprende sempre la possibilità di filtrare per i metadati "Data Creazione" e "Data Ultima Modifica" e
 * insieme a tutti gli attributi di contenuto (del tipo specificato) dichiarati ricercabili.
 * La lista è e servizio dell'interfaccia di gestione del filtro.
 * @return La lista di filtri possibili per il tipo di contenuto specificato.
 */
public List<SelectItem> getFilterTypes() {
    List<SelectItem> types = new ArrayList<SelectItem>();
    types.add(new SelectItem(METADATA_KEY_PREFIX + IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, this.getText("label.creationDate")));
    types.add(new SelectItem(METADATA_KEY_PREFIX + IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY, this.getText("label.lastModifyDate")));
    Content prototype = this.getContentManager().createContentType(this.getContentType());
    List<AttributeInterface> contentAttributes = prototype.getAttributeList();
    for (int i = 0; i < contentAttributes.size(); i++) {
        AttributeInterface attribute = contentAttributes.get(i);
        if (attribute.isSearchable()) {
            types.add(new SelectItem(attribute.getName(), this.getText("label.attribute", new String[] { attribute.getName() })));
        }
    }
    return types;
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 100 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class ContentListViewerWidgetAction method getAllowedUserFilterTypes.

public List<SelectItem> getAllowedUserFilterTypes() throws ApsSystemException {
    List<SelectItem> types = new ArrayList<SelectItem>();
    try {
        types.add(new SelectItem(UserFilterOptionBean.KEY_FULLTEXT, this.getText("label.fulltext")));
        types.add(new SelectItem(UserFilterOptionBean.KEY_CATEGORY, this.getText("label.category")));
        String contentType = this.getWidget().getConfig().getProperty(IContentListWidgetHelper.WIDGET_PARAM_CONTENT_TYPE);
        Content prototype = this.getContentManager().createContentType(contentType);
        List<AttributeInterface> contentAttributes = prototype.getAttributeList();
        for (int i = 0; i < contentAttributes.size(); i++) {
            AttributeInterface attribute = contentAttributes.get(i);
            if (attribute.isSearchable()) {
                types.add(new SelectItem(UserFilterOptionBean.TYPE_ATTRIBUTE + "_" + attribute.getName(), this.getText("label.attribute", new String[] { attribute.getName() })));
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting allowed user filter types", t);
        throw new ApsSystemException("Error extracting allowed user filter types", t);
    }
    return types;
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)147 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)38 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)37 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 ArrayList (java.util.ArrayList)18 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)17 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)16 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)14 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)12 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)11 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)10 HttpSession (javax.servlet.http.HttpSession)10 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)9 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)7 Lang (com.agiletec.aps.system.services.lang.Lang)7 Date (java.util.Date)7