Search code examples
sap-cloud-sdk

OData generator - change name of specific entities


Is it possible to change the names of individual entities with the OData generator (maven client)?

I'm not sure how exactly the naming strategy works, but apparently the label is included and and the names of the classes become very messy. Mixed with german umlauts (ViewFürConditonContract.java). I also tried SimpleNamingStrategy, but similar thing happens here.


Solution

  • I think there are a few options to deal with this (other than just ignoring it):

    • You can define the <nameSource> parameter to be NAME (instead of LABEL which is the default). This would use the field name instead. If this produces better results of course depends on how exactly the fields are named.

    • Alternatively, you could change the EDMX file, adjusting the labels to better fit for the generated code. The main downside of this is that the EDMX file diverges from the actual service metadata, which can become impractical if the services changes frequently and you have to merge the changes into your modified EDMX.

    • Finally, you could also supply your own implementation of NamingStrategy. It is a lengthy interface, so perhaps extending AbstractNamingStrategy could be a good starting point. You can pass it to the Maven plugin by giving the fully qualified classname as parameter.

    You can refer to the documentation for more details on the parameters and programatic usage of the generator.