Search in sources :

Example 1 with EntityPropertyDiff

use of com.haulmont.cuba.core.entity.diff.EntityPropertyDiff 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;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) EntityCollectionPropertyDiff(com.haulmont.cuba.core.entity.diff.EntityCollectionPropertyDiff) EntityClassPropertyDiff(com.haulmont.cuba.core.entity.diff.EntityClassPropertyDiff) Node(com.haulmont.bali.datastruct.Node) Security(com.haulmont.cuba.core.global.Security) EntityPropertyDiff(com.haulmont.cuba.core.entity.diff.EntityPropertyDiff)

Example 2 with EntityPropertyDiff

use of com.haulmont.cuba.core.entity.diff.EntityPropertyDiff in project cuba by cuba-platform.

the class DiffTreeDatasource method loadTree.

@Override
protected Tree<EntityPropertyDiff> loadTree(Map params) {
    Tree<EntityPropertyDiff> diffTree = new Tree<>();
    List<Node<EntityPropertyDiff>> rootNodes = new ArrayList<>();
    if (entityDiff != null) {
        for (EntityPropertyDiff childPropertyDiff : entityDiff.getPropertyDiffs()) {
            Node<EntityPropertyDiff> childPropDiffNode = loadPropertyDiff(childPropertyDiff);
            if (childPropDiffNode != null)
                rootNodes.add(childPropDiffNode);
        }
    }
    diffTree.setRootNodes(rootNodes);
    return diffTree;
}
Also used : Node(com.haulmont.bali.datastruct.Node) ArrayList(java.util.ArrayList) Tree(com.haulmont.bali.datastruct.Tree) EntityPropertyDiff(com.haulmont.cuba.core.entity.diff.EntityPropertyDiff)

Aggregations

Node (com.haulmont.bali.datastruct.Node)2 EntityPropertyDiff (com.haulmont.cuba.core.entity.diff.EntityPropertyDiff)2 Tree (com.haulmont.bali.datastruct.Tree)1 MetaClass (com.haulmont.chile.core.model.MetaClass)1 EntityClassPropertyDiff (com.haulmont.cuba.core.entity.diff.EntityClassPropertyDiff)1 EntityCollectionPropertyDiff (com.haulmont.cuba.core.entity.diff.EntityCollectionPropertyDiff)1 Security (com.haulmont.cuba.core.global.Security)1 ArrayList (java.util.ArrayList)1