0

I want to create an OData client in Java via odata-generator-cli 3.35.0.

Using .edmx and swagger file of following Service from Business Hub.

The OData client is being generated with an exception:

[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Processing 1 OData service...
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Processing OData service 'Integration Content' at /cpi/api/v1
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type IntegrationDesigntimeArtifact from set IntegrationDesigntimeArtifacts
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type RuntimeArtifactErrorInformation from set RuntimeArtifactErrorInformations
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type Configuration from set Configurations
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type Resource from set Resources
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type IntegrationRuntimeArtifact from set IntegrationRuntimeArtifacts
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamingContext - Found more than one occurrence of the Java identifier type. The new identifier has been renamed to type_2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type IntegrationPackage from set IntegrationPackages
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type ServiceEndpoint from set ServiceEndpoints
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type EntryPoint from set EntryPoints
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamingContext - Found more than one occurrence of the Java identifier type. The new identifier has been renamed to type_2
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type Definition from set APIDefinitions
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type ValueMappingDesigntimeArtifact from set ValueMappingDesigntimeArtifacts
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator -   Found entity type ValMapSchema from set ValMapSchema
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Error in file IntegrationContent; unable to generate all VDM classes.
com.sap.cloud.sdk.datamodel.odata.generator.ODataGeneratorReadException: org.apache.olingo.odata2.api.edm.EdmException: An exception occurred.
        at com.sap.cloud.sdk.datamodel.odata.generator.EdmService$TypedAdapter.getType(EdmService.java:317)
        at com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator.processNavigationProperties(NamespaceClassGenerator.java:1098)
        at com.sap.cloud.sdk.datamodel.odata.generator.NamespaceClassGenerator.processEntitySet(NamespaceClassGenerator.java:891)
        at com.sap.cloud.sdk.datamodel.odata.generator.EntitySetProcessor.processEntitySets(EntitySetProcessor.java:74)
        at com.sap.cloud.sdk.datamodel.odata.generator.CodeModelClassGenerator.processService(CodeModelClassGenerator.java:102)
        at com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator.createCodeModelForServices(ODataToVdmGenerator.java:133)
        at com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator.generate(ODataToVdmGenerator.java:98)
        at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGenerator.execute(DataModelGenerator.java:797)
        at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli.run(DataModelGeneratorCli.java:206)
        at com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli.main(DataModelGeneratorCli.java:188)
Caused by: org.apache.olingo.odata2.api.edm.EdmException: An exception occurred.
        at org.apache.olingo.odata2.core.edm.provider.EdmAssociationEndImplProv.getEntityType(EdmAssociationEndImplProv.java:51)
        at org.apache.olingo.odata2.core.edm.provider.EdmNavigationPropertyImplProv.getType(EdmNavigationPropertyImplProv.java:44)
        at com.sap.cloud.sdk.datamodel.odata.generator.EdmService$TypedAdapter.getType(EdmService.java:314)
        ... 9 more
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.ODataToVdmGenerator - Generating Java classes to C:\Users\W4ff3l\Downloads\odata-gen\trg
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - ------------------------------------------------------------
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli -  Generator SUCCEEDED but had the following 1 warning messages:
[main] WARN com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - Error in file IntegrationContent; unable to generate all VDM classes.
[main] INFO com.sap.cloud.sdk.datamodel.odata.generator.DataModelGeneratorCli - ------------------------------------------------------------

Seems like there is a problem with navigation but I don't know how to debug or solve this.

To replicate the problem download .edmx and .json from the Business Hub and use them in the generator.

Waffel
  • 11
  • 3
  • Thanks for reporting this. I am now trying to reproduce this exception on my system to allow further exploration. – Emdee Jan 08 '21 at 14:41
  • I can reproduce the problem and so far my observation is that the entity type "com.sap.hci.api.ValMap" is undefined within the metadata document. Will update here once I have further information. – Emdee Jan 11 '21 at 07:57

3 Answers3

2

The official fix for the missing entity type is currently in our release pipeline and will presumably be available via the SAP API Business Hub in around 4 weeks from now.


In the meantime, you can already retrieve the latest service metadata using the SAP Integration Suite (formerly known as SAP Cloud Platform Integration, CPI) by navigating to your deployed service and exchanging the API path with /api/v1/$metadata.

For example, assuming you have your service running at https://<YourAccountShortName>-tmn.<SSLHost>.<Landscapehost>, simply navigate to https://<YourAccountShortName>-tmn.<SSLHost>.<Landscapehost>/api/v1/$metadata.

Use the displayed metadata together with the Swagger definition from the SAP API Business Hub to generate your OData client.

  • I am not sure if I missed a configuration here but using the metadata together with the swagger definition does not provide all requests. For example the swagger definition includes the request to get all artifacts of one package "/IntegrationPackages('{Id}')/IntegrationDesigntimeArtifacts" but there is no method provided for this after generation of the client. – Waffel Mar 13 '21 at 10:43
1

No, you have not missed a configuration. This indeed is currently only supported for OData v4 services and is a feature gap for OData v2 in Cloud SDK. But you can leverage our generic OData Client to achieve this.

Here is the sample code with the explanation:

ODataEntityKey entityKey = new ODataEntityKey(ODataProtocol.V2);
entityKey.addKeyProperty("keyId", "keyValue");

// creating resource path
final ODataResourcePath resourcePath = ODataResourcePath.of("IntegrationPackages", entityKey)
        .addSegment("IntegrationDesigntimeArtifacts"); // here "IntegrationPackages" is the entityCollection

// creating read request
ODataRequestRead request = new ODataRequestRead(Service.DEFAULT_SERVICE_PATH, resourcePath,"encodedQueryStringIfAny", ODataProtocol.V2);

//executing
final ODataRequestResultGeneric result = request.execute(HttpClientAccessor.getHttpClient(destination));

//response parsing
result.asList(IntegrationDesigntimeArtifact.class);
Anton Menshov
  • 2,266
  • 14
  • 34
  • 55
0

There is an issue in the metadata of that SCP service, an entity type is missing. I will update this answer if the corrected metadata can be downloaded from the API Business Hub.

Emdee
  • 1,689
  • 5
  • 22
  • 35