public static boolean hasSelect(final SelectOption select) { return select != null && select.getSelectItems() != null && !select.getSelectItems().isEmpty(); }
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); } }
public static boolean hasSelect(final SelectOption select) { return select != null && select.getSelectItems() != null && !select.getSelectItems().isEmpty(); }
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); } }
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); } } }
if (select == null || select.getSelectItems().isEmpty() || select.getSelectItems().get(0).isStar()) { for (final JPAPath selectItemPath : jpaEntity.getPathList()) { if (pathContainsCollection(selectItemPath)) for (SelectItem sItem : select.getSelectItems()) { final String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPERATOR));
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); } } }
if (selectOption != null && !selectOption.getSelectItems().isEmpty()) { gen.writeFieldName("select"); appendSelectedPropertiesJson(gen, selectOption.getSelectItems());
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); } } }
if (selectOption != null && !selectOption.getSelectItems().isEmpty()) { gen.writeFieldName("select"); appendSelectedPropertiesJson(gen, selectOption.getSelectItems());
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); } } }