@Override public ExpandSelectTreeNode buildExpandSelectTree(final List<SelectItem> select, final List<ArrayList<NavigationPropertySegment>> expand) throws EdmException { return new ExpandSelectTreeCreator(select, expand).create(); }
public ExpandSelectTreeNodeImpl create() throws EdmException { // Initial node ExpandSelectTreeNodeImpl root = new ExpandSelectTreeNodeImpl(); if (!initialSelect.isEmpty()) { // Create a full expand tree createSelectTree(root); } else { // If no select is given the root node is explicitly selected for all expand clauses root.setExplicitlySelected(); } // Merge in the expand tree mergeExpandTree(root); // consolidate the tree consolidate(root); return root; }
private void consolidate(final ExpandSelectTreeNodeImpl node) { switch (node.getAllKind()) { case EXPLICITLYTRUE: case IMPLICITLYTRUE: consolidateTrueNode(node); break; case FALSE: consolidateFalseNode(node); } }
private void consolidateFalseNode(final ExpandSelectTreeNodeImpl node) { Iterator<Map.Entry<String, ExpandSelectTreeNode>> iterator = node.getLinks().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, ExpandSelectTreeNode> entry = iterator.next(); ExpandSelectTreeNodeImpl subNode = (ExpandSelectTreeNodeImpl) entry.getValue(); if (!subNode.isExpanded()) { node.putLink(entry.getKey(), null); } else { consolidate(subNode); } } }
private void mergeExpandTree(final ExpandSelectTreeNodeImpl root) throws EdmException { for (ArrayList<NavigationPropertySegment> singleExpand : initialExpand) { ExpandSelectTreeNodeImpl actualNode = root; for (NavigationPropertySegment navSegment : singleExpand) { actualNode = addExpandNode(actualNode, navSegment.getNavigationProperty().getName()); if (actualNode == null) { break; } } } }
private void createSelectTree(final ExpandSelectTreeNodeImpl root) throws EdmException { for (SelectItem item : initialSelect) { ExpandSelectTreeNodeImpl actualNode = root; for (NavigationPropertySegment navSegement : item.getNavigationPropertySegments()) { actualNode = addSelectNode(actualNode, navSegement.getNavigationProperty().getName()); } if (item.getProperty() != null) { actualNode.addProperty(item.getProperty()); } else if (item.isStar()) { actualNode.setAllExplicitly(); } else { // The actual node is a navigation property and has no property or star so it is explicitly selected actualNode.setExplicitlySelected(); } } }
private void consolidateFalseNode(final ExpandSelectTreeNodeImpl node) { Iterator<Map.Entry<String, ExpandSelectTreeNode>> iterator = node.getLinks().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, ExpandSelectTreeNode> entry = iterator.next(); ExpandSelectTreeNodeImpl subNode = (ExpandSelectTreeNodeImpl) entry.getValue(); if (!subNode.isExpanded()) { node.putLink(entry.getKey(), null); } else { consolidate(subNode); } } }
private void mergeExpandTree(final ExpandSelectTreeNodeImpl root) throws EdmException { for (ArrayList<NavigationPropertySegment> singleExpand : initialExpand) { ExpandSelectTreeNodeImpl actualNode = root; for (NavigationPropertySegment navSegment : singleExpand) { actualNode = addExpandNode(actualNode, navSegment.getNavigationProperty().getName()); if (actualNode == null) { break; } } } }
private void createSelectTree(final ExpandSelectTreeNodeImpl root) throws EdmException { for (SelectItem item : initialSelect) { ExpandSelectTreeNodeImpl actualNode = root; for (NavigationPropertySegment navSegement : item.getNavigationPropertySegments()) { actualNode = addSelectNode(actualNode, navSegement.getNavigationProperty().getName()); } if (item.getProperty() != null) { actualNode.addProperty(item.getProperty()); } else if (item.isStar()) { actualNode.setAllExplicitly(); } else { // The actual node is a navigation property and has no property or star so it is explicitly selected actualNode.setExplicitlySelected(); } } }
public ExpandSelectTreeNodeImpl create() throws EdmException { // Initial node ExpandSelectTreeNodeImpl root = new ExpandSelectTreeNodeImpl(); if (!initialSelect.isEmpty()) { // Create a full expand tree createSelectTree(root); } else { // If no select is given the root node is explicitly selected for all expand clauses root.setExplicitlySelected(); } // Merge in the expand tree mergeExpandTree(root); // consolidate the tree consolidate(root); return root; }
@Override public ExpandSelectTreeNode buildExpandSelectTree(final List<SelectItem> select, final List<ArrayList<NavigationPropertySegment>> expand) throws EdmException { return new ExpandSelectTreeCreator(select, expand).create(); }
private void consolidate(final ExpandSelectTreeNodeImpl node) { switch (node.getAllKind()) { case EXPLICITLYTRUE: case IMPLICITLYTRUE: consolidateTrueNode(node); break; case FALSE: consolidateFalseNode(node); } }
private void consolidateFalseNode(final ExpandSelectTreeNodeImpl node) { Iterator<Map.Entry<String, ExpandSelectTreeNode>> iterator = node.getLinks().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, ExpandSelectTreeNode> entry = iterator.next(); ExpandSelectTreeNodeImpl subNode = (ExpandSelectTreeNodeImpl) entry.getValue(); if (!subNode.isExpanded()) { node.putLink(entry.getKey(), null); } else { consolidate(subNode); } } }
private void mergeExpandTree(final ExpandSelectTreeNodeImpl root) throws EdmException { for (ArrayList<NavigationPropertySegment> singleExpand : initialExpand) { ExpandSelectTreeNodeImpl actualNode = root; for (NavigationPropertySegment navSegment : singleExpand) { actualNode = addExpandNode(actualNode, navSegment.getNavigationProperty().getName()); if (actualNode == null) { break; } } } }
private void createSelectTree(final ExpandSelectTreeNodeImpl root) throws EdmException { for (SelectItem item : initialSelect) { ExpandSelectTreeNodeImpl actualNode = root; for (NavigationPropertySegment navSegement : item.getNavigationPropertySegments()) { actualNode = addSelectNode(actualNode, navSegement.getNavigationProperty().getName()); } if (item.getProperty() != null) { actualNode.addProperty(item.getProperty()); } else if (item.isStar()) { actualNode.setAllExplicitly(); } else { // The actual node is a navigation property and has no property or star so it is explicitly selected actualNode.setExplicitlySelected(); } } }
public ExpandSelectTreeNodeImpl create() throws EdmException { // Initial node ExpandSelectTreeNodeImpl root = new ExpandSelectTreeNodeImpl(); if (!initialSelect.isEmpty()) { // Create a full expand tree createSelectTree(root); } else { // If no select is given the root node is explicitly selected for all expand clauses root.setExplicitlySelected(); } // Merge in the expand tree mergeExpandTree(root); // consolidate the tree consolidate(root); return root; }
@Override public ExpandSelectTreeNode buildExpandSelectTree(final List<SelectItem> select, final List<ArrayList<NavigationPropertySegment>> expand) throws EdmException { return new ExpandSelectTreeCreator(select, expand).create(); }
private void consolidate(final ExpandSelectTreeNodeImpl node) { switch (node.getAllKind()) { case EXPLICITLYTRUE: case IMPLICITLYTRUE: consolidateTrueNode(node); break; case FALSE: consolidateFalseNode(node); } }
private void consolidateTrueNode(final ExpandSelectTreeNodeImpl node) { Map<String, ExpandSelectTreeNode> links = node.getLinks(); Set<Entry<String, ExpandSelectTreeNode>> linkEntries = links.entrySet(); List<String> toRemove = new ArrayList<String>(); for (Entry<String, ExpandSelectTreeNode> entry : linkEntries) { ExpandSelectTreeNodeImpl subNode = (ExpandSelectTreeNodeImpl) entry.getValue(); if (subNode.isExpanded() && node.isExplicitlySelected()) { subNode.setExplicitlySelected(); consolidate(subNode); } else if (subNode.isExpanded()) { consolidate(subNode); } else { toRemove.add(entry.getKey()); } } // for (String key : toRemove) { node.removeLink(key); } }
private ExpandSelectTreeNodeImpl getExpandSelect() { try { return uriInfo.getExpand().isEmpty() && uriInfo.getSelect().isEmpty() ? null : new ExpandSelectTreeCreator(uriInfo.getSelect(), uriInfo.getExpand()).create(); } catch (final EdmException e) { return null; } }