AgileApps Support Wiki Pre Release

Difference between revisions of "Part 2: Implementing a Java API Class"

From AgileApps Support Wiki
 
Line 36: Line 36:
# For expert Java programmers, learn how to integrate the AgileApps plugin in your Eclipse installations:
# For expert Java programmers, learn how to integrate the AgileApps plugin in your Eclipse installations:
#:* http://agileappscloud.info/aawiki/Eclipse_Plug-In
#:* http://agileappscloud.info/aawiki/Eclipse_Plug-In
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
:{| border="0" align="left" cellpadding="5" cellspacing="1"
|
[[Part 1: Integrating a Web Service|Previous]]
|}
:{| border="0" align="right" cellpadding="5" cellspacing="1"
|
[[Exercise 09: Managing Data|Next]]
|}

Latest revision as of 11:09, 14 December 2022

In this part of the exercise, you implement a new service on the Orders Object to iterate through all the Line Items and update the Line Item count on the order. You are given an example Java API that uses the “Search API” as well as the “Update Object API”. (See the http://agileappscloud.info/aawiki/Java_API for information on these APIs.)

  1. Set up your package namespace:
    1. Log in to AgileApps Cloud as yourself and navigate to Configuration > Customization > Developer Resources.
    2. Click Developer Configuration, and then Edit.
    3. In the Update Configuration page, for the Namespace, type <your_ subdomain>Orders where you replace <your_subdomain> with your webMethods AgileApps Cloud tenant subdomain name. For example: johnrichardsOrders. Leave the Debug Log Level unchanged.

      Developer Resources Update Configuration Namespace.PNG

      Note: The chosen Namespace will become a part of the Package name of the Java classes you add later. You will also define subspaces, when you add classes.
    4. Click Save.
  2. Select Classes and click New Class.
  3. Provide the values for a new Class named UpdateOrder in a package sub-folder TrainingOrders as shown:

    Developer Resources Classes New Class.PNG

  4. Click Next. The Class Editor opens already providing a skeleton of the class implementation:

    New Class johnrichardsOrders.PNG

  5. In Windows Explorer, navigate to the <workshop_dir> folder and open the file UpdateOrderClass.txt using a text editor, such as Notepad.
  6. In the editor, select all the content of the file. Copy the entire content and replace all the content in the webMethods AgileApps Cloud Class Editor by pasting the copied code.

    New Class UpdateOrder.png

  7. Adapt the package name: change <your_subdomain>Orders to the Namespace you defined in step 1c) of this exercise, for example: package com.platform.johnrichardsOrders.TrainingOrders;
  8. Click Save.
  9. To set up a test to validate the Class, create a new Business Rule that runs whenever an order is updated to Resolved status:
    1. Navigate to Configuration > Customization > Objects > Orders > Business Rules.
    2. On the Event Rules tab, select Updated(0) from the On Record drop-down list, and then click New Rule.

      800px

    3. Configure a new Event Rule named Total Line Items that:
      • Only fires when an Order is updated with a new Status of Resolved
      • Performs two actions:
      o Sets the status to Closed (to prevent the Update Event Rule from firing recursively)
      o Invokes the UpdateLineItems method within class UpdateOrder, which calculates and updates the Line Items Total field for an Order.

      New Record Updated Event Rule.png

    4. Click Save.
  10. Test the new class:
    1. Create a new Order record related to the SouthEast region. Provide valid values for Currency and New Currency. Assign the order to account Fred Supplies and click Save.

      New Order Test Java Class.png

    2. Add three Line Items to the order:

      Three Line Items.png

    3. Change the status of the order to Resolved, show the Order details, and click Save Changes.
      Here is the resulting Order after running the Rule: the Order Status is Closed and the Number Line Item field is updated.

      Record Test Java Class.png

Taking It Further

  1. To try another example that uses a Java API class to provide a pattern validation of the Line Item Object’s Part Number field whenever a Line Item is created or updated. Use the steps in Part 2 of this exercise as guidance and the code provided in the <workshop-dir>\FieldValidations.txt file.
  2. To extend what you learned in this exercise, see these AgileApps Cloud wiki pages:
  3. For expert Java programmers, learn how to integrate the AgileApps plugin in your Eclipse installations:

Previous

Next