/** * 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; } }
protected MetaPropertyPath resolveMetaPropertyPath(MetaClass metaClass, String property) { MetaPropertyPath mpp = metaClass.getPropertyPath(property); if (mpp == null && DynamicAttributesUtils.isDynamicAttribute(property)) { mpp = DynamicAttributesUtils.getMetaPropertyPath(metaClass, property); } return mpp; }
/** * Creates ListEditor component. * * @param valueSource value source * @param propertyId property id of dynamic attribute * @return list editor component or null */ @Nullable public Component generateComponent(ValueSource valueSource, String propertyId) { if (valueSource instanceof EntityValueSource) { MetaClass metaClass = ((EntityValueSource) valueSource).getEntityMetaClass(); MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, propertyId); if (metaPropertyPath == null) { log.error("MetaPropertyPath for dynamic attribute {} not found", propertyId); return null; } return generateComponent(valueSource, metaPropertyPath); } return null; }
protected MetaPropertyPath resolveMetaPropertyPath(MetaClass metaClass, String property) { MetaPropertyPath mpp = metaClass.getPropertyPath(property); if (mpp == null && DynamicAttributesUtils.isDynamicAttribute(property)) { mpp = DynamicAttributesUtils.getMetaPropertyPath(metaClass, property); } return mpp; }
/** * 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; }
private String getCollectionString(Object collection) { if (DynamicAttributesUtils.isDynamicAttribute(propertyName)) { Metadata metadata = AppBeans.get(Metadata.class); com.haulmont.chile.core.model.MetaClass metaClass = metadata.getClassNN(metaClassName); MetaPropertyPath path = DynamicAttributesUtils.getMetaPropertyPath(metaClass, propertyName); return metadata.getTools().format(collection, path.getMetaProperty()); } return String.valueOf(beforeValue); }
@Override public String getLocCaption() { if (isBlank(caption) && !isBlank(propertyPath)) { MessageTools messageTools = AppBeans.get(MessageTools.class); String propertyCaption = messageTools.getPropertyCaption(metaClass, propertyPath); if (!isBlank(propertyCaption)) { return propertyCaption + "." + locCaption; } } else if (isNotBlank(caption)) { MessageTools messageTools = AppBeans.get(MessageTools.class); return messageTools.loadString(messagesPack, caption); } MetaPropertyPath mpp = DynamicAttributesUtils.getMetaPropertyPath(metaClass, getCategoryAttributeId()); if (mpp != null) { return DynamicAttributesUtils.getCategoryAttribute(mpp.getMetaProperty()).getLocaleName(); } return super.getLocCaption(); } }
protected boolean suitableCondition(AbstractCondition condition) { if (condition instanceof PropertyCondition) { return adapter.getMetaClass() .getPropertyPath(condition.getName()) != null; } if (condition instanceof DynamicAttributesCondition) { return DynamicAttributesUtils.getMetaPropertyPath( adapter.getMetaClass(), ((DynamicAttributesCondition) condition).getCategoryAttributeId() ) != null; } return true; }
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; }
if (!categoryAttributes.isEmpty()) { for (CategoryAttribute attribute : categoryAttributes) { MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, attribute); String propertyCaption = attribute.getLocaleName();
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); } }
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()); properties.addAll(dynamicProperties);
if (categoryAttributes != null) { for (CategoryAttribute categoryAttribute : categoryAttributes) { MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, categoryAttribute); MetaProperty metaProperty = metaPropertyPath.getMetaProperty();
DynamicAttributesUtils.getMetaPropertyPath(metaClass, attribute);
if (attributes != null) { for (CategoryAttribute categoryAttribute : attributes) { MetaPropertyPath propertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, categoryAttribute); MetaProperty property = propertyPath.getMetaProperty(); if (allowLogProperty(property, categoryAttribute)) {
final MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, attribute);
@Override public Param.Builder getParamBuilder(AbstractCondition condition) { Param.Builder builder; DynamicAttributesCondition _condition = (DynamicAttributesCondition) condition; if (_condition.getCategoryAttributeId() != null) { Class paramJavaClass = _condition.getUnary() ? Boolean.class : _condition.getJavaClass(); MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath( _condition.getEntityMetaClass(), _condition.getCategoryAttributeId()); builder = Param.Builder.getInstance() .setJavaClass(paramJavaClass) .setName(condition.getParamName()) .setEntityWhere(null) .setEntityView(null) .setProperty(metaPropertyPath != null ? metaPropertyPath.getMetaProperty() : null) .setInExpr(_condition.getInExpr()) .setCategoryAttrId(_condition.getCategoryAttributeId()) .setRequired(condition.getRequired()); } else builder = super.getParamBuilder(condition); return builder; } }
.setJavaClass(paramJavaClass) .setMetaClass(condition.getEntityMetaClass()) .setProperty(DynamicAttributesUtils.getMetaPropertyPath(null, attribute).getMetaProperty()) .setInExpr(condition.getInExpr()) .setRequired(condition.getRequired())