/** * 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; }
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()); }
/** * 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; } }
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; }
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; }
List<CategoryAttribute> categoryAttributes = (List<CategoryAttribute>) dynamicAttributes.getAttributesForMetaClass(metaClass); if (!categoryAttributes.isEmpty()) { for (CategoryAttribute attribute : categoryAttributes) {
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); } }
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) {