use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute 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.CompositeAttribute 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.CompositeAttribute in project entando-core by entando.
the class CompositeAttributeManager method updateAttribute.
@Override
protected void updateAttribute(AttributeInterface attribute, AttributeTracer tracer, HttpServletRequest request) {
List<AttributeInterface> attributes = ((CompositeAttribute) attribute).getAttributes();
for (int i = 0; i < attributes.size(); i++) {
AttributeInterface attributeElement = attributes.get(i);
AttributeTracer elementTracer = (AttributeTracer) tracer.clone();
elementTracer.setCompositeElement(true);
elementTracer.setParentAttribute(attribute);
AbstractAttributeManager elementManager = (AbstractAttributeManager) this.getManager(attributeElement);
if (elementManager != null) {
elementManager.updateAttribute(attributeElement, elementTracer, request);
}
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute in project entando-core by entando.
the class CompositeAttributeConfigAction method saveAttributeElement.
@Override
public String saveAttributeElement() {
try {
CompositeAttribute composite = this.getCompositeAttributeOnEdit();
if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
throw new RuntimeException("The edit operation on this attribute is not supported");
} else {
AttributeInterface attribute = this.getAttributePrototype(this.getAttributeTypeCode());
attribute.setName(this.getAttributeName());
super.fillAttributeFields(attribute);
composite.getAttributes().add(attribute);
composite.getAttributeMap().put(attribute.getName(), attribute);
}
} catch (Throwable t) {
_logger.error("error in saveAttributeElement", t);
// ApsSystemUtils.logThrowable(t, this, "saveAttributeElement");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute in project entando-core by entando.
the class CompositeAttributeConfigAction method removeAttributeElement.
@Override
public String removeAttributeElement() {
try {
int elementIndex = this.getAttributeIndex();
CompositeAttribute composite = this.getCompositeAttributeOnEdit();
AttributeInterface attributeToRemove = composite.getAttributes().get(elementIndex);
composite.getAttributes().remove(elementIndex);
composite.getAttributeMap().remove(attributeToRemove.getName());
} catch (Throwable t) {
_logger.error("error in removeAttribute", t);
// ApsSystemUtils.logThrowable(t, this, "removeAttribute");
return FAILURE;
}
return SUCCESS;
}
Aggregations