@Override protected void lazyBuildEdmItem() throws ODataJPAModelException { if (edmFunction == null) { edmFunction = new CsdlFunction(); edmFunction.setName(getExternalName()); edmFunction.setParameters(returnNullIfEmpty(determineEdmInputParameter())); edmFunction.setReturnType(determineEdmResultType(jpaFunction.returnType())); edmFunction.setBound(jpaFunction.isBound()); // TODO edmFunction.setComposable(isComposable) edmFunction.setComposable(false); // TODO edmFunction.setEntitySetPath(entitySetPath) for bound functions } }
@Override public boolean isBound() throws ODataJPAModelException { return getEdmItem().isBound(); }
@Override public CsdlReturnType getReturnType() { return edmFunction.getReturnType(); }
private void readFunction(XMLEventReader reader, StartElement element, CsdlSchema schema) throws XMLStreamException { CsdlFunction function = new CsdlFunction(); function.setParameters(new ArrayList<CsdlParameter>()); function.setName(attr(element, "Name")); function.setBound(Boolean.parseBoolean(attr(element, "IsBound"))); function.setComposable(Boolean.parseBoolean(attr(element, "IsComposable"))); String entitySetPath = attr(element, "EntitySetPath"); if (entitySetPath != null) { // TODO: need to parse into binding and path. function.setEntitySetPath(entitySetPath); } readOperationParameters(reader, function); schema.getFunctions().add(function); }
protected List<EdmFunction> createFunctions() { final List<EdmFunction> edmFunctions = new ArrayList<EdmFunction>(); final List<CsdlFunction> providerFunctions = schema.getFunctions(); if (providerFunctions != null) { for (CsdlFunction function : providerFunctions) { FullQualifiedName functionName = new FullQualifiedName(namespace, function.getName()); EdmFunctionImpl functionImpl = new EdmFunctionImpl(edm, functionName, function); edmFunctions.add(functionImpl); edm.cacheFunction(functionName, functionImpl); } } return edmFunctions; }
parameterNames == null ? Collections.<String> emptyList() : parameterNames; for (CsdlFunction function : functions) { if (!function.isBound()) { List<CsdlParameter> providerParameters = function.getParameters(); if (providerParameters == null) { providerParameters = Collections.emptyList();
@Override protected void lazyBuildEdmItem() throws ODataJPAModelException { super.lazyBuildEdmItem(); edmFunction.setBound(false); }
private void readFunction(XMLEventReader reader, StartElement element, CsdlSchema schema) throws XMLStreamException { CsdlFunction function = new CsdlFunction(); function.setParameters(new ArrayList<CsdlParameter>()); function.setName(attr(element, "Name")); function.setBound(Boolean.parseBoolean(attr(element, "IsBound"))); function.setComposable(Boolean.parseBoolean(attr(element, "IsComposable"))); String entitySetPath = attr(element, "EntitySetPath"); if (entitySetPath != null) { // TODO: need to parse into binding and path. function.setEntitySetPath(entitySetPath); } readOperationParameters(reader, function); schema.getFunctions().add(function); }
@Override public List<CsdlFunction> getFunctions(FullQualifiedName fqn) throws ODataException { ArrayList<CsdlFunction> foundFuncs = new ArrayList<CsdlFunction>(); CsdlSchema schema = getSchema(fqn.getNamespace()); if (schema != null) { List<CsdlFunction> functions = schema.getFunctions(); if (functions != null) { for (CsdlFunction func : functions) { if (func.getName().equals(fqn.getName())) { foundFuncs.add(func); } } } } return foundFuncs; }
parameterNames == null ? Collections.<String> emptyList() : parameterNames; for (CsdlFunction function : functions) { if (!function.isBound()) { List<CsdlParameter> providerParameters = function.getParameters(); if (providerParameters == null) { providerParameters = Collections.emptyList();
ArrayList<CsdlFunctionImport> functionImports, CsdlSchema csdlSchema) { CsdlFunction edmFunction = new CsdlFunction(); edmFunction.setName(proc.getName()); edmFunction.setBound(false); EdmPrimitiveTypeKind odataType = ODataTypeManager.odataType(pp); if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) { edmFunction.setReturnType(new CsdlReturnType().setType(odataType.getFullQualifiedName()).setCollection(DataTypeManager.isArrayType(pp.getRuntimeType()))); continue; edmFunction.setParameters(params); complexTypes.add(complexType); FullQualifiedName odataType = new FullQualifiedName(schemaName, complexType.getName()); edmFunction.setReturnType((new CsdlReturnType().setType(odataType).setCollection(true)));
protected List<EdmFunction> createFunctions() { final List<EdmFunction> edmFunctions = new ArrayList<EdmFunction>(); final List<CsdlFunction> providerFunctions = schema.getFunctions(); if (providerFunctions != null) { for (CsdlFunction function : providerFunctions) { FullQualifiedName functionName = new FullQualifiedName(namespace, function.getName()); EdmFunctionImpl functionImpl = new EdmFunctionImpl(edm, functionName, function); edmFunctions.add(functionImpl); edm.cacheFunction(functionName, functionImpl); } } return edmFunctions; }
parameterNames == null ? Collections.<String> emptyList() : parameterNames; for (CsdlFunction function : functions) { if (function.isBound()) { List<CsdlParameter> providerParameters = function.getParameters(); if (providerParameters == null || providerParameters.isEmpty()) { throw new EdmException("No parameter specified for bound function: " + functionName);
@Override protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) { List<EdmFunction> result = new ArrayList<EdmFunction>(); try { List<CsdlFunction> functions = functionsMap.get(functionName); if (functions == null) { functions = provider.getFunctions(functionName); if (functions != null) { functionsMap.put(functionName, functions); } } if (functions != null) { for (CsdlFunction function : functions) { if (!function.isBound()) { result.add(new EdmFunctionImpl(this, functionName, function)); } } } } catch (ODataException e) { throw new EdmException(e); } return result; }
@Override public CsdlReturnType getReturnType() { return edmFunction.getReturnType(); }
@Override public List<CsdlFunction> getFunctions(FullQualifiedName fqn) throws ODataException { ArrayList<CsdlFunction> foundFuncs = new ArrayList<CsdlFunction>(); CsdlSchema schema = getSchema(fqn.getNamespace()); if (schema != null) { List<CsdlFunction> functions = schema.getFunctions(); if (functions != null) { for (CsdlFunction func : functions) { if (func.getName().equals(fqn.getName())) { foundFuncs.add(func); } } } } return foundFuncs; }
parameterNames == null ? Collections.<String> emptyList() : parameterNames; for (CsdlFunction function : functions) { if (function.isBound()) { List<CsdlParameter> providerParameters = function.getParameters(); if (providerParameters == null || providerParameters.isEmpty()) { throw new EdmException("No parameter specified for bound function: " + functionName);
@Override protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) { List<EdmFunction> result = new ArrayList<EdmFunction>(); try { List<CsdlFunction> functions = functionsMap.get(functionName); if (functions == null) { functions = provider.getFunctions(functionName); if (functions != null) { functionsMap.put(functionName, functions); } } if (functions != null) { for (CsdlFunction function : functions) { if (!function.isBound()) { result.add(new EdmFunctionImpl(this, functionName, function)); } } } } catch (ODataException e) { throw new EdmException(e); } return result; }
public static CommonJavaObjectForEdmx convertFromActionsNfunctions(CommonJavaObjectForEdmx comModel, CDXEdmProvider edmxProvider, Map<String, String> namespaceToServMap) { CommonJavaObjectForEdmx updatedComModel = comModel; try { List<CsdlAction> actions = edmxProvider.getSchemas().get(0).getActions(); for (CsdlAction action : actions) { if (action.getReturnType() != null && !action.getReturnType().getType().startsWith("Edm")) { FullQualifiedName fqn = action.getReturnType().getTypeFQN(); updatedComModel = addCsdlComplexOrEntityToComModel(comModel, edmxProvider, fqn, namespaceToServMap); } } List<CsdlFunction> functions = edmxProvider.getSchemas().get(0).getFunctions(); for (CsdlFunction function : functions) { if (function.getReturnType() != null && function.getReturnType().getType().startsWith("Edm")) { FullQualifiedName fqn = function.getReturnType().getTypeFQN(); updatedComModel = addCsdlComplexOrEntityToComModel(updatedComModel, edmxProvider, fqn, namespaceToServMap); } } } catch (ODataException e) { PojoGenUtil.logDebug(log, "Could not parse Action/Function return type"); } return updatedComModel; }
/** * Creates the FunctionImports. Function Imports have to be created for <i>unbound</i> functions. These are functions, * which do not depend on an entity set. E.g. .../MyFunction(). <p> * Details are described in : <a href= * "https://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part3-csdl/odata-v4.0-errata02-os-part3-csdl-complete.html#_Toc406398042" * >OData Version 4.0 Part 3 - 13.6 Element edm:FunctionImport</a> * @param CsdlFunction edmFu */ private CsdlFunctionImport buildFunctionImport(final CsdlFunction edmFu) { final CsdlFunctionImport edmFuImport = new CsdlFunctionImport(); edmFuImport.setName(edmFu.getName()); edmFuImport.setFunction(nameBuilder.buildFQN(edmFu.getName())); edmFuImport.setIncludeInServiceDocument(true); // edmFuImport.setEntitySet(entitySet) return edmFuImport; }