use of org.kie.server.client.ProcessServicesClient in project rhpam-7-openshift-image by jboss-container-images.
the class LibraryClient method returnLoan.
boolean returnLoan(Loan loan) {
ReturnRequest returnRequest = new ReturnRequest();
returnRequest.setLoan(loan);
ReturnResponse returnResponse;
if (appcfg.getKieSession() != null) {
KieSession kieSession = appcfg.getKieSession();
WorkflowProcessInstance procinst = (WorkflowProcessInstance) kieSession.getProcessInstance(loan.getId());
procinst.signalEvent("ReturnSignal", returnRequest);
returnResponse = (ReturnResponse) procinst.getVariable("returnResponse");
} else {
ProcessServicesClient procserv = appcfg.getProcessServicesClient();
procserv.signalProcessInstance("rhpam-kieserver-library", loan.getId(), "ReturnSignal", returnRequest);
// returnResponse = (ReturnResponse)procserv.getProcessInstanceVariable("rhpam-kieserver-library", loan.getId(), "returnResponse");
returnResponse = new ReturnResponse();
returnResponse.setAcknowledged(true);
}
return returnResponse != null ? returnResponse.isAcknowledged() : false;
}
use of org.kie.server.client.ProcessServicesClient in project rhpam-7-openshift-image by jboss-container-images.
the class LibraryClient method attemptLoan.
Loan attemptLoan(String isbn) {
Map<String, Object> parameters = new HashMap<String, Object>();
LoanRequest loanRequest = new LoanRequest();
loanRequest.setIsbn(isbn);
parameters.put("loanRequest", loanRequest);
LoanResponse loanResponse;
if (appcfg.getKieSession() != null) {
KieSession kieSession = appcfg.getKieSession();
WorkflowProcessInstance procinst = (WorkflowProcessInstance) kieSession.startProcess("LibraryProcess", parameters);
loanResponse = (LoanResponse) procinst.getVariable("loanResponse");
} else {
ProcessServicesClient procserv = appcfg.getProcessServicesClient();
Long pid = procserv.startProcess("rhpam-kieserver-library", "LibraryProcess", parameters);
loanResponse = (LoanResponse) procserv.getProcessInstanceVariable("rhpam-kieserver-library", pid, "loanResponse");
}
return loanResponse != null ? loanResponse.getLoan() : null;
}
use of org.kie.server.client.ProcessServicesClient in project rhpam-7-openshift-image by jboss-container-images.
the class LibraryClient method runRemote.
private void runRemote(PrintWriter out, KieServicesConfiguration kiecfg) throws Exception {
appcfg.setKieSession(null);
MarshallingFormat marshallingFormat = appcfg.getMarshallingFormat();
out.println(String.format("Using %s MarshallingFormat.%s", marshallingFormat.getType(), marshallingFormat.name()));
kiecfg.setMarshallingFormat(marshallingFormat);
if (MarshallingFormat.JAXB.equals(marshallingFormat)) {
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Book.class);
classes.add(Loan.class);
classes.add(LoanRequest.class);
classes.add(LoanResponse.class);
classes.add(ReturnRequest.class);
classes.add(ReturnResponse.class);
classes.add(Suggestion.class);
classes.add(SuggestionRequest.class);
classes.add(SuggestionResponse.class);
kiecfg.addExtraClasses(classes);
}
KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(kiecfg);
RuleServicesClient ruleServicesClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
ProcessServicesClient processServicesClient = kieServicesClient.getServicesClient(ProcessServicesClient.class);
appcfg.setRuleServicesClient(ruleServicesClient);
appcfg.setProcessServicesClient(processServicesClient);
runApp(out);
}
use of org.kie.server.client.ProcessServicesClient in project kiegroup-examples by tkobayas.
the class KieServerRestUtils method getProcessServicesClient.
public static ProcessServicesClient getProcessServicesClient(String username, String password) {
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(BASE_URL, username, password);
List<String> capabilities = new ArrayList<String>();
capabilities.add(KieServerConstants.CAPABILITY_BPM);
config.setCapabilities(capabilities);
config.setMarshallingFormat(MarshallingFormat.JSON);
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
ProcessServicesClient processServiceClient = client.getServicesClient(ProcessServicesClient.class);
return processServiceClient;
}
use of org.kie.server.client.ProcessServicesClient in project kiegroup-examples by tkobayas.
the class DemoTest method testRest.
public void testRest() throws Exception {
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(BASE_URL, USERNAME, PASSWORD);
List<String> capabilities = new ArrayList<String>();
capabilities.add(KieServerConstants.CAPABILITY_BPM);
config.setCapabilities(capabilities);
config.setMarshallingFormat(MarshallingFormat.JSON);
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
ProcessServicesClient processServiceClient = client.getServicesClient(ProcessServicesClient.class);
Map<String, Object> params = new HashMap<String, Object>();
params.put("processVar1", "AAA1");
params.put("processVar2", "BBB2");
long processInstanceId = processServiceClient.startProcess(CONTAINER_ID, "project1.helloProcess", params);
System.out.println("startProcess() : processInstanceId = " + processInstanceId);
UserTaskServicesClient userTaskServiceClient = client.getServicesClient(UserTaskServicesClient.class);
List<TaskSummary> taskList = userTaskServiceClient.findTasksAssignedAsPotentialOwner(USERNAME, 0, 100);
for (TaskSummary taskSummary : taskList) {
System.out.println("taskSummary.getId() = " + taskSummary.getId() + ", staus = " + taskSummary.getStatus());
long taskId = taskSummary.getId();
if (taskSummary.getStatus().equals("Reserved")) {
userTaskServiceClient.startTask(CONTAINER_ID, taskId, USERNAME);
}
userTaskServiceClient.completeTask(CONTAINER_ID, taskId, USERNAME, null);
}
}
Aggregations