Search in sources :

Example 21 with AttributeTracer

use of com.agiletec.aps.system.common.entity.model.AttributeTracer 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 22 with AttributeTracer

use of com.agiletec.aps.system.common.entity.model.AttributeTracer 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)

Example 23 with AttributeTracer

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

the class TestValidateBooleanAttributes method validateSingle.

protected void validateSingle(String attributeName) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        AttributeInterface booleanAttribute = (AttributeInterface) content.getAttribute(attributeName);
        String formFieldName = tracer.getFormFieldName(booleanAttribute);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "true");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "false");
        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 24 with AttributeTracer

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

the class TestValidateBooleanAttributes method validateListElement.

protected void validateListElement(String listAttributeName) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        ListAttribute list = (ListAttribute) content.getAttribute(listAttributeName);
        AttributeInterface attributeIT = list.addAttribute("it");
        assertEquals(0, list.getAttributeList("en").size());
        assertEquals(1, list.getAttributeList("it").size());
        tracerIT.setListIndex(list.getAttributeList("it").size() - 1);
        tracerIT.setListLang(this.getLangManager().getLang("it"));
        tracerIT.setListElement(true);
        String formFieldItName = tracerIT.getFormFieldName(attributeIT);
        String formFieldPrefix = "List:" + attributeIT.getType() + ":";
        assertEquals(formFieldPrefix + "it_" + listAttributeName + "_0", formFieldItName);
        AttributeTracer tracerEN = tracerIT.clone();
        tracerEN.setLang(this.getLangManager().getLang("en"));
        tracerEN.setListLang(this.getLangManager().getLang("en"));
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "true");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "false");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        AttributeInterface attribute2 = list.addAttribute("it");
        tracerIT.setListIndex(list.getAttributes().size() - 1);
        formFieldItName = tracerIT.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "it_" + listAttributeName + "_1", formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldItName, "true");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldItName);
        AttributeInterface attributeEN = list.addAttribute("en");
        String formFieldEnName = tracerEN.getFormFieldName(attributeEN);
        assertEquals(formFieldPrefix + "en_" + listAttributeName + "_0", formFieldEnName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldEnName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldEnName, "true");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldEnName);
    } 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) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 25 with AttributeTracer

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

the class TestValidateBooleanAttributes method validateCompositeElement.

protected void validateCompositeElement(String compositeAttributeName, String attributeName) throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracer = this.getTracer();
        CompositeAttribute compositeAttribute = (CompositeAttribute) content.getAttribute(compositeAttributeName);
        AttributeInterface attribute = compositeAttribute.getAttribute(attributeName);
        tracer.setCompositeElement(true);
        tracer.setParentAttribute(compositeAttribute);
        String formFieldName = tracer.getFormFieldName(attribute);
        String formFieldPrefix = "Composite:" + attribute.getType() + ":";
        assertEquals(formFieldPrefix + compositeAttributeName + "_" + attributeName, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "true");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, formFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formFieldName, "false");
        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)

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