Go to window and select Samples Console from open perspective. Then click
on import projects in Data sources for BOM Domains to import the project as
shown in the below fig.
Now the bomdomainpopulate project is
imported into our Rule Designer. This project uses a plugin project with the
name ilog.rules.studio.samples.bomdomainpopulate to fetch the domain values
from DB. This plugin project works with Derby DB. To work with Derby DB, we can
refer the following link here(using default derby data base use above link.
If we want to use a database other
than derby, then we need to do some changes in the plugin project, so that it
can work with the preferred DB. To do the changes in the plugin project, we
need to follow these steps
Select Project with source folders and click on next.
Select ilog.rules.studio.samples.bomdomainpopulate and click on add.
click to finsh.
We have imported is an existing plugin project. Now we will do the
following changes in this project, to make it work with other DB. Click on the
plugin project and select properties. Click on Java Build Path and remove
derbyclient.jar and click on OK
Now remove the derbyclient.jar from lib folder.
Now add the required DB driver jar file in the
lib folder as shown. For example let us make this plugin to fetch domains from
Oracle DB. So add ojdbc6.jar file in the lib folder
Then Select the plugin project and click on
properties. Click on java Build Path and add the ojdbc6.jar file, which is
present in the lib folder of the plugin project
Then click on data and select database.properties. This properties file has
the properties w.r.t., derby DB.
Change the properties w.r.t. the preferred DB. For eg., the following
figure shows the connection properties with reference to the Oracle DB.
After that, select the MANIFEST.MF file and
click on run time tab as shown. Remove the Derby references
After removing the derby references, add the DB
references which we wanted to use. Here we take it as oracle references.
Now click on build tab as shown in the fig and select the lib folder in
which the ojdbc6.jar is present.
Now click on MANIFEST.MF tab and remove the “lib/derbyclient.jar” and add
“lib/ojdbc6.jar”.
Now go the default plugin folder in your PC. The
default plugin folder will be in the path:
<INSTALL_DIR>/IBM/IMShared/plugins. Here the number 8.8.0.0 in the folder
name refers to the ODM version we are using. Take the backup of the folder
shown below. This is the same plugin project which we have worked in eclipse.
But the changes done by us are done at the work space level. To reflect the
changes in the plugin level, copy the plugin project from eclipse IDE and paste
in this default plugin location
Now go the preferred DB console and enter the following commands. Click
Here.
Now the changes are completed. Restart the
eclipse IDE, so that the changes made in the plugin will be reflected in the
eclipse IDE. After restarting the eclipse IDE, select the
bomdomainpopulate-rules project and click on Currency Type. If there are any
domain values in the domains section, select “Edit the domain” option.
Select all the domains and click on remove. Click Finish.
Then select all the members and click on delete.
Click on save and then click on synchronize with
dynamic values.
Now we will be able to see the domain values which are fetched from the preferred
DB i.e., Oracle.
If we add or delete any domain values in the DB, click on synchronize with
dynamic values to reflect the changes.
Creating Dynamic Domains at Decision Center using Database:
Go to Samples and Tutorials window in Rule designer. Select Data sources
for BOM domains in decision center tab and click on import projects.
The serverbompopulate project will
be imported to the Rule designer. The src folder of serverbompopulate contains
two classes DomainValueProvider and DomainHelper. When we click the
DomainHelper class, we will see this following code.
We can see the values are hard coded and it is not dealing with Database.
So we are going to change the code so that it can work with DB. Delete the
DomainHelper.java and download the two java files given in the link Click Here.
Place the java files in serverbompopulate package of src folder. Add the
required database driver jar into the lib folder. If Oracle DB is used, then
add ojdbc6.jar into the lib folder. If derby DB is used, add derbyclient.jar
into the lib folder. Here Oracle DB is taken as reference in this context.
Then click on the serverbompopulate project and click properties. Select
Java Build Path and click on add jars. Add the jar which is recently added to
the lib folder of serverbompopulate.
Now we need to do some modifications in the bulid.xml file to make this
project work in context with the changes. So The below fig., depicts the
changes that are needed to be done in build.xml.
Give the name of your jar file in the boxes shown in the above image. As we
have used Oracle DB, it is ojbc6.jar. Now the changes are done. Now go to
window and then show view. Click on ant. Double-click on the repack command in
the build.xml file.
This command does a series of tasks. It copies the jrules-team server.ear
file into a temporary location. In that temporary location, it unpacks the ear
file and then unpacks the teamserver ear file. After that, it converts the src
folder of serverbompopulate to a jar file and also copies the ojdbc6.jar file
to lib folder of the war file. Then it packs the war file again and then it
packs the ear file. The final ear file will be seen in the websources folder of
the serverbompopulate project in Rule Designer.
After you see the BUILD SUCCESSFUL message in the console, click on deploy
command in build.xml. This copies the ear file and it deploys it in the samples
server.
After successful deployment, click on set-config-param command to assign
the custom property with key derbyDataBaseDomainProvider. The sample logs
generated when executing the repack, deploy and set-config-param can be seen
here.
Now go to decision center and select bomdomainpopulate-rules project.
Depending on the ODM version, it will be in Work on a rule project or in Work
on a decision service.
Go to Project tab and click on Update dynamic domains
Click on the required type that is needed to be updated and click on
update.
On successful updation, a message will be displayed as shown
Now we will be able to see the new domain value. If we removed a domain
value from the database, then that value will be shown as deprecated and it
cannot be visible in the drop down box as shown.
No comments:
Post a Comment