typeDefinition = edm.getTypeDefinition(fullQualifiedName); if (typeDefinition == null) { enumType = edm.getEnumType(fullQualifiedName); if (enumType == null) { complexType = edm.getComplexType(fullQualifiedName); if (complexType == null) { entityType = edm.getEntityType(fullQualifiedName);
public ResourcePathParser(final Edm edm, final Map<String, AliasQueryOption> aliases) { this.edm = edm; this.aliases = aliases; edmEntityContainer = edm.getEntityContainer(); }
private void appendDataServices(final XMLStreamWriter writer) throws XMLStreamException { writer.setDefaultNamespace(NS_EDM); writer.writeStartElement(NS_EDMX, DATA_SERVICES); for (EdmSchema schema : serviceMetadata.getEdm().getSchemas()) { appendSchema(writer, schema); } writer.writeEndElement(); }
@Override protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) { EdmEntityType baseType = null; if (baseTypeName != null) { baseType = edm.getEntityType(baseTypeName); if (baseType == null) { throw new EdmException("Cannot find base type with name: " + baseTypeName + " for entity type: " + getName()); } } return baseType; }
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()); }
@Override protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) { EdmComplexType baseType = null; if (baseTypeName != null) { baseType = edm.getComplexType(baseTypeName); if (baseType == null) { throw new EdmException("Can't find base type with name: " + baseTypeName + " for complex type: " + getName()); } } return baseType; }
EdmEntityType entityType = getClient().getCachedEdm().getEntityType(entity.getTypeName()); EdmEntityType baseType = entityType; while (boundOp == null && baseType != null) { final EdmAction action = this.getClient().getCachedEdm().getBoundAction( new FullQualifiedName(targetFQN.getNamespace(), operation.name()), baseType.getFullQualifiedName(), while (boundOp == null && baseType != null) { final EdmFunction func = this.getClient().getCachedEdm().getBoundFunction( new FullQualifiedName(targetFQN.getNamespace(), operation.name()), baseType.getFullQualifiedName(), false, parameterNames); while (edmOperation == null && entityType != null) { edmOperation = operation.type() == OperationType.FUNCTION ? getClient().getCachedEdm().getBoundFunction( operationFQN, entityType.getFullQualifiedName(), false, parameterNames) : getClient().getCachedEdm().getBoundAction( operationFQN, entityType.getFullQualifiedName(), false); if (entityType.getBaseType() != null) {
protected static EdmStructuredType parseTypeCast(UriTokenizer tokenizer, final Edm edm, final EdmStructuredType referencedType) throws UriParserException { if (tokenizer.next(TokenKind.QualifiedName)) { final FullQualifiedName qualifiedName = new FullQualifiedName(tokenizer.getText()); final EdmStructuredType type = referencedType.getKind() == EdmTypeKind.ENTITY ? edm.getEntityType(qualifiedName) : edm.getComplexType(qualifiedName); if (type == null) { throw new UriParserSemanticException("Type '" + qualifiedName + "' not found.", UriParserSemanticException.MessageKeys.UNKNOWN_PART, qualifiedName.getFullQualifiedNameAsString()); } else { if (!type.compatibleTo(referencedType)) { throw new UriParserSemanticException("The type cast '" + qualifiedName + "' is not compatible.", UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER, type.getName()); } } return type; } return null; }
final Edm edm = ((EdmEnabledODataClient) client).getEdm(metadataETag); if (StringUtils.isNotBlank(candidateTypeName)) { type = edm.getEntityType(new FullQualifiedName(candidateTypeName)); for (EdmSchema schema : edm.getSchemas()) { final EdmEntityContainer container = schema.getEntityContainer(); if (container != null) { type = edm.getEntityType(new FullQualifiedName(contextURL.getDerivedEntity()));
private UriResourcePartTyped parseBoundOperation(UriTokenizer tokenizer, final FullQualifiedName qualifiedName, final EdmStructuredType referencedType, final boolean referencedIsCollection) throws UriParserException { final EdmAction boundAction = edm.getBoundAction(qualifiedName, referencedType.getFullQualifiedName(), referencedIsCollection); if (boundAction == null) { final List<String> parameterNames = parseFunctionParameterNames(tokenizer); final EdmFunction boundFunction = edm.getBoundFunction(qualifiedName, referencedType.getFullQualifiedName(), referencedIsCollection, parameterNames); if (boundFunction == null) { throw new UriParserSemanticException("Function not found.", UriParserSemanticException.MessageKeys.UNKNOWN_PART, qualifiedName.getFullQualifiedNameAsString()); } else { return new UriResourceFunctionImpl(null, boundFunction, null); } } else { return new UriResourceActionImpl(boundAction); } }
final EdmEnumType edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getEnumType(type); if (!valuable.isCollection() && valuable.isPrimitive() && edmType != null) { valuable.setValue(ValueType.ENUM, valuable.asPrimitive()); edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getComplexType(type); edm = ((EdmEnabledODataClient) client).getEdm(metadataETag); if (edm != null && edm.getComplexType(type) != null) { ClientComplexValue cValue = client.getObjectFactory().newComplexValue(type.toString()); value = cValue; EdmComplexType edmType = null; if (client instanceof EdmEnabledODataClient && type != null) { edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getComplexType(type);
public static void addAnnotations( final EdmEnabledODataClient client, final Map<Class<? extends AbstractTerm>, Object> annotations, final ClientAnnotatable annotatable) { for (Map.Entry<Class<? extends AbstractTerm>, Object> entry : annotations.entrySet()) { final Namespace nsAnn = entry.getKey().getAnnotation(Namespace.class); final Term termAnn = entry.getKey().getAnnotation(Term.class); final FullQualifiedName termName = new FullQualifiedName(nsAnn.value(), termAnn.name()); final EdmTerm term = client.getCachedEdm().getTerm(termName); if (term == null) { LOG.error("Could not find term for class {}", entry.getKey().getName()); } else { annotatable.getAnnotations().add(getODataAnnotation( client, term.getFullQualifiedName().toString(), term.getType(), entry.getValue())); } } }
@Override @SuppressWarnings("unchecked") public <RES extends ClientInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest( final URI bindingParameterURI, final FullQualifiedName functionName, final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, final Map<String, ClientValue> parameters) { final EdmFunction function = edmClient.getCachedEdm().getBoundFunction( functionName, bindingParameterTypeName, isBindingParameterCollection, parameters == null ? null : new ArrayList<String>(parameters.keySet())); if (function == null) { throw new IllegalArgumentException("Could not find Function for name " + functionName); } return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.GET, edmClient.newURIBuilder(bindingParameterURI.toASCIIString()). appendOperationCallSegment(function.getFullQualifiedName().toString()).build(), getResultReference(function.getReturnType()), parameters); }
private void parseFunction(final FullQualifiedName fullQualifiedName, UriInfoImpl uriInfo, final EdmType lastType, final boolean lastIsCollection) throws UriParserException, UriValidationException { final List<UriParameter> parameters = ParserHelper.parseFunctionParameters(tokenizer, edm, referringType, true, aliases); final List<String> parameterNames = ParserHelper.getParameterNames(parameters); final EdmFunction boundFunction = edm.getBoundFunction(fullQualifiedName, lastType.getFullQualifiedName(), lastIsCollection, parameterNames); if (boundFunction != null) { ParserHelper.validateFunctionParameters(boundFunction, parameters, edm, referringType, aliases); parseFunctionRest(uriInfo, boundFunction, parameters); return; } final EdmFunction unboundFunction = edm.getUnboundFunction(fullQualifiedName, parameterNames); if (unboundFunction != null) { ParserHelper.validateFunctionParameters(unboundFunction, parameters, edm, referringType, aliases); parseFunctionRest(uriInfo, unboundFunction, parameters); return; } throw new UriParserSemanticException("No function '" + fullQualifiedName + "' found.", UriParserSemanticException.MessageKeys.FUNCTION_NOT_FOUND, fullQualifiedName.getFullQualifiedNameAsString()); }
@Override @SuppressWarnings("unchecked") public <RES extends ClientInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest( final String functionImportName, final Map<String, ClientValue> parameters) { EdmFunctionImport efi = null; for (EdmSchema schema : edmClient.getCachedEdm().getSchemas()) { final EdmEntityContainer container = schema.getEntityContainer(); if (container != null) { efi = container.getFunctionImport(functionImportName); } } if (efi == null) { throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName); } final EdmFunction function = edmClient.getCachedEdm(). getUnboundFunction(efi.getFunctionFqn(), parameters == null ? null : new ArrayList<String>(parameters.keySet())); if (function == null) { throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn()); } return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.GET, edmClient.newURIBuilder().appendOperationCallSegment(functionImportName).build(), getResultReference(function.getReturnType()), parameters); }
private EdmEnumType getEnumType(final String primitiveValueLiteral) throws UriParserException { final String enumTypeName = primitiveValueLiteral.substring(0, primitiveValueLiteral.indexOf('\'')); final EdmEnumType type = edm.getEnumType(new FullQualifiedName(enumTypeName)); if (type == null) { throw new UriParserSemanticException("Unknown Enum type '" + enumTypeName + "'.", UriParserSemanticException.MessageKeys.UNKNOWN_TYPE, enumTypeName); } return type; }
@Override public EdmFunction getUnboundFunction(final List<String> parameterNames) { return edm.getUnboundFunction(getFunctionFqn(), parameterNames); }
@Override @SuppressWarnings("unchecked") public <RES extends ClientInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest( final URI bindingParameterURI, final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, final Map<String, ClientValue> parameters) { final EdmAction action = edmClient.getCachedEdm().getBoundAction( actionName, bindingParameterTypeName, isBindingParameterCollection); if (action == null) { throw new IllegalArgumentException("Could not find Action for name " + actionName); } return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.POST, edmClient.newURIBuilder(bindingParameterURI.toASCIIString()). appendOperationCallSegment(action.getFullQualifiedName().toString()).build(), getResultReference(action.getReturnType()), parameters); } }
@Override protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) { EdmEntityType baseType = null; if (baseTypeName != null) { baseType = edm.getEntityType(baseTypeName); if (baseType == null) { throw new EdmException("Cannot find base type with name: " + baseTypeName + " for entity type: " + getName()); } } return baseType; }
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()); }