/** * Get special meta property path object for dynamic attribute by code */ @Nullable public static MetaPropertyPath getMetaPropertyPath(MetaClass metaClass, String attributeCode) { return AppBeans.get(DynamicAttributesTools.NAME, DynamicAttributesTools.class) .getMetaPropertyPath(metaClass, attributeCode); }
/** * Get special meta property path object for dynamic attribute id */ @Nullable public static MetaPropertyPath getMetaPropertyPath(MetaClass metaClass, UUID attributeId) { return AppBeans.get(DynamicAttributesTools.NAME, DynamicAttributesTools.class) .getMetaPropertyPath(metaClass, attributeId); }
protected Set<String> filterRemovedAttributes(MetaClass metaClass, Set<String> attributes) { // filter attributes that do not exists in entity anymore return attributes.stream() .filter(attributeName -> { if (DynamicAttributesUtils.isDynamicAttribute(attributeName)) { return dynamicAttributesTools.getMetaPropertyPath(metaClass, attributeName) != null; } else { return metaClass.getPropertyPath(attributeName) != null; } }) .collect(Collectors.toSet()); }
protected MetaPropertyPath resolveMetaPropertyPath(MetaClass metaClass, String property) { MetaPropertyPath mpp = metaClass.getPropertyPath(property); if (mpp == null && DynamicAttributesUtils.isDynamicAttribute(property)) { mpp = dynamicAttributesTools.getMetaPropertyPath(metaClass, property); } return mpp; }
/** * Returns a {@link MetaPropertyPath} which can include the special MetaProperty for a dynamic attribute. * * @param metaClass originating meta-class * @param propertyPath path to the attribute * @return MetaPropertyPath instance */ @Nullable public MetaPropertyPath resolveMetaPropertyPath(MetaClass metaClass, String propertyPath) { checkNotNullArgument(metaClass, "metaClass is null"); MetaPropertyPath metaPropertyPath = metaClass.getPropertyPath(propertyPath); if (metaPropertyPath == null && DynamicAttributesUtils.isDynamicAttribute(propertyPath)) { metaPropertyPath = dynamicAttributesTools.getMetaPropertyPath(metaClass, propertyPath); } return metaPropertyPath; }
@Override public void applyColumnSettings(Element element) { super.applyColumnSettings(element); Element groupPropertiesElement = element.element("groupProperties"); if (groupPropertiesElement != null) { MetaClass metaClass = ((EntityTableItems) getItems()).getEntityMetaClass(); List elements = groupPropertiesElement.elements("property"); List<MetaPropertyPath> properties = new ArrayList<>(elements.size()); for (Object o : elements) { String id = ((Element) o).attributeValue("id"); MetaPropertyPath property = DynamicAttributesUtils.isDynamicAttribute(id) ? dynamicAttributesTools.getMetaPropertyPath(metaClass, id) : metaClass.getPropertyPath(id); if (property != null) { properties.add(property); } else { LoggerFactory.getLogger(WebGroupTable.class) .warn("Ignored group property '{}'", id); } } groupBy(properties.toArray()); } }
protected void loadEditable(FieldGroup fieldGroup, FieldGroup.FieldConfig field) { if (fieldGroup.isEditable()) { MetaClass metaClass = rds.resolveCategorizedEntityClass(); MetaPropertyPath propertyPath = dynamicAttributesTools.getMetaPropertyPath(metaClass, field.getProperty()); checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass); boolean editableFromPermissions = security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString()); if (!editableFromPermissions) { field.setEditable(false); } boolean visibleFromPermissions = security.isEntityAttrReadPermitted(metaClass, propertyPath.toString()); if (!visibleFromPermissions) { field.setVisible(false); } } }
String value; if (DynamicAttributesUtils.isDynamicAttribute(columnId)) { metaProperty = dynamicAttributesTools.getMetaPropertyPath(item.getMetaClass(), columnId).getMetaProperty(); value = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty, item.getValueEx(columnId)); } else {