@Override
  public void refresh() {
    initiatorText.removeFocusListener(listener);
    formKeyText.removeFocusListener(listener);
    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      Object bo = getBusinessObject(pe);
      // the filter assured, that it is a EClass
      if (bo == null) return;

      StartEvent startEvent = ((StartEvent) bo);

      if (startEvent.getInitiator() != null) {
        initiatorText.setText(startEvent.getInitiator());
      } else {
        initiatorText.setText("");
      }

      if (startEvent.getFormKey() != null) {

        String condition = startEvent.getFormKey();
        formKeyText.setText(condition);
      } else {
        formKeyText.setText("");
      }
    }
    initiatorText.addFocusListener(listener);
    formKeyText.addFocusListener(listener);
  }
  @Deployment
  public void testGetBpmnModel() {
    ProcessDefinition processDefinition =
        repositoryService.createProcessDefinitionQuery().singleResult();

    // Some basic assertions
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
    assertNotNull(bpmnModel);
    assertEquals(1, bpmnModel.getProcesses().size());
    assertTrue(bpmnModel.getLocationMap().size() > 0);
    assertTrue(bpmnModel.getFlowLocationMap().size() > 0);

    // Test the flow
    org.activiti.bpmn.model.Process process = bpmnModel.getProcesses().get(0);
    List<StartEvent> startEvents = process.findFlowElementsOfType(StartEvent.class);
    assertEquals(1, startEvents.size());
    StartEvent startEvent = startEvents.get(0);
    assertEquals(1, startEvent.getOutgoingFlows().size());
    assertEquals(0, startEvent.getIncomingFlows().size());

    String nextElementId = startEvent.getOutgoingFlows().get(0).getTargetRef();
    UserTask userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals("First Task", userTask.getName());

    assertEquals(1, userTask.getOutgoingFlows().size());
    assertEquals(1, userTask.getIncomingFlows().size());
    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    ParallelGateway parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(2, parallelGateway.getOutgoingFlows().size());

    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
    assertEquals(1, parallelGateway.getIncomingFlows().size());
    userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals(1, userTask.getOutgoingFlows().size());

    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(1, parallelGateway.getOutgoingFlows().size());
    assertEquals(2, parallelGateway.getIncomingFlows().size());

    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
    EndEvent endEvent = (EndEvent) process.getFlowElement(nextElementId);
    assertEquals(0, endEvent.getOutgoingFlows().size());
    assertEquals(1, endEvent.getIncomingFlows().size());
  }
 private String getActivitiJobXml(String namespace, String jobName) {
   BpmnModel bpmnModel = new BpmnModel();
   Process process = new Process();
   process.setId(namespace + '.' + jobName);
   {
     StartEvent element = new StartEvent();
     element.setId("start");
     process.addFlowElement(element);
   }
   {
     EndEvent element = new EndEvent();
     element.setId("end");
     process.addFlowElement(element);
   }
   process.addFlowElement(new SequenceFlow("start", "end"));
   bpmnModel.addProcess(process);
   return getActivitiXmlFromBpmnModel(bpmnModel);
 }
Example #4
0
 public void setValues(StartEvent otherEvent) {
   super.setValues(otherEvent);
   setInitiator(otherEvent.getInitiator());
   setFormKey(otherEvent.getFormKey());
   setInterrupting(otherEvent.isInterrupting());
   formProperties = new ArrayList<FormProperty>();
   if (otherEvent.getFormProperties() != null && otherEvent.getFormProperties().size() > 0) {
     for (FormProperty property : otherEvent.getFormProperties()) {
       formProperties.add(property.clone());
     }
   }
 }
  protected void convertJsonToFormProperties(JsonNode objectNode, BaseElement element) {

    JsonNode formPropertiesNode = getProperty(PROPERTY_FORM_PROPERTIES, objectNode);
    if (formPropertiesNode != null) {
      formPropertiesNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(formPropertiesNode);
      JsonNode propertiesArray = formPropertiesNode.get("formProperties");
      if (propertiesArray != null) {
        for (JsonNode formNode : propertiesArray) {
          JsonNode formIdNode = formNode.get(PROPERTY_FORM_ID);
          if (formIdNode != null && StringUtils.isNotEmpty(formIdNode.asText())) {

            FormProperty formProperty = new FormProperty();
            formProperty.setId(formIdNode.asText());
            formProperty.setName(getValueAsString(PROPERTY_FORM_NAME, formNode));
            formProperty.setType(getValueAsString(PROPERTY_FORM_TYPE, formNode));
            formProperty.setExpression(getValueAsString(PROPERTY_FORM_EXPRESSION, formNode));
            formProperty.setVariable(getValueAsString(PROPERTY_FORM_VARIABLE, formNode));

            if ("date".equalsIgnoreCase(formProperty.getType())) {
              formProperty.setDatePattern(getValueAsString(PROPERTY_FORM_DATE_PATTERN, formNode));

            } else if ("enum".equalsIgnoreCase(formProperty.getType())) {
              JsonNode enumValuesNode = formNode.get(PROPERTY_FORM_ENUM_VALUES);
              if (enumValuesNode != null) {
                List<FormValue> formValueList = new ArrayList<FormValue>();
                for (JsonNode enumNode : enumValuesNode) {
                  if (enumNode.get(PROPERTY_FORM_ENUM_VALUES_ID) != null
                      && enumNode.get(PROPERTY_FORM_ENUM_VALUES_ID).isNull() == false
                      && enumNode.get(PROPERTY_FORM_ENUM_VALUES_NAME) != null
                      && enumNode.get(PROPERTY_FORM_ENUM_VALUES_NAME).isNull() == false) {

                    FormValue formValue = new FormValue();
                    formValue.setId(enumNode.get(PROPERTY_FORM_ENUM_VALUES_ID).asText());
                    formValue.setName(enumNode.get(PROPERTY_FORM_ENUM_VALUES_NAME).asText());
                    formValueList.add(formValue);

                  } else if (enumNode.get("value") != null
                      && enumNode.get("value").isNull() == false) {
                    FormValue formValue = new FormValue();
                    formValue.setId(enumNode.get("value").asText());
                    formValue.setName(enumNode.get("value").asText());
                    formValueList.add(formValue);
                  }
                }
                formProperty.setFormValues(formValueList);
              }
            }

            formProperty.setRequired(getValueAsBoolean(PROPERTY_FORM_REQUIRED, formNode));
            formProperty.setReadable(getValueAsBoolean(PROPERTY_FORM_READABLE, formNode));
            formProperty.setWriteable(getValueAsBoolean(PROPERTY_FORM_WRITABLE, formNode));

            if (element instanceof StartEvent) {
              ((StartEvent) element).getFormProperties().add(formProperty);
            } else if (element instanceof UserTask) {
              ((UserTask) element).getFormProperties().add(formProperty);
            }
          }
        }
      }
    }
  }
Example #6
0
 public StartEvent clone() {
   StartEvent clone = new StartEvent();
   clone.setValues(this);
   return clone;
 }