protected Set<EntityLogAttr> createDynamicLogAttribute(CategoryAttributeValue entity, @Nullable EntityAttributeChanges changes, boolean registerDeleteOp) { Set<EntityLogAttr> result = new HashSet<>(); EntityLogAttr attr = metadata.create(EntityLogAttr.class); attr.setName(DynamicAttributesUtils.encodeAttributeCode(entity.getCode())); MetaProperty valueMetaProperty = entity.getMetaClass().getProperty(getCategoryAttributeValueName(entity)); Object value = entity.getValue(); attr.setValue(stringify(value, valueMetaProperty)); Object valueId = getValueId(value); if (valueId != null) attr.setValueId(valueId.toString()); if (changes != null || registerDeleteOp) { Object oldValue = getOldCategoryAttributeValue(entity, changes); attr.setOldValue(stringify(oldValue, valueMetaProperty)); Object oldValueId = getValueId(oldValue); if (oldValueId != null) { attr.setOldValueId(oldValueId.toString()); } } result.add(attr); return result; }
public DynamicAttributesMetaProperty(MetaClass metaClass, CategoryAttribute attribute) { this.attribute = attribute; this.javaClass = DynamicAttributesUtils.getAttributeClass(attribute); this.metaClass = metaClass; this.name = DynamicAttributesUtils.encodeAttributeCode(attribute.getCode()); this.mandatory = attribute.getRequired(); Metadata metadata = AppBeans.get(Metadata.NAME); Session metadataSession = metadata.getSession(); if (Entity.class.isAssignableFrom(javaClass)) { range = new ClassRange(metadataSession.getClass(javaClass)); this.type = Type.ASSOCIATION; } else { this.range = new DatatypeRange(Datatypes.getNN(javaClass)); this.type = Type.DATATYPE; } }
protected void internalRegisterModifyAttributeValue(CategoryAttributeValue entity, @Nullable EntityAttributeChanges changes, Set<String> attributes) { String propertyName = DynamicAttributesUtils.encodeAttributeCode(entity.getCode()); if (!attributes.contains(propertyName)) { return; } Date ts = timeSource.currentTimestamp(); EntityManager em = persistence.getEntityManager(); Set<String> dirty = changes == null ? persistence.getTools().getDirtyFields(entity) : changes.getOwnAttributes(); boolean registerDeleteOp = dirty.contains("deleteTs") && entity.isDeleted(); boolean hasChanges = dirty.stream().anyMatch(s -> s.endsWith("Value")); if (hasChanges) { EntityLogItem item = metadata.create(EntityLogItem.class); item.setEventTs(ts); item.setUser(findUser(em)); item.setType(EntityLogItem.Type.MODIFY); item.setEntity(getEntityName(entity)); item.setObjectEntityId(entity.getObjectEntityId()); item.setAttributes(createDynamicLogAttribute(entity, changes, registerDeleteOp)); enqueueItem(item); } }
MetaPropertyPath metaPropertyPath = metadataTools.resolveMetaPropertyPathNN(metaClass, DynamicAttributesUtils.encodeAttributeCode(dynamicAttribute.getCode())); propertyList.add(metaPropertyPath.getMetaProperty());
DynamicAttributesUtils.encodeAttributeCode(attribute.getCode())); field.setProperty(DynamicAttributesUtils.encodeAttributeCode(attribute.getCode())); field.setCaption(attribute.getLocaleName()); field.setDatasource(ds); CustomFieldGenerator fieldGenerator = new DynamicAttributeCustomFieldGenerator(); Component fieldComponent = fieldGenerator.generateField(ds, DynamicAttributesUtils.encodeAttributeCode(attribute.getCode())); field.setCustom(true); field.setComponent(fieldComponent);
for (CategoryAttributeValue cav : dynamicAttributes.values()) { if (BaseEntityInternalAccess.isNew(cav)) { changes.add(new AttributeChanges.Change(DynamicAttributesUtils.encodeAttributeCode(cav.getCode()), null)); } else { if (deleted) { oldValue = null; changes.add(new AttributeChanges.Change(DynamicAttributesUtils.encodeAttributeCode(cav.getCode()), oldValue)); } else { AttributeChangeListener changeListener = changes.add(new AttributeChanges.Change(DynamicAttributesUtils.encodeAttributeCode(cav.getCode()), oldValue)); break;
String code = DynamicAttributesUtils.encodeAttributeCode(attribute.getCode());
String code = DynamicAttributesUtils.encodeAttributeCode(categoryAttribute.getCode()); if (entityIsCategorized && !categoryAttribute.getCategory().equals(((Categorized) item).getCategory())) {
String dynamicAttributeCode = entry.getKey(); CategoryAttributeValue srcDynamicAttribute = entry.getValue(); dstEntity.setValue(DynamicAttributesUtils.encodeAttributeCode(dynamicAttributeCode), srcDynamicAttribute.getValue());