Search in sources :

Example 6 with Node

use of com.haulmont.bali.datastruct.Node in project cuba by cuba-platform.

the class FilteringLookupAction method createFilterXml.

protected String createFilterXml(Filter filterComponent) {
    ConditionsTree tree = new ConditionsTree();
    CustomCondition condition = createCustomCondition(filterComponent);
    tree.setRootNodes(Collections.singletonList(new Node<>(condition)));
    return AppBeans.get(FilterParser.class).getXml(tree, Param.ValueProperty.VALUE);
}
Also used : CustomCondition(com.haulmont.cuba.gui.components.filter.condition.CustomCondition) Node(com.haulmont.bali.datastruct.Node) FilterParser(com.haulmont.cuba.gui.components.filter.FilterParser) ConditionsTree(com.haulmont.cuba.gui.components.filter.ConditionsTree)

Example 7 with Node

use of com.haulmont.bali.datastruct.Node in project cuba by cuba-platform.

the class BasicPermissionTreeDatasource method cloneNode.

private Node<BasicPermissionTarget> cloneNode(Node<BasicPermissionTarget> node) {
    Node<BasicPermissionTarget> clone = new Node<>();
    try {
        BasicPermissionTarget targetClone = node.data.clone();
        clone.setData(targetClone);
    } catch (CloneNotSupportedException e) {
        throw new RuntimeException(e);
    }
    for (Node<BasicPermissionTarget> childNode : node.getChildren()) {
        clone.addChild(cloneNode(childNode));
    }
    return clone;
}
Also used : Node(com.haulmont.bali.datastruct.Node) BasicPermissionTarget(com.haulmont.cuba.gui.app.security.entity.BasicPermissionTarget)

Example 8 with Node

use of com.haulmont.bali.datastruct.Node in project cuba by cuba-platform.

the class ManagedBeanInfoDatasource method loadTree.

@Override
protected Tree<ManagedBeanInfo> loadTree(Map<String, Object> params) {
    String tag = getLoggingTag("TDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
    List<Node<ManagedBeanInfo>> nodes = new ArrayList<>();
    if (jmxInstance != null) {
        List<ManagedBeanDomain> domains = jmxControlAPI.getDomains(jmxInstance);
        Map<String, Node<ManagedBeanInfo>> domainMap = new HashMap<>();
        for (ManagedBeanDomain mbd : domains) {
            ManagedBeanInfo dummy = metadata.create(ManagedBeanInfo.class);
            dummy.setDomain(mbd.getName());
            Node<ManagedBeanInfo> node = new Node<>(dummy);
            domainMap.put(mbd.getName(), node);
            nodes.add(node);
        }
        List<ManagedBeanInfo> list = loadManagedBeans(params);
        for (ManagedBeanInfo mbi : list) {
            if (mbi != null) {
                if (domainMap.containsKey(mbi.getDomain())) {
                    domainMap.get(mbi.getDomain()).addChild(new Node<>(mbi));
                }
            }
        }
        // remove root nodes that might have left without children after filtering
        for (Node<ManagedBeanInfo> rootNode : new ArrayList<>(nodes)) {
            if (rootNode.getChildren().isEmpty()) {
                nodes.remove(rootNode);
            }
        }
    }
    sw.stop();
    return new Tree<>(nodes);
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Node(com.haulmont.bali.datastruct.Node) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) ManagedBeanDomain(com.haulmont.cuba.web.jmx.entity.ManagedBeanDomain) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) Tree(com.haulmont.bali.datastruct.Tree)

Example 9 with Node

use of com.haulmont.bali.datastruct.Node 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 10 with Node

use of com.haulmont.bali.datastruct.Node 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)17 ConditionsTree (com.haulmont.cuba.gui.components.filter.ConditionsTree)5 AbstractCondition (com.haulmont.cuba.gui.components.filter.condition.AbstractCondition)5 Tree (com.haulmont.bali.datastruct.Tree)4 MetaClass (com.haulmont.chile.core.model.MetaClass)3 ArrayList (java.util.ArrayList)3 MetaProperty (com.haulmont.chile.core.model.MetaProperty)2 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)2 EntityPropertyDiff (com.haulmont.cuba.core.entity.diff.EntityPropertyDiff)2 BasicPermissionTarget (com.haulmont.cuba.gui.app.security.entity.BasicPermissionTarget)2 GroupCondition (com.haulmont.cuba.gui.components.filter.condition.GroupCondition)2 GroupConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.GroupConditionDescriptor)2 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)2 UIPerformanceLogger (com.haulmont.cuba.gui.logging.UIPerformanceLogger)2 Collectors (java.util.stream.Collectors)2 Element (org.dom4j.Element)2 StopWatch (org.perf4j.StopWatch)2 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)2 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 Entity (com.haulmont.cuba.core.entity.Entity)1