Chapter 3. Setting up a New Project
To create a project a business user has to create an organizational unit. An organizational unit is based on any domain in a particular business sector. It holds the repositories, where projects and packages can be created. Packages are deployable collections of assets like rules, fact models, decision tables and so on, that can be validated and compiled for deployment.
3.1. Creating an Organizational Unit Copy linkLink copied to clipboard!
It is possible to create an organizational unit in the Administration perspective of Business Central, using the kie-config-cli tool, or the REST API calls.
Creating an Organizational Unit in Business Central
Note that only users with the admin role in Business Central can create organizational units.
Procedure: Using Business Central to Create an Organizational Unit
-
In Business Central, go to Authoring
Administration. -
On the perspective menu, click Organizational Units
Manage Organizational Units. In the Organization Unit Manager view, click Add.
The Add New Organizational Unit dialog window opens.
Figure 3.1. *Add New Organizational Unit*Dialog Window
-
Enter the two mandatory parameters (
nameanddefault group ID) and click Ok.
Creating an Organizational Unit Using the kie-config-cli Tool
Organizational units can be created using the kie-config-cli tool as well. To do so, run the create-org-unit command. The tool then guides you through the entire process of creating an organizational unit by asking for other required parameters. Type help for a list of all commands.
For more information about the kie-config-cli tool, see Red Hat JBoss BRMS Administration and Configuration Guide, chapter Command Line Configuration.
Creating an Organizational Unit Using the REST API
Note that only users with the rest-all role can create organizational units.
To create an organizational unit in Knowledge Store, issue the POST REST API call. Details of the organizational unit are defined by the JSON entity.
Input parameter of the call is an OrganizationalUnit instance. The call returns a CreateOrganizationalUnitRequest instance.
Example 3.1. Creating an Organizational Unit Using the Curl Utility
Example JSON entity containing details of an organizational unit to be created:
{
"name" : "helloWorldUnit",
"owner" : "tester",
"description" : null,
"repositories" : []
}
Execute the following command:
curl -X POST 'localhost:8080/business-central/rest/organizationalunits/' -u USERNAME:PASSWORD -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"name":"helloWorldUnit","owner":"tester","description":null,"repositories":[]}'
For further information, see the Red Hat JBoss BPM Suite Development Guide, chapter Knowledge Store REST API, section Organizational Unit Calls.
3.2. Creating a Repository Copy linkLink copied to clipboard!
There are three ways to create a repository: using the Administration perspective of Business Central, the kie-config-cli tool, or the REST API calls.
Creating a Repository in Business Central
Note that only users with the admin role in Business Central can create repositories.
Procedure: Using Business Central to Create a Repository
-
In Business Central, go to Authoring
Administration. On the perspective menu, click Repositories
New repository. The New Repository pop-up window is displayed.
Figure 3.2. *New Repository*Dialog Window
Specify the two mandatory parameters:
repository name
NoteMake sure that the repository name is a valid file name. Avoid using a space or any special character that might lead to an invalid name.
- organizational unit: specifies the location of the newly created repository.
- Click Finish.
You can view the newly created repository either in the File Explorer or the Project Explorer.
Creating a Repository Using the kie-config-cli Tool
To create a new Git repository using the kie-config-cli tool, run the create-repo command. The tool then guides you through the entire process of creating a repository by asking for other required parameters. Type help for a list of all commands.
For more information about the kie-config-cli tool, see Red Hat JBoss BRMS Administration and Configuration Guide .
Creating a Repository Using the REST API
Note that only users with the rest-all role can create repositories.
To create a repository in the Knowledge Store, issue the POST REST API call. Details of the repository are defined by the JSON entity. Make sure you established an authenticated HTTP session before executing this call.
Input parameter of the call is a RepositoryRequest instance. The call returns a CreateOrCloneRepositoryRequest instance.
Example 3.2. Creating a Repository Using the Curl Utility
Example JSON entity containing details of a repository to be created:
{
"name" : "newRepository",
"description" : null,
"gitURL" : null,
"requestType" : "new",
"organizationalUnitName" : "helloWorldUnit"
}
Execute the following command:
curl -X POST 'localhost:8080/business-central/rest/repositories/' -u USERNAME:PASSWORD -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"name":"newRepository","description":null,"requestType":"new","gitURL":null,"organizationalUnitName":"helloWorldUnit"}'
For further information, see the Red Hat JBoss BPM Suite Development Guide, chapter Knowledge Store REST API, section Repository Calls.
3.3. Cloning a Repository Copy linkLink copied to clipboard!
It is possible to clone a repository either in Business Central or using the REST API calls. The kie-config-cli tool cannot be used to clone arbitrary repositories - run git clone or use one of the following options instead.
Cloning a Repository in Business Central
Note that only users with the admin role in Business Central can clone repositories.
Procedure: Using Business Central to Clone a Repository
-
In Business Central, go to Authoring
Administration. On the perspective menu, choose Repositories
Clone repository. The Clone Repository pop-up window is displayed.
Figure 3.3. *Clone Repository*Dialog Window
In the Clone Repository dialog window, enter the repository details:
- Enter the Repository Name to be used as the repository identifier in the Asset repository and select the Organizational Unit it should be added to.
Enter the URL of the Git repository:
for a local repository, use
file:///PATH_TO_REPOSITORY/REPOSITORY_NAME;NoteThe file protocol is only supported for READ operations. WRITE operations are not supported.
for a remote or preexisting repository, use
https://github.com/USERNAME/REPOSITORY_NAME.gitorgit://HOST_NAME/REPOSITORY_NAME.ImportantIt is important to use the HTTPS or Git protocol instead of a SCP-style SSH URL. Business Central does not support the basic SSH URL and fails with Invalid URL format.
- If applicable, enter the User Name and Password of your Git account to be used for authentication.
Click Clone.
A confirmation prompt with the notification that the repository was created successfully is displayed.
Click Ok.
The repository is now being indexed. Some workbench features may be unavailable until the indexing has completed.
You can view the cloned repository either in the File Explorer or the Project Explorer.
Cloning a Repository Using the REST API
Note that only users with the rest-all role can clone repositories.
To clone a repository, issue the POST REST API call. This call creates or clones (according to the value of the requestType parameter) the repository defined by the JSON entity.
Input parameter of the call is a RepositoryRequest instance. The call returns a CreateOrCloneRepositoryRequest instance.
Example 3.3. Cloning a Repository Using the Curl Utility
Example JSON entity containing details of a repository to be cloned:
{
"name" : "clonedRepository",
"description" : null,
"requestType" : "clone",
"gitURL" : "git://localhost:9418/newRepository",
"organizationalUnitName" : "helloWorldUnit"
}
Execute the following command:
curl -X POST 'localhost:8080/business-central/rest/repositories/' -u USERNAME:PASSWORD -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"name":"clonedRepository","description":null,"requestType":"clone","gitURL":"git://localhost:9418/newRepository","organizationalUnitName":"helloWorldUnit"}'
For further information, see the Red Hat JBoss BPM Suite Development Guide, chapter Knowledge Store REST API, section Repository Calls.
3.4. Creating a Project Copy linkLink copied to clipboard!
It is possible to create a project either in the Project Authoring perspective of Business Central or using the REST API calls.
Creating a Project in Business Central
Note that only users with the admin role in Business Central can create projects.
Procedure: Using Business Central to Create a Project
-
In Business Central, go to Authoring
Project Authoring. - In the Project Explorer, select the organizational unit and the repository in which you want to create the project.
On the perspective menu, click New Item
Project. The New Project dialog window opens.
Define the Project General Settings and Group artifact version details of the new project. These parameters are stored in the
pom.xmlMaven configuration file.See the detailed description of the parameters:
-
Project Name: name of the project (for exampleMortgageProject). -
Project Description: description of the project, which may be useful for the project documentation purposes. -
Group ID: group ID of the project (for exampleorg.mycompany.commons). -
Artifact ID: artifact ID unique in the group (for examplemyframework). Avoid using a space or any other special character that might lead to an invalid name. -
Version: version of the project (for example2.1.1).
-
Click Finish.
The project screen view is updated with the new project details as defined in the
pom.xmlfile. You can switch between project descriptor files and edit their content by clicking the Project Settings: Project General Settings button at the top of the project screen view.
Creating a Project Using the REST API
Note that only users with the rest-all or rest-project role can create projects.
To create a project in the repository, issue the POST REST API call. Details of the project are defined by the corresponding JSON entity.
Input parameter of the call is an Entity instance. The call returns a CreateProjectRequest instance.
Example 3.4. Creating a Project Using the Curl Utility
Example JSON entity containing details of a project to be created:
{
"name" : "MortgageProject",
"description" : null,
"groupId" : "org.mycompany.commons",
"version" : "2.1.1"
}
Execute the following command:
curl -X POST 'localhost:8080/business-central/rest/repositories/REPOSITORY_NAME/projects/' -u USERNAME:PASSWORD -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"name":"MortgageProject","description":null,"groupId":"org.mycompany.commons","version":"2.1.1"}'
For further information, see the Red Hat JBoss BPM Suite Development Guide, chapter Knowledge Store REST API, section Repository Calls.
3.5. Creating a New Package Copy linkLink copied to clipboard!
It is possible to create a new package in the Project Authoring perspective of Business Central.
Procedure: Creating a New Package in Business Central
-
In Business Central, go to Authoring
Project Authoring. - In the Project Explorer view, select the organizational unit, repository and the project where you want to create the package.
On the perspective menu, click New Item
Package. The Create new Package dialog window opens.
- Define the package details: enter the package name a specify the package.
Click Ok.
A new package is now created under the selected project.
3.6. Adding Dependencies Copy linkLink copied to clipboard!
To add dependencies to your project, do the following:
Open the Project Editor for the given project:
- In the Project Explorer view of the Project Authoring perspective, open the project directory.
- Click Open Project Editor to open the project view.
- In the Project Screen view, select in the Project Settings drop-down box the Dependencies item.
On the updated Project Screen, click the Add button to add a maven dependency or click the Add from repository button to add a dependency from the Knowledge Store (Artifact repository):
- When adding a maven dependency, a user has to define the Group ID, Artifact ID and the Version ID in the Dependency dialogue window.
- When adding a dependency from the Knowledge Store, select the dependency in the displayed dialog box: the dependency will be added to the dependency table.
- To apply the various changes, the dependencies must be saved.
Additionally, you can use the Package white list when working with dependencies. When you add a repository, you can click the gear icon and select Add all or Add none, which results in including all or none of the packages from the added dependency.
If working with modified artifacts, do not re-upload modified non-snapshot artifacts as Maven will not know these artifacts have been updated, and it will not work if it is deployed in this manner.
3.7. Defining KIE Bases and Sessions Copy linkLink copied to clipboard!
A KIE base is a repository of the application’s knowledge definitions. It contains rules, processes, functions, and type models. A KIE base does not contain runtime data, instead sessions are created from the KIE base into which data can be inserted and process instances started.
A KIE session stores runtime data created from a KIE base. See the KIE Sessions chapter of the Red Hat JBoss BPM Suite Development Guide for more information.
You can create KIE bases and sessions by editing the kmodule.xml project descriptor file of your project.You can do so through Business Central or by editing kmodule.xml in the src/main/resources/META-INF/ folder by navigating through the Repository view.
Defining KIE Bases and Sessions in the Project Editor
To define a KIE base or session in Business Central, do the following:
-
Click Authoring
Project Authoring and navigate to your project. - In the Project Explorer window, click Open Project Editor.
-
Click Project Settings: Project General Settings
Knowledge bases and sessions. This view provides a user interface for changing kmodule.xml. Click Add to define and add your bases.
-
After you enter a name for your Knowledge Base, add Packages. For including all packages, click Add below Packages and enter asterisk
*.
-
After you enter a name for your Knowledge Base, add Packages. For including all packages, click Add below Packages and enter asterisk
- Below Knowledge Sessions, click Add and enter the name of your session.
Mark it
Defaultand select appropriate state.For Red Hat JBoss BRMS, you can choose between
statefulandstatelesssessions. Usestatelessif you do not need iterative invocations of the facts. Otherwise, usestatefulsession.- Click Save in the top right corner once you are done.
Defining KIE Bases and Sessions in kmodule.xml
To define a KIE base or session by editing kmodule.xml, do the following:
Open the repository view for your project.
Figure 3.4. Changing to Repository View
-
Navigate to
/src/main/resources/META-INF. Click onkmodule.xmlto edit the file directly. Define your
kbasesandksessions. For example:<kmodule xmlns="http://www.drools.org/xsd/kmodule" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <kbase name="myBase" default="true" eventProcessingMode="stream" equalsBehavior="identity" packages="*"> <ksession name="mySession" type="stateless" default="true" clockType="realtime"/> </kbase> </kmodule>- Click save in the top right corner.
You can switch between the Project Editor view and the Repository view to look at the changes you make in each view. To do so, close and reopen the view each time a change is made.
3.8. Creating a Resource Copy linkLink copied to clipboard!
A Project may contain an arbitrary number of packages, which contain files with resources, such as Process definition, Work Item definition, Form definition, Business Rule definition, etc.
To create a resource, select the Project and the package in the Project Explorer and click on the perspective menu and select the resource you want to create.
It is recommended to create your resources, such as Process definitions, Work Item definitions, Data Models, etc., inside a package of a Project to allow importing of resources and referencing their content.
To create a package, do the following:
-
In the Repository view of the Project Explorer, navigate to the
REPOSITORY/PROJECT/src/main/resources/directory. -
Go to New Item
Package. - In the New resource dialog, define the package name and check the location of the package in the repository.