Search in sources :

Example 1 with FieldBaseStructureInstance

use of org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance in project Activiti by Activiti.

the class MessageImplicitDataInputAssociation method evaluate.

@Override
public void evaluate(ActivityExecution execution) {
    if (StringUtils.isNotEmpty(this.source)) {
        Object value = execution.getVariable(this.source);
        MessageInstance message = (MessageInstance) execution.getVariable(WebServiceActivityBehavior.CURRENT_MESSAGE);
        if (message.getStructureInstance() instanceof FieldBaseStructureInstance) {
            FieldBaseStructureInstance structure = (FieldBaseStructureInstance) message.getStructureInstance();
            structure.setFieldValue(this.target, value);
        }
    }
}
Also used : FieldBaseStructureInstance(org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance)

Example 2 with FieldBaseStructureInstance

use of org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance in project Activiti by Activiti.

the class WebServiceUELTest method testWebServiceInvocationWithDataFlowUEL.

@Deployment
public void testWebServiceInvocationWithDataFlowUEL() throws Exception {
    ProcessDefinitionEntity processDefinition = processEngineConfiguration.getCommandExecutor().execute(new Command<ProcessDefinitionEntity>() {

        public ProcessDefinitionEntity execute(CommandContext commandContext) {
            return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("webServiceInvocationWithDataFlowUEL");
        }
    });
    ItemDefinition itemDefinition = processDefinition.getIoSpecification().getDataInputs().get(0).getDefinition();
    ItemInstance itemInstance = itemDefinition.createInstance();
    FieldBaseStructureInstance structureInstance = (FieldBaseStructureInstance) itemInstance.getStructureInstance();
    structureInstance.setFieldValue("prefix", "The counter has the value ");
    structureInstance.setFieldValue("suffix", ". Good news");
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("dataInputOfProcess", itemInstance);
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey("webServiceInvocationWithDataFlowUEL", variables);
    waitForJobExecutorToProcessAllJobs(10000L, 250L);
    String response = (String) processEngine.getRuntimeService().getVariable(instance.getId(), "dataOutputOfProcess");
    assertEquals("The counter has the value -1. Good news", response);
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) HashMap(java.util.HashMap) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) FieldBaseStructureInstance(org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance) ItemInstance(org.activiti.engine.impl.bpmn.data.ItemInstance) Deployment(org.activiti.engine.test.Deployment)

Example 3 with FieldBaseStructureInstance

use of org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance in project Activiti by Activiti.

the class WebServiceUELTest method testAsyncInvocationWithDataFlowUEL.

@Deployment
public void testAsyncInvocationWithDataFlowUEL() throws Exception {
    assertEquals(-1, webServiceMock.getCount());
    ProcessDefinitionEntity processDefinition = processEngineConfiguration.getCommandExecutor().execute(new Command<ProcessDefinitionEntity>() {

        public ProcessDefinitionEntity execute(CommandContext commandContext) {
            return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("asyncWebServiceInvocationWithDataFlowUEL");
        }
    });
    ItemDefinition itemDefinition = processDefinition.getIoSpecification().getDataInputs().get(0).getDefinition();
    ItemInstance itemInstance = itemDefinition.createInstance();
    FieldBaseStructureInstance structureInstance = (FieldBaseStructureInstance) itemInstance.getStructureInstance();
    structureInstance.setFieldValue("newCounterValue", 23);
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("dataInputOfProcess", itemInstance);
    processEngine.getRuntimeService().startProcessInstanceByKey("asyncWebServiceInvocationWithDataFlowUEL", variables);
    waitForJobExecutorToProcessAllJobs(10000L, 250L);
    assertEquals(23, webServiceMock.getCount());
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) HashMap(java.util.HashMap) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) FieldBaseStructureInstance(org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance) ItemInstance(org.activiti.engine.impl.bpmn.data.ItemInstance) Deployment(org.activiti.engine.test.Deployment)

Example 4 with FieldBaseStructureInstance

use of org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance in project Activiti by Activiti.

the class MessageImplicitDataOutputAssociation method evaluate.

@Override
public void evaluate(ActivityExecution execution) {
    MessageInstance message = (MessageInstance) execution.getVariable(WebServiceActivityBehavior.CURRENT_MESSAGE);
    if (message.getStructureInstance() instanceof FieldBaseStructureInstance) {
        FieldBaseStructureInstance structure = (FieldBaseStructureInstance) message.getStructureInstance();
        execution.setVariable(this.getTarget(), structure.getFieldValue(this.getSource()));
    }
}
Also used : FieldBaseStructureInstance(org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance)

Aggregations

FieldBaseStructureInstance (org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance)4 HashMap (java.util.HashMap)2 ItemDefinition (org.activiti.engine.impl.bpmn.data.ItemDefinition)2 ItemInstance (org.activiti.engine.impl.bpmn.data.ItemInstance)2 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)2 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Deployment (org.activiti.engine.test.Deployment)2 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1