private ExpandSelectTreeNodeImpl addExpandNode(final ExpandSelectTreeNodeImpl actualNode, final String navigationPropertyName) { Map<String, ExpandSelectTreeNode> links = actualNode.getLinks(); if (!links.containsKey(navigationPropertyName)) { if (actualNode.isExplicitlySelected() || (actualNode.isExplicitlySelected() && actualNode.isExpanded())) { ExpandSelectTreeNodeImpl subNode = new ExpandSelectTreeNodeImpl(); subNode.setExpanded(); subNode.setExplicitlySelected(); actualNode.putLink(navigationPropertyName, subNode); return subNode; } else { return null; } } else { ExpandSelectTreeNodeImpl subNode = (ExpandSelectTreeNodeImpl) links.get(navigationPropertyName); subNode.setExpanded(); return subNode; } }
private ExpandSelectTreeNodeImpl addSelectNode(final ExpandSelectTreeNodeImpl actualNode, final String navigationPropertyName) { Map<String, ExpandSelectTreeNode> links = actualNode.getLinks(); if (!links.containsKey(navigationPropertyName)) { ExpandSelectTreeNodeImpl subNode = new ExpandSelectTreeNodeImpl(); actualNode.putLink(navigationPropertyName, subNode); if (actualNode.isExplicitlySelected()) { // if a node was explicitly selected all sub nodes are explicitly selected subNode.setExplicitlySelected(); } else { if (actualNode.getAllKind() == AllKinds.IMPLICITLYTRUE) { actualNode.setAllKindFalse(); } } return subNode; } else { return (ExpandSelectTreeNodeImpl) links.get(navigationPropertyName); } }
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 void updateExpandSelectTree(final String navigationPropertyName, final ODataEntry entry) { expandSelectTree.setExpanded(); expandSelectTree.setExplicitlySelected(); expandSelectTree.putLink(navigationPropertyName, (ExpandSelectTreeNodeImpl) entry.getExpandSelectTree()); }
private void updateExpandSelectTree(final String navigationPropertyName, final ODataFeed feed) { List<ODataEntry> entries = feed.getEntries(); if (!entries.isEmpty()) { updateExpandSelectTree(navigationPropertyName, entries.get(0)); } else { expandSelectTree.setExpanded(); expandSelectTree.setExplicitlySelected(); expandSelectTree.putLink(navigationPropertyName, new ExpandSelectTreeNodeImpl()); } }
@Override public ExpandSelectTreeNode build() throws EdmException { EdmEntityType entityType = entitySet.getEntityType(); if (selectedPropertyNames != null) { handleProperties(entityType); } if (selectedNavigationPropertyNames != null) { setAllKindFalse(); handleLinks(entityType, selectedNavigationPropertyNames, null); } if (expandedNavigationPropertyNames != null) { ExpandSelectTreeNodeImpl subNode = new ExpandSelectTreeNodeImpl(); subNode.setExplicitlySelected(); handleLinks(entityType, expandedNavigationPropertyNames, subNode); } if (customExpandedNavigationProperties != null) { handleCustomLinks(entityType); } return ExpandSelectTreeNodeImpl.this; }
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 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(); } } }
@Override public ExpandSelectTreeNodeBuilder createExpandSelectTreeNodeBuilder() { ExpandSelectTreeNodeImpl expandSelectTreeNode = new ExpandSelectTreeNodeImpl(); return expandSelectTreeNode.new ExpandSelectTreeNodeBuilderImpl(); }
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; }
/** * Updates the expand select tree ({@link #expandSelectTree}) for this {@link ReadEntryResult} ( * {@link #readEntryResult}). * * @param navigationPropertyName * @param inlineEntries * @throws EntityProviderException */ private void updateExpandSelectTree(final String navigationPropertyName, final List<ODataEntry> inlineEntries) throws EntityProviderException { expandSelectTree.setExpanded(); ExpandSelectTreeNodeImpl subNode = getExpandSelectTreeNode(inlineEntries); expandSelectTree.putLink(navigationPropertyName, subNode); }
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer); jsonStreamWriter.beginObject() .name("all").unquotedValue(Boolean.toString(isAll())).separator() .name("properties") .beginArray(); jsonStreamWriter.separator(); final String nodeString = entry.getValue() == null ? null : entry.getValue().toJsonString(); jsonStreamWriter.beginObject() .name(entry.getKey()).unquotedValue(nodeString)
private void handleCustomLinks(final EdmEntityType entityType) throws EdmException { for (Map.Entry<String, ExpandSelectTreeNode> entry : customExpandedNavigationProperties.entrySet()) { EdmTyped navigationProperty = entityType.getProperty(entry.getKey()); if (navigationProperty == null) { throw new EdmException(EdmException.NAVIGATIONPROPERTYNOTFOUND.addContent(entry.getKey())); } if (!(navigationProperty instanceof EdmNavigationProperty)) { throw new EdmException(EdmException.MUSTBENAVIGATIONPROPERTY.addContent(entry.getKey())); } putLink(entry.getKey(), (ExpandSelectTreeNodeImpl) entry.getValue()); } }
private void handleProperties(final EdmEntityType entityType) throws EdmException { for (String propertyName : selectedPropertyNames) { EdmTyped property = entityType.getProperty(propertyName); if (property == null) { throw new EdmException(EdmException.PROPERTYNOTFOUND.addContent(propertyName)); } else if (!(property instanceof EdmProperty)) { throw new EdmException(EdmException.MUSTBEPROPERTY.addContent(propertyName)); } addProperty((EdmProperty) property); } }
public void setExplicitlySelected() { isExplicitlySelected = true; setAllExplicitly(); }
private void consolidate(final ExpandSelectTreeNodeImpl node) { switch (node.getAllKind()) { case EXPLICITLYTRUE: case IMPLICITLYTRUE: consolidateTrueNode(node); break; case FALSE: consolidateFalseNode(node); } }
private void updateExpandSelectTree(final String navigationPropertyName, final ODataFeed feed) { List<ODataEntry> entries = feed.getEntries(); if (!entries.isEmpty()) { updateExpandSelectTree(navigationPropertyName, entries.get(0)); } else { expandSelectTree.setExpanded(); expandSelectTree.setExplicitlySelected(); expandSelectTree.putLink(navigationPropertyName, new ExpandSelectTreeNodeImpl()); } }
@Override public ExpandSelectTreeNode build() throws EdmException { EdmEntityType entityType = entitySet.getEntityType(); if (selectedPropertyNames != null) { handleProperties(entityType); } if (selectedNavigationPropertyNames != null) { setAllKindFalse(); handleLinks(entityType, selectedNavigationPropertyNames, null); } if (expandedNavigationPropertyNames != null) { ExpandSelectTreeNodeImpl subNode = new ExpandSelectTreeNodeImpl(); subNode.setExplicitlySelected(); handleLinks(entityType, expandedNavigationPropertyNames, subNode); } if (customExpandedNavigationProperties != null) { handleCustomLinks(entityType); } return ExpandSelectTreeNodeImpl.this; }
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 updateExpandSelectTree(final String navigationPropertyName, final ODataEntry entry) { expandSelectTree.setExpanded(); expandSelectTree.setExplicitlySelected(); expandSelectTree.putLink(navigationPropertyName, (ExpandSelectTreeNodeImpl) entry.getExpandSelectTree()); }