public static boolean hasExpand(final ExpandOption expand) { return expand != null && expand.getExpandItems() != null && !expand.getExpandItems().isEmpty(); }
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); } } }
@Override public SystemQueryOptionKind getKind() { return parentOptions.getKind(); }
@Override public String getText() { return parentOptions.getText(); }
@Override public String getName() { return parentOptions.getName(); }
public static boolean hasExpand(final ExpandOption expand) { return expand != null && expand.getExpandItems() != null && !expand.getExpandItems().isEmpty(); }
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); } } }
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; }
if (expandOption != null && !expandOption.getExpandItems().isEmpty()) { gen.writeFieldName("expand"); appendExpandedPropertiesJson(gen, expandOption.getExpandItems());
if (expandOption != null && !expandOption.getExpandItems().isEmpty()) { gen.writeFieldName("expand"); appendExpandedPropertiesJson(gen, expandOption.getExpandItems());
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()))
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()); } }