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);
}
}
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"));
}
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);
}
}
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);
}
}
}
}
Aggregations