use of com.haulmont.cuba.core.entity.diff.EntityClassPropertyDiff in project cuba by cuba-platform.
the class DiffTreeDatasource method loadPropertyDiff.
protected Node<EntityPropertyDiff> loadPropertyDiff(EntityPropertyDiff propertyDiff) {
Node<EntityPropertyDiff> diffNode = null;
if (propertyDiff != null) {
Security security = AppBeans.get(Security.NAME);
MetaClass propMetaClass = metadata.getClassNN(propertyDiff.getMetaClassName());
if (!security.isEntityOpPermitted(propMetaClass, EntityOp.READ) || !security.isEntityAttrPermitted(propMetaClass, propertyDiff.getPropertyName(), EntityAttrAccess.VIEW)) {
return null;
}
diffNode = new Node<>(propertyDiff);
if (propertyDiff instanceof EntityClassPropertyDiff) {
EntityClassPropertyDiff classPropertyDiff = (EntityClassPropertyDiff) propertyDiff;
for (EntityPropertyDiff childPropertyDiff : classPropertyDiff.getPropertyDiffs()) {
Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
if (childPropDiffNode != null)
diffNode.addChild(childPropDiffNode);
}
} else if (propertyDiff instanceof EntityCollectionPropertyDiff) {
EntityCollectionPropertyDiff collectionPropertyDiff = (EntityCollectionPropertyDiff) propertyDiff;
for (EntityPropertyDiff childPropertyDiff : collectionPropertyDiff.getAddedEntities()) {
Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
if (childPropDiffNode != null)
diffNode.addChild(childPropDiffNode);
}
for (EntityPropertyDiff childPropertyDiff : collectionPropertyDiff.getModifiedEntities()) {
Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
if (childPropDiffNode != null)
diffNode.addChild(childPropDiffNode);
}
for (EntityPropertyDiff childPropertyDiff : collectionPropertyDiff.getRemovedEntities()) {
Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
if (childPropDiffNode != null)
diffNode.addChild(childPropDiffNode);
}
}
}
return diffNode;
}
Aggregations