vFunction Logo

Order Controller

  1. Configure the DB as described in section Config Data Source under OrderController.

  2. Run the OpenRewrite recipes, either via the VSCode UI (like we was done for the common library) or by going to the command line window and doing:

    cd C:\vFunctionLab\oms-services\order-controller
    mvn rewrite:run

    The compilation will fail an import statement (import javax.transaction.Transactional;) in com.oms.service.OrderService.java. Open the file OrderService.java (you can use Ctrl+P in VSCode) and modify the import to:

    import jakarta.transaction.Transactional;

    Now re-run mvn rewrite:run and it should succeed.

  3. Edit the class com.oms.ordercontroller.OrderControllerApp.java

  4. Add the annotations @EntityScan({ "com.oms.entity" }) and @ComponentScan("com.oms")(ensure the double quotes are copied correctly - see above note)

  5. Add the requirement import statements (import org.springframework.boot.autoconfigure.domain.EntityScan; and import org.springframework.context.annotation.ComponentScan;)

  6. The file should be similar to the below (the added lines are marked //added):

    package com.oms.ordercontroller;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.autoconfigure.domain.EntityScan; // added
    import org.springframework.context.annotation.ComponentScan; // added
    import org.springframework.context.annotation.ImportResource; 
    
    @SpringBootApplication
    @ImportResource({"META-INF/rr/**/*.xml"})
    @ComponentScan("com.oms") // added
    @EntityScan("com.oms.entity") // added
    public class OrderControllerApp {
        public static void main(String[] args)
        {
            SpringApplication.run(OrderControllerApp.class, args);
        }
    }
  7. Compile the service by doing Maven clean and Maven install

  8. Run the service as a Spring Boot App, either from the Spring Boot Dashboard in VSCode (screenshot below) Run-SBApp

    or by doing in the command window:

    cd c:\vFunctionLab\oms-services\order-controller
    java -jar .\target\OrderController-1.0-SNAPSHOT.jar
  9. Click on “Thunder Client” icon on the left panel to switch to the Client Thunder view in VSCpde

  10. Click on Collections, then the menu item import

    Import postman

  11. Import the file C:\vFunctionLab\oms-tutorial\oms-services\OMS Services.postman_collection.json

  12. Select under Orders the POST message “Create Order”, switch to Body and change the customerOrderId to 1.

  13. Hit send - you should get an OK response

    Create Order

  14. Try the other API calls under Orders

  15. Commit the modified files (no need to commit oms-log.txt and launch.json)

vFunction Logo