Bug 1090744
| Summary: | Improve the documentation for RemoteRestRuntimeEngineFactory | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Retired] JBoss BPMS Platform 6 | Reporter: | William Antônio <wsiqueir> | ||||
| Component: | Documentation | Assignee: | Shelly McGowan <smcgowan> | ||||
| Status: | CLOSED EOL | QA Contact: | Lukáš Petrovický <lpetrovi> | ||||
| Severity: | urgent | Docs Contact: | Dawn Eisner <deisner> | ||||
| Priority: | urgent | ||||||
| Version: | 6.0.2 | CC: | agiertli, alazarot, brms-docs, smcgowan, tradej, wsiqueir | ||||
| Target Milestone: | CR1 | ||||||
| Target Release: | 6.2.0 | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2020-03-27 20:03:59 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
|
Description
William Antônio
2014-04-24 04:20:58 UTC
Eva, I've just added a bunch of examples for the documentation here: https://github.com/droolsjbpm/droolsjbpm-integration/tree/master/kie-remote/kie-remote-client/src/test/java/org/kie/services/client/documentation (Ignore the "Scratch.java" class, I included that by accident.. ) Maybe it would be a good idea to add an examples section to the Remote API documentation so that all of the examples can be included? Created attachment 1115958 [details]
Examples updated for 6.2
Hi, Here are my findings regarding the new remote API:
Maven dependencies:
Using BPM Suite 6.2 BOM, the only dependency we must add is the following:
<dependency>
<groupId>org.kie.remote</groupId>
<artifactId>kie-remote-client</artifactId>
</dependency>
First Code example:
It is slightly deprecated for BPM Suite 6.2. I made sure the code in [1] was tested against BPM Suite 6.2.x. Kindly update the doc with this code.
Retrieving potential owner example:
The code is correct, however, please include that the mentioned Task is from package org.kie.api.task.model.Task and that the method in taskService uses the task Id. I would update it as you can see in [2].
First code example from section 17.4.2. Calling tasks without Deployment Id:
It is also using a deprecated code. The working version would be the one I show in [3].
Section 17.4.3. Custom Model Objects and Remote API:
The sample behind the item 3 is also using a deprecated code, please change it to use the new builder, see [4] for a working sample.
I would also add at some part of this section that the class must have the @org.kie.api.remote.Remotable annotation. It can be done by editing the source of the class directly or marking the "Is Remotable" flag when creating the object using the Data Modeller business central tool.
I am adding my updated project for BPM Suite 6.2.
CODES
[1]
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.manager.RuntimeEngine;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.api.task.TaskService;
import org.kie.api.task.model.TaskSummary;
import org.kie.remote.client.api.RemoteRuntimeEngineFactory;
public void startProcessAndHandleTaskViaRestRemoteJavaAPI(URL instanceUrl,
String deploymentId, String user, String password) {
// the serverRestUrl should contain a URL similar to
// "http://localhost:8080/business-central/"
// Setup the factory class with the necessary information to communicate
// with the REST services
RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder()
.addUrl(instanceUrl).addUserName(user).addPassword(password)
.addDeploymentId(deploymentId).build();
KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
// Each operation on a KieSession, TaskService or AuditService (client)
// instance
// sends a request for the operation to the server side and waits for
// the response
// If something goes wrong on the server side, the client will throw an
// exception.
ProcessInstance processInstance = ksession
.startProcess("project1.start_and_task_test");
long procId = processInstance.getId();
String taskUserId = user;
taskService = engine.getTaskService();
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(
user, "en-UK");
long taskId = -1;
for (TaskSummary task : tasks) {
if (task.getProcessInstanceId() == procId) {
taskId = task.getId();
}
}
if (taskId == -1) {
throw new IllegalStateException("Unable to find task for " + user
+ " in process instance " + procId);
}
taskService.start(taskId, taskUserId);
}
[2]
import org.kie.api.task.model.OrganizationalEntity;
import org.kie.api.task.model.Task;
Task task = taskService.getTaskById(TASK_ID);
List<OrganizationalEntity> org = task.getPeopleAssignments().getPotentialOwners();
for (OrganizationalEntity ent: org) {
System.out.println("org: " + ent.getId());
}
[3]
RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder()
.addUrl(instanceUrl).addUserName(user).addPassword(password)
.build();
// this call doesn't require the deployment id and will return
// successfully
engine.getTaskService().claim(23l, "user");
// this will throw a "MissingRequiredInfoException" because the
// deployment id is required here
engine.getKieSession().startProcess("org.test.process");
[4]
RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder()
.addUrl(instanceUrl).addUserName(user).addPassword(password)
.addExtraJaxbClasses(Person.class)
.addDeploymentId(deploymentId).build();
KieSession kSession = engine.getKieSession();
Map<String, Object> params = new HashMap<>();
Person person = new Person();
person.setName("anton");
params.put("pVar", person);
ProcessInstance pi = kSession.startProcess(PROCESS2_ID, params);
System.out.println("Process Started: " + pi.getId())
|