private void buildExpandGraph(HashSet<String> seen, List<ExpandNode> starExpand, EdmEntityType edmEntityType, int remainingLevels) { for (String name : edmEntityType.getNavigationPropertyNames()) { if (seen != null && seen.contains(name)) { continue; //explicit expand supersedes } EdmNavigationProperty property = edmEntityType.getNavigationProperty(name); ExpandNode en = new ExpandNode(); en.navigationProperty = property; starExpand.add(en); if (remainingLevels > 0) { buildExpandGraph(null, en.children, property.getType(), remainingLevels - 1); } } }
private void consumeExpandedNavigationProperties(final EdmEntityType edmEntityType, final ObjectNode node, final Entity entity, final ExpandTreeBuilder expandBuilder) throws DeserializerException { List<String> navigationPropertyNames = edmEntityType.getNavigationPropertyNames(); for (String navigationPropertyName : navigationPropertyNames) { // read expanded navigation property JsonNode jsonNode = node.get(navigationPropertyName); if (jsonNode != null) { EdmNavigationProperty edmNavigationProperty = edmEntityType.getNavigationProperty(navigationPropertyName); checkNotNullOrValidNull(jsonNode, edmNavigationProperty); Link link = createLink(expandBuilder, navigationPropertyName, jsonNode, edmNavigationProperty); entity.getNavigationLinks().add(link); node.remove(navigationPropertyName); } } }
private void consumeExpandedNavigationProperties(final EdmEntityType edmEntityType, final ObjectNode node, final Entity entity, final ExpandTreeBuilder expandBuilder) throws DeserializerException { List<String> navigationPropertyNames = edmEntityType.getNavigationPropertyNames(); for (String navigationPropertyName : navigationPropertyNames) { // read expanded navigation property JsonNode jsonNode = node.get(navigationPropertyName); if (jsonNode != null) { EdmNavigationProperty edmNavigationProperty = edmEntityType.getNavigationProperty(navigationPropertyName); checkNotNullOrValidNull(jsonNode, edmNavigationProperty); Link link = createLink(expandBuilder, navigationPropertyName, jsonNode, edmNavigationProperty); entity.getNavigationLinks().add(link); node.remove(navigationPropertyName); } } }
private static ExpandOptionImpl constructDraftTreeExpand(EdmEntityType rootEntityType,ExpandOptionImpl eO,Map<String,List<String>> draftTree) { if(eO==null) { eO=new ExpandOptionImpl(); } if(rootEntityType.getNavigationPropertyNames()!=null && !rootEntityType.getNavigationPropertyNames().isEmpty()) { for(String navName:rootEntityType.getNavigationPropertyNames()) { EdmNavigationProperty expandNp=rootEntityType.getNavigationProperty(navName); if(draftTree.get(rootEntityType.getName()).contains(expandNp.getType().getName())) { UriResourceNavigationPropertyImpl adminNaVPropImpl=new UriResourceNavigationPropertyImpl(expandNp); UriInfoImpl uriInfoForExpand = new UriInfoImpl().addResourcePart(adminNaVPropImpl); //Recursively set compositions ExpandOption innerExpandoption=constructDraftTreeExpand(expandNp.getType(),(ExpandOptionImpl) uriInfoForExpand.getExpandOption(),draftTree); if(innerExpandoption!=null) { uriInfoForExpand.setSystemQueryOption(innerExpandoption); ExpandItem eI = new ExpandItemImpl().setResourcePath(uriInfoForExpand).setSystemQueryOption(innerExpandoption); eO.addExpandItem(eI); } } } return eO; } return eO; }
throws DeserializerException { if (constants instanceof Constantsv01) { List<String> navigationPropertyNames = edmEntityType.getNavigationPropertyNames(); for (String navigationPropertyName : navigationPropertyNames) {
private int insertDepth(EdmEntityType entityType, Entity entity) throws SQLException, TeiidException { int depth = 1; int childDepth = 0; for (String navigationName:entityType.getNavigationPropertyNames()) { EdmNavigationProperty navProperty = entityType.getNavigationProperty(navigationName); Link navLink = entity.getNavigationLink(navigationName); if (navLink != null && navLink.getInlineEntity() != null) { childDepth = Math.max(childDepth, insertDepth(navProperty.getType(), navLink.getInlineEntity())); } else if (navLink != null && navLink.getInlineEntitySet() != null && !navLink.getInlineEntitySet().getEntities().isEmpty()) { for (Entity inlineEntity:navLink.getInlineEntitySet().getEntities()) { childDepth = Math.max(childDepth, insertDepth(navProperty.getType(), inlineEntity)); } } } return depth + childDepth; }
private UpdateResponse performDeepInsert(String rawURI, UriInfo uriInfo, EdmEntityType entityType, Entity entity, List<ExpandNode> expandNodes) throws SQLException, TeiidException { UpdateResponse response = performInsert(rawURI, uriInfo, entityType, entity); for (String navigationName:entityType.getNavigationPropertyNames()) { EdmNavigationProperty navProperty = entityType.getNavigationProperty(navigationName); Link navLink = entity.getNavigationLink(navigationName); if (navLink != null && navLink.getInlineEntity() != null) { ExpandNode node = new ExpandNode(); node.navigationProperty = navProperty; expandNodes.add(node); performDeepInsert(rawURI, uriInfo, navProperty.getType(), navLink.getInlineEntity(), node.children); } else if (navLink != null && navLink.getInlineEntitySet() != null && !navLink.getInlineEntitySet().getEntities().isEmpty()) { ExpandNode node = new ExpandNode(); node.navigationProperty = navProperty; expandNodes.add(node); for (Entity inlineEntity:navLink.getInlineEntitySet().getEntities()) { performDeepInsert(rawURI, uriInfo, navProperty.getType(), inlineEntity, node.children); } } } return response; }
if(mainEntity.getNavigationPropertyNames()!=null&&!mainEntity.getNavigationPropertyNames().isEmpty()) { for(String navName:mainEntity.getNavigationPropertyNames()){ EdmNavigationProperty navProp=mainEntity.getNavigationProperty(navName); Map<String,List<String>> draftTree=CSNUtil.getDraftTree( EdmHelper.getServiceName(uriInfo.asUriInfoResource()));
for (String name:entityType.getNavigationPropertyNames()) { Link navLink = new Link(); navLink.setTitle(name);