/** * For collection dynamic attributes the method returns a list of formatted collection items joined with the comma, * for non-collection dynamic attribute a formatted value is returned */ @SuppressWarnings("unchecked") public String getDynamicAttributeValueAsString(MetaProperty metaProperty, Object value) { CategoryAttribute categoryAttribute = getCategoryAttribute(metaProperty); if (categoryAttribute.getIsCollection()) { if (value instanceof Collection) { List<String> valuesList = ((Collection<Object>) value).stream() .map(item -> metadataTools.format(item, metaProperty)) .collect(Collectors.toList()); return Joiner.on(", ").join(valuesList); } } return metadataTools.format(value, metaProperty); } }
protected boolean isCollectionDynamicAttribute(MetaProperty metaProperty) { if (DynamicAttributesUtils.isDynamicAttribute(metaProperty.getName())) { CategoryAttribute attribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty); return attribute != null && BooleanUtils.isTrue(attribute.getIsCollection()); } return false; } }
.filter(cav -> cav.getCategoryAttribute().getIsCollection()) .collect(Collectors.toList());
protected EntityPropertyDiff getDynamicAttributeDifference(Object firstValue, Object secondValue, MetaProperty metaProperty, CategoryAttribute categoryAttribute) { Range range = metaProperty.getRange(); if (range.isDatatype() || range.isEnum()) { if (!Objects.equals(firstValue, secondValue)) { return new EntityBasicPropertyDiff(firstValue, secondValue, metaProperty); } } else if (range.isClass()) { if (BooleanUtils.isTrue(categoryAttribute.getIsCollection())) { return getDynamicAttributeCollectionDiff(firstValue, secondValue, metaProperty); } else { if (!Objects.equals(firstValue, secondValue)) { return new EntityClassPropertyDiff(firstValue, secondValue, metaProperty); } } } return null; }
protected void fillOperationSelect(CategoryAttribute categoryAttribute) { Class clazz = DynamicAttributesUtils.getAttributeClass(categoryAttribute); OpManager opManager = AppBeans.get(OpManager.class); EnumSet<Op> availableOps = BooleanUtils.isTrue(categoryAttribute.getIsCollection()) ? opManager.availableOpsForCollectionDynamicAttribute() : opManager.availableOps(clazz); List<Op> ops = new LinkedList<>(availableOps); operationLookup.setOptionsList(ops); Op operator = condition.getOperator(); if (operator != null) { operationLookup.setValue(operator); } } }
protected Set<String> getAllAttributes(Entity entity) { if (entity == null) { return null; } Set<String> attributes = new HashSet<>(); MetaClass metaClass = metadata.getClassNN(entity.getClass()); for (MetaProperty metaProperty : metaClass.getProperties()) { Range range = metaProperty.getRange(); if (range.isClass() && range.getCardinality().isMany()) { continue; } attributes.add(metaProperty.getName()); } Collection<CategoryAttribute> categoryAttributes = dynamicAttributes.getAttributesForMetaClass(metaClass); if (categoryAttributes != null) { for (CategoryAttribute categoryAttribute : categoryAttributes) { if (BooleanUtils.isNotTrue(categoryAttribute.getIsCollection())) { attributes.add( DynamicAttributesUtils.getMetaPropertyPath(metaClass, categoryAttribute).getMetaProperty().getName()); } } } return attributes; }
protected boolean allowLogProperty(MetaProperty metaProperty, CategoryAttribute categoryAttribute) { if (systemAttrsList.contains(metaProperty.getName())) { return false; } Range range = metaProperty.getRange(); if (range.isClass() && metadata.getTools().hasCompositePrimaryKey(range.asClass()) && !HasUuid.class.isAssignableFrom(range.asClass().getJavaClass())) { return false; } if (range.isClass() && range.getCardinality().isMany()) { return false; } if (categoryAttribute != null && BooleanUtils.isTrue(categoryAttribute.getIsCollection())) { return false; } return true; }
@Nullable public Field createField(Datasource datasource, MetaProperty property) { if (DynamicAttributesUtils.isDynamicAttribute(property)) { CategoryAttribute attribute = DynamicAttributesUtils.getCategoryAttribute(property); if (attribute.getDataType().equals(PropertyType.ENUMERATION)) { return createEnumField(datasource, property); } else if (attribute.getIsCollection()) { return createListEditorField(datasource, property); } } if (property.getRange().isDatatype()) { Class type = property.getRange().asDatatype().getJavaClass(); if (type.equals(String.class)) { return createStringField(datasource, property); } else if (type.equals(Boolean.class)) { return createBooleanField(datasource, property); } else if (type.equals(java.sql.Date.class) || type.equals(Date.class)) { return createDateField(datasource, property); } else if (type.equals(Time.class)) { return createTimeField(datasource, property); } else if (Number.class.isAssignableFrom(type)) { return createNumberField(datasource, property); } } else if (property.getRange().isClass()) { return createEntityField(datasource, property); } else if (property.getRange().isEnum()) { return createEnumField(datasource, property); } return null; }
if (categoryAttribute.getIsCollection() && value instanceof Collection) { return dynamicAttributesTools.getDynamicAttributeValueAsString(property, value);
if (BooleanUtils.isTrue(categoryAttributeValue.getCategoryAttribute().getIsCollection()) && categoryAttributeValue.getChildValues() != null) { for (CategoryAttributeValue childCAV : categoryAttributeValue.getChildValues()) { for (CategoryAttributeValue mergedChildCAV : mergedCategoryAttributeValue.getChildValues()) { if (BooleanUtils.isTrue(mergedCategoryAttributeValue.getCategoryAttribute().getIsCollection())) { storeCategoryAttributeValueWithCollectionType(mergedCategoryAttributeValue);
if (Boolean.TRUE.equals(attribute.getIsCollection())) { dynamicAttrComponent = getDynamicAttributesComponentsGenerator() .generateComponent(provider.getValueSource(code), attribute);
Entity defaultEntity = dataManager.load(lc); item.setValue(code, defaultEntity); } else if (Boolean.TRUE.equals(categoryAttribute.getIsCollection())) { List<Object> list = new ArrayList<>(); list.add(categoryAttribute.getDefaultValue());
if (BooleanUtils.isTrue(attribute.getIsCollection())) { CustomFieldGenerator fieldGenerator = new DynamicAttributeCustomFieldGenerator();
valueFieldName = "dateValue"; if (!attribute.getIsCollection()) { condition.setJoin(", sys$CategoryAttributeValue " + cavAlias + " "); condition.setCategoryId(categoryLookup.getValue().getId()); condition.setCategoryAttributeId(attributeLookup.getValue().getId()); condition.setIsCollection(BooleanUtils.isTrue(attributeLookup.getValue().getIsCollection())); condition.setLocCaption(attribute.getLocaleName()); condition.setCaption(caption.getValue());