protected void fillAttributeCode() { CategoryAttribute attribute = getItem(); if (StringUtils.isBlank(attribute.getCode()) && StringUtils.isNotBlank(attribute.getName())) { String categoryName = StringUtils.EMPTY; if (attribute.getCategory() != null) { categoryName = StringUtils.defaultString(attribute.getCategory().getName()); } attribute.setCode(StringUtils.deleteWhitespace(categoryName + attribute.getName())); } }
protected void loadRequired(FieldGroup fieldGroup, FieldGroup.FieldConfig field) { CategoryAttribute attribute = dynamicAttributes.getAttributeForMetaClass(rds.resolveCategorizedEntityClass(), field.getId()); if (attribute != null) { String requiredMessage = messages.formatMainMessage( "validation.required.defaultMsg", attribute.getName() ); field.setRequired(Boolean.TRUE.equals(attribute.getRequired()) && requiredControlEnabled); field.setRequiredMessage(requiredMessage); } }
protected String getColumnCaption(Object columnId, Column column) { String caption = column.getCaption(); if (caption != null) { return caption; } if (!(columnId instanceof MetaPropertyPath)) { return StringUtils.capitalize(getColumnCaption(columnId)); } MetaPropertyPath mpp = (MetaPropertyPath) columnId; MetaProperty metaProperty = mpp.getMetaProperty(); if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) { CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty); if (LocaleHelper.isLocalizedValueDefined(categoryAttribute.getLocaleNames())) { return categoryAttribute.getLocaleName(); } caption = StringUtils.capitalize(categoryAttribute.getName()); } else { caption = StringUtils.capitalize(getColumnCaption(columnId)); } return caption; }
@Override public void postValidate(ValidationErrors errors) { @SuppressWarnings("unchecked") CollectionDatasource<CategoryAttribute, UUID> parent = (CollectionDatasource<CategoryAttribute, UUID>) ((DatasourceImplementation) attributeDs).getParent(); if (parent != null) { CategoryAttribute categoryAttribute = getItem(); for (UUID id : parent.getItemIds()) { CategoryAttribute ca = parent.getItemNN(id); if (ca.getName().equals(categoryAttribute.getName()) && (!ca.equals(categoryAttribute))) { errors.add(getMessage("uniqueName")); return; } else if (ca.getCode() != null && ca.getCode().equals(categoryAttribute.getCode()) && (!ca.equals(categoryAttribute))) { errors.add(getMessage("uniqueCode")); return; } } } }
StringUtils.capitalize(categoryAttribute.getName()); } else { MetaClass propertyMetaClass = getMetadataTools().getPropertyEnclosingMetaClass(mpp);
columnCaption = LocaleHelper.isLocalizedValueDefined(categoryAttribute.getLocaleNames()) ? categoryAttribute.getLocaleName() : StringUtils.capitalize(categoryAttribute.getName()); } else { MetaClass propertyMetaClass = getMetadataTools().getPropertyEnclosingMetaClass(column.getPropertyPath());
StringUtils.capitalize(attribute.getName()));
StringUtils.capitalize(attribute.getName()));