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);
}
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;
}
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);
}
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;
}
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;
}
Aggregations