Search in sources :

Example 1 with ExecutionResults

use of org.jbpm.executor.api.ExecutionResults in project jBPM5-Developer-Guide by Salaboy.

the class CalculateHospitalRatesCommand method execute.

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;
}
Also used : ConceptCode(com.salaboy.jbpm5.dev.guide.model.ConceptCode) PatientDataServiceWorkItemHandler(com.salaboy.jbpm5.dev.guide.workitems.PatientDataServiceWorkItemHandler) MalformedURLException(java.net.MalformedURLException) InsuranceService(com.salaboy.jbpm5.dev.guide.webservice.InsuranceService) ExecutionResults(org.jbpm.executor.api.ExecutionResults) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal)

Example 2 with ExecutionResults

use of org.jbpm.executor.api.ExecutionResults in project jBPM5-Developer-Guide by Salaboy.

the class NotifyInsuranceCompanyCommand method execute.

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;
}
Also used : ConceptCode(com.salaboy.jbpm5.dev.guide.model.ConceptCode) MalformedURLException(java.net.MalformedURLException) InsuranceService(com.salaboy.jbpm5.dev.guide.webservice.InsuranceService) ExecutionResults(org.jbpm.executor.api.ExecutionResults) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal)

Example 3 with ExecutionResults

use of org.jbpm.executor.api.ExecutionResults in project jBPM5-Developer-Guide by Salaboy.

the class CXFWebServiceCommand method execute.

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;
    }
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    Client client = dcf.createClient(wsdlUrl, CXFWebServiceCommand.class.getClassLoader());
    ExecutionResults results = new ExecutionResults();
    try {
        Object[] result = client.invoke(methodName, arguments);
        if (result == null) {
            System.out.println("Null response");
            results.setData(outputName, null);
        } else {
            System.out.println("Echo response: " + result[0]);
            results.setData(outputName, (Serializable) result[0]);
        }
    } catch (Exception e) {
        results.setData(outputName, e);
        System.out.println("Exception inside CXFCmd: " + e.getMessage());
        e.printStackTrace(System.out);
    }
    return results;
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) ExecutionResults(org.jbpm.executor.api.ExecutionResults) Client(org.apache.cxf.endpoint.Client)

Example 4 with ExecutionResults

use of org.jbpm.executor.api.ExecutionResults in project jBPM5-Developer-Guide by Salaboy.

the class IsPatientInsuredCommand method execute.

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) InsuranceService(com.salaboy.jbpm5.dev.guide.webservice.InsuranceService) ExecutionResults(org.jbpm.executor.api.ExecutionResults)

Example 5 with ExecutionResults

use of org.jbpm.executor.api.ExecutionResults in project jBPM5-Developer-Guide by Salaboy.

the class PrintOutCommand method execute.

public ExecutionResults execute(CommandContext ctx) {
    System.out.println(">>> Hi This is the first command!");
    ExecutionResults executionResults = new ExecutionResults();
    return executionResults;
}
Also used : ExecutionResults(org.jbpm.executor.api.ExecutionResults)

Aggregations

ExecutionResults (org.jbpm.executor.api.ExecutionResults)8 InsuranceService (com.salaboy.jbpm5.dev.guide.webservice.InsuranceService)5 MalformedURLException (java.net.MalformedURLException)4 ConceptCode (com.salaboy.jbpm5.dev.guide.model.ConceptCode)3 BigDecimal (java.math.BigDecimal)3 Patient (com.salaboy.jbpm5.dev.guide.model.Patient)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PatientDataServiceWorkItemHandler (com.salaboy.jbpm5.dev.guide.workitems.PatientDataServiceWorkItemHandler)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Client (org.apache.cxf.endpoint.Client)1 JaxWsDynamicClientFactory (org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory)1 Transactional (org.jboss.seam.transaction.Transactional)1 Command (org.jbpm.executor.api.Command)1 CommandCallback (org.jbpm.executor.api.CommandCallback)1 CommandContext (org.jbpm.executor.api.CommandContext)1