congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
CommandContext
Code IndexAdd Tabnine to your IDE (free)

How to use
CommandContext
in
org.jbpm.executor.api

Best Java code snippets using org.jbpm.executor.api.CommandContext (Showing top 19 results out of 315)

origin: salaboy/jBPM5-Developer-Guide

public ExecutionResults execute(CommandContext ctx) {
  String patientName = (String) ctx.getData("bedrequest_patientname");
  System.out.println("Check In for patient " + patientName + " happening NOW!!!");
  checkInCount.incrementAndGet();
  return null;
}

origin: salaboy/jBPM5-Developer-Guide

    String callbacks = (String) workItem.getParameter("callbacks");
this.execKey = workItem.getName() + "_" + workItem.getProcessInstanceId() + "_" + workItemId + "@sessionId="+this.sessionId;
CommandContext ctx = new CommandContext();
for (Map.Entry<String, Object> entry : workItem.getParameters().entrySet()) {
  if (entry.getValue() instanceof Object) {
    ctx.setData(entry.getKey(), entry.getValue());
ctx.setData("_workItemId", String.valueOf(workItemId));
    ctx.setData("callbacks", callbacks);
    ctx.setData("businessKey", this.execKey);     
    Long requestId = this.executor.scheduleRequest(command, ctx);
    workItem.getParameters().put("requestId", requestId);
origin: org.jbpm/executor-services

@Test
public void executorExceptionTest() throws InterruptedException {
  CommandContext commandContext = new CommandContext();
  commandContext.setData("businessKey", UUID.randomUUID().toString());
  cachedEntities.put((String) commandContext.getData("businessKey"), new AtomicLong(1));
  commandContext.setData("callbacks", "org.jbpm.executor.SimpleIncrementCallback");
  commandContext.setData("retries", 0);
  executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", commandContext);
  System.out.println(System.currentTimeMillis() + "  >>> Sleeping for 10 secs");
  Thread.sleep(10000);
  List<RequestInfo> inErrorRequests = executorService.getInErrorRequests();
  assertEquals(1, inErrorRequests.size());
  System.out.println("Error: " + inErrorRequests.get(0));
  List<ErrorInfo> errors = executorService.getAllErrors();
  System.out.println(" >>> Errors: " + errors);
  assertEquals(1, errors.size());
}
origin: org.jbpm/executor-services

@Test
public void callbackTest() throws InterruptedException {
  CommandContext commandContext = new CommandContext();
  commandContext.setData("businessKey", UUID.randomUUID().toString());
  cachedEntities.put((String) commandContext.getData("businessKey"), new AtomicLong(1));
  commandContext.setData("callbacks", "org.jbpm.executor.SimpleIncrementCallback");
  executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", commandContext);
  Thread.sleep(10000);
  List<RequestInfo> inErrorRequests = executorService.getInErrorRequests();
  assertEquals(0, inErrorRequests.size());
  List<RequestInfo> queuedRequests = executorService.getQueuedRequests();
  assertEquals(0, queuedRequests.size());
  List<RequestInfo> executedRequests = executorService.getCompletedRequests();
  assertEquals(1, executedRequests.size());
  assertEquals(2, ((AtomicLong) cachedEntities.get((String) commandContext.getData("businessKey"))).longValue());
}
origin: salaboy/jBPM5-Developer-Guide

public ExecutionResults execute(CommandContext ctx) {
  Patient patient = (Patient) ctx.getData("invoice_patient");
  BigDecimal finalAmount = (BigDecimal) ctx.getData("invoice_finalAmount");
  List<ConceptCode> concepts = (List<ConceptCode>) ctx.getData("invoice_concepts");
  boolean patientNotified = false;
  try {
    InsuranceService client = getClient();
    patientNotified = client.notifyAndChargePatient(patient, finalAmount, concepts);
  } catch (MalformedURLException ex) {
    ex.printStackTrace();
  }
  System.out.println(" >>> Patient Notified = " + patientNotified);
  ExecutionResults results = new ExecutionResults();
  results.setData("invoice_patientNotified", patientNotified);
  return results;
}
origin: org.jbpm/executor-services

public void FIXMEfutureRequestTest() throws InterruptedException {
  CommandContext ctxCMD = new CommandContext();
  ctxCMD.setData("businessKey", UUID.randomUUID().toString());
  Long requestId = executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", new Date(new Date().getTime() + 10000), ctxCMD);
  
  Thread.sleep(5000);
  
  List<RequestInfo> runningRequests = executorService.getRunningRequests();
  assertEquals(0, runningRequests.size());
  
  List<RequestInfo> futureQueuedRequests = executorService.getFutureQueuedRequests();
  assertEquals(1, futureQueuedRequests.size());
  
  Thread.sleep(10000);
  
  List<RequestInfo> completedRequests = executorService.getCompletedRequests();
  assertEquals(1, completedRequests.size());
}

origin: salaboy/jBPM5-Developer-Guide

public ExecutionResults execute(CommandContext ctx) {
  String wsdlUrl = (String) ctx.getData("wsdlUrl");
  String methodName = (String) ctx.getData("methodName");
  String argumentNamesString = (String) ctx.getData("webServiceParameters");
  String outputName = (String) ctx.getData("outputName");
  String[] argumentNames = argumentNamesString.split(",");
  Object[] arguments = new Object[argumentNames.length];
  for (int index = 0; index < argumentNames.length; index++) {
    Object argument = ctx.getData(argumentNames[index]);
    arguments[index] = argument;
origin: org.jbpm/executor-services

@Test
public void cancelRequestTest() throws InterruptedException {
  //  The executor is on purpose not started to not fight against race condition 
  // with the request cancelations.
  CommandContext ctxCMD = new CommandContext();
  ctxCMD.setData("businessKey", UUID.randomUUID().toString());
  Long requestId = executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
  // cancel the task immediately
  executorService.cancelRequest(requestId);
  List<RequestInfo> cancelledRequests = executorService.getCancelledRequests();
  assertEquals(1, cancelledRequests.size());
}

origin: org.jbpm/executor-services

  public void onCommandDone(CommandContext ctx, ExecutionResults results) {
    String businessKey = (String) ctx.getData("businessKey");
    System.out.println(" >>> Before Incrementing = " + ((AtomicLong) BasicExecutorBaseTest.cachedEntities.get(businessKey)).get());
    ((AtomicLong) BasicExecutorBaseTest.cachedEntities.get(businessKey)).incrementAndGet();
    System.out.println(" >>> After Incrementing = " + BasicExecutorBaseTest.cachedEntities.get(businessKey));

  }
}
origin: org.jbpm/executor-services

@Test
public void defaultRequestRetryTest() throws InterruptedException {
  CommandContext ctxCMD = new CommandContext();
  ctxCMD.setData("businessKey", UUID.randomUUID().toString());
  executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", ctxCMD);
  Thread.sleep(12000);
  List<RequestInfo> inErrorRequests = executorService.getInErrorRequests();
  assertEquals(1, inErrorRequests.size());
  List<ErrorInfo> errors = executorService.getAllErrors();
  System.out.println(" >>> Errors: " + errors);
  // Three retries means 4 executions in total 1(regular) + 3(retries)
  assertEquals(4, errors.size());
}
origin: salaboy/jBPM5-Developer-Guide

public ExecutionResults execute(CommandContext ctx) {
  String patientId = (String) ctx.getData("rates_patientName");
  BigDecimal finalAmount = BigDecimal.ZERO;
  //Mock Data
  List<ConceptCode> concepts = new ArrayList<ConceptCode>(2);
  concepts.add(new ConceptCode("CO-123", new BigDecimal(125), "Dialy Hospital Bed Rate", 4));
  concepts.add(new ConceptCode("CO-123", new BigDecimal(100), "Nurse Service", 1));
  try {
    InsuranceService client = getClient();
    //Fixed rate for insured patients
    finalAmount = client.calculateHospitalRates(patientId, concepts);
  } catch (MalformedURLException ex) {
    Logger.getLogger(PatientDataServiceWorkItemHandler.class.getName()).log(Level.SEVERE, null, ex);
  }
  ExecutionResults results = new ExecutionResults();
  results.setData("rates_finalAmount", finalAmount);
  results.setData("rates_concepts", concepts);
  return results;
}

origin: org.jbpm/executor-services

@Test
public void simpleExcecutionTest() throws InterruptedException {
  CommandContext ctxCMD = new CommandContext();
  ctxCMD.setData("businessKey", UUID.randomUUID().toString());
  executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
  Thread.sleep(10000);
  List<RequestInfo> inErrorRequests = executorService.getInErrorRequests();
  assertEquals(0, inErrorRequests.size());
  List<RequestInfo> queuedRequests = executorService.getQueuedRequests();
  assertEquals(0, queuedRequests.size());
  List<RequestInfo> executedRequests = executorService.getCompletedRequests();
  assertEquals(1, executedRequests.size());
}
origin: salaboy/jBPM5-Developer-Guide

public ExecutionResults execute(CommandContext ctx) {
  String patientId = (String) ctx.getData("insured_patientName");
  boolean isPatientInsured = false;
  try {
    InsuranceService client = getClient();
    isPatientInsured = client.isPatientInsured(patientId);
  } catch (MalformedURLException ex) {
    ex.printStackTrace();
  }
  ExecutionResults results = new ExecutionResults();
  results.setData("insured_isPatientInsured", isPatientInsured);
  return results;
}

origin: salaboy/jBPM5-Developer-Guide

public ExecutionResults execute(CommandContext ctx) {
  String patientId = (String) ctx.getData("company_patientName");
  BigDecimal finalAmount = BigDecimal.ZERO;
  try {
    InsuranceService client = getClient();
    //Fixed rate for insured patients
    finalAmount = client.notifyInsuranceCompany("Company 1", patientId, new BigDecimal(100));
    
  } catch (MalformedURLException ex) {
    ex.printStackTrace();
  }
  ExecutionResults results = new ExecutionResults();
  results.setData("company_finalAmount", finalAmount);
  List<ConceptCode> concepts = new ArrayList<ConceptCode>(1);
  concepts.add(new ConceptCode("CO-9999", finalAmount, " Insured Flat Rate", 1));
  results.setData("company_concepts", concepts);
  return results;  
}

origin: salaboy/jBPM5-Developer-Guide

  throw new IllegalStateException("A Context Must Be Provided! ");
String businessKey = (String) ctx.getData("businessKey");
RequestInfo requestInfo = new RequestInfo();
requestInfo.setCommandName(commandId);
requestInfo.setStatus(STATUS.QUEUED);
requestInfo.setMessage("Ready to execute");
if (ctx.getData("retries") != null) {
  requestInfo.setRetries((Integer) ctx.getData("retries"));
} else {
  requestInfo.setRetries(retries);
origin: salaboy/jBPM5-Developer-Guide

public ExecutionResults execute(CommandContext ctx) throws MalformedURLException {
  String patientId = (String) ctx.getData("gatherdata_patientName");
  InsuranceService client = getClient();
  Patient patientData = client.getPatientData(patientId);
  ExecutionResults executionResults = new ExecutionResults();
  executionResults.setData("gatherdata_patient", patientData);
  return executionResults;
}
origin: org.jbpm/executor-services

  throw new IllegalStateException("A Context Must Be Provided! ");
String businessKey = (String) ctx.getData("businessKey");
RequestInfo requestInfo = new RequestInfo();
requestInfo.setCommandName(commandId);
requestInfo.setTime(date);
requestInfo.setMessage("Ready to execute");
if (ctx.getData("retries") != null) {
  requestInfo.setRetries(Integer.valueOf(String.valueOf(ctx.getData("retries"))));
} else {
  requestInfo.setRetries(retries);
origin: salaboy/jBPM5-Developer-Guide

if (ctx != null && ctx.getData("callbacks") != null) {
  logger.log(Level.INFO, " ### Callback: {0}", ctx.getData("callbacks"));
  String[] callbacksArray = ((String) ctx.getData("callbacks")).split(",");;
  List<String> callbacks = (List<String>) Arrays.asList(callbacksArray);
  for (String callbackName : callbacks) {
origin: org.jbpm/executor-services

if (ctx != null && ctx.getData("callbacks") != null) {
  logger.log(Level.INFO, " ### Callback: {0}", ctx.getData("callbacks"));
  String[] callbacksArray = ((String) ctx.getData("callbacks")).split(",");;
  List<String> callbacks = (List<String>) Arrays.asList(callbacksArray);
  for (String callbackName : callbacks) {
org.jbpm.executor.apiCommandContext

Most used methods

  • getData
  • <init>
  • setData

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Notification (javax.management)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now