Ejemplo n.º 1
0
 public FormInstance createFormInstance(ScopeInstanceImpl scopeInstance) {
   FormInstance formInstance = new FormInstance(form);
   if (formFieldBindings != null) {
     for (String fieldId : formFieldBindings.keySet()) {
       FormFieldBinding formFieldBinding = formFieldBindings.get(fieldId);
       Object value = scopeInstance.getValue(formFieldBinding.binding);
       formInstance.value(fieldId, value);
     }
   }
   return formInstance;
 }
Ejemplo n.º 2
0
 public void applyFormInstanceData(FormInstance formInstance, ScopeInstanceImpl scopeInstance) {
   if (formInstance != null && formInstance.getFields() != null) {
     for (FormInstanceField field : formInstance.getFields()) {
       Object value = field.getValue();
       FormFieldBinding formFieldBinding = formFieldBindings.get(field.getId());
       if (isWritable(formFieldBinding)) {
         String variableId = formFieldBinding.binding.expression.variableId;
         scopeInstance.setVariableValue(variableId, value);
       }
     }
   }
 }
Ejemplo n.º 3
0
 public void deserializeFormInstance(FormInstance formInstance) {
   if (formInstance == null) {
     return;
   }
   if (formInstance.getFields() != null) {
     for (FormInstanceField field : formInstance.getFields()) {
       String fieldId = field.getId();
       FormFieldBinding formFieldBinding = formFieldBindings.get(fieldId);
       if (formFieldBinding != null) {
         formFieldBinding.deserializeFormField(field);
       } else {
         log.debug("Ignoring undefined form field '" + fieldId + "'");
       }
     }
   }
 }
Ejemplo n.º 4
0
  @Test
  public void testExclusiveGateway() {
    Workflow workflow =
        new Workflow()
            .variable("Conclusion", new TextType())
            .variable("Decision", new ChoiceType().option("Approve").option("Reject"))
            .activity("Start", new StartEvent().transitionToNext())
            .activity(
                "Submit conclusion",
                new UserTask().form(new Form().field("Conclusion")).transitionToNext())
            .activity(
                "Approve conclusion",
                new UserTask()
                    .form(
                        new Form()
                            .field(new FormField().binding("Conclusion").readOnly())
                            .field(
                                new FormField()
                                    .binding("Decision")
                                    .required()
                                    .property("asButtons", true)))
                    .transitionToNext())
            .activity(
                "Approved?",
                new ExclusiveGateway()
                    .transitionWithConditionTo("Conclusion == 'Reject'", "Submit conclusion")
                    .transitionWithConditionTo("Conclusion == 'Approve'", "End"))
            .activity("End", new EndEvent());

    deploy(workflow).checkNoErrors();

    WorkflowInstance workflowInstance = start(workflow);

    Task task = getTaskByActivityId("Submit conclusion", workflowInstance);
    FormInstance formInstance = task.getFormInstance();
    assertNotNull(formInstance);

    formInstance.value("Conclusion", "Approvals suck");
    taskService.saveFormInstance(task.getId(), formInstance);
    taskService.completeTask(task.getId());
  }