public static boolean hasExpand(final ExpandOption expand) { return expand != null && expand.getExpandItems() != null && !expand.getExpandItems().isEmpty(); }
public static boolean hasExpand(final ExpandOption expand) { return expand != null && expand.getExpandItems() != null && !expand.getExpandItems().isEmpty(); }
public static ExpandItem getExpandAll(final ExpandOption expand) { for (final ExpandItem item : expand.getExpandItems()) { if (item.isStar()) { return item; } } return null; }
public JPAExpandLevelWrapper(final ExpandOption option, final JPAEntityType jpaEntityType) { super(); this.option = option; this.item = option.getExpandItems().get(0); this.levelOptions = determineLevel(item); this.jpaEntityType = jpaEntityType; }
public static ExpandItem getExpandAll(final ExpandOption expand) { for (final ExpandItem item : expand.getExpandItems()) { if (item.isStar()) { return item; } } return null; }
private ExpandOptionWrapper(ExpandOption expandOption) { this.items = new ArrayList<>(); this.items.add(new ExpandItemWrapper(expandOption.getExpandItems().get(0))); this.parentOptions = expandOption; expandOption.getExpandItems().get(0).getLevelsOption(); }
private void checkExpand(UriInfoResource queryInfo) { if (queryInfo.getExpandOption() != null && !queryInfo.getExpandOption().getExpandItems().isEmpty()) { throw new UnsupportedOperationException("Expand is not supported"); //$NON-NLS-1$ } }
private boolean hasExpand(String name, ExpandOption expandOption) { if (expandOption == null) { return false; } for (ExpandItem ei:expandOption.getExpandItems()) { String expand = ((UriResourceEntitySetImpl)ei.getResourcePath().getUriResourceParts().get(0)).getEntitySet().getName(); if (expand.equalsIgnoreCase(name)) { return true; } } return false; }
public static Set<List<String>> getExpandedItemsPath(ExpandOption expand) { Set<List<String>> expandPaths = new HashSet<List<String>>(); if (expand != null) { List<ExpandItem> expandItems = expand.getExpandItems(); for (ExpandItem item : expandItems) { if (item.isStar()) { continue; } List<UriResource> resourceParts = item.getResourcePath().getUriResourceParts(); if (resourceParts.get(0) instanceof UriResourceComplexProperty) { List<String> path = new ArrayList<String>(); for (UriResource resource : resourceParts) { if (resource instanceof UriResourceNavigation) { path.add(((UriResourceNavigation) resource).getProperty().getName()); } else if (resource instanceof UriResourceProperty) { path.add(((UriResourceProperty) resource).getProperty().getName()); } } expandPaths.add(path); } } } return expandPaths; }
public static Set<List<String>> getExpandedItemsPath(ExpandOption expand) { Set<List<String>> expandPaths = new HashSet<List<String>>(); if (expand != null) { List<ExpandItem> expandItems = expand.getExpandItems(); for (ExpandItem item : expandItems) { if (item.isStar()) { continue; } List<UriResource> resourceParts = item.getResourcePath().getUriResourceParts(); if (resourceParts.get(0) instanceof UriResourceComplexProperty) { List<String> path = new ArrayList<String>(); for (UriResource resource : resourceParts) { if (resource instanceof UriResourceNavigation) { path.add(((UriResourceNavigation) resource).getProperty().getName()); } else if (resource instanceof UriResourceProperty) { path.add(((UriResourceProperty) resource).getProperty().getName()); } } expandPaths.add(path); } } } return expandPaths; }
private static void handleExpand(final EdmStructuredType type, final ExpandOption expand, final StringBuilder result) throws SerializerException { final Set<String> expandedPropertyNames = ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems()); for (final String propertyName : type.getNavigationPropertyNames()) { if (expandedPropertyNames.contains(propertyName)) { final ExpandItem expandItem = ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName); if (ExpandSelectHelper.hasExpand(expandItem.getExpandOption()) && !(null != ExpandSelectHelper.getExpandAll(expandItem.getExpandOption()))
public JPAExpandLevelWrapper(final JPAServiceDocument sd, final ExpandOption option) throws ODataApplicationException { super(); this.option = option; this.item = option.getExpandItems().get(0); this.levelOptions = determineLevel(item); try { this.jpaEntityType = sd.getEntity(Util.determineTargetEntityType(getUriResourceParts())); } catch (ODataJPAModelException e) { throw new ODataJPAQueryException(ODataJPAQueryException.MessageKeys.QUERY_PREPARATION_ENTITY_UNKNOWN, HttpStatusCode.BAD_REQUEST, e, Util.determineTargetEntityType(getUriResourceParts()).getName()); } }
public List<String> generateCDSStatement(UriInfo uriInfo,ODataRequest request, List<ApplyTransformationsPerGroup> applyTrafoList) throws CDSRuntimeException{ checkForUnimplementedFeatures(uriInfo, request); List<String> sqlList = new ArrayList<String>(); if(uriInfo.getExpandOption()!=null&&uriInfo.getExpandOption().getExpandItems()!=null&&!uriInfo.getExpandOption().getExpandItems().isEmpty()){ checkForUnimplementedFeaturesWithinExpand(uriInfo.getExpandOption().getExpandItems(), request); } qH=new QueryHelperV4(uriInfo, request, applyTrafoList); if(uriInfo.getTopOption()!=null){ qH.setTopValue((long)uriInfo.getTopOption().getValue()); } if(uriInfo.getSkipOption()!=null){ qH.setSkipValue((long)uriInfo.getSkipOption().getValue()); } if(pageSize!=null){ modTopSkipforPagination(qH); } CDSQueryGenerator cdsq=new CDSQueryGenerator(qH); String sql= cdsq.generateSQl(); sqlList.add(sql); if(uriInfo.getCountOption() != null && uriInfo.getCountOption().getValue() == true) { qH.getEntityInfo().setCountStar(true); String countSql = new CDSQueryGenerator(qH).generateSQl(); sqlList.add(countSql); } return sqlList; }
private void parseExpandOption(ExpandOption expandOption, final EdmType contextType, final boolean isAll, final List<String> entitySetNames, final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException { if (expandOption != null) { if (!(contextType instanceof EdmStructuredType || isAll || (entitySetNames != null && !entitySetNames.isEmpty()))) { throw new UriValidationException("Expand is only allowed on structured types!", UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED, expandOption.getName()); } final String optionValue = expandOption.getText(); UriTokenizer expandTokenizer = new UriTokenizer(optionValue); final ExpandOption option = new ExpandParser(edm, odata, aliases, entitySetNames).parse(expandTokenizer, contextType instanceof EdmStructuredType ? (EdmStructuredType) contextType : null); checkOptionEOF(expandTokenizer, expandOption.getName(), optionValue); for (final ExpandItem item : option.getExpandItems()) { ((ExpandOptionImpl) expandOption).addExpandItem(item); } } }
private void parseExpandOption(ExpandOption expandOption, final EdmType contextType, final boolean isAll, final List<String> entitySetNames, final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException { if (expandOption != null) { if (!(contextType instanceof EdmStructuredType || isAll || (entitySetNames != null && !entitySetNames.isEmpty()))) { throw new UriValidationException("Expand is only allowed on structured types!", UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED, expandOption.getName()); } final String optionValue = expandOption.getText(); UriTokenizer expandTokenizer = new UriTokenizer(optionValue); final ExpandOption option = new ExpandParser(edm, odata, aliases, entitySetNames).parse(expandTokenizer, contextType instanceof EdmStructuredType ? (EdmStructuredType) contextType : null); checkOptionEOF(expandTokenizer, expandOption.getName(), optionValue); for (final ExpandItem item : option.getExpandItems()) { ((ExpandOptionImpl) expandOption).addExpandItem(item); } } }
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); } } } } }
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); } } } } }
private void writeExpandedStreamProperty(ExpandOption expand, String propertyName, EdmProperty edmProperty, Linked linked, ExpandItem expandAll, JsonGenerator json) throws SerializerException, DecoderException, IOException { final ExpandItem innerOptions = ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName); if (innerOptions != null || expandAll != null) { if(constants instanceof Constantsv00){
.addExpandItem(nestedExpand.getExpandItems().get(0));
.addExpandItem(nestedExpand.getExpandItems().get(0));