Search in sources :

Example 51 with AttributeInterface

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;
}
Also used : ListAttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) List(java.util.List) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ListAttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Example 52 with AttributeInterface

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);
        }
    }
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 53 with AttributeInterface

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());
}
Also used : DateAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.DateAttributeValidationRules) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) Date(java.util.Date)

Example 54 with AttributeInterface

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);
            }
        }
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Lang(com.agiletec.aps.system.services.lang.Lang) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)

Example 55 with AttributeInterface

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);
        }
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)147 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)38 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)37 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 ArrayList (java.util.ArrayList)18 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)17 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)16 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)14 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)12 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)11 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)10 HttpSession (javax.servlet.http.HttpSession)10 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)9 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)7 Lang (com.agiletec.aps.system.services.lang.Lang)7 Date (java.util.Date)7