/** * Get attributes which should be added automatically to the screen and component. * Based on visibility settings from category attribute editor. */ public Set<CategoryAttribute> getAttributesToShowOnTheScreen(MetaClass metaClass, String screen, @Nullable String component) { Collection<CategoryAttribute> attributesForMetaClass = dynamicAttributes.getAttributesForMetaClass(metaClass); Set<CategoryAttribute> categoryAttributes = new LinkedHashSet<>(); for (CategoryAttribute attribute : attributesForMetaClass) { if (attributeShouldBeShownOnTheScreen(screen, component, attribute)) { categoryAttributes.add(attribute); } } return categoryAttributes; }
/** * Get special meta property path object for dynamic attribute by code */ @Nullable public MetaPropertyPath getMetaPropertyPath(MetaClass metaClass, String attributeCode) { attributeCode = decodeAttributeCode(attributeCode); CategoryAttribute attribute = dynamicAttributes.getAttributeForMetaClass(metaClass, attributeCode); if (attribute != null) { return DynamicAttributesUtils.getMetaPropertyPath(metaClass, attribute); } else { return null; } }
@Nullable public Category getDefaultCategory() { MetaClass metaClass = resolveCategorizedEntityClass(); DynamicAttributes dynamicAttributes = AppBeans.get(DynamicAttributes.class); Collection<Category> categoriesForMetaClass = dynamicAttributes.getCategoriesForMetaClass(metaClass); for (Category category : categoriesForMetaClass) { if (Boolean.TRUE.equals(category.getIsDefault())) { return category; } } return null; }
protected Set<Class> collectEntityClassesWithDynamicAttributes(@Nullable View view) { if (view == null) { return Collections.emptySet(); } DynamicAttributes dynamicAttributes = AppBeans.get(DynamicAttributes.class); Metadata metadata = AppBeans.get(Metadata.class); return collectEntityClasses(view, new HashSet<>()).stream() .filter(BaseGenericIdEntity.class::isAssignableFrom) .filter(aClass -> !dynamicAttributes.getAttributesForMetaClass(metadata.getClassNN(aClass)).isEmpty()) .collect(Collectors.toSet()); }
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); } }
Collection<Category> categories = dynamicAttributes.getCategoriesForMetaClass(metaClass); UUID catId = condition.getCategoryId(); Category selectedCategory = null;
/** * Get special meta property path object for dynamic attribute id */ @Nullable public MetaPropertyPath getMetaPropertyPath(MetaClass metaClass, UUID attributeId) { Collection<CategoryAttribute> attributes = dynamicAttributes.getAttributesForMetaClass(metaClass); CategoryAttribute attribute = null; for (CategoryAttribute theAttribute : attributes) { if (theAttribute.getId().equals(attributeId)) { attribute = theAttribute; break; } } if (attribute != null) { return DynamicAttributesUtils.getMetaPropertyPath(metaClass, attribute); } else { return null; } }
dynamicAttributes.getAttributeForMetaClass(metaClass, property) != null;
public static List<MetaProperty> getActualMetaProperties(MetaClass metaClass, Entity entity) { List<MetaProperty> result = new ArrayList<MetaProperty>(metaClass.getProperties()); if (entity instanceof BaseGenericIdEntity && ((BaseGenericIdEntity) entity).getDynamicAttributes() != null) { Collection<CategoryAttribute> dynamicAttributes = AppBeans.get(DynamicAttributes.NAME, DynamicAttributes.class).getAttributesForMetaClass(metaClass); for (CategoryAttribute dynamicAttribute : dynamicAttributes) { result.add(DynamicAttributesUtils.getMetaPropertyPath(metaClass, dynamicAttribute).getMetaProperty()); } } Collections.sort(result, PROPERTY_COMPARATOR); return result; }
DynamicAttributes dynamicAttributesBean = AppBeans.get(DynamicAttributes.NAME); categoryAttributeValue.setCategoryAttribute( dynamicAttributesBean.getAttributeForMetaClass(getMetaClass(), attributeCode)); dynamicAttributes.put(attributeCode, categoryAttributeValue);
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; }
public RuntimePropsDatasourceImpl(DsContext dsContext, DataSupplier dataSupplier, String id, String mainDsId, @Nullable MetaClass categorizedEntityClass) { this.categorizedEntityClass = categorizedEntityClass; this.id = id; this.dsContext = dsContext; this.dataSupplier = dataSupplier; this.dynamicAttributesGuiTools = AppBeans.get(DynamicAttributesGuiTools.NAME); this.metaClass = new DynamicAttributesMetaClass(); this.setMainDs(mainDsId); this.setCommitMode(CommitMode.DATASTORE); this.attributes = AppBeans.get(DynamicAttributes.NAME, DynamicAttributes.class).getAttributesForMetaClass(resolveCategorizedEntityClass()); for (CategoryAttribute attribute : attributes) { MetaProperty metaProperty = DynamicAttributesUtils.getMetaPropertyPath(mainDs.getMetaClass(), attribute).getMetaProperty(); this.metaClass.addProperty(metaProperty, attribute); } }
List<CategoryAttribute> categoryAttributes = (List<CategoryAttribute>) dynamicAttributes.getAttributesForMetaClass(metaClass); if (!categoryAttributes.isEmpty()) { for (CategoryAttribute attribute : categoryAttributes) {
PermissionConfig.this.dynamicAttributes.getAttributesForMetaClass(metaClass);
protected void writeFields(Entity entity, JsonObject jsonObject, @Nullable View view, Set<Entity> cyclicReferences) { Collection<MetaProperty> properties = new ArrayList<>(entity.getMetaClass().getProperties()); if (entity instanceof BaseGenericIdEntity && ((BaseGenericIdEntity) entity).getDynamicAttributes() != null) { List<MetaProperty> dynamicProperties = dynamicAttributes.getAttributesForMetaClass(entity.getMetaClass()).stream() .map(categoryAttribute -> DynamicAttributesUtils.getMetaPropertyPath(entity.getMetaClass(), categoryAttribute).getMetaProperty()) .collect(Collectors.toList());
if (!hideDynamicAttributes && !dynamicAttributes.getAttributesForMetaClass(entityMetaClass).isEmpty()) { rootNodes.add(new Node<>(new DynamicAttributesConditionCreator(filterComponentName, entityMetaClass, "", entityAlias)));
if (!dynamicAttributes.getAttributesForMetaClass(childMetaClass).isEmpty()) { DynamicAttributesConditionCreator descriptor = new DynamicAttributesConditionCreator(filterComponentName, entityMetaClass, propertyId, entityAlias);
public void initDefaultAttributeValues(BaseGenericIdEntity item, MetaClass metaClass) { Preconditions.checkNotNullArgument(metaClass, "metaClass is null"); Collection<CategoryAttribute> attributes = dynamicAttributes.getAttributesForMetaClass(metaClass); if (item.getDynamicAttributes() == null) { item.setDynamicAttributes(new HashMap<>());
Collection<CategoryAttribute> attributes = dynamicAttributes.getAttributesForMetaClass(metaClass); if (attributes != null) { for (CategoryAttribute categoryAttribute : attributes) {