use of org.drools.core.process.instance.WorkItemManager in project jbpm by kiegroup.
the class ProcessServiceImpl method completeWorkItem.
@Override
public void completeWorkItem(String deploymentId, Long processInstanceId, Long id, Map<String, Object> results) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
results = process(results, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
WorkItem workItem = ((WorkItemManager) ksession.getWorkItemManager()).getWorkItem(id);
if (workItem == null) {
throw new WorkItemNotFoundException("Work item with id " + id + " was not found");
}
ksession.getWorkItemManager().completeWorkItem(id, results);
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.drools.core.process.instance.WorkItemManager in project jbpm by kiegroup.
the class RestGeoCodeApiCallWorkItemHandlerTest method FIXMEtestYahooGeoCode.
@Test
@Ignore
public void FIXMEtestYahooGeoCode() throws Exception {
RestGeoCodeApiCallWorkItemHandler handler = new RestGeoCodeApiCallWorkItemHandler();
Map<String, Object> queryParams = new HashMap<String, Object>();
queryParams.put("URL", "http://local.yahooapis.com/");
queryParams.put("Service", "MapsService/V1/");
queryParams.put("Method", "geocode?");
queryParams.put("appid", "TIpNDenV34Fwcw_x32k1eX6AlQzq4wajFEFvG501Pwc6w9jKEfy2vGnkIn.r5qSQqVvyhPPaTFo-");
// Real parameters
queryParams.put("street", "701+First+Ave");
queryParams.put("city", "Sunnyvale");
queryParams.put("state", "CA");
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameters(queryParams);
WorkItemManager manager = new DefaultWorkItemManager(null);
handler.executeWorkItem(workItem, manager);
assertEquals(HttpURLConnection.HTTP_OK, handler.getHttpResponseCode());
assertEquals(1, handler.getResults().size());
assertEquals("US", ((ResultGeoCodeApi) handler.getResults().get(0)).getCountry());
}
use of org.drools.core.process.instance.WorkItemManager in project drools by kiegroup.
the class GetWorkItemIdsCommand method execute.
public List<Long> execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
Set<WorkItem> workItems = ((WorkItemManager) ksession.getWorkItemManager()).getWorkItems();
List<Long> workItemIds = new ArrayList<Long>(workItems.size());
for (WorkItem workItem : workItems) {
workItemIds.add(workItem.getId());
}
if (this.outIdentifier != null) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, workItemIds);
}
return workItemIds;
}
Aggregations