Search in sources :

Example 1 with ResourceAttributeInterface

use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface in project entando-core by entando.

the class ResourceAttributeHandler method startResource.

private void startResource(Attributes attributes, String qName) throws SAXException {
    String id = extractAttribute(attributes, "id", qName, true);
    String langCode = extractAttribute(attributes, "lang", qName, false);
    try {
        ResourceInterface resource = this.getResourceManager().loadResource(id);
        if (null != this.getCurrentAttr() && null != resource) {
            ((ResourceAttributeInterface) this.getCurrentAttr()).setResource(resource, langCode);
        }
    } catch (Exception e) {
        _logger.error("Error loading resource {}", id, e);
    }
}
Also used : ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) SAXException(org.xml.sax.SAXException)

Example 2 with ResourceAttributeInterface

use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface in project entando-core by entando.

the class TestContentManager method testLoadContent.

public void testLoadContent() throws Throwable {
    Content content = this._contentManager.loadContent("ART111", false);
    assertEquals(Content.STATUS_PUBLIC, content.getStatus());
    assertEquals("coach", content.getMainGroup());
    assertEquals(2, content.getGroups().size());
    assertTrue(content.getGroups().contains("customers"));
    assertTrue(content.getGroups().contains("helpdesk"));
    Map<String, AttributeInterface> attributes = content.getAttributeMap();
    assertEquals(7, attributes.size());
    TextAttribute title = (TextAttribute) attributes.get("Titolo");
    assertEquals("Titolo Contenuto 3 Coach", title.getTextForLang("it"));
    assertNull(title.getTextForLang("en"));
    MonoListAttribute authors = (MonoListAttribute) attributes.get("Autori");
    assertEquals(4, authors.getAttributes().size());
    LinkAttribute link = (LinkAttribute) attributes.get("VediAnche");
    assertNull(link.getSymbolicLink());
    HypertextAttribute hypertext = (HypertextAttribute) attributes.get("CorpoTesto");
    assertEquals("<p>Corpo Testo Contenuto 3 Coach</p>", hypertext.getTextForLang("it").trim());
    assertNull(hypertext.getTextForLang("en"));
    ResourceAttributeInterface image = (ResourceAttributeInterface) attributes.get("Foto");
    assertNull(image.getResource());
    DateAttribute date = (DateAttribute) attributes.get("Data");
    assertEquals("13/12/2006", DateConverter.getFormattedDate(date.getDate(), "dd/MM/yyyy"));
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) HypertextAttribute(com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) TextAttribute(com.agiletec.aps.system.common.entity.model.attribute.TextAttribute) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute) 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) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 3 with ResourceAttributeInterface

use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface 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 4 with ResourceAttributeInterface

use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface in project entando-core by entando.

the class IndexerDAO method indexAttribute.

private void indexAttribute(Document document, AttributeInterface attribute, Lang lang) throws ApsSystemException {
    attribute.setRenderingLang(lang.getCode());
    if (attribute instanceof IndexableAttributeInterface) {
        String valueToIndex = ((IndexableAttributeInterface) attribute).getIndexeableFieldValue();
        String indexingType = attribute.getIndexingType();
        String fieldName = lang.getCode();
        if (attribute instanceof ResourceAttributeInterface) {
            fieldName += IIndexerDAO.ATTACHMENT_FIELD_SUFFIX;
        }
        if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_UNSTORED.equalsIgnoreCase(indexingType)) {
            document.add(new TextField(fieldName, valueToIndex, Field.Store.NO));
        }
        if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_TEXT.equalsIgnoreCase(indexingType)) {
            document.add(new TextField(fieldName, valueToIndex, Field.Store.YES));
        }
    }
    if (attribute.isSearchable()) {
        List<Lang> langs = new ArrayList<Lang>();
        langs.add(lang);
        AttributeTracer tracer = new AttributeTracer();
        tracer.setLang(lang);
        String name = tracer.getFormFieldName(attribute);
        List<AttributeSearchInfo> searchInfos = attribute.getSearchInfos(langs);
        if (null != searchInfos) {
            for (int i = 0; i < searchInfos.size(); i++) {
                AttributeSearchInfo info = searchInfos.get(i);
                Field field = null;
                if (null != info.getDate()) {
                    field = new TextField(name, DateTools.timeToString(info.getDate().getTime(), DateTools.Resolution.MINUTE), Field.Store.YES);
                } else if (null != info.getBigDecimal()) {
                    field = new IntField(name, info.getBigDecimal().intValue(), Field.Store.YES);
                } else {
                    field = new TextField(name, info.getString(), Field.Store.YES);
                }
                document.add(field);
            }
        }
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) IntField(org.apache.lucene.document.IntField) AttributeSearchInfo(com.agiletec.aps.system.common.entity.model.AttributeSearchInfo) StringField(org.apache.lucene.document.StringField) Field(org.apache.lucene.document.Field) TextField(org.apache.lucene.document.TextField) IntField(org.apache.lucene.document.IntField) TextField(org.apache.lucene.document.TextField) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)

Aggregations

ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)4 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)2 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)2 AttributeSearchInfo (com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)1 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)1 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)1 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)1 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)1 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)1 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)1 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)1 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)1 ArrayList (java.util.ArrayList)1 Field (org.apache.lucene.document.Field)1 IntField (org.apache.lucene.document.IntField)1 StringField (org.apache.lucene.document.StringField)1 TextField (org.apache.lucene.document.TextField)1