Getting Started with OSLC integration
You can integrate TRIRIGA application with other applications by using Open Services for Lifecycle Collaboration (OSLC) REST API. IBM® TRIRIGA® provides an OSLC REST API as part of the on-premises IBM TRIRIGA Connector for Business Applications (CBA) license and the IBM Facilities and Real Estate Management on Cloud (TRIRIGA) Enterprise User license.
OSLC integration with IBM TRIRIGA is accomplished between a consumer application and TRIRIGA, the provider application. As the OSLC provider application, TRIRIGA makes its resource data available to the consumer application through containers, which are known as service providers. With the resource data made available, the consumer application can create links between its data and the resource data of TRIRIGA. You can configure and enable any part of TRIRIGA to act as an OSLC provider application.
Contents
I. Creating Prerequisites on TRIRIGA Server
- TRIRIGA Server
- User with access to builder tools
- Advanced REST Client that can be downloaded to Google Chrome
- Buisness Object, Form, Query, and Navigation Item
- Login to TRIRIGA and navigate to the Data Modeler.
- Click Home > Tools > Data Modeler.
- Click New and then select New Module.
- Specify the name of the module and then click Save Module.
- In newly created module, click New and then click New Business Object.
- Speicfy the name of the Business Object and then click SaveBO.
- Add fields to the BO by either adding them manually or finding them from an existing BO. The fields added to the BO are triControlNumber (Control Number), triNameTX (Text), triDescriptionTX (Text), triRecordIdSY(System Read Only), triRecordNameSY (System Read Only), and triNumber (Number).
- Add a State Transition family:
- Click Tools > BO State Transition. Either set up or import the State Transition.
- To import the State Transition, click Import> Import From Business Object> triPeople for both Module and BO.
- Click Ok, and then click Save.
- Create BO Mapping:
- Click Tools > BO Mapping. In the following example, the BO mapping set it to show the ControlNumber, then a hyphen followed by Name. You can set it as per your requirement or choice.
- Click Save Mapping and then click Publish BO.
- Navigate to .
- Select the appropriate Module (amOSLCTutorial) and then click New.
- Select the appropriate BO in the Properties Window. In this example, only one BO amRecord is assigned to this module.
- Click Apply.
- Click Add Tab.
- Specify the name of the tab and then click Apply.
- On the newly created tab click Add Section, provide a name to the section, and then click Apply.
- Add the fields required for the form:
- On the section created in the previous step, click Add Field.
- In the Properties window, select a Data Field from the BO, and then click Apply. In this example, the following fileds are added to the form: fields triControlNumber, triNameTX, triDescriptionTX, and triNumber. The form should look something like this:
- Click Publish to publish the form.
- Navigate to .
- Click System Reports tab.
- Click New.
- Specify the name of the query.
- On the Business Object tab, click Add Business Object. On the form, select the Module, Business Object, and Form that were created in the previous steps and click OK.
- Click on the Columns tab. Add the fields from the form (ControlNumber, Description, Name, Number) to display in the query.
- Click Save & Close.
- Navigate to .
- Click Add to bring up Navigation Items Library, and then click Add.
- In the Navigation Item Editor window, specify the name of the item, and set the Target Type to Master/Detail Default Query.
- In the Form section, select the Module and Form created in the previous sections.
- In the Action section, add actions to create, update, or delete records, and then click Save & Close.
- Select the menu to add the navigation item.
- Click Navigation Items Library, search the recently created Navigation Item, and then Save & Close.
- Add records to the navigation item by clicking .
II. OSLC on TRIRIGA Server
Creating an OSLC Resource for the BO
Create an OSLC resource for the Business Object. The resource is data that can be identified by a URI.
- Navigate to .
- Click Add.
- Specify the ID, Resource Name, and Title.
- In Namespace the prefix "spi" is used which has the base of http://jazz.net/ns/ism/smarter_physical_infrastructure#. The namespace is used to provide unique name to the fields but does not change any logic. You can use any namespace or create your own.
- In the Module drop-down menu, select the module that was created earlier. The corresponding BO, Form, and Query created in previous section are now available for selection.
- In the Properties section, click Import All Fields to set up the fields for the resource based on the BO fields.
- After the import is completed, click Create.
A service provider contains the resources that allow use of the resource. This also includes the creation factory and query capability.
- Navigate to .
- Click Add.
- On the Service Provider creation form, specify a name, and then click Create.
- Open the Service Provider created in the previous section.
- Under the Service section, click Add.
- In the new form name the service and set the domain to match what is set in the resource: http://jazz.net/ns/ism/smarter_physical_infrastructure#.
- Click Create.
The query capability allows to create a base URI that can be used to query the resources easily.
- In the Query Capabilities section of the service form, click Add to bring up the Query Capability form.
- In the Resource section, click Find.
- Select the OSLC Resource that was created earlier and then click OK.
- In the General section, specify a name and title.Note: If you want to override the query that is added to the resource, you can select the query from the Query drop-down menu. In this example, the query is already added to the resource. So the Query field can be left blank.
Creating a creation factory proivdes a URI which can then be used to create new records for resources.
- In the Creation Factories section of the service form, click Add.
- In the Resource section, click Find.
- Select the OSLC Resource that was created earlier and then click OK.
- In the General section, specify a name and title.
III. Using Advanced REST Client
- The commands used in this guide follows this format: http://TRIRIGAServerURL:port/context. The TRIRIGAServerURL, port, and context must be replaced with appropriate values based on your TRIRIGA server.
- To receive responses that include URI's that you can directly use with the REST Client, you must first set the OSLC_BASE_URI property in the TRIRIGAWEB.properties file. You can find the TRIRIGAWEB.properties file in your TRIRIGA install directory in the config folder. Set the OSLC_BASE_URL property to http://TRIRIGAServerURL:port/context/oslc, save this file, and then restart your TRIRIGA server.
After running the command, you might see that the status is 200 OK. It means the command ran without any errors. Scroll down to see the result in the Response section. The results of the query that was run is displayed. The records that are created are displayed as resources in the command section.
You can query a specific field value to return any record that makes
mention of the field by using oslc.where command. For example, you can run a query on
all records with the word “TRIRIGA” anywhere in its description by running GET on the
following URI:
http://TRIRIGAServerURL:port/context/oslc/spq/RecordQC?oslc.select=*&oslc.where=spi:triDescriptionTX="%25TRIRIGA%25
- oslc.where=spi:triDescriptionTX="%25TRIRIGA%25: Displays any records that have “TRIRIGA” anywhere in the description.
- "%25string%25" = string anywhere in the field
- "%25string" = string ends the field
- "string%25" =string starts the field.
For more information, see OSLC resources.
All the fields that were defined in the resource including triNumber and triNameTX are displayed in the response. You can also use oslc.properties to specify the fields you want to see in the results. For example if you want to just get the triNumber field, you can run GET on: http://TRIRIGAServerURL:port/context/oslc/so/amRecordRS/20029510?oslc.properties=spi:triNumber
- The Accept field is used to determine what file formats the browser is trying to get.
- The Content-Type field helps determine how to use the data being received:
- Header: Accept: application/json
- Content-Type: application/json;charset=utf-8
Use a record that is can be updated by using the PUT command. The newly create record in the previous section is in the draft state and is not in the read only state. You can get the URL for this record by running the query capability again. For example, you can update the triNumber on the record. The header is same from the POST command. To update only the number field, you can set the request body to: {"spi:triNumber":"24" }
This action changes the number in the record from 42 to the new value 24. Ensure to select PUT before clicking SEND.
You can also delete a record using PUT. To delete a record, run the delete action that brings the record to the null state. For example, to delete one of the records, run a PUT command with the request body of: {"spi:action":"Delete"}
Run a DELETE command: http://TRIRIGAServerURL:port/context/oslc/
You can use the REST Client to login to the TRIRIGA Server. When you send the first request upon opening the REST Client, you are prompted to specify your user name and password. To login or switch users you can simply run a GET command on: http://TRIRIGAServerURL:port/context/oslc/login?USERNAME=name&PASSWORD=pass. Set the USERNAME and PASSWORD parameters to the username and password that you would use to login to the TRIRIGA. These login parameters can then be run by using any request.
Another useful command that you can run is to check to see which user account who you are logged in with. A query capability is already included on the TRIRIGA Server and is set up in the triFriendOfAFriendSV (which can be found in the triFriendOfAFriendSP) and is called triCurrentUserQC. To see the user logged in, run a GET command on: http://TRIRIGAServerURL:port/context/oslc/spq/triCurrentUserQC?oslc.select=*. The “?oslc.select=*” part is not manadatory but can be used to view the record details returned.