Search in sources :

Example 11 with AttributeTracer

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

the class TestValidateNumberAttribute method testValidate_Single_1.

public void testValidate_Single_1() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        AttributeInterface numberAttribute = (AttributeInterface) content.getAttribute("Number");
        String formFieldName = tracer.getFormFieldName(numberAttribute);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "wrongNumber");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "41");
        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) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 12 with AttributeTracer

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

the class TestValidateNumberAttribute 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("Number");
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeAttribute);
        String formFieldName = tracer.getFormFieldName(attribute);
        String formFieldPrefix = "Composite:" + attribute.getType() + ":";
        assertEquals(formFieldPrefix + "Composite_Number", formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "wrongNumberValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        // OGNL VALIDATION - evalOnValuedAttribute="true"
        // #entity.getAttribute(''Number'').value == null || (#entity.getAttribute(''Number'').value != null && value > #entity.getAttribute(''Number'').value)
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "58");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter("Number:Number", "100");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "101");
        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 13 with AttributeTracer

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

the class TestValidateResourceAttribute method testValidate_MonolistCompositeElement.

protected void testValidate_MonolistCompositeElement(String elementName, String testResourceId) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLCom");
        CompositeAttribute compositeElement = (CompositeAttribute) monolistAttribute.addAttribute();
        AttributeInterface attribute = compositeElement.getAttribute(elementName);
        String monolistElementFieldPrefix = "Monolist:Composite:";
        String formFieldPrefix = monolistElementFieldPrefix + attribute.getType() + ":";
        tracerIT.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracerIT.setListLang(this.getLangManager().getDefaultLang());
        tracerIT.setMonoListElement(true);
        tracerIT.setCompositeElement(true);
        tracerIT.setParentAttribute(compositeElement);
        String formITFieldName = tracerIT.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + "it_MonoLCom_" + elementName + "_0", formITFieldName);
        String monolistElementName = tracerIT.getMonolistElementFieldName(compositeElement);
        assertEquals(monolistElementFieldPrefix + "MonoLCom_0", monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formITFieldName, "itValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldPrefix + "MonoLCom_" + elementName + "_0");
        content = this.getContentOnEdit(contentOnSessionMarker);
        monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLCom");
        compositeElement = (CompositeAttribute) monolistAttribute.getAttribute(0);
        AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) compositeElement.getAttribute(elementName);
        ResourceInterface resource = this._resourceManager.loadResource(testResourceId);
        resourceAttribute.setResource(resource, this.getLangManager().getDefaultLang().getCode());
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, "MonoLCom_" + elementName + "_0");
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) 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) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 14 with AttributeTracer

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

the class TestValidateResourceAttribute method testValidate_CompositeElement.

protected void testValidate_CompositeElement(String elementName, String testResourceId) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        CompositeAttribute compositeAttribute = (CompositeAttribute) content.getAttribute("Composite");
        AttributeInterface attribute = compositeAttribute.getAttribute(elementName);
        String formFieldPrefix = "Composite:" + attribute.getType() + ":";
        tracerIT.setCompositeElement(true);
        tracerIT.setParentAttribute(compositeAttribute);
        String formITFieldName = tracerIT.getFormFieldName(attribute);
        assertEquals(formFieldPrefix + "it_Composite_" + elementName, formITFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formITFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formITFieldName, "itValue");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, formFieldPrefix + "Composite_" + elementName);
        content = this.getContentOnEdit(contentOnSessionMarker);
        compositeAttribute = (CompositeAttribute) content.getAttribute("Composite");
        AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) compositeAttribute.getAttribute(elementName);
        ResourceInterface resource = this._resourceManager.loadResource(testResourceId);
        resourceAttribute.setResource(resource, this.getLangManager().getDefaultLang().getCode());
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldPrefix + "Composite_" + elementName);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) 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) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 15 with AttributeTracer

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

the class TestValidateResourceAttribute method testValidate_MonoListElement.

protected void testValidate_MonoListElement(String mlAttributeName) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute(mlAttributeName);
        AttributeInterface newResourceAttribute = monolistAttribute.addAttribute();
        String monolistElementFieldPrefix = "Monolist:" + newResourceAttribute.getType() + ":";
        tracer.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracer.setListLang(this.getLangManager().getDefaultLang());
        tracer.setMonoListElement(true);
        tracer.setParentAttribute(monolistAttribute);
        String monolistElementName = tracer.getMonolistElementFieldName(newResourceAttribute);
        assertEquals(monolistElementFieldPrefix + mlAttributeName + "_0", monolistElementName);
        String formFieldName = tracer.getFormFieldName(newResourceAttribute);
        assertEquals(monolistElementFieldPrefix + "it_" + mlAttributeName + "_0", formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "resourceDescrMonolElement0Value");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        content = this.getContentOnEdit(contentOnSessionMarker);
        monolistAttribute = (MonoListAttribute) content.getAttribute(mlAttributeName);
        AbstractResourceAttribute resourceAttribute = (AbstractResourceAttribute) monolistAttribute.getAttribute(0);
        ResourceInterface resource = this._resourceManager.loadResource("7");
        resourceAttribute.setResource(resource, this.getLangManager().getDefaultLang().getCode());
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, monolistElementName);
        AttributeInterface attribute2 = monolistAttribute.addAttribute();
        tracer.setListIndex(monolistAttribute.getAttributes().size() - 1);
        String formFieldName2 = tracer.getFormFieldName(attribute2);
        assertEquals(monolistElementFieldPrefix + "it_" + mlAttributeName + "_1", formFieldName2);
        String monolistElementName2 = tracer.getMonolistElementFieldName(attribute2);
        assertEquals(monolistElementFieldPrefix + mlAttributeName + "_1", monolistElementName2);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName2);
    } catch (Throwable t) {
        this.deleteTestContent();
        throw t;
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)51 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)39 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)18 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)9 Lang (com.agiletec.aps.system.services.lang.Lang)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)5 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)5 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)3 ArrayList (java.util.ArrayList)3 AttributeSearchInfo (com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)2 AttributeManagerInterface (com.agiletec.apsadmin.system.entity.attribute.manager.AttributeManagerInterface)1 SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)1 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)1 SymbolicLinkValidator (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator)1 Field (org.apache.lucene.document.Field)1 IntField (org.apache.lucene.document.IntField)1 StringField (org.apache.lucene.document.StringField)1