private boolean determineIsCollection(final UriResource lastItem) { if (lastItem instanceof UriResourcePartTyped) return ((UriResourcePartTyped) lastItem).isCollection(); return false; }
@Override public boolean isCollection() { UriInfoImpl uriInfo = (UriInfoImpl) path; UriResource lastResourcePart = uriInfo.getLastResourcePart(); return lastResourcePart instanceof UriResourcePartTyped ? ((UriResourcePartTyped) lastResourcePart).isCollection() : false; }
@Override public boolean isCollection() { UriInfoImpl uriInfo = (UriInfoImpl) path; UriResource lastResourcePart = uriInfo.getLastResourcePart(); return lastResourcePart instanceof UriResourcePartTyped ? ((UriResourcePartTyped) lastResourcePart).isCollection() : false; }
public JPANavigationProptertyInfo(final JPAServiceDocument sd, final UriResourcePartTyped uriResource, final JPAAssociationPath associationPath, final UriInfoResource uriInfo) throws ODataApplicationException { this.navigationTarget = uriResource; this.associationPath = associationPath; this.keyPredicates = uriResource.isCollection() ? new ArrayList<>(1) : Util.determineKeyPredicates(uriResource); this.uriInfo = uriInfo; this.sd = sd; }
private boolean isCollection(final UriResource pathSegment) throws UriValidationException { if (pathSegment instanceof UriResourcePartTyped) { return ((UriResourcePartTyped) pathSegment).isCollection(); } else { throw new UriValidationException( "Path segment is not an instance of UriResourcePartTyped but " + pathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, pathSegment.toString()); } }
private boolean isCollection(final UriResource pathSegment) throws UriValidationException { if (pathSegment instanceof UriResourcePartTyped) { return ((UriResourcePartTyped) pathSegment).isCollection(); } else { throw new UriValidationException( "Path segment is not an instance of UriResourcePartTyped but " + pathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, pathSegment.toString()); } }
private JPASerializer createSerializer(final JPASerializerFactory jpaSerializerFactory, final ContentType responseFormat, final UriInfo uriInfo) throws ODataJPASerializerException, SerializerException { final List<UriResource> resourceParts = uriInfo.getUriResourceParts(); final UriResourcePartTyped operation = (UriResourcePartTyped) resourceParts.get(resourceParts.size() - 1); final EdmTypeKind edmTypeKind = determineReturnEdmTypeKind(operation); return jpaSerializerFactory.createSerializer(responseFormat, uriInfo, edmTypeKind, operation.isCollection()); }
private UriResource count(final UriResource previous) throws UriParserException { ParserHelper.requireTokenEnd(tokenizer); requireTyped(previous, "$count"); if (((UriResourcePartTyped) previous).isCollection()) { return new UriResourceCountImpl(); } else { throw new UriParserSemanticException("$count is only allowed on collections.", UriParserSemanticException.MessageKeys.ONLY_FOR_COLLECTIONS, "$count"); } }
private UriResource count(final UriResource previous) throws UriParserException { ParserHelper.requireTokenEnd(tokenizer); requireTyped(previous, "$count"); if (((UriResourcePartTyped) previous).isCollection()) { return new UriResourceCountImpl(); } else { throw new UriParserSemanticException("$count is only allowed on collections.", UriParserSemanticException.MessageKeys.ONLY_FOR_COLLECTIONS, "$count"); } }
private UriResource value(final UriResource previous) throws UriParserException { ParserHelper.requireTokenEnd(tokenizer); requireTyped(previous, "$value"); if (!((UriResourcePartTyped) previous).isCollection()) { requireMediaResourceInCaseOfEntity(previous); return new UriResourceValueImpl(); } else { throw new UriParserSemanticException("$value is only allowed on typed path segments.", UriParserSemanticException.MessageKeys.ONLY_FOR_TYPED_PARTS, "$value"); } }
private UriResource value(final UriResource previous) throws UriParserException { ParserHelper.requireTokenEnd(tokenizer); requireTyped(previous, "$value"); if (!((UriResourcePartTyped) previous).isCollection()) { requireMediaResourceInCaseOfEntity(previous); return new UriResourceValueImpl(); } else { throw new UriParserSemanticException("$value is only allowed on typed path segments.", UriParserSemanticException.MessageKeys.ONLY_FOR_TYPED_PARTS, "$value"); } }
private void parseBoundFunction(final FullQualifiedName fullQualifiedName, UriInfoImpl uriInfo, final UriResourcePartTyped lastResource) throws UriParserException, UriValidationException { final EdmType type = lastResource.getType(); final List<UriParameter> parameters = ParserHelper.parseFunctionParameters(tokenizer, edm, referringType, true, aliases); final List<String> parameterNames = ParserHelper.getParameterNames(parameters); final EdmFunction boundFunction = edm.getBoundFunction(fullQualifiedName, type.getFullQualifiedName(), lastResource.isCollection(), parameterNames); if (boundFunction == null) { throw new UriParserSemanticException("Bound function '" + fullQualifiedName + "' not found.", UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND, fullQualifiedName.getFullQualifiedNameAsString()); } ParserHelper.validateFunctionParameters(boundFunction, parameters, edm, referringType, aliases); parseFunctionRest(uriInfo, boundFunction, parameters); }
private void parseBoundFunction(final FullQualifiedName fullQualifiedName, UriInfoImpl uriInfo, final UriResourcePartTyped lastResource) throws UriParserException, UriValidationException { final EdmType type = lastResource.getType(); final List<UriParameter> parameters = ParserHelper.parseFunctionParameters(tokenizer, edm, referringType, true, aliases); final List<String> parameterNames = ParserHelper.getParameterNames(parameters); final EdmFunction boundFunction = edm.getBoundFunction(fullQualifiedName, type.getFullQualifiedName(), lastResource.isCollection(), parameterNames); if (boundFunction == null) { throw new UriParserSemanticException("Bound function '" + fullQualifiedName + "' not found.", UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND, fullQualifiedName.getFullQualifiedNameAsString()); } ParserHelper.validateFunctionParameters(boundFunction, parameters, edm, referringType, aliases); parseFunctionRest(uriInfo, boundFunction, parameters); }
if (resource instanceof UriResourcePartTyped) { appendType(gen, "type", ((UriResourcePartTyped) resource).getType()); gen.writeBooleanField("isCollection", ((UriResourcePartTyped) resource).isCollection());
if (resource instanceof UriResourcePartTyped) { appendType(gen, "type", ((UriResourcePartTyped) resource).getType()); gen.writeBooleanField("isCollection", ((UriResourcePartTyped) resource).isCollection());
private UriResource boundOperationOrTypeCast(UriResource previous) throws UriParserException, UriValidationException { final FullQualifiedName name = new FullQualifiedName(tokenizer.getText()); requireTyped(previous, name.getFullQualifiedNameAsString()); final UriResourcePartTyped previousTyped = (UriResourcePartTyped) previous; final EdmType previousTypeFilter = getPreviousTypeFilter(previousTyped); final EdmType previousType = previousTypeFilter == null ? previousTyped.getType() : previousTypeFilter; // We check for bound actions first because they cannot be followed by anything. final EdmAction boundAction = edm.getBoundAction(name, previousType.getFullQualifiedName(), previousTyped.isCollection()); if (boundAction != null) { ParserHelper.requireTokenEnd(tokenizer); return new UriResourceActionImpl(boundAction); } // Type casts can be syntactically indistinguishable from bound function calls in the case of additional keys. // But normally they are shorter, so they come next. final EdmStructuredType type = previousTyped.getType() instanceof EdmEntityType ? edm.getEntityType(name) : edm.getComplexType(name); if (type != null) { return typeCast(name, type, previousTyped); } if (tokenizer.next(TokenKind.EOF)) { throw new UriParserSemanticException("Type '" + name.getFullQualifiedNameAsString() + "' not found.", UriParserSemanticException.MessageKeys.UNKNOWN_TYPE, name.getFullQualifiedNameAsString()); } // Now a bound function call is the only remaining option. return functionCall(null, name, previousType.getFullQualifiedName(), previousTyped.isCollection()); }
private UriResource boundOperationOrTypeCast(UriResource previous) throws UriParserException, UriValidationException { final FullQualifiedName name = new FullQualifiedName(tokenizer.getText()); requireTyped(previous, name.getFullQualifiedNameAsString()); final UriResourcePartTyped previousTyped = (UriResourcePartTyped) previous; final EdmType previousTypeFilter = getPreviousTypeFilter(previousTyped); final EdmType previousType = previousTypeFilter == null ? previousTyped.getType() : previousTypeFilter; // We check for bound actions first because they cannot be followed by anything. final EdmAction boundAction = edm.getBoundAction(name, previousType.getFullQualifiedName(), previousTyped.isCollection()); if (boundAction != null) { ParserHelper.requireTokenEnd(tokenizer); return new UriResourceActionImpl(boundAction); } // Type casts can be syntactically indistinguishable from bound function calls in the case of additional keys. // But normally they are shorter, so they come next. final EdmStructuredType type = previousTyped.getType() instanceof EdmEntityType ? edm.getEntityType(name) : edm.getComplexType(name); if (type != null) { return typeCast(name, type, previousTyped); } if (tokenizer.next(TokenKind.EOF)) { throw new UriParserSemanticException("Type '" + name.getFullQualifiedNameAsString() + "' not found.", UriParserSemanticException.MessageKeys.UNKNOWN_TYPE, name.getFullQualifiedNameAsString()); } // Now a bound function call is the only remaining option. return functionCall(null, name, previousType.getFullQualifiedName(), previousTyped.isCollection()); }
final boolean isCollection = ((UriResourcePartTyped) uriInfo.getUriResourceParts() .get(lastPathSegmentIndex - 1)) .isCollection();
if (previousTyped.isCollection()) { throw new UriParserSemanticException("Property '" + name + "' is not allowed after collection.", UriParserSemanticException.MessageKeys.PROPERTY_AFTER_COLLECTION, name);
if (previousTyped.isCollection()) { throw new UriParserSemanticException("Property '" + name + "' is not allowed after collection.", UriParserSemanticException.MessageKeys.PROPERTY_AFTER_COLLECTION, name);