public static boolean hasSelect(final SelectOption select) { return select != null && select.getSelectItems() != null && !select.getSelectItems().isEmpty(); }
public static boolean hasSelect(final SelectOption select) { return select != null && select.getSelectItems() != null && !select.getSelectItems().isEmpty(); }
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; } }
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 boolean areKeyPredicateNamesSelected(SelectOption select, EdmEntityType type) { if (select == null || ExpandSelectHelper.isAll(select)) { return true; } final Set<String> selected = ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); for (String key : type.getKeyPredicateNames()) { if (!selected.contains(key)) { return false; } } return true; }
private boolean areKeyPredicateNamesSelected(SelectOption select, EdmEntityType type) { if (select == null || ExpandSelectHelper.isAll(select)) { return true; } final Set<String> selected = ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); for (String key : type.getKeyPredicateNames()) { if (!selected.contains(key)) { return false; } } return true; }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final JsonGenerator json) throws IOException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select .getSelectItems()); for (final String propertyName : type.getPropertyNames()) { if ((all || selected.contains(propertyName)) && !properties.isEmpty()) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper .getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, json); } } }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final JsonGenerator json) throws IOException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select .getSelectItems()); for (final String propertyName : type.getPropertyNames()) { if ((all || selected.contains(propertyName)) && !properties.isEmpty()) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper .getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, json); } } }
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); } } }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final JsonGenerator json) throws IOException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select .getSelectItems()); for (final String propertyName : type.getPropertyNames()) { if (all || selected.contains(propertyName)) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper .getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, json); } } }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final JsonGenerator json) throws IOException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select .getSelectItems()); for (final String propertyName : type.getPropertyNames()) { if (all || selected.contains(propertyName)) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper .getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, json); } } }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final JsonGenerator json, Linked linked, ExpandOption expand) throws IOException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); addKeyPropertiesToSelected(selected, type); Set<List<String>> expandedPaths = ExpandSelectHelper.getExpandedItemsPath(expand); for (final String propertyName : type.getPropertyNames()) { if (all || selected.contains(propertyName)) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, json, expandedPaths, linked, expand); } } }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final JsonGenerator json, Linked linked, ExpandOption expand) throws IOException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); addKeyPropertiesToSelected(selected, type); Set<List<String>> expandedPaths = ExpandSelectHelper.getExpandedItemsPath(expand); for (final String propertyName : type.getPropertyNames()) { if (all || selected.contains(propertyName)) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, json, expandedPaths, linked, expand); } } }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final String xml10InvalidCharReplacement, final XMLStreamWriter writer, Linked linked, ExpandOption expand) throws XMLStreamException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); addKeyPropertiesToSelected(selected, type); Set<List<String>> expandedPaths = ExpandSelectHelper.getExpandedItemsPath(expand); for (final String propertyName : type.getPropertyNames()) { if (all || selected.contains(propertyName)) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer, expandedPaths, linked, expand); } } }
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, final List<Property> properties, final SelectOption select, final String xml10InvalidCharReplacement, final XMLStreamWriter writer, Linked linked, ExpandOption expand) throws XMLStreamException, SerializerException { final boolean all = ExpandSelectHelper.isAll(select); final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); addKeyPropertiesToSelected(selected, type); Set<List<String>> expandedPaths = ExpandSelectHelper.getExpandedItemsPath(expand); for (final String propertyName : type.getPropertyNames()) { if (all || selected.contains(propertyName)) { final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final Property property = findProperty(propertyName, properties); final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName); writeProperty(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer, expandedPaths, linked, expand); } } }
private static void handleSelect(EdmStructuredType type, final SelectOption select, final StringBuilder result) { if (ExpandSelectHelper.isAll(select)) { result.append('*'); } else { final List<SelectItem> selectItems = select.getSelectItems(); type = getTypeFromSelectItems(selectItems, type); final Set<String> selectedPropertyNames = ExpandSelectHelper.getSelectedPropertyNames(selectItems); for (final String propertyName : type.getPropertyNames()) { constructSelectItemList(type, result, selectItems, selectedPropertyNames, propertyName); } for (final String propertyName : type.getNavigationPropertyNames()) { constructSelectItemList(type, result, selectItems, selectedPropertyNames, propertyName); } constructSelectItemListForActionsAndFunctions(type, result, selectItems); } }
private static void handleSelect(EdmStructuredType type, final SelectOption select, final StringBuilder result) { if (ExpandSelectHelper.isAll(select)) { result.append('*'); } else { final List<SelectItem> selectItems = select.getSelectItems(); type = getTypeFromSelectItems(selectItems, type); final Set<String> selectedPropertyNames = ExpandSelectHelper.getSelectedPropertyNames(selectItems); for (final String propertyName : type.getPropertyNames()) { constructSelectItemList(type, result, selectItems, selectedPropertyNames, propertyName); } for (final String propertyName : type.getNavigationPropertyNames()) { constructSelectItemList(type, result, selectItems, selectedPropertyNames, propertyName); } constructSelectItemListForActionsAndFunctions(type, result, selectItems); } }
private void parseSelectOption(SelectOption selectOption, final EdmType contextType, final boolean contextIsCollection) throws UriParserException, UriValidationException { if (selectOption != null) { final String optionValue = selectOption.getText(); UriTokenizer selectTokenizer = new UriTokenizer(optionValue); ((SelectOptionImpl) selectOption).setSelectItems( new SelectParser(edm).parse(selectTokenizer, contextType instanceof EdmStructuredType ? (EdmStructuredType) contextType : null, contextIsCollection) .getSelectItems()); checkOptionEOF(selectTokenizer, selectOption.getName(), optionValue); } }
private void parseSelectOption(SelectOption selectOption, final EdmType contextType, final boolean contextIsCollection) throws UriParserException, UriValidationException { if (selectOption != null) { final String optionValue = selectOption.getText(); UriTokenizer selectTokenizer = new UriTokenizer(optionValue); ((SelectOptionImpl) selectOption).setSelectItems( new SelectParser(edm).parse(selectTokenizer, contextType instanceof EdmStructuredType ? (EdmStructuredType) contextType : null, contextIsCollection) .getSelectItems()); checkOptionEOF(selectTokenizer, selectOption.getName(), optionValue); } }
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); } } } }