use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface 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.AttributeInterface 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.AttributeInterface in project entando-core by entando.
the class DateAttributeManager method getCustomAttributeErrorMessage.
@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
AttributeInterface attribute = attributeFieldError.getAttribute();
DateAttributeValidationRules valRule = (DateAttributeValidationRules) attribute.getValidationRules();
if (null != valRule) {
String errorCode = attributeFieldError.getErrorCode();
if (errorCode.equals(FieldError.GREATER_THAN_ALLOWED)) {
Date endValue = (valRule.getRangeEnd() != null) ? (Date) valRule.getRangeEnd() : this.getOtherAttributeValue(attribute, valRule.getRangeEndAttribute());
String[] args = { DateConverter.getFormattedDate(endValue, "dd/MM/yyyy") };
return action.getText("DateAttribute.fieldError.greaterValue", args);
} else if (errorCode.equals(FieldError.LESS_THAN_ALLOWED)) {
Date startValue = (valRule.getRangeStart() != null) ? (Date) valRule.getRangeStart() : this.getOtherAttributeValue(attribute, valRule.getRangeStartAttribute());
String[] args = { DateConverter.getFormattedDate(startValue, "dd/MM/yyyy") };
return action.getText("DateAttribute.fieldError.lessValue", args);
} else if (errorCode.equals(FieldError.NOT_EQUALS_THAN_ALLOWED)) {
Date value = (valRule.getValue() != null) ? (Date) valRule.getValue() : this.getOtherAttributeValue(attribute, valRule.getValueAttribute());
String[] args = { DateConverter.getFormattedDate(value, "dd/MM/yyyy") };
return action.getText("DateAttribute.fieldError.wrongValue", args);
}
}
return action.getText(this.getInvalidAttributeMessage());
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class ListAttributeManager method updateAttribute.
@Override
protected void updateAttribute(AttributeInterface attribute, AttributeTracer tracer, HttpServletRequest request) {
List<Lang> langs = this.getLangManager().getLangs();
for (int i = 0; i < langs.size(); i++) {
Lang lang = langs.get(i);
List<AttributeInterface> attributeList = ((ListAttribute) attribute).getAttributeList(lang.getCode());
for (int j = 0; j < attributeList.size(); j++) {
AttributeInterface attributeElement = attributeList.get(j);
AttributeTracer elementTracer = (AttributeTracer) tracer.clone();
elementTracer.setListElement(true);
elementTracer.setListLang(lang);
elementTracer.setListIndex(j);
AbstractAttributeManager elementManager = (AbstractAttributeManager) this.getManager(attributeElement);
if (elementManager != null) {
elementManager.updateAttribute(attributeElement, elementTracer, request);
}
}
}
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class MonoListAttributeManager method updateAttribute.
@Override
protected void updateAttribute(AttributeInterface attribute, AttributeTracer tracer, HttpServletRequest request) {
List<AttributeInterface> attributes = ((MonoListAttribute) attribute).getAttributes();
for (int i = 0; i < attributes.size(); i++) {
AttributeInterface attributeElement = attributes.get(i);
AttributeTracer elementTracer = (AttributeTracer) tracer.clone();
elementTracer.setMonoListElement(true);
elementTracer.setListIndex(i);
AbstractAttributeManager elementManager = (AbstractAttributeManager) this.getManager(attributeElement);
if (elementManager != null) {
elementManager.updateAttribute(attributeElement, elementTracer, request);
}
}
}
Aggregations