use of com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface in project entando-core by entando.
the class ListAttributeAction method moveListElement.
@Override
public String moveListElement() {
IApsEntity entity = this.getCurrentApsEntity();
try {
int elementIndex = this.getElementIndex();
ListAttributeInterface currentAttribute = (ListAttributeInterface) entity.getAttribute(this.getAttributeName());
if (currentAttribute instanceof MonoListAttribute) {
List<AttributeInterface> monoList = ((MonoListAttribute) currentAttribute).getAttributes();
this.moveListElement(monoList, elementIndex, this.getMovement());
} else if (currentAttribute instanceof ListAttribute) {
List<AttributeInterface> list = ((ListAttribute) currentAttribute).getAttributeList(this.getListLangCode());
this.moveListElement(list, elementIndex, this.getMovement());
}
_logger.debug("Moved element of type {} of the list {} in the position {} with a '{}' movement ", currentAttribute.getNestedAttributeTypeCode(), currentAttribute.getName(), elementIndex, this.getMovement());
} catch (Throwable t) {
_logger.error("error in moveListElement", t);
// ApsSystemUtils.logThrowable(t, this, "moveListElement");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface in project entando-core by entando.
the class ListAttributeAction method removeListElement.
@Override
public String removeListElement() {
IApsEntity entity = this.getCurrentApsEntity();
try {
int elementIndex = this.getElementIndex();
ListAttributeInterface currentAttribute = (ListAttributeInterface) entity.getAttribute(this.getAttributeName());
if (currentAttribute instanceof MonoListAttribute) {
((MonoListAttribute) currentAttribute).removeAttribute(elementIndex);
} else if (currentAttribute instanceof ListAttribute) {
((ListAttribute) currentAttribute).removeAttribute(this.getListLangCode(), elementIndex);
}
_logger.debug("Element oy type {} removed fomr the list {}", currentAttribute.getNestedAttributeTypeCode(), currentAttribute.getName());
} catch (Throwable t) {
_logger.error("error in removeListElement", t);
// ApsSystemUtils.logThrowable(t, this, "removeListElement");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface in project entando-core by entando.
the class ListAttributeAction method addListElement.
@Override
public String addListElement() {
IApsEntity entity = this.getCurrentApsEntity();
try {
ListAttributeInterface currentAttribute = (ListAttributeInterface) entity.getAttribute(this.getAttributeName());
if (currentAttribute instanceof MonoListAttribute) {
((MonoListAttribute) currentAttribute).addAttribute();
} else if (currentAttribute instanceof ListAttribute) {
((ListAttribute) currentAttribute).addAttribute(this.getListLangCode());
}
_logger.debug("Added element of type {} to the list {}", currentAttribute.getNestedAttributeTypeCode(), currentAttribute.getName());
} catch (Throwable t) {
_logger.error("error in addListElement", t);
// ApsSystemUtils.logThrowable(t, this, "addListElement");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface in project entando-core by entando.
the class ListAttributeAction method addListElement.
@Override
public String addListElement() {
try {
super.addListElement();
Content content = this.getContent();
int index = -1;
ListAttributeInterface currentAttribute = (ListAttributeInterface) content.getAttribute(this.getAttributeName());
String nestedType = currentAttribute.getNestedAttributeTypeCode();
if (!nestedType.equals("Attach") && !nestedType.equals("Image") && !nestedType.equals("Link")) {
return SUCCESS;
}
if (currentAttribute instanceof MonoListAttribute) {
List<AttributeInterface> attributes = ((MonoListAttribute) currentAttribute).getAttributes();
index = attributes.size() - 1;
} else if (currentAttribute instanceof ListAttribute) {
List<AttributeInterface> attributes = ((ListAttribute) currentAttribute).getAttributeList(this.getListLangCode());
index = attributes.size() - 1;
}
this.setElementIndex(index);
if (nestedType.equals("Attach") || nestedType.equals("Image")) {
this.setResourceTypeCode(nestedType);
return "chooseResource";
} else {
return "chooseLink";
}
} catch (Throwable t) {
_logger.error("error in addListElement", t);
// ApsSystemUtils.logThrowable(t, this, "addListElement");
return FAILURE;
}
}
Aggregations