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