use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class LinkAttributeActionHelper method removeLink.
protected void removeLink(AttributeInterface attribute, HttpServletRequest request) {
HttpSession session = request.getSession();
if (attribute instanceof CompositeAttribute) {
String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
removeLink(includedAttribute, request);
} else if (attribute instanceof LinkAttribute) {
((LinkAttribute) attribute).setSymbolicLink(null);
((LinkAttribute) attribute).getTextMap().clear();
} else if (attribute instanceof MonoListAttribute) {
Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
removeLink(attributeElement, request);
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class LinkAttributeActionHelper method joinLink.
protected void joinLink(AttributeInterface attribute, String[] destinations, int destType, HttpServletRequest request) {
HttpSession session = request.getSession();
if (attribute instanceof CompositeAttribute) {
String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
updateLink(includedAttribute, destinations, destType);
} else if (attribute instanceof MonoListAttribute) {
Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
joinLink(attributeElement, destinations, destType, request);
} else if (attribute instanceof LinkAttribute) {
updateLink(attribute, destinations, destType);
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class ResourceAttributeActionHelper method removeResource.
private static void removeResource(AttributeInterface attribute, HttpServletRequest request) {
HttpSession session = request.getSession();
if (attribute instanceof CompositeAttribute) {
String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
removeResource(includedAttribute, request);
} else if (attribute instanceof AbstractResourceAttribute) {
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, request);
String langCode = (String) session.getAttribute(RESOURCE_LANG_CODE_SESSION_PARAM);
AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) attribute;
if (langCode == null || langCode.length() == 0 || langManager.getDefaultLang().getCode().equals(langCode)) {
resourceAttribute.getResources().clear();
resourceAttribute.getTextMap().clear();
} else {
resourceAttribute.setResource(null, langCode);
resourceAttribute.setText(null, langCode);
}
} else if (attribute instanceof MonoListAttribute) {
int elementIndex = ((Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM)).intValue();
AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex);
removeResource(attributeElement, request);
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class ContentListViewerWidgetAction method getAllowedFilterTypes.
public List<SelectItem> getAllowedFilterTypes() throws ApsSystemException {
List<SelectItem> types = new ArrayList<SelectItem>();
try {
types.add(new SelectItem(IContentListFilterAction.METADATA_KEY_PREFIX + IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, this.getText("label.creationDate")));
types.add(new SelectItem(IContentListFilterAction.METADATA_KEY_PREFIX + IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY, this.getText("label.lastModifyDate")));
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(attribute.getName(), this.getText("label.attribute", new String[] { attribute.getName() })));
}
}
} catch (Throwable t) {
_logger.error("Error extracting allowed filter types", t);
throw new ApsSystemException("Error extracting allowed filter types", t);
}
return types;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class EntityActionHelper method getAttributeFilters.
@Override
public EntitySearchFilter[] getAttributeFilters(AbstractApsEntityFinderAction entityFinderAction, IApsEntity prototype) {
EntitySearchFilter[] filters = new EntitySearchFilter[0];
if (null == prototype) {
return filters;
}
List<AttributeInterface> contentAttributes = prototype.getAttributeList();
for (int i = 0; i < contentAttributes.size(); i++) {
AttributeInterface attribute = contentAttributes.get(i);
if (attribute.isActive() && attribute.isSearcheable()) {
if (attribute instanceof ITextAttribute) {
String insertedText = entityFinderAction.getSearchFormFieldValue(attribute.getName() + "_textFieldName");
if (null != insertedText && insertedText.trim().length() > 0) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(attribute.getName(), true, insertedText.trim(), true);
filters = this.addFilter(filters, filterToAdd);
}
} else if (attribute instanceof DateAttribute) {
Date dateStart = this.getDateSearchFormValue(entityFinderAction, attribute.getName(), "_dateStartFieldName", true);
Date dateEnd = this.getDateSearchFormValue(entityFinderAction, attribute.getName(), "_dateEndFieldName", false);
if (null != dateStart || null != dateEnd) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(attribute.getName(), true, dateStart, dateEnd);
filters = this.addFilter(filters, filterToAdd);
}
} else if (attribute instanceof BooleanAttribute) {
String booleanValue = entityFinderAction.getSearchFormFieldValue(attribute.getName() + "_booleanFieldName");
if (null != booleanValue && booleanValue.trim().length() > 0) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(attribute.getName(), true, booleanValue, false);
filters = this.addFilter(filters, filterToAdd);
}
} else if (attribute instanceof NumberAttribute) {
BigDecimal numberStart = this.getNumberSearchFormValue(entityFinderAction, attribute.getName(), "_numberStartFieldName", true);
BigDecimal numberEnd = this.getNumberSearchFormValue(entityFinderAction, attribute.getName(), "_numberEndFieldName", false);
if (null != numberStart || null != numberEnd) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(attribute.getName(), true, numberStart, numberEnd);
filters = this.addFilter(filters, filterToAdd);
}
}
}
}
return filters;
}
Aggregations