private String getSelectString(final SelectItem selectItem) { if (selectItem.isStar()) { if (selectItem.getAllOperationsInSchemaNameSpace() == null) { return "*"; } else { return selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + ".*"; } } else { final StringBuilder tmp = new StringBuilder(); for (UriResource resourcePart : selectItem.getResourcePath().getUriResourceParts()) { if (tmp.length() > 0) { tmp.append('/'); } tmp.append(resourcePart.toString()); } return tmp.toString(); } }
/** * This fetches the correct EntityType if there is an entity type cast * specified in the select option of the url * @param selectItems * @param type * @return */ private static EdmStructuredType getTypeFromSelectItems(List<SelectItem> selectItems, EdmStructuredType type) { EdmStructuredType edmType = type; for (final SelectItem item : selectItems) { if (item.getStartTypeFilter() != null && item.getStartTypeFilter() instanceof EdmEntityType) { edmType = (EdmEntityType) item.getStartTypeFilter(); } } return edmType; }
private void buildSelectionAddNavigationAndSelect(final UriInfoResource uriResource, final List<JPAPath> jpaPathList, final SelectOption select) throws ODataApplicationException, ODataJPAModelException { final UriResource last = !uriResource.getUriResourceParts().isEmpty() ? uriResource.getUriResourceParts().get( uriResource.getUriResourceParts().size() - 1) : null; final boolean targetIsCollection = (last != null && last instanceof UriResourceProperty && ((UriResourceProperty) last).isCollection()); final String pathPrefix = Util.determineProptertyNavigationPrefix(uriResource.getUriResourceParts()); if (Util.VALUE_RESOURCE.equals(pathPrefix)) jpaPathList.addAll(buildPathValue(jpaEntity)); else if (select == null || select.getSelectItems().isEmpty() || select.getSelectItems().get(0).isStar()) { if (pathPrefix == null || pathPrefix.isEmpty()) copyNonCollectionProperties(jpaPathList, buildEntityPathList(jpaEntity)); else { expandPath(jpaEntity, jpaPathList, pathPrefix, targetIsCollection); } } else { for (SelectItem sItem : select.getSelectItems()) { String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPERATOR)); expandPath(jpaEntity, jpaPathList, pathPrefix.isEmpty() ? pathItem : pathPrefix + "/" + pathItem, targetIsCollection); } } }
public static Set<List<String>> getSelectedPaths(final List<SelectItem> selectItems) { Set<List<String>> selectedPaths = new HashSet<List<String>>(); for (final SelectItem item : selectItems) { final List<UriResource> parts = item.getResourcePath().getUriResourceParts(); final UriResource resource = parts.get(0); if (resource instanceof UriResourceProperty) { if (!parts.isEmpty()) { List<String> path = new ArrayList<String>(); for (final UriResource part : parts.subList(0, parts.size())) { if (part instanceof UriResourceProperty) { path.add(((UriResourceProperty) part).getProperty().getName()); } } selectedPaths.add(path); } else { return null; } } } return selectedPaths.isEmpty() ? null : selectedPaths; }
Set<List<String>> selectedPaths = new HashSet<List<String>>(); for (final SelectItem item : selectItems) { final List<UriResource> parts = item.getResourcePath().getUriResourceParts(); final UriResource resource = parts.get(0); if (resource instanceof UriResourceProperty && propertyName.equals(((UriResourceProperty) resource).getProperty().getName())) { List<String> path = new ArrayList<String>(); if (item.getStartTypeFilter() != null) { path.add(item.getStartTypeFilter().getFullQualifiedName().getFullQualifiedNameAsString()); && propertyName.equals(((UriResourceNavigation) resource).getProperty().getName()) ) { List<String> path = new ArrayList<String>(); if (item.getStartTypeFilter() != null) { path.add(item.getStartTypeFilter().getFullQualifiedName().getFullQualifiedNameAsString());
public static boolean isAll(final SelectOption select) { if (hasSelect(select)) { for (final SelectItem item : select.getSelectItems()) { if (item.isStar()) { return true; } } return false; } else { return true; } }
if (select == null || select.getSelectItems().isEmpty() || select.getSelectItems().get(0).isStar()) { for (final JPAPath selectItemPath : jpaEntity.getPathList()) { if (pathContainsCollection(selectItemPath)) final String pathPrefix = ""; for (SelectItem sItem : select.getSelectItems()) { final String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPERATOR)); final JPAPath selectItemPath = jpaEntity.getPath(pathPrefix.isEmpty() ? pathItem : pathPrefix
public static Set<List<String>> getSelectedPaths(final List<SelectItem> selectItems) { Set<List<String>> selectedPaths = new HashSet<List<String>>(); for (final SelectItem item : selectItems) { final List<UriResource> parts = item.getResourcePath().getUriResourceParts(); final UriResource resource = parts.get(0); if (resource instanceof UriResourceProperty) { if (!parts.isEmpty()) { List<String> path = new ArrayList<String>(); for (final UriResource part : parts.subList(0, parts.size())) { if (part instanceof UriResourceProperty) { path.add(((UriResourceProperty) part).getProperty().getName()); } } selectedPaths.add(path); } else { return null; } } } return selectedPaths.isEmpty() ? null : selectedPaths; }
Set<List<String>> selectedPaths = new HashSet<List<String>>(); for (final SelectItem item : selectItems) { final List<UriResource> parts = item.getResourcePath().getUriResourceParts(); final UriResource resource = parts.get(0); if (resource instanceof UriResourceProperty && propertyName.equals(((UriResourceProperty) resource).getProperty().getName())) { List<String> path = new ArrayList<String>(); if (item.getStartTypeFilter() != null) { path.add(item.getStartTypeFilter().getFullQualifiedName().getFullQualifiedNameAsString()); && propertyName.equals(((UriResourceNavigation) resource).getProperty().getName()) ) { List<String> path = new ArrayList<String>(); if (item.getStartTypeFilter() != null) { path.add(item.getStartTypeFilter().getFullQualifiedName().getFullQualifiedNameAsString());
public static boolean isAll(final SelectOption select) { if (hasSelect(select)) { for (final SelectItem item : select.getSelectItems()) { if (item.isStar()) { return true; } } return false; } else { return true; } }
private void processSelectOption(SelectOption option, DocumentNode resource, boolean onlyReference) throws TeiidException { if (option == null) { // default select columns resource.addAllColumns(onlyReference); } else { boolean addkeys = true; ArrayList<String> keys = new ArrayList<String>(resource.getKeyColumnNames()); for (SelectItem si:option.getSelectItems()) { if (si.isStar()) { resource.addAllColumns(onlyReference); addkeys = false; continue; } ODataExpressionToSQLVisitor visitor = new ODataExpressionToSQLVisitor( resource, false, getUriInfo(), this.metadata, this.odata, this.nameGenerator, this.params, this.parseService); ElementSymbol expr = (ElementSymbol)visitor.getExpression(si.getResourcePath()); resource.addProjectedColumn(expr.getShortName(), expr); keys.remove(expr.getShortName()); } if (!keys.isEmpty() && addkeys) { for (String key:keys) { ElementSymbol es = new ElementSymbol(key, resource.getGroupSymbol()); resource.addProjectedColumn(key, es); } } } }
private String getSelectString(final SelectItem selectItem) { if (selectItem.isStar()) { if (selectItem.getAllOperationsInSchemaNameSpace() == null) { return "*"; } else { return selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + ".*"; } } else { final StringBuilder tmp = new StringBuilder(); for (UriResource resourcePart : selectItem.getResourcePath().getUriResourceParts()) { if (tmp.length() > 0) { tmp.append('/'); } tmp.append(resourcePart.toString()); } return tmp.toString(); } }
public static Set<List<String>> getSelectedPaths(final List<SelectItem> selectItems, final String propertyName) { Set<List<String>> selectedPaths = new HashSet<List<String>>(); for (final SelectItem item : selectItems) { final List<UriResource> parts = item.getResourcePath().getUriResourceParts(); final UriResource resource = parts.get(0); if (resource instanceof UriResourceProperty && propertyName.equals(((UriResourceProperty) resource).getProperty().getName())) { if (parts.size() > 1) { List<String> path = new ArrayList<String>(); for (final UriResource part : parts.subList(1, parts.size())) { if (part instanceof UriResourceProperty) { path.add(((UriResourceProperty) part).getProperty().getName()); } else if (part instanceof UriResourceNavigation) { path.add(((UriResourceNavigation) part).getProperty().getName()); } } selectedPaths.add(path); } else { return null; } } } return selectedPaths.isEmpty() ? null : selectedPaths; }
if (select == null || select.getSelectItems().isEmpty() || select.getSelectItems().get(0).isStar()) {
/** * This fetches the correct EntityType if there is an entity type cast * specified in the select option of the url * @param selectItems * @param type * @return */ private static EdmStructuredType getTypeFromSelectItems(List<SelectItem> selectItems, EdmStructuredType type) { EdmStructuredType edmType = type; for (final SelectItem item : selectItems) { if (item.getStartTypeFilter() != null && item.getStartTypeFilter() instanceof EdmEntityType) { edmType = (EdmEntityType) item.getStartTypeFilter(); } } return edmType; }
|| select.getSelectItems().isEmpty() || select.getSelectItems().get(0).isStar()) else { for (SelectItem sItem : select.getSelectItems()) { String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPERATOR)); pathItem = pathPrefix == null || pathPrefix.isEmpty() ? pathItem : pathPrefix + JPAPath.PATH_SEPERATOR
public static Set<List<String>> getSelectedPaths(final List<SelectItem> selectItems, final String propertyName) { Set<List<String>> selectedPaths = new HashSet<List<String>>(); for (final SelectItem item : selectItems) { final List<UriResource> parts = item.getResourcePath().getUriResourceParts(); final UriResource resource = parts.get(0); if (resource instanceof UriResourceProperty && propertyName.equals(((UriResourceProperty) resource).getProperty().getName())) { if (parts.size() > 1) { List<String> path = new ArrayList<String>(); for (final UriResource part : parts.subList(1, parts.size())) { if (part instanceof UriResourceProperty) { path.add(((UriResourceProperty) part).getProperty().getName()); } else if (part instanceof UriResourceNavigation) { path.add(((UriResourceNavigation) part).getProperty().getName()); } } selectedPaths.add(path); } else { return null; } } } return selectedPaths.isEmpty() ? null : selectedPaths; }
public static Set<String> getSelectedPropertyNames(final List<SelectItem> selectItems) { Set<String> selected = new HashSet<String>(); for (final SelectItem item : selectItems) { final UriResource resource = item.getResourcePath().getUriResourceParts().get(0); if (resource instanceof UriResourceProperty) { selected.add(((UriResourceProperty) resource).getProperty().getName()); } else if (resource instanceof UriResourceNavigation) { selected.add(((UriResourceNavigation) resource).getProperty().getName()); } else if (resource instanceof UriResourceAction) { selected.add(((UriResourceAction) resource).getAction().getName()); } else if (resource instanceof UriResourceFunction) { selected.add(((UriResourceFunction) resource).getFunction().getName()); } } return selected; }
public static Set<String> getSelectedPropertyNames(final List<SelectItem> selectItems) { Set<String> selected = new HashSet<String>(); for (final SelectItem item : selectItems) { final UriResource resource = item.getResourcePath().getUriResourceParts().get(0); if (resource instanceof UriResourceProperty) { selected.add(((UriResourceProperty) resource).getProperty().getName()); } else if (resource instanceof UriResourceNavigation) { selected.add(((UriResourceNavigation) resource).getProperty().getName()); } else if (resource instanceof UriResourceAction) { selected.add(((UriResourceAction) resource).getAction().getName()); } else if (resource instanceof UriResourceFunction) { selected.add(((UriResourceFunction) resource).getFunction().getName()); } } return selected; }
Set<List<String>> selectedPaths) { for (SelectItem item : selectItems) { final List<UriResource> parts = item.getResourcePath().getUriResourceParts(); int i = 0; for (UriResource part : parts) {