SAP-archive / cloud-espm-v2

This sample is a reference application project, showcasing an end-to-end development scenario for a Java-based app on SAP BTP. The app has a SAPUI5 web frontend, uses OData to connect to a Java-based cloud backend which in turn connects via JPA to an SAP HANA DB in the cloud.
https://open.sap.com/courses/hcp2-1
Apache License 2.0
104 stars 85 forks source link

Extend CRUD operations #10

Closed equilibrium999 closed 6 years ago

equilibrium999 commented 6 years ago

Hi SAP, I'm not sure if it is the right place to ask. And this is not an issue. I've followed this repo and found it very informative and interesting. Just one more thing is I'm curious about how to extend CRUD operations. For example, I need to validate values passed to backend before creating a sales order. How can I implement that?

Regards,

Tri

skrishnakumar commented 6 years ago

Hello @equilibrium999

To my understanding, you would like to do some pre-processing before the sales order is created. in espm we have used apache olingo for the oData/REST services. So, the SalesOrder creation is exposed via oData and the creation of the same is triggered in the UI using ajax.

https://github.com/SAP/cloud-espm-v2/blob/master/espm-cloud-web/src/main/webapp/webshop/controller/Checkout.controller.js

Line 334

The actual creation of the Sales Order is happening in https://github.com/SAP/cloud-espm-v2/blob/master/espm-cloud-jpa/src/main/java/com/sap/espm/model/SalesOrderHeader.java

you can use the @PrePersist tag to do some processing.

Hope that this helps

skrishnakumar commented 6 years ago

closing this ticket for now