use of com.agiletec.aps.system.common.entity.model.attribute.EnumeratorAttribute 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());
}
}
Aggregations