Search in sources :

Example 6 with LinkAttribute

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

the class LinkAttributeActionHelper method joinLink.

protected void joinLink(AttributeInterface attribute, String[] destinations, int destType, HttpServletRequest request) {
    HttpSession session = request.getSession();
    if (attribute instanceof CompositeAttribute) {
        String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
        AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
        updateLink(includedAttribute, destinations, destType);
    } else if (attribute instanceof MonoListAttribute) {
        Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
        joinLink(attributeElement, destinations, destType, request);
    } else if (attribute instanceof LinkAttribute) {
        updateLink(attribute, destinations, destType);
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) HttpSession(javax.servlet.http.HttpSession) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 7 with LinkAttribute

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

the class TestApiContentInterface method checkAttributes.

private void checkAttributes(AttributeInterface oldAttribute, AttributeInterface newAttribute) {
    if (null == newAttribute) {
        fail();
    }
    assertEquals(oldAttribute.getName(), newAttribute.getName());
    assertEquals(oldAttribute.getType(), newAttribute.getType());
    if (!oldAttribute.isSimple()) {
        if (oldAttribute instanceof AbstractListAttribute) {
            List<AttributeInterface> oldListAttributes = ((AbstractComplexAttribute) oldAttribute).getAttributes();
            List<AttributeInterface> newListAttributes = ((AbstractComplexAttribute) newAttribute).getAttributes();
            assertEquals(oldListAttributes.size(), newListAttributes.size());
            for (int i = 0; i < oldListAttributes.size(); i++) {
                AttributeInterface oldElement = oldListAttributes.get(i);
                AttributeInterface newElement = newListAttributes.get(i);
                this.checkAttributes(oldElement, newElement);
            }
        } else if (oldAttribute instanceof CompositeAttribute) {
            Map<String, AttributeInterface> oldAttributeMap = ((CompositeAttribute) oldAttribute).getAttributeMap();
            Map<String, AttributeInterface> newAttributeMap = ((CompositeAttribute) newAttribute).getAttributeMap();
            assertEquals(oldAttributeMap.size(), newAttributeMap.size());
            Iterator<String> iterator = oldAttributeMap.keySet().iterator();
            while (iterator.hasNext()) {
                String key = iterator.next();
                AttributeInterface oldElement = oldAttributeMap.get(key);
                AttributeInterface newElement = newAttributeMap.get(key);
                this.checkAttributes(oldElement, newElement);
            }
        }
    } else {
        if (oldAttribute instanceof AbstractResourceAttribute || oldAttribute instanceof LinkAttribute) {
            return;
        }
        assertEquals(oldAttribute.getValue(), newAttribute.getValue());
    }
}
Also used : AbstractResourceAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute) LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) AbstractComplexAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractComplexAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) Iterator(java.util.Iterator) Map(java.util.Map) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 8 with LinkAttribute

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

the class TestContentManager method testLoadContent.

public void testLoadContent() throws Throwable {
    Content content = this._contentManager.loadContent("ART111", false);
    assertEquals(Content.STATUS_PUBLIC, content.getStatus());
    assertEquals("coach", content.getMainGroup());
    assertEquals(2, content.getGroups().size());
    assertTrue(content.getGroups().contains("customers"));
    assertTrue(content.getGroups().contains("helpdesk"));
    Map<String, AttributeInterface> attributes = content.getAttributeMap();
    assertEquals(7, attributes.size());
    TextAttribute title = (TextAttribute) attributes.get("Titolo");
    assertEquals("Titolo Contenuto 3 Coach", title.getTextForLang("it"));
    assertNull(title.getTextForLang("en"));
    MonoListAttribute authors = (MonoListAttribute) attributes.get("Autori");
    assertEquals(4, authors.getAttributes().size());
    LinkAttribute link = (LinkAttribute) attributes.get("VediAnche");
    assertNull(link.getSymbolicLink());
    HypertextAttribute hypertext = (HypertextAttribute) attributes.get("CorpoTesto");
    assertEquals("<p>Corpo Testo Contenuto 3 Coach</p>", hypertext.getTextForLang("it").trim());
    assertNull(hypertext.getTextForLang("en"));
    ResourceAttributeInterface image = (ResourceAttributeInterface) attributes.get("Foto");
    assertNull(image.getResource());
    DateAttribute date = (DateAttribute) attributes.get("Data");
    assertEquals("13/12/2006", DateConverter.getFormattedDate(date.getDate(), "dd/MM/yyyy"));
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) HypertextAttribute(com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) TextAttribute(com.agiletec.aps.system.common.entity.model.attribute.TextAttribute) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 9 with LinkAttribute

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

the class TestValidateContent method testValidate_2.

public void testValidate_2() throws Throwable {
    try {
        Content content = this._contentManager.loadContent("EVN191", true);
        content.setId(null);
        // Valorizzo il gruppo proprietario
        content.setMainGroup(Group.FREE_GROUP_NAME);
        content.getGroups().add("customers");
        MonoListAttribute linksCorrelati = (MonoListAttribute) content.getAttribute("LinkCorrelati");
        LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
        List<FieldError> errors = content.validate(this._groupManager);
        assertNotNull(errors);
        assertEquals(1, errors.size());
        FieldError error = errors.get(0);
        // Verifica obbligatorietĂ  attributo "Titolo"
        assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
        assertEquals(FieldError.INVALID, error.getErrorCode());
        // AGGIUNGO LINK SU PAGINA COACH
        linkAttribute.setText("Descrizione link", "it");
        SymbolicLink symbolicLink = new SymbolicLink();
        // Contenuto di coach
        symbolicLink.setDestinationToContent("EVN103");
        linkAttribute.setSymbolicLink(symbolicLink);
        errors = content.validate(this._groupManager);
        assertNotNull(errors);
        assertEquals(1, errors.size());
        error = errors.get(0);
        assertEquals("Monolist:Link:LinkCorrelati_0", error.getFieldCode());
        assertEquals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS, error.getErrorCode());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) FieldError(com.agiletec.aps.system.common.entity.model.FieldError) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 10 with LinkAttribute

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

the class TestContentAction method testValidate_2.

public void testValidate_2() throws Throwable {
    String insertedDescr = "XXX Prova Validazione XXX";
    try {
        Content contentForTest = this.getContentManager().loadContent("EVN191", true);
        String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(contentForTest, ApsAdminSystemConstants.EDIT);
        contentForTest.setId(null);
        contentForTest.setDescription(insertedDescr);
        // Valorizzo il gruppo proprietario
        contentForTest.setMainGroup("coach");
        contentForTest.getGroups().add("customers");
        // AGGIUNGO LINK SU PAGINA COACH
        MonoListAttribute linksCorrelati = (MonoListAttribute) contentForTest.getAttribute("LinkCorrelati");
        LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
        linkAttribute.setText("Descrizione link", "it");
        SymbolicLink symbolicLink = new SymbolicLink();
        // Contenuto di coach
        symbolicLink.setDestinationToContent("EVN103");
        linkAttribute.setSymbolicLink(symbolicLink);
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, contentForTest);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getFieldErrors().size());
        assertEquals(1, action.getFieldErrors().get("Monolist:Link:LinkCorrelati_0").size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Aggregations

LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)15 SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)9 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)6 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)6 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)4 HttpSession (javax.servlet.http.HttpSession)4 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)1 AbstractComplexAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractComplexAttribute)1 AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)1 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)1 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)1 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)1 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)1 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)1 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)1 ActionSupport (com.opensymphony.xwork2.ActionSupport)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1