@Override public UriInfoResource getResourcePath() { return parentItem.getResourcePath(); }
@Override public ExpandOption getExpandOption() { return item.getExpandOption(); }
@Override public FilterOption getFilterOption() { return parentItem.getFilterOption(); }
private void appendExpandItemJson(final JsonGenerator gen, final ExpandItem item) throws IOException { gen.writeStartObject(); if (item.isStar()) { gen.writeBooleanField("star", item.isStar()); } else if (item.getResourcePath() != null && !item.getResourcePath().getUriResourceParts().isEmpty()) { gen.writeFieldName("expandPath"); appendURIResourceParts(gen, item.getResourcePath().getUriResourceParts()); } if (item.isRef()) { gen.writeBooleanField("isRef", item.isRef()); } if (item.getLevelsOption() != null) { gen.writeFieldName("levels"); if (item.getLevelsOption().isMax()) { gen.writeString("max"); } else { gen.writeNumber(item.getLevelsOption().getValue()); } } appendCommonJsonObjects(gen, item.getCountOption(), item.getSkipOption(), item.getTopOption(), item.getFilterOption(), item.getOrderByOption(), item.getSelectOption(), item.getExpandOption(), item.getSearchOption(), item.getApplyOption()); gen.writeEndObject(); }
HashSet<String> seen = new HashSet<String>(); for (ExpandItem ei : option.getExpandItems()) { if (ei.getSearchOption() != null) { throw new TeiidNotImplementedException( ODataPlugin.Event.TEIID16035, ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16035)); } else if (ei.getLevelsOption() != null) { if (ei.getLevelsOption().isMax()) { levels = MAX_EXPAND_LEVEL - expandLevel + 1; } else { levels = ei.getLevelsOption().getValue(); checkExpandLevel(expandLevel + levels - 1); EdmNavigationProperty property = esb.getNavigationProperty(); if (property == null) { if (ei.isStar()) { if (starLevels > 0) { throw new TeiidProcessingException( if (ei.getFilterOption() != null) { Expression expandCriteria = processFilterOption(ei.getFilterOption(), expandResource); expandResource.addCriteria(expandCriteria); if (ei.getOrderByOption() != null) { expandOrder = new OrderBy(); processOrderBy(expandOrder, ei.getOrderByOption().getOrders(), expandResource); } else { expandOrder = expandResource.addDefaultOrderBy();
protected void writeNavigationProperties(final ServiceMetadata metadata, final EdmStructuredType type, final Linked linked, final ExpandOption expand, final String name, final JsonGenerator json) throws SerializerException, IOException { if (ExpandSelectHelper.hasExpand(expand)) { final boolean expandAll = ExpandSelectHelper.getExpandAll(expand) != null; final Set<String> expanded = expandAll ? new HashSet<String>() : ExpandSelectHelper.getExpandedPropertyNames( expand.getExpandItems()); for (final String propertyName : type.getNavigationPropertyNames()) { if (expandAll || expanded.contains(propertyName)) { final EdmNavigationProperty property = type.getNavigationProperty(propertyName); final Link navigationLink = linked.getNavigationLink(property.getName()); final ExpandItem innerOptions = expandAll ? null : ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName); if (innerOptions != null && innerOptions.getLevelsOption() != null) { throw new SerializerException("Expand option $levels is not supported.", SerializerException.MessageKeys.NOT_IMPLEMENTED); } if (navigationLink != null) { writeExpandedNavigationProperty(metadata, property, navigationLink, innerOptions == null ? null : innerOptions.getExpandOption(), innerOptions == null ? null : innerOptions.getSelectOption(), innerOptions == null ? null : innerOptions.getCountOption(), innerOptions == null ? false : innerOptions.hasCountPath(), innerOptions == null ? false : innerOptions.isRef(), name, json); } } } } }
List<ExpandItem> expandItems = expandOption.getExpandItems(); for (int i = 0; i < expandItems.size(); i++) { UriResource uriResource = expandItems.get(i).getResourcePath().getUriResourceParts().get(0); EdmEntityType entity = ((UriResourceNavigation) uriResource).getProperty().getType(); String navName=((UriResourceNavigation) uriResource).getProperty().getName(); if (expandItems.get(i).getFilterOption() != null) { String filterExpExpand = null; filterExpExpand = prepeareFilter(expandItems.get(i).getFilterOption().getExpression()); if (filterExpExpand != null) { eInfo.getFilters().add(new Filter(filterExpExpand)); if(expandItems.get(i).getSearchOption()!=null){ handleSearchQueryOption(expandItems.get(i).getSearchOption(), eInfo, entity.getFullQualifiedName().getName(), true); if(expandItems.get(i).getTopOption()!=null){ eInfo.setLeveltop(expandItems.get(i).getTopOption().getValue()); if(expandItems.get(i).getSkipOption()!=null){ eInfo.setLevelSkip(expandItems.get(i).getSkipOption().getValue()); if (expandItems.get(i).getOrderByOption() != null) { for (OrderByItem orderByItem : expandItems.get(i).getOrderByOption().getOrders()) { OrderBy orderBy = new OrderBy(); Expression expression = orderByItem.getExpression(); if (expandItems.get(i).getExpandOption() != null) { eInfo.setEntitiesExpanded( prepExpandInfoList(expandItems.get(i).getExpandOption(), eInfo.getParententityName(),igonoreDraftAdminData));
public static ExpandItem getExpandItem(final List<ExpandItem> expandItems, final String propertyName) { for (final ExpandItem item : expandItems) { if (item.isStar()) { continue; } final List<UriResource> resourceParts = item.getResourcePath().getUriResourceParts(); UriResource resource = null; if (resourceParts.get(resourceParts.size() - 1) instanceof UriResourceRef || resourceParts.get(resourceParts.size() - 1) instanceof UriResourceCount) { resource = resourceParts.get(resourceParts.size() - 2); } else { resource = resourceParts.get(resourceParts.size() - 1); } if ((resource instanceof UriResourceNavigation && propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) || resource instanceof UriResourceProperty && propertyName.equals(((UriResourceProperty) resource).getProperty().getName())) { return item; } } return null; }
if (item.isStar()) { final EdmEntitySet edmEntitySet = determineTargetEntitySet(startResourceList); try { final List<UriResource> targetResourceList = item.getResourcePath().getUriResourceParts(); associationName = new StringBuilder(); associationName.append(associationNamePrefix); if (item.getLevelsOption() != null) pathList.put(new JPAExpandLevelWrapper(sd, expandOption), Util.determineAssoziation(sd, ((UriResourcePartTyped) startResourceItem).getType(), associationName));
if (ExpandSelectHelper.hasExpand(expandItem.getExpandOption()) && !(null != ExpandSelectHelper.getExpandAll(expandItem.getExpandOption())) || ExpandSelectHelper.hasSelect(expandItem.getSelectOption())) { final String innerSelectList = buildSelectList(type.getNavigationProperty(propertyName).getType(), expandItem.getExpandOption(), expandItem.getSelectOption()); if (innerSelectList != null) { if (result.length() > 0) { final List<UriResource> resourceParts = expandItem.getResourcePath().getUriResourceParts(); if (resourceParts.size() > 1) { if (result.length() > 0) {
private void checkForUnimplementedFeaturesWithinExpand(List<ExpandItem> expandItems,ODataRequest request) throws CDSRuntimeException { for(ExpandItem expandItem : expandItems) { CDSRuntimeException cdsRuntimeException; if((expandItem).getCountOption() != null){ cdsRuntimeException = new CDSRuntimeException(CDSRuntimeException.MessageKeys.NOT_IMPLEMENTED, "$count in expand is not implemented", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), HeaderUtil.getlocale(request), "$count in Expand"); logger.error("$count system query option is not implemented", cdsRuntimeException); throw cdsRuntimeException; } if(expandItem.getLevelsOption() != null){ cdsRuntimeException = new CDSRuntimeException(CDSRuntimeException.MessageKeys.NOT_IMPLEMENTED, "$level in expand is not implemented", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), HeaderUtil.getlocale(request), "$level in Expand"); logger.error("$levels option is not implemented", cdsRuntimeException); throw cdsRuntimeException; } if(expandItem.isStar()){ cdsRuntimeException = new CDSRuntimeException(CDSRuntimeException.MessageKeys.NOT_IMPLEMENTED, "$expand=* in Expand not mplemented", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), HeaderUtil.getlocale(request), "$expand=* in Expand"); logger.error("$expand=* option is not implemented", cdsRuntimeException); throw cdsRuntimeException; } } }
public static ExpandItem getExpandAll(final ExpandOption expand) { for (final ExpandItem item : expand.getExpandItems()) { if (item.isStar()) { return item; } } return null; }
private LevelsExpandOption determineLevel(ExpandItem item2) { return item.getLevelsOption(); }
@Override public OrderByOption getOrderByOption() { return item.getOrderByOption(); }
@Override public SkipOption getSkipOption() { return parentItem.getSkipOption(); }
@Override public TopOption getTopOption() { return parentItem.getTopOption(); }
@Override public SearchOption getSearchOption() { return item.getSearchOption(); }
@Override public CountOption getCountOption() { return parentItem.getCountOption(); }
private void appendExpandItemJson(final JsonGenerator gen, final ExpandItem item) throws IOException { gen.writeStartObject(); if (item.isStar()) { gen.writeBooleanField("star", item.isStar()); } else if (item.getResourcePath() != null && !item.getResourcePath().getUriResourceParts().isEmpty()) { gen.writeFieldName("expandPath"); appendURIResourceParts(gen, item.getResourcePath().getUriResourceParts()); } if (item.isRef()) { gen.writeBooleanField("isRef", item.isRef()); } if (item.getLevelsOption() != null) { gen.writeFieldName("levels"); if (item.getLevelsOption().isMax()) { gen.writeString("max"); } else { gen.writeNumber(item.getLevelsOption().getValue()); } } appendCommonJsonObjects(gen, item.getCountOption(), item.getSkipOption(), item.getTopOption(), item.getFilterOption(), item.getOrderByOption(), item.getSelectOption(), item.getExpandOption(), item.getSearchOption(), item.getApplyOption()); gen.writeEndObject(); }
protected void writeNavigationProperties(final ServiceMetadata metadata, final EdmStructuredType type, final Linked linked, final ExpandOption expand, final String name, final JsonGenerator json) throws SerializerException, IOException { if (ExpandSelectHelper.hasExpand(expand)) { final boolean expandAll = ExpandSelectHelper.getExpandAll(expand) != null; final Set<String> expanded = expandAll ? new HashSet<String>() : ExpandSelectHelper.getExpandedPropertyNames( expand.getExpandItems()); for (final String propertyName : type.getNavigationPropertyNames()) { if (expandAll || expanded.contains(propertyName)) { final EdmNavigationProperty property = type.getNavigationProperty(propertyName); final Link navigationLink = linked.getNavigationLink(property.getName()); final ExpandItem innerOptions = expandAll ? null : ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName); if (innerOptions != null && innerOptions.getLevelsOption() != null) { throw new SerializerException("Expand option $levels is not supported.", SerializerException.MessageKeys.NOT_IMPLEMENTED); } if (navigationLink != null) { writeExpandedNavigationProperty(metadata, property, navigationLink, innerOptions == null ? null : innerOptions.getExpandOption(), innerOptions == null ? null : innerOptions.getSelectOption(), innerOptions == null ? null : innerOptions.getCountOption(), innerOptions == null ? false : innerOptions.hasCountPath(), innerOptions == null ? false : innerOptions.isRef(), name, json); } } } } }