Setting up the Sample Meal Program Library Project
It is assumed that you have already completed Module 1, and now have a working code-less Application.
To augment it in code, there are two paths you could theoretically follow:
- You could convert the Application you have already build from a code-less to a coded one, and then start adding code. In the end you will have a single Application that has both definitions and code.
- You could build and deploy a new Library project, then modify your Application to use it. Your code will always remain in the Library, and most of your definitions will always remain in the Application.
For this tutorial, the sample source provided is based on option 2. What we will do is:
- Get the Sample Source
- Build It using Maven
- Set up your Development Environment
- Adjust the source to match your Application (we will make a quick check that the constants in it match your definitions)
- Rebuild and Deploy it using Maven
- Quick Sanity Check (that the code was successfully deployed into BMC Helix Platform)
Only then will we take an in-depth look at all the custom Java services,and Javascript components, that this project contains.
Get the Util Library
If you have been following along with the tutorial, you have already installed this and you will see com.example.util-lib package, listed in BMC Helix Innovation Studio simply as Util. If not, you can get it by following the directions described in Creating a view to order from a dish. You will need this because it is a dependency of com.example.meal-program-lib.
Get the Sample Source
Get a hold of the source code in the attached project: sample-project-meal-program-lib-20.08.zip.
Important
- To download the ZIP file, right-click the URL > Save link as. The ZIP file will get downloaded to the default download location of your web browser. You must use the 7-Zip utility to extract the contents of the ZIP file, and view the install package components. The contents of the install ZIP file cannot be extracted by using the Windows Zip utility or Mac archive utility.
Create some working folder, shown as \projects in this tutorial, that you will use for your projects. Unzip it so that you now have the project source residing in \projects\meal-program-lib. At this point, it should look like this:
Build It
You will need to follow documented steps for Setting up your IDE and installing BMC Helix Platform SDK. In fact, it's a good idea if, by now, you have installed everything, set the RX_SDK_HOME environment variable, created and deployed some small Application or Library, successfully used the Maven Archetype, modified the POM.xml file to put your credentials in, and so forth. Consult the documentation to be sure your environment is configured correctly.
Go ahead and build the source code (don't try to deploy it yet).
projects\meal-program-lib> mvn clean install
It should succeed if your environment is set up correctly. You should see the success messages like this - if not, there is something amiss in your environment setup and you should refer again to Setting up your IDE and installing BMC Helix Platform SDK and/or Deploying your Digital Service application for the first time to start working in BMC Helix Innovation Studio.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] meal-program-lib-all .............................. SUCCESS [ 0.251 s]
[INFO] Meal Program Library .............................. SUCCESS [ 30.665 s]
[INFO] meal-program-lib-package .......................... SUCCESS [ 1.242 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.480 s
[INFO] Finished at: 2017-09-15T17:30:31-08:00
[INFO] Final Memory: 34M/323M
[INFO] ------------------------------------------------------------------------
Open the Project in an IDE
You can use any IDE you like, or a simple text editor. For example, to bring this Maven-based project into Eclipse, use the "Import…" and "Existing Maven Projects" option to import the following POM file.
projects/meal-program-lib/bundle/pom.xml
The steps are very similar for other IDEs, such as IntelliJ IDEA.
If Enabled, Set up Remote Debugging
For cloud-based instances, debugging is not typically enabled by default, so this section will not apply. If you do have remote debugging enabled, you can follow these instructions to connect from your instance of Eclipse (or use a similar procedure for your particular debugger).
- Right-click on the project node, and select Debug As > Debug Configurations
- Create a new configuration for Remote Java Application. Set the debugging Host and Port of your instance (these are not currently available for AWS-based sandboxes).
Click Debug to connect
Adjust the source to match your Application
In your IDE, open up the source file MealOrderConstants.java and take a look.
One thing about code-less development in BMC Helix Innovation Studio is that it is very easy to create Records (which have names) and Fields (which have IDs), and other definitions with specific identifiers (like Associations). You don't have to think about these all that much when working code-lessly. However, when using the API found in the BMC Helix Platform SDK, you will find that it requires knowing the exact identifiers that you have created for your definitions in BMC Helix Innovation Studio.
If you had actually installed a solution for the com.example.lunchtutorial, the constants may already match with your definitions perfectly. If you built your own application according to the tutorial steps, it's possible that some of the names and id definitions may not match exactly and you will need to adjust the sample source code for meal-program-lib.
The identifiers that appear in in the sample source code for Meal Program Library do not match your definitions, even if you have followed the steps in the tutorial exactly. What you have to make sure are matching are:
Identifier Type | Example(s) Constant in Source | Example Value that may require correction in Source |
---|---|---|
Bundle ID | LUNCH_TUTORIAL_BUNDLE_ID | com.example.lunchtutorial |
Record Definition Name | MEAL_ORDER_RECORD_DEF_NAME | LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Order" |
Field ID | MEAL_ORDER_DELIVERED_FIELD_ID_STRING | "10029002" |
Field ID | MEAL_ORDER_REQUESTED_DATE_FIELD_ID | 10029004 |
Field ID | MEAL_DISH_PRICE_FIELD_ID_STRING | "10029005" |
Field ID | MEAL_RESTAURANT_DELIVERYCHARGE_FIELD_ID_STRING | "10029005" |
Selection Field Value | MEAL_ORDER_STATUS_CANCELLED | "30" |
Assocation Name | MEAL_ORDER_DISH_CAN_BE_ORDERED_ASSOCIATION | LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Dish can be Ordered" |
Assocation Name | MEAL_ORDER_RESTAURANT_FULFILLS_ORDERS_ASSOCIATION | LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Restaurant Fulfills Orders" |
Assocation Name | MEAL_ORDER_RESTAURANT_PROVIDES_DISHES_ASSOCIATION | LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Restaurant Provides Dishes" |
For example, when reviewing the Delivered Field ID constant in the source, you might see this:
public static final String MEAL_ORDER_DELIVERED_FIELD_ID_STRING = "10029002";
you would open up that Field in the Record Designer and check it to make sure it matches.
If it does not, since it is not easy to modify the Field ID in BMC Helix Innovation Studio, update MealOrderConstants.java so that the code refers to the correct Field ID values.
public static final String MEAL_ORDER_DELIVERED_FIELD_ID_STRING = "10029002";
Here are all the constants that need to be checked and possibly corrected:
package com.example.meal.business.impl;
public class MealOrderConstants {
/**
* CONSTANTS YOU ARE LIKELY TO HAVE TO CHECK AGAINST YOUR
* APPLICATION IN INNOVATION STUDIO
*/
// Change this to reflect the actual bundle id of your code-less app.
public static final String LUNCH_TUTORIAL_BUNDLE_ID = "com.example.lunchtutorial";
// Order
public static final String MEAL_ORDER_RECORD_DEF_NAME = LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Order";
public static final Integer MEAL_ORDER_STATUS_FIELD_ID = 7;
public static final String MEAL_ORDER_STATUS_FIELD_ID_STRING = "7";
public static final String MEAL_ORDER_DELIVERED_FIELD_ID_STRING = "10029002";
public static final Integer MEAL_ORDER_REQUESTED_DATE_FIELD_ID = 10029004;
// Selection values for Status of Order
public static final String MEAL_ORDER_STATUS_SUBMITTED = "0";
public static final String MEAL_ORDER_STATUS_INPROGRESS = "10";
public static final String MEAL_ORDER_STATUS_DELIVERED = "20";
public static final String MEAL_ORDER_STATUS_CANCELLED = "30";
public static final String MEAL_ORDER_STATUS_CLOSED = "40";
public static final String MEAL_ORDER_STATUS_FIELD_NAME = "Status";
// Dish
public static final String MEAL_ORDER_DISH_RECORD_DEF_NAME = LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Dish";
public static final String MEAL_ORDER_DISH_CAN_BE_ORDERED_ASSOCIATION = LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Dish can be Ordered";
public static final String MEAL_DISH_RECORD_DEF_NAME = LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Dish";
public static final String MEAL_DISH_NAME_FIELD_ID_STRING = "8";
public static final String MEAL_DISH_PRICE_FIELD_ID_STRING = "10029005";
// Restaurant
public static final String MEAL_ORDER_RESTAURANT_FULFILLS_ORDERS_ASSOCIATION = LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Restaurant Fulfills Orders";
public static final String MEAL_ORDER_RESTAURANT_PROVIDES_DISHES_ASSOCIATION = LUNCH_TUTORIAL_BUNDLE_ID + ":" + "Restaurant Provides Dishes";
public static final String MEAL_RESTAURANT_NAME_FIELD_ID_STRING = "8";
public static final String MEAL_RESTAURANT_DELIVERYCHARGE_FIELD_ID_STRING = "10029005";
. . .
Rebuild and Deploy it using Maven
In order to actually deploy it to your server, make sure you have updated the POM file credentials as described here (if you have already successfully deployed another project using Maven, you can "steal" the credentials part from that POM file and copy them in here).
<properties>
<!-- START: Bundle specific configuration. Verify and Change as per environment -->
<developerUserName>DEVELOPER_USER</developerUserName>
<developerPassword>DEVELOPER_PASSWORD</developerPassword>
<!-- Server name with Jetty port. -->
<webUrl>DEVELOPMENT_URL</webUrl>
<!-- END: Bundle specific configuration.-->
Once credentials are in place, you can go ahead and deploy it.
projects\meal-program-lib> mvn clean install -Pdeploy
This time with your success messages you should see that it was deployed as well as built.
Quick Sanity Check
At this point, the additional Service Actions and View Components are now available in BMC Helix Innovation Studio.
You will have to refresh the browser (a hard refresh, such as Shift-Refresh on Chrome, is recommended - to make sure the code is present and ready to use). To verify that it is there,
- On the Workspace page, you should now see the Meal Program Library appearing. Don't be concerned if you don't see a lot of definitions inside it - after all, it is mostly code that you will not see in the Workspace.
- Open up the Process Designer within your Lunch Tutorial Application (for any Process or create a new one). The palette should contain a new section with custom Service Actions for the Meal Order:
- The View Designer, similarly, will have new View Components in the Palette.
What you Learned
We have set the stage for diving into a lot of really useful coding examples and techniques. We can now examine the code, and immediately test it out. First we will look a lot more deeply at the design of the Java services in the sample project and the code that implements it.
Comments
Hi, when I downloaded "sample-project-meal-progran-lib-20.8.0.zip". The table says it's a 21kb file, but turns out to be 34MB. The folder is "util-lib-source" instead of "meal-program-lib". Is the zip file. Is this correct?
Hello Anthony Chung,
Thanks for pointing this out. I have attached the correct .zip file with the meal-program-lib.
Aaditi
Hello, how can I get the ip address and port of my innovation suite sandbox to configure debugging for the meal-program-lib eclipse project? Thanks'
Hello Christian,
As mentioned in this topic, for cloud-based instances, debugging is not typically enabled by default, so this section will not apply.
Thanks,
Prachi
Log in or register to comment.