Search in sources :

Example 21 with MonoListAttribute

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

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

the class EntityAttributeConfigAction method getAllowedNestedTypes.

public List<AttributeInterface> getAllowedNestedTypes(AttributeInterface listType) {
    List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
        while (attributeIter.hasNext()) {
            AttributeInterface attribute = attributeIter.next();
            boolean simple = attribute.isSimple();
            boolean multiLanguage = attribute.isMultilingual();
            if ((listType instanceof ListAttribute && simple && !multiLanguage) || (listType instanceof MonoListAttribute && !(attribute instanceof AbstractListAttribute))) {
                attributes.add(attribute);
            }
        }
        Collections.sort(attributes, new BeanComparator("type"));
    } catch (Throwable t) {
        _logger.error("Error while extracting Allowed Nested Types", t);
        // ApsSystemUtils.logThrowable(t, this, "getAllowedNestedTypes");
        throw new RuntimeException("Error while extracting Allowed Nested Types", t);
    }
    return attributes;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Example 23 with MonoListAttribute

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

the class EntityAttributeDto method fillEntityAttribute.

public void fillEntityAttribute(AttributeInterface attribute, BindingResult bindingResult) {
    if (attribute instanceof ITextAttribute) {
        ITextAttribute textAttribute = (ITextAttribute) attribute;
        if (attribute.isMultilingual() && this.getValues() != null && !this.getValues().isEmpty()) {
            this.getValues().keySet().stream().forEach(langCode -> textAttribute.setText(this.getValues().get(langCode).toString(), langCode));
        } else if (null != this.getValue()) {
            textAttribute.setText(this.getValue().toString(), null);
        }
    }
    if (attribute instanceof NumberAttribute && (null != this.getValue())) {
        BigDecimal number = new BigDecimal(this.getValue().toString());
        ((NumberAttribute) attribute).setValue(number);
    }
    if (attribute instanceof BooleanAttribute) {
        ((BooleanAttribute) attribute).setBooleanValue((Boolean) this.getValue());
    }
    if (attribute instanceof DateAttribute && (null != this.getValue())) {
        Date date = null;
        String dateValue = null;
        try {
            date = DateConverter.parseDate(this.getValue().toString(), SystemConstants.API_DATE_FORMAT);
        } catch (Exception e) {
            dateValue = this.getValue().toString();
        }
        ((DateAttribute) attribute).setDate(date);
        ((DateAttribute) attribute).setFailedDateString(dateValue);
    }
    if (attribute instanceof CompositeAttribute && (null != this.getCompositeElements())) {
        this.getCompositeElements().stream().forEach(i -> {
            AttributeInterface compositeElement = ((CompositeAttribute) attribute).getAttribute(i.getCode());
            i.fillEntityAttribute(compositeElement, bindingResult);
        });
    } else if (attribute instanceof MonoListAttribute && (null != this.getElements())) {
        this.getElements().stream().forEach(i -> {
            AttributeInterface prototype = ((MonoListAttribute) attribute).addAttribute();
            prototype.setName(((MonoListAttribute) attribute).getName());
            i.fillEntityAttribute(prototype, bindingResult);
        });
    } else if (attribute instanceof ListAttribute && (null != this.getListElements())) {
        ((ListAttribute) attribute).getAttributeListMap().clear();
        this.getListElements().keySet().stream().forEach(langCode -> {
            List<EntityAttributeDto> list = this.getListElements().get(langCode);
            list.stream().forEach(i -> {
                AttributeInterface prototype = ((ListAttribute) attribute).addAttribute(langCode);
                prototype.setName(((ListAttribute) attribute).getName());
                i.fillEntityAttribute(prototype, bindingResult);
            });
        });
    }
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) Logger(org.slf4j.Logger) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) Date(java.util.Date) SystemConstants(com.agiletec.aps.system.SystemConstants) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) BindingResult(org.springframework.validation.BindingResult) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) TextAttribute(com.agiletec.aps.system.common.entity.model.attribute.TextAttribute) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute) BigDecimal(java.math.BigDecimal) AbstractMap(java.util.AbstractMap) List(java.util.List) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) Map(java.util.Map) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) DateConverter(com.agiletec.aps.util.DateConverter) ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) BigDecimal(java.math.BigDecimal) Date(java.util.Date) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 24 with MonoListAttribute

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

the class TestContentManager method testLoadFullContent.

public void testLoadFullContent() throws Throwable {
    Content content = this._contentManager.loadContent("ALL4", false);
    assertEquals(Content.STATUS_PUBLIC, content.getStatus());
    assertEquals(Group.FREE_GROUP_NAME, content.getMainGroup());
    assertEquals(0, content.getGroups().size());
    Map<String, AttributeInterface> attributes = content.getAttributeMap();
    assertEquals(43, attributes.size());
    AttachAttribute attachAttribute = (AttachAttribute) attributes.get("Attach");
    assertNotNull(attachAttribute);
    assertEquals("7", attachAttribute.getResource("it").getId());
    assertEquals("text Attach", attachAttribute.getTextForLang("it"));
    CheckBoxAttribute checkBoxAttribute = (CheckBoxAttribute) attributes.get("CheckBox");
    assertNotNull(checkBoxAttribute);
    assertNull(checkBoxAttribute.getBooleanValue());
    DateAttribute dateAttribute = (DateAttribute) attributes.get("Date");
    assertNotNull(dateAttribute);
    assertEquals("20100321", DateConverter.getFormattedDate(dateAttribute.getDate(), "yyyyMMdd"));
    DateAttribute dateAttribute2 = (DateAttribute) attributes.get("Date2");
    assertNotNull(dateAttribute2);
    assertEquals("20120321", DateConverter.getFormattedDate(dateAttribute2.getDate(), "yyyyMMdd"));
    EnumeratorAttribute enumeratorAttribute = (EnumeratorAttribute) attributes.get("Enumerator");
    assertNotNull(enumeratorAttribute);
    assertEquals("a", enumeratorAttribute.getText());
    EnumeratorMapAttribute enumeratorMapAttribute = (EnumeratorMapAttribute) attributes.get("EnumeratorMap");
    assertNotNull(enumeratorMapAttribute);
    assertEquals("02", enumeratorMapAttribute.getMapKey());
    assertEquals("Value 2", enumeratorMapAttribute.getMapValue());
    HypertextAttribute hypertextAttribute = (HypertextAttribute) attributes.get("Hypertext");
    assertNotNull(hypertextAttribute);
    assertEquals("<p>text Hypertext</p>", hypertextAttribute.getTextForLang("it"));
    ImageAttribute imageAttribute = (ImageAttribute) attributes.get("Image");
    assertNotNull(imageAttribute);
    assertEquals("44", imageAttribute.getResource("it").getId());
    assertEquals("text image", imageAttribute.getTextForLang("it"));
    TextAttribute longtextAttribute = (TextAttribute) attributes.get("Longtext");
    assertNotNull(longtextAttribute);
    assertEquals("text Longtext", longtextAttribute.getTextForLang("it"));
    MonoTextAttribute monoTextAttribute = (MonoTextAttribute) attributes.get("Monotext");
    assertNotNull(monoTextAttribute);
    assertEquals("text Monotext", monoTextAttribute.getText());
    MonoTextAttribute monoTextAttribute2 = (MonoTextAttribute) attributes.get("Monotext2");
    assertNotNull(monoTextAttribute2);
    assertEquals("aaaa@entando.com", monoTextAttribute2.getText());
    NumberAttribute numberAttribute = (NumberAttribute) attributes.get("Number");
    assertNotNull(numberAttribute);
    assertEquals(25, numberAttribute.getValue().intValue());
    NumberAttribute numberAttribute2 = (NumberAttribute) attributes.get("Number2");
    assertNotNull(numberAttribute2);
    assertEquals(85, numberAttribute2.getValue().intValue());
    TextAttribute textAttribute = (TextAttribute) attributes.get("Text");
    assertNotNull(textAttribute);
    assertEquals("text Text", textAttribute.getTextForLang("it"));
    TextAttribute textAttribute2 = (TextAttribute) attributes.get("Text2");
    assertNotNull(textAttribute2);
    assertEquals("bbbb@entando.com", textAttribute2.getTextForLang("it"));
    ThreeStateAttribute threeStateAttribute = (ThreeStateAttribute) attributes.get("ThreeState");
    assertNotNull(threeStateAttribute);
    assertEquals(Boolean.FALSE, threeStateAttribute.getBooleanValue());
    CompositeAttribute compositeAttribute = (CompositeAttribute) attributes.get("Composite");
    assertNotNull(compositeAttribute);
    assertEquals(13, compositeAttribute.getAttributeMap().size());
    ListAttribute listAttribute1 = (ListAttribute) attributes.get("ListBoolea");
    assertNotNull(listAttribute1);
    assertEquals(2, listAttribute1.getAttributeList("it").size());
    ListAttribute listAttribute2 = (ListAttribute) attributes.get("ListCheck");
    assertNotNull(listAttribute2);
    assertEquals(2, listAttribute2.getAttributeList("it").size());
    ListAttribute listAttribute3 = (ListAttribute) attributes.get("ListDate");
    assertNotNull(listAttribute3);
    assertEquals(2, listAttribute3.getAttributeList("it").size());
    ListAttribute listAttribute4 = (ListAttribute) attributes.get("ListEnum");
    assertNotNull(listAttribute4);
    assertEquals(2, listAttribute4.getAttributeList("it").size());
    ListAttribute listAttribute5 = (ListAttribute) attributes.get("ListMonot");
    assertNotNull(listAttribute5);
    assertEquals(2, listAttribute5.getAttributeList("it").size());
    ListAttribute listAttribute6 = (ListAttribute) attributes.get("ListNumber");
    assertNotNull(listAttribute6);
    assertEquals(2, listAttribute6.getAttributeList("it").size());
    ListAttribute listAttribute7 = (ListAttribute) attributes.get("List3Stat");
    assertNotNull(listAttribute7);
    assertEquals(3, listAttribute7.getAttributeList("it").size());
    MonoListAttribute monoListAttribute1 = (MonoListAttribute) attributes.get("MonoLAtta");
    assertNotNull(monoListAttribute1);
    assertEquals(1, monoListAttribute1.getAttributes().size());
    MonoListAttribute monoListAttribute2 = (MonoListAttribute) attributes.get("MonoLBool");
    assertNotNull(monoListAttribute2);
    assertEquals(2, monoListAttribute2.getAttributes().size());
    MonoListAttribute monoListAttribute3 = (MonoListAttribute) attributes.get("MonoLChec");
    assertNotNull(monoListAttribute3);
    assertEquals(2, monoListAttribute3.getAttributes().size());
    MonoListAttribute monoListAttribute4 = (MonoListAttribute) attributes.get("MonoLCom");
    assertNotNull(monoListAttribute4);
    assertEquals(1, monoListAttribute4.getAttributes().size());
    MonoListAttribute monoListAttribute5 = (MonoListAttribute) attributes.get("MonoLCom2");
    assertNotNull(monoListAttribute5);
    assertEquals(2, monoListAttribute5.getAttributes().size());
    MonoListAttribute monoListAttribute6 = (MonoListAttribute) attributes.get("MonoLDate");
    assertNotNull(monoListAttribute6);
    assertEquals(2, monoListAttribute6.getAttributes().size());
    MonoListAttribute monoListAttribute7 = (MonoListAttribute) attributes.get("MonoLEnum");
    assertNotNull(monoListAttribute7);
    assertEquals(2, monoListAttribute7.getAttributes().size());
    MonoListAttribute monoListAttribute8 = (MonoListAttribute) attributes.get("MonoLHyper");
    assertNotNull(monoListAttribute8);
    assertEquals(2, monoListAttribute8.getAttributes().size());
    MonoListAttribute monoListAttribute9 = (MonoListAttribute) attributes.get("MonoLImage");
    assertNotNull(monoListAttribute9);
    assertEquals(1, monoListAttribute9.getAttributes().size());
    MonoListAttribute monoListAttribute10 = (MonoListAttribute) attributes.get("MonoLLink");
    assertNotNull(monoListAttribute10);
    assertEquals(2, monoListAttribute10.getAttributes().size());
    MonoListAttribute monoListAttribute11 = (MonoListAttribute) attributes.get("MonoLLong");
    assertNotNull(monoListAttribute11);
    assertEquals(1, monoListAttribute11.getAttributes().size());
    MonoListAttribute monoListAttribute12 = (MonoListAttribute) attributes.get("MonoLMonot");
    assertNotNull(monoListAttribute12);
    assertEquals(2, monoListAttribute12.getAttributes().size());
    MonoListAttribute monoListAttribute13 = (MonoListAttribute) attributes.get("MonoLNumb");
    assertNotNull(monoListAttribute13);
    assertEquals(2, monoListAttribute13.getAttributes().size());
    MonoListAttribute monoListAttribute14 = (MonoListAttribute) attributes.get("MonoLText");
    assertNotNull(monoListAttribute14);
    assertEquals(2, monoListAttribute14.getAttributes().size());
    MonoListAttribute monoListAttribute15 = (MonoListAttribute) attributes.get("MonoL3stat");
    assertNotNull(monoListAttribute15);
    assertEquals(3, monoListAttribute15.getAttributes().size());
    EnumeratorMapAttribute enumeratorMapAttribute2 = (EnumeratorMapAttribute) attributes.get("EnumeratorMapBis");
    assertNotNull(enumeratorMapAttribute2);
    assertEquals("01", enumeratorMapAttribute2.getMapKey());
    assertEquals("Value 1 Bis", enumeratorMapAttribute2.getMapValue());
}
Also used : HypertextAttribute(com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute) EnumeratorMapAttribute(org.entando.entando.aps.system.common.entity.model.attribute.EnumeratorMapAttribute) TextAttribute(com.agiletec.aps.system.common.entity.model.attribute.TextAttribute) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute) ImageAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ImageAttribute) ThreeStateAttribute(com.agiletec.aps.system.common.entity.model.attribute.ThreeStateAttribute) EnumeratorAttribute(com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) AttachAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AttachAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) CheckBoxAttribute(com.agiletec.aps.system.common.entity.model.attribute.CheckBoxAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 25 with MonoListAttribute

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

Aggregations

MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)41 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)34 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)25 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)16 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)14 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)9 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)6 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)5 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)5 HttpSession (javax.servlet.http.HttpSession)5 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)4 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)4 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)4 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)4 List (java.util.List)4 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)3 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)3 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3