Search in sources :

Example 1 with ItemDefinition

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

the class BpmnParse method createMessages.

public void createMessages() {
    for (Message messageElement : bpmnModel.getMessages()) {
        MessageDefinition messageDefinition = new MessageDefinition(messageElement.getId(), name);
        if (StringUtils.isNotEmpty(messageElement.getItemRef())) {
            if (this.itemDefinitions.containsKey(messageElement.getItemRef())) {
                ItemDefinition itemDefinition = this.itemDefinitions.get(messageElement.getItemRef());
                messageDefinition.setItemDefinition(itemDefinition);
            }
        }
        this.messages.put(messageDefinition.getId(), messageDefinition);
    }
}
Also used : MessageDefinition(org.activiti.engine.impl.bpmn.webservice.MessageDefinition) Message(org.activiti.bpmn.model.Message) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition)

Example 2 with ItemDefinition

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

the class BpmnParse method createItemDefinitions.

protected void createItemDefinitions() {
    for (org.activiti.bpmn.model.ItemDefinition itemDefinitionElement : bpmnModel.getItemDefinitions().values()) {
        StructureDefinition structure = null;
        try {
            // it is a class
            Class<?> classStructure = ReflectUtil.loadClass(itemDefinitionElement.getStructureRef());
            structure = new ClassStructureDefinition(classStructure);
        } catch (ActivitiException e) {
            // it is a reference to a different structure
            structure = this.structures.get(itemDefinitionElement.getStructureRef());
        }
        ItemDefinition itemDefinition = new ItemDefinition(itemDefinitionElement.getId(), structure);
        if (StringUtils.isNotEmpty(itemDefinitionElement.getItemKind())) {
            itemDefinition.setItemKind(ItemKind.valueOf(itemDefinitionElement.getItemKind()));
        }
        itemDefinitions.put(itemDefinition.getId(), itemDefinition);
    }
}
Also used : ClassStructureDefinition(org.activiti.engine.impl.bpmn.data.ClassStructureDefinition) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) ClassStructureDefinition(org.activiti.engine.impl.bpmn.data.ClassStructureDefinition) ActivitiException(org.activiti.engine.ActivitiException) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition)

Example 3 with ItemDefinition

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

the class AbstractBpmnParseHandler method createIOSpecification.

protected IOSpecification createIOSpecification(BpmnParse bpmnParse, org.activiti.bpmn.model.IOSpecification specificationModel) {
    IOSpecification ioSpecification = new IOSpecification();
    for (DataSpec dataInputElement : specificationModel.getDataInputs()) {
        ItemDefinition itemDefinition = bpmnParse.getItemDefinitions().get(dataInputElement.getItemSubjectRef());
        Data dataInput = new Data(bpmnParse.getTargetNamespace() + ":" + dataInputElement.getId(), dataInputElement.getId(), itemDefinition);
        ioSpecification.addInput(dataInput);
    }
    for (DataSpec dataOutputElement : specificationModel.getDataOutputs()) {
        ItemDefinition itemDefinition = bpmnParse.getItemDefinitions().get(dataOutputElement.getItemSubjectRef());
        Data dataOutput = new Data(bpmnParse.getTargetNamespace() + ":" + dataOutputElement.getId(), dataOutputElement.getId(), itemDefinition);
        ioSpecification.addOutput(dataOutput);
    }
    for (String dataInputRef : specificationModel.getDataInputRefs()) {
        DataRef dataRef = new DataRef(dataInputRef);
        ioSpecification.addInputRef(dataRef);
    }
    for (String dataOutputRef : specificationModel.getDataOutputRefs()) {
        DataRef dataRef = new DataRef(dataOutputRef);
        ioSpecification.addOutputRef(dataRef);
    }
    return ioSpecification;
}
Also used : DataRef(org.activiti.engine.impl.bpmn.data.DataRef) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition) DataSpec(org.activiti.bpmn.model.DataSpec) Data(org.activiti.engine.impl.bpmn.data.Data)

Example 4 with ItemDefinition

use of org.activiti.engine.impl.bpmn.data.ItemDefinition 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 5 with ItemDefinition

use of org.activiti.engine.impl.bpmn.data.ItemDefinition 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)

Aggregations

ItemDefinition (org.activiti.engine.impl.bpmn.data.ItemDefinition)5 HashMap (java.util.HashMap)2 FieldBaseStructureInstance (org.activiti.engine.impl.bpmn.data.FieldBaseStructureInstance)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 DataSpec (org.activiti.bpmn.model.DataSpec)1 Message (org.activiti.bpmn.model.Message)1 ActivitiException (org.activiti.engine.ActivitiException)1 ClassStructureDefinition (org.activiti.engine.impl.bpmn.data.ClassStructureDefinition)1 Data (org.activiti.engine.impl.bpmn.data.Data)1 DataRef (org.activiti.engine.impl.bpmn.data.DataRef)1 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)1 StructureDefinition (org.activiti.engine.impl.bpmn.data.StructureDefinition)1 MessageDefinition (org.activiti.engine.impl.bpmn.webservice.MessageDefinition)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1