Decision Management (ODM, ADS)

 View Only

Configuring external library and using it in IBM Automation Decision Services (ADS)

By Era Sharma posted Thu July 21, 2022 04:26 AM

  

Introduction

This article is the second part of article Configure a Maven artifact repository to be used with IBM Automation Decision Services (ADS) where we discussed on how to configure a maven repository on OpenShift Cluster.
continuing with that, in this
article we will focus on how to create an external Library, upload to configured maven repository and use it in ADS project

Automation Decision Services allows you to import and use external libraries in your decision services. External libraries allow you to enrich your data model and extend rule authoring with custom data types and functions from Java™ libraries.

repository in Maven holds build artifacts and dependencies of varying types.you execute the Automation Decision Services maven plug-ins to generate the external library files. the java file are build into maven artifacts (.pom and .jar files) The Project Object Model (POM) file contains information about the external library and configuration details that are used by Maven to build the library.The deployable JAR  contains the library files. If you are not satisfied with the generated library, you can annotate the source code or edit the vocabulary files. After the JAR file is deployed to the maven repository, the external library is ready to be imported into Decision Designer.
For more information on External Library refer: external-libraries

Pre-requisite

  • A Maven Repository hosted on any OpenShift Cluster
  • ADS instance hosted on any OpenShift cluster
  • Python 3.6 or above
  • Git

Steps to be executed

Download the github repository external library code samples github 
we will be using this automation-decision-services-samples/samples/ExternalLibraryStartTutorial project in the repository to create the external library

  • install maven using following command in terminal sudo apt install maven 
  • open pom.xml file in below directories
    automation-decision-services-samples/samples/ExternalLibraryStartTutorial/pom.xml
    automation-decision-services-samples/samples/ExternalLibraryStartTutorial/sampleLibrary/pom.xml
    automation-decision-services-samples/samples/ExternalLibraryStartTutorial/adsSampleLibrary/pom.xml

    and add correct artifact id, group id and version ,dependencies in below snippet 
    • version of plugin mentioned here in automation-decision-services-samples/samples/ExternalLibraryStartTutorial/pom.xml file should match the version of com.ibm.decision plugins present in your nexus repository. 
    •    <properties>
             <archive.repository.snapshot.url>SNAPSHOT URL TO BE SET</archive.repository.snapshot.url>
             <archive.repository.release.url>RELEASE URL TO BE SET</archive.repository.release.url>
             <ads-mojo.version>6.1.5.4</ads-mojo.version>
             <ads-annotations.version>1.0.16</ads-annotations.version>
         </properties>

    • <groupId>ads.samples</groupId>
      <artifactId>adsSampleLibrary</artifactId>
      <version>1.0.10</version>
    • to prevent duplicate external library artifact deployment error you have to change version in pom file accordingly,
    • the group id and artifact id is basically package path written in java files of your external library project.
      example : if source java file in automation-decision-services-samples/samples/ExternalLibraryStartTutorial/sampleLibrary contains  package name like : "package  ads.samples.externalLibrary;"
      so "ads.samples" becomes the group id and "externalLibrary" becomes artifact id
    • you can change the artifact, group names in pom file ,but you have to reflect the changes in java files too by changing package names.
    • add repository links where you will be deploying library
    • <distributionManagement>
      <snapshotRepository>
      <id>maven-releases</id>
      <url><maven release url></url>
      </snapshotRepository>
      <repository>
      <id>maven-snapshot</id>
      <url><maven snapshot url></url>
      </repository>
      </distributionManagement>
  • To access the sample-repository-manager to deploy the sample external library, replace the following placeholders :
    • %MAVEN_RELEASES-REPOSITORY_TO_BE_SET% : The URL of the sample-repository-manager release repository where you deploy the external library.
    • %USER TO BE SET%: A username that can access the repository manager where you deploy the external library.
    • %PASSWORD TO BE SET%: The username's password to access the repository manager where you deploy the external library.
    • you can access the urls by going to maven repository service->repsitories->maven -releases and copy maven-release url from there.
  • upload the library to maven repository : go to root folder containing pom file open command prompt and run command
    •  mvn clean deploy -s settings.xml if local repository path in settings.xml is current directory
    • else run  mvn clean deploy if local repository path in settings.xml is user home directory
    • local repository is the path where your .m2 directory (containing maven build plugins) created by maven build command resides.
  • check if the library is available in the maven repository or not by searching keyword "ads"

Configure maven repository credentials
  • Create an ADS Project in aADS instance
  • in order to import external library from ADS, configure credentials on ADS admin platform page  https://<decision_designer_url>/admin-platform ,where decision designer url is ads instance url
  • you should have decision automation admin role to access admin platform page
  • click on "add a credential" ,add "maven release" repository url
  • In the Authentication type field, select USERNAME from the drop-down menu
  • add nexus username and password
  • In the Credentials type field, select MAVEN from the drop-down menu.
Import External Library
  • in ADS project ,go to settings
  • click on external library -> enter group id ,artifact id and version of you external library
  • your external library should get imported
  • open it and you should be able to see all the data types and function defined in it
now you need to add external library to decision service data model,so that its data is accessible 

  • go to decision service -> Data and library->click on Add Library , this should list all imported library in particular ADS project
  • choose the external library
the variables will be now accessible from different decision and task models in the project.
#AutomationDecisionServices(ADS)
#RedHatOpenShift
0 comments
65 views

Permalink