Search in sources :

Example 21 with CompositeAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute in project entando-core by entando.

the class TestValidateMonotextAttribute method testValidate_CompositeElement.

public void testValidate_CompositeElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        CompositeAttribute compositeAttribute = (CompositeAttribute) content.getAttribute("Composite");
        AttributeInterface attribute = compositeAttribute.getAttribute("Monotext");
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeAttribute);
        String formFieldName = tracer.getFormFieldName(attribute);
        String formFieldPrefix = "Composite:" + attribute.getType() + ":";
        assertEquals(formFieldPrefix + "Composite_Monotext", formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "MonotextValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 22 with CompositeAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute in project entando-core by entando.

the class TestValidateMonotextAttribute method testValidate_MonolistCompositeElement.

public void testValidate_MonolistCompositeElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLCom");
        CompositeAttribute compositeElement = (CompositeAttribute) monolist.addAttribute();
        AttributeInterface attribute = compositeElement.getAttribute("Monotext");
        String monolistElementFieldPrefix = "Monolist:Composite:";
        String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
        tracer.setListIndex(monolist.getAttributes().size() - 1);
        tracer.setListLang(this.getLangManager().getDefaultLang());
        tracer.setMonoListElement(true);
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeElement);
        String formFieldName = tracer.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + "MonoLCom_Monotext_0", formFieldName);
        String monolistElementName = tracer.getMonolistElementFieldName(compositeElement);
        assertEquals(monolistElementFieldPrefix + "MonoLCom_0", monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "MonotextValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 23 with CompositeAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute in project entando-core by entando.

the class TestValidateNumberAttribute method testValidate_MonolistCompositeElement.

public void testValidate_MonolistCompositeElement() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLCom");
        CompositeAttribute compositeElement = (CompositeAttribute) monolist.addAttribute();
        AttributeInterface attribute = compositeElement.getAttribute("Number");
        String monolistElementFieldPrefix = "Monolist:Composite:";
        String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
        tracer.setListIndex(monolist.getAttributes().size() - 1);
        tracer.setListLang(this.getLangManager().getDefaultLang());
        tracer.setMonoListElement(true);
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeElement);
        String formFieldName = tracer.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + "MonoLCom_Number_0", formFieldName);
        String monolistElementName = tracer.getMonolistElementFieldName(compositeElement);
        assertEquals(monolistElementFieldPrefix + "MonoLCom_0", monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "wrongNumberValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        // validation: start range 25
        this.addParameter(formFieldName, "10");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        // validation: start range 25
        this.addParameter(formFieldName, "50");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        // validation: end range attribute "Number"
        this.addParameter("Number:Number", "40");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        // validation: end range attribute "Number"
        this.addParameter(formFieldName, "35");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 24 with CompositeAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute in project entando-core by entando.

the class CompositeAttributeConfigAction method moveAttributeElement.

@Override
public String moveAttributeElement() {
    try {
        CompositeAttribute composite = this.getCompositeAttributeOnEdit();
        int elementIndex = this.getAttributeIndex();
        String movement = this.getMovement();
        List<AttributeInterface> attributes = composite.getAttributes();
        if (!(elementIndex == 0 && movement.equals(ApsAdminSystemConstants.MOVEMENT_UP_CODE)) && !(elementIndex == attributes.size() - 1 && movement.equals(ApsAdminSystemConstants.MOVEMENT_DOWN_CODE))) {
            AttributeInterface attributeToMove = attributes.get(elementIndex);
            attributes.remove(elementIndex);
            if (movement.equals(ApsAdminSystemConstants.MOVEMENT_UP_CODE)) {
                attributes.add(elementIndex - 1, attributeToMove);
            }
            if (movement.equals(ApsAdminSystemConstants.MOVEMENT_DOWN_CODE)) {
                attributes.add(elementIndex + 1, attributeToMove);
            }
        }
    } catch (Throwable t) {
        _logger.error("error in moveAttribute", t);
        // ApsSystemUtils.logThrowable(t, this, "moveAttribute");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 25 with CompositeAttribute

use of com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute in project entando-core by entando.

the class CompositeAttributeConfigAction method validate.

@Override
public void validate() {
    super.validate();
    CompositeAttribute composite = this.getCompositeAttributeOnEdit();
    if (null != composite.getAttribute(this.getAttributeName())) {
        String[] args = { this.getAttributeName() };
        this.addFieldError("attributeName", this.getText("error.entity.attribute.name.already.exists", args));
    }
}
Also used : CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)

Aggregations

CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)28 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)27 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)15 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)13 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)13 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)4 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)4 HttpSession (javax.servlet.http.HttpSession)4 AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)3 EnumeratorAttribute (com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute)3 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)3 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)3 CheckBoxAttribute (com.agiletec.aps.system.common.entity.model.attribute.CheckBoxAttribute)2 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)2 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)2 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)2 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)2 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)2 ThreeStateAttribute (com.agiletec.aps.system.common.entity.model.attribute.ThreeStateAttribute)2 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)2