Search in sources :

Example 1 with AttributeRole

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

the class BaseContentDispenser method getBaseRenderizationInfo.

public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx, boolean cacheable) {
    ContentRenderizationInfo renderInfo = null;
    try {
        List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
        if (authInfo.isUserAllowed(userGroups)) {
            Content contentToRender = this.getContentManager().loadContent(contentId, true, cacheable);
            String renderedContent = this.buildRenderedContent(contentToRender, modelId, langCode, reqCtx);
            if (null != renderedContent && renderedContent.trim().length() > 0) {
                List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
                renderInfo = new ContentRenderizationInfo(contentToRender, renderedContent, modelId, langCode, roles);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error while rendering content {}", contentId, t);
        return null;
    }
    return renderInfo;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)

Example 2 with AttributeRole

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

the class EntityActionHelper method getRoleFilters.

@Override
public EntitySearchFilter[] getRoleFilters(AbstractApsEntityFinderAction entityFinderAction) {
    EntitySearchFilter[] filters = new EntitySearchFilter[0];
    List<AttributeRole> attributeRoles = entityFinderAction.getAttributeRoles();
    if (null != attributeRoles) {
        for (int i = 0; i < attributeRoles.size(); i++) {
            AttributeRole attributeRole = attributeRoles.get(i);
            if (AttributeRole.FormFieldTypes.TEXT.equals(attributeRole.getFormFieldType())) {
                String insertedText = entityFinderAction.getSearchFormFieldValue(attributeRole.getName() + "_textFieldName");
                if (null != insertedText && insertedText.trim().length() > 0) {
                    EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), insertedText.trim(), true);
                    filters = this.addFilter(filters, filterToAdd);
                }
            } else if (AttributeRole.FormFieldTypes.DATE.equals(attributeRole.getFormFieldType())) {
                Date dateStart = this.getDateSearchFormValue(entityFinderAction, attributeRole.getName(), "_dateStartFieldName", true);
                Date dateEnd = this.getDateSearchFormValue(entityFinderAction, attributeRole.getName(), "_dateEndFieldName", false);
                if (null != dateStart || null != dateEnd) {
                    EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), dateStart, dateEnd);
                    filters = this.addFilter(filters, filterToAdd);
                }
            } else if (AttributeRole.FormFieldTypes.BOOLEAN.equals(attributeRole.getFormFieldType())) {
                String booleanValue = entityFinderAction.getSearchFormFieldValue(attributeRole.getName() + "_booleanFieldName");
                if (null != booleanValue && booleanValue.trim().length() > 0) {
                    EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), booleanValue, false);
                    filters = this.addFilter(filters, filterToAdd);
                }
            } else if (AttributeRole.FormFieldTypes.NUMBER.equals(attributeRole.getFormFieldType())) {
                BigDecimal numberStart = this.getNumberSearchFormValue(entityFinderAction, attributeRole.getName(), "_numberStartFieldName", true);
                BigDecimal numberEnd = this.getNumberSearchFormValue(entityFinderAction, attributeRole.getName(), "_numberEndFieldName", false);
                if (null != numberStart || null != numberEnd) {
                    EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), numberStart, numberEnd);
                    filters = this.addFilter(filters, filterToAdd);
                }
            }
        }
    }
    return filters;
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole) Date(java.util.Date) BigDecimal(java.math.BigDecimal)

Example 3 with AttributeRole

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

the class AbstractBaseEntityAttributeConfigAction method getAttributeRoles.

protected List<AttributeRole> getAttributeRoles(String attributeTypeCode) {
    List<AttributeRole> rolesByType = new ArrayList<AttributeRole>();
    List<AttributeRole> roles = this.getEntityManager().getAttributeRoles();
    if (null == roles) {
        return rolesByType;
    }
    for (int i = 0; i < roles.size(); i++) {
        AttributeRole role = roles.get(i);
        if (role.getAllowedAttributeTypes().contains(attributeTypeCode)) {
            rolesByType.add(role);
        }
    }
    return rolesByType;
}
Also used : ArrayList(java.util.ArrayList) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)

Example 4 with AttributeRole

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

the class AbstractBaseEntityAttributeConfigAction method getFreeAttributeRoleNames.

/**
 * Return the list of the attribute role not in use on the entity type on edit.
 * @return The list of the free attribute roles.
 */
public List<AttributeRole> getFreeAttributeRoleNames() {
    List<AttributeRole> freeRoles = new ArrayList<AttributeRole>();
    List<AttributeRole> roles = this.getAttributeRoles(this.getAttributeTypeCode());
    if (null == roles) {
        return freeRoles;
    }
    for (int i = 0; i < roles.size(); i++) {
        AttributeRole role = roles.get(i);
        AttributeInterface utilizer = this.getEntityType().getAttributeByRole(role.getName());
        if (null == utilizer || utilizer.getName().equals(this.getAttributeName())) {
            freeRoles.add(role);
        }
    }
    return freeRoles;
}
Also used : ArrayList(java.util.ArrayList) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 5 with AttributeRole

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

the class EntityAttributeConfigAction method addAttributeRole.

@Override
public String addAttributeRole() {
    try {
        String attributeRoleName = this.getAttributeRoleName();
        if (null == this.getAttributeRoles()) {
            this.setAttributeRoles(new ArrayList<String>());
        }
        List<AttributeRole> allowedRoles = this.getAttributeRoles(this.getAttributeTypeCode());
        boolean allowed = false;
        if (null != allowedRoles) {
            for (int i = 0; i < allowedRoles.size(); i++) {
                AttributeRole role = allowedRoles.get(i);
                if (role.getName().equals(this.getAttributeRoleName())) {
                    allowed = true;
                    break;
                }
            }
        }
        if (!allowed) {
            // TODO ADD FIELD ERRORS - Role not allowed for type ...
            return SUCCESS;
        }
        if (!this.getAttributeRoles().contains(attributeRoleName)) {
            this.getAttributeRoles().add(attributeRoleName);
        }
    } catch (Throwable t) {
        _logger.error("error in addAttributeRole", t);
        // ApsSystemUtils.logThrowable(t, this, "addAttributeRole");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)

Aggregations

AttributeRole (com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)9 ArrayList (java.util.ArrayList)4 Group (com.agiletec.aps.system.services.group.Group)2 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)2 IManager (com.agiletec.aps.system.common.IManager)1 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)1 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 AttributeRoleDOM (com.agiletec.aps.system.common.entity.parse.AttributeRoleDOM)1 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)1 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)1 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 Element (org.jdom.Element)1