Search in sources :

Example 6 with AttributeRole

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

the class ContentPreviewDispenser method getBaseRenderizationInfo.

@Override
public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx) {
    ContentRenderizationInfo renderInfo = null;
    try {
        List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
        if (authInfo.isUserAllowed(userGroups)) {
            Content contentOnSession = this.extractContentOnSession(reqCtx);
            String renderedContent = this.buildRenderedContent(contentOnSession, modelId, langCode, reqCtx);
            if (null != renderedContent && renderedContent.trim().length() > 0) {
                List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
                renderInfo = new ContentRenderizationInfo(contentOnSession, renderedContent, modelId, langCode, roles);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error while rendering content {}", contentId, t);
        return null;
    }
    return renderInfo;
}
Also used : ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) 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 7 with AttributeRole

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

the class AttributeRoleDOM method extractRoles.

private Map<String, AttributeRole> extractRoles(Document document) {
    Map<String, AttributeRole> roles = new HashMap<>();
    List<Element> roleElements = document.getRootElement().getChildren("role");
    for (int i = 0; i < roleElements.size(); i++) {
        Element roleElement = roleElements.get(i);
        String name = roleElement.getChildText("name");
        String description = roleElement.getChildText("description");
        String allowedTypesCSV = roleElement.getChildText("allowedTypes");
        String[] array = allowedTypesCSV.split(",");
        List<String> allowedTypes = Arrays.asList(array);
        AttributeRole role = new AttributeRole(name, description, allowedTypes);
        String formFieldTypeText = roleElement.getChildText("formFieldType");
        if (null != formFieldTypeText) {
            role.setFormFieldType(Enum.valueOf(AttributeRole.FormFieldTypes.class, formFieldTypeText.toUpperCase()));
        }
        roles.put(name, role);
    }
    return roles;
}
Also used : HashMap(java.util.HashMap) Element(org.jdom.Element) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)

Example 8 with AttributeRole

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

the class ApsEntityManager method getOrderedAttributeRoles.

private List<AttributeRole> getOrderedAttributeRoles() {
    List<AttributeRole> roles = new ArrayList<>(this.attributeRoles.size());
    Iterator<AttributeRole> iter = this.attributeRoles.values().iterator();
    while (iter.hasNext()) {
        AttributeRole role = iter.next();
        roles.add(role.clone());
    }
    BeanComparator comparator = new BeanComparator("name");
    Collections.sort(roles, comparator);
    return roles;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)

Example 9 with AttributeRole

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

the class ExtraAttributeRolesWrapper method executeLoading.

public void executeLoading(Map<String, AttributeRole> collectionToFill, IEntityManager entityManager) throws ApsSystemException {
    String managerName = ((IManager) entityManager).getName();
    if (!managerName.equals(super.getEntityManagerNameDest())) {
        return;
    }
    AttributeRoleDOM dom = new AttributeRoleDOM();
    try {
        String xml = super.extractXml();
        Map<String, AttributeRole> attributeRoles = dom.extractRoles(xml, this.getDefsFilePath());
        List<AttributeRole> roles = new ArrayList<>(attributeRoles.values());
        for (int i = 0; i < roles.size(); i++) {
            AttributeRole role = roles.get(i);
            if (collectionToFill.containsKey(role.getName())) {
                _logger.warn("You can't override existing attribute role : {} - {}", role.getName(), role.getDescription());
            } else {
                collectionToFill.put(role.getName(), role);
                _logger.info("Added new attribute role : {} - {}", role.getName(), role.getDescription());
            }
        }
    } catch (Throwable t) {
        // ApsSystemUtils.logThrowable(t, this, "executeLoading", "Error loading extra attribute Roles");
        _logger.error("Error loading extra attribute Roles", t);
    }
}
Also used : IManager(com.agiletec.aps.system.common.IManager) ArrayList(java.util.ArrayList) AttributeRoleDOM(com.agiletec.aps.system.common.entity.parse.AttributeRoleDOM) 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