Search in sources :

Example 81 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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 82 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content 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)

Example 83 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestValidateTextAttribute method testValidate_MonoListElement_2.

public void testValidate_MonoListElement_2() throws Throwable {
    try {
        String contentOnSessionMarker = this.executeCreateNewContent();
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        AttributeTracer tracerIT = this.getTracer();
        MonoListAttribute monolistAttribute = (MonoListAttribute) content.getAttribute("MonoLText");
        AttributeInterface textAttribute = monolistAttribute.addAttribute();
        String formFieldPrefix = "Monolist:" + textAttribute.getType() + ":";
        tracerIT.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracerIT.setListLang(this.getLangManager().getDefaultLang());
        tracerIT.setMonoListElement(true);
        tracerIT.setParentAttribute(monolistAttribute);
        AttributeTracer tracerEN = tracerIT.clone();
        tracerEN.setLang(this.getLangManager().getLang("en"));
        String monolistElementName = tracerIT.getMonolistElementFieldName(textAttribute);
        assertEquals(formFieldPrefix + "MonoLText_0", monolistElementName);
        String formITFieldName = tracerIT.getFormFieldName(textAttribute);
        assertEquals(formFieldPrefix + "it_MonoLText_0", formITFieldName);
        String formENFieldName = tracerEN.getFormFieldName(textAttribute);
        assertEquals(formFieldPrefix + "en_MonoLText_0", formENFieldName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName, "MonoLMonotElement0ValueEN");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName, "MonoLMonotElement0ValueEN");
        this.addParameter(formITFieldName, "MonoLMonotElement0ValueIT");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, monolistElementName);
        AttributeInterface attribute2 = monolistAttribute.addAttribute();
        tracerIT.setListIndex(monolistAttribute.getAttributes().size() - 1);
        tracerEN.setListIndex(monolistAttribute.getAttributes().size() - 1);
        String formITFieldName2 = tracerIT.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "it_MonoLText_1", formITFieldName2);
        String formENFieldName2 = tracerEN.getFormFieldName(attribute2);
        assertEquals(formFieldPrefix + "en_MonoLText_1", formENFieldName2);
        String monolistElementName2 = tracerIT.getMonolistElementFieldName(attribute2);
        assertEquals(formFieldPrefix + "MonoLText_1", monolistElementName2);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName2, "MonoLMonotElement1ValueEN");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(1, monolistElementName2);
        this.initSaveContentAction(contentOnSessionMarker);
        this.addParameter(formENFieldName2, "MonoLMonotElement1ValueEN");
        this.addParameter(formITFieldName2, "MonoLMonotElement1ValueIT");
        this.executeAction(Action.INPUT);
        this.checkFieldErrors(0, monolistElementName2);
    } 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) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 84 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentGroupBulkAction method deleteContents.

private void deleteContents(List<String> contentIds) throws ApsSystemException {
    for (String contentId : contentIds) {
        Content current = this._contentManager.loadContent(contentId, false);
        this._contentManager.deleteContent(current);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 85 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class ContentDAO method buildAddEntityStatement.

@Override
protected void buildAddEntityStatement(IApsEntity entity, PreparedStatement stat) throws Throwable {
    Content content = (Content) entity;
    stat.setString(1, content.getId());
    stat.setString(2, content.getTypeCode());
    stat.setString(3, content.getDescription());
    stat.setString(4, content.getStatus());
    stat.setString(5, content.getXML());
    String currentDate = DateConverter.getFormattedDate(new Date(), JacmsSystemConstants.CONTENT_METADATA_DATE_FORMAT);
    stat.setString(6, currentDate);
    stat.setString(7, currentDate);
    stat.setString(8, content.getMainGroup());
    stat.setString(9, content.getVersion());
    stat.setString(10, content.getFirstEditor());
    stat.setString(11, content.getLastEditor());
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) Date(java.util.Date)

Aggregations

Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)227 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)29 ArrayList (java.util.ArrayList)26 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 ActionSupport (com.opensymphony.xwork2.ActionSupport)14 List (java.util.List)14 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 HttpSession (javax.servlet.http.HttpSession)13 UserDetails (com.agiletec.aps.system.services.user.UserDetails)12 IPage (com.agiletec.aps.system.services.page.IPage)10 Date (java.util.Date)8 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)7 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)7 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)7 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)7 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6