Search in sources :

Example 11 with NumberAttribute

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

the class UserProfile method getValue.

private Object getValue(AttributeInterface attribute) {
    if (null == attribute)
        return "";
    if (attribute.isTextAttribute()) {
        return ((ITextAttribute) attribute).getText();
    } else if (attribute instanceof NumberAttribute) {
        return ((NumberAttribute) attribute).getValue();
    } else if (attribute instanceof BooleanAttribute) {
        return ((BooleanAttribute) attribute).getValue();
    } else if (attribute instanceof DateAttribute) {
        return ((DateAttribute) attribute).getDate();
    } else if (!attribute.isSimple()) {
        String text = "";
        List<AttributeInterface> attributes = ((AbstractComplexAttribute) attribute).getAttributes();
        for (int i = 0; i < attributes.size(); i++) {
            if (i > 0)
                text += ",";
            AttributeInterface attributeElem = attributes.get(i);
            text += this.getValue(attributeElem);
        }
        return text;
    }
    return null;
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) AbstractComplexAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractComplexAttribute) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 12 with NumberAttribute

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

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

the class BaseFilterAction method setFilterType.

@Override
public String setFilterType() {
    try {
        Content prototype = this.getContentManager().createContentType(this.getContentType());
        String key = this.getFilterKey();
        int attrFilterType = -1;
        AttributeInterface attribute = (AttributeInterface) prototype.getAttribute(key);
        if (null != attribute) {
            if (attribute instanceof ITextAttribute) {
                attrFilterType = TEXT_ATTRIBUTE_FILTER_TYPE;
            } else if (attribute instanceof NumberAttribute) {
                attrFilterType = NUMBER_ATTRIBUTE_FILTER_TYPE;
            } else if (attribute instanceof BooleanAttribute) {
                attrFilterType = BOOLEAN_ATTRIBUTE_FILTER_TYPE;
            } else if (attribute instanceof DateAttribute) {
                attrFilterType = DATE_ATTRIBUTE_FILTER_TYPE;
            }
        } else if ((METADATA_KEY_PREFIX + IContentManager.CONTENT_CREATION_DATE_FILTER_KEY).equals(key) || (METADATA_KEY_PREFIX + IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY).equals(key)) {
            key = key.substring(METADATA_KEY_PREFIX.length());
            this.setFilterKey(key);
            attrFilterType = METADATA_FILTER_TYPE;
        }
        this.setFilterTypeId(attrFilterType);
        if (this.getFilterTypeId() < 0) {
            this.setFilterKey(null);
        }
    } catch (Throwable t) {
        _logger.error("error in setFilterType", t);
        // ApsSystemUtils.logThrowable(t, this, "setFilterType");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 14 with NumberAttribute

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

the class NumberAttributeManager method setValue.

@Override
protected void setValue(AttributeInterface attribute, String value) {
    NumberAttribute numberAttribute = (NumberAttribute) attribute;
    BigDecimal number = null;
    if (value != null) {
        value = value.trim();
    }
    if (CheckFormatUtil.isValidNumber(value)) {
        try {
            number = new BigDecimal(value);
            numberAttribute.setFailedNumberString(null);
        } catch (NumberFormatException e) {
            throw new RuntimeException("The submitted string is not recognized as a valid number - " + value + " -");
        }
    } else {
        numberAttribute.setFailedNumberString(value);
    }
    numberAttribute.setValue(number);
}
Also used : NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) BigDecimal(java.math.BigDecimal)

Example 15 with NumberAttribute

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

the class AbstractBaseEntityAttributeConfigAction method valueFormFields.

/**
 * Fill form fields.
 * @param attribute
 */
protected void valueFormFields(AttributeInterface attribute) {
    this.setAttributeName(attribute.getName());
    if (null != attribute.getDescription() && attribute.getDescription().trim().length() > 0) {
        this.setAttributeDescription(attribute.getDescription());
    }
    this.setAttributeTypeCode(attribute.getType());
    if (null != attribute.getRoles()) {
        this.setAttributeRoles(Arrays.asList(attribute.getRoles()));
    }
    if (null != attribute.getDisablingCodes()) {
        this.setDisablingCodes(Arrays.asList(attribute.getDisablingCodes()));
    }
    IAttributeValidationRules valRule = attribute.getValidationRules();
    this.setRequired(valRule.isRequired());
    this.setOgnlValidationRule(valRule.getOgnlValidationRule());
    this.setSearchable(attribute.isSearchable());
    String indexingType = attribute.getIndexingType();
    if (null != indexingType) {
        this.setIndexable(indexingType.equalsIgnoreCase(IndexableAttributeInterface.INDEXING_TYPE_TEXT));
    }
    if (attribute.isTextAttribute()) {
        TextAttributeValidationRules textValRule = (TextAttributeValidationRules) valRule;
        if (null != textValRule.getMaxLength() && textValRule.getMaxLength() > -1) {
            this.setMaxLength(textValRule.getMaxLength());
        }
        if (null != textValRule.getMinLength() && textValRule.getMinLength() > -1) {
            this.setMinLength(textValRule.getMinLength());
        }
        this.setRegexp(textValRule.getRegexp());
        this.setRangeEndString((String) textValRule.getRangeEnd());
        this.setRangeStartString((String) textValRule.getRangeStart());
        this.setEqualString((String) textValRule.getValue());
        this.setRangeEndStringAttribute(textValRule.getRangeEndAttribute());
        this.setRangeStartStringAttribute(textValRule.getRangeStartAttribute());
        this.setEqualStringAttribute(textValRule.getValueAttribute());
        if (attribute instanceof EnumeratorAttribute) {
            EnumeratorAttribute enumeratorAttribute = (EnumeratorAttribute) attribute;
            this.setEnumeratorStaticItems(enumeratorAttribute.getStaticItems());
            this.setEnumeratorStaticItemsSeparator(enumeratorAttribute.getCustomSeparator());
            this.setEnumeratorExtractorBean(enumeratorAttribute.getExtractorBeanName());
        }
    }
    if (attribute instanceof DateAttribute) {
        DateAttributeValidationRules dateValRule = (DateAttributeValidationRules) valRule;
        this.setRangeEndDate((Date) dateValRule.getRangeEnd());
        this.setRangeStartDate((Date) dateValRule.getRangeStart());
        this.setEqualDate((Date) dateValRule.getValue());
        this.setRangeEndDateAttribute(dateValRule.getRangeEndAttribute());
        this.setRangeStartDateAttribute(dateValRule.getRangeStartAttribute());
        this.setEqualDateAttribute(dateValRule.getValueAttribute());
    }
    if (attribute instanceof NumberAttribute) {
        NumberAttributeValidationRules nulValRule = (NumberAttributeValidationRules) valRule;
        this.setRangeEndNumber((Integer) nulValRule.getRangeEnd());
        this.setRangeStartNumber((Integer) nulValRule.getRangeStart());
        this.setEqualNumber((Integer) nulValRule.getValue());
        this.setRangeEndNumberAttribute(nulValRule.getRangeEndAttribute());
        this.setRangeStartNumberAttribute(nulValRule.getRangeStartAttribute());
        this.setEqualNumberAttribute(nulValRule.getValueAttribute());
    }
}
Also used : EnumeratorAttribute(com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute) DateAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.DateAttributeValidationRules) IAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.IAttributeValidationRules) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) TextAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.TextAttributeValidationRules) NumberAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.NumberAttributeValidationRules) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Aggregations

NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)20 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)17 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)12 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)10 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)7 BigDecimal (java.math.BigDecimal)7 Date (java.util.Date)7 EnumeratorAttribute (com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute)4 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)3 DateAttributeValidationRules (com.agiletec.aps.system.common.entity.model.attribute.util.DateAttributeValidationRules)3 IAttributeValidationRules (com.agiletec.aps.system.common.entity.model.attribute.util.IAttributeValidationRules)3 NumberAttributeValidationRules (com.agiletec.aps.system.common.entity.model.attribute.util.NumberAttributeValidationRules)3 TextAttributeValidationRules (com.agiletec.aps.system.common.entity.model.attribute.util.TextAttributeValidationRules)3 CheckBoxAttribute (com.agiletec.aps.system.common.entity.model.attribute.CheckBoxAttribute)2 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)2 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)2 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)2 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)2 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)2