示例#1
0
  /**
   * Start the workflow run asynchronously.
   *
   * @param name The name of the workflow
   * @return json response containing id
   */
  @Security.Authenticated(Secured.class)
  public Result runWorkflow(String name) {
    FormDefinition form = formDefinitionForWorkflow(name);

    // Process file upload first if present in form data
    Http.MultipartFormData body = request().body().asMultipartFormData();

    for (Object obj : body.getFiles()) {
      Http.MultipartFormData.FilePart filePart = (Http.MultipartFormData.FilePart) obj;
      UserUpload userUpload = uploadFile(filePart);

      BasicField fileInputField = form.getField(filePart.getKey());
      fileInputField.setValue(userUpload);
    }

    //  Set the form definition field values from the request data
    Map<String, String[]> data = body.asFormUrlEncoded();
    for (String key : data.keySet()) {
      BasicField field = form.getField(key);
      field.setValue(data.get(key));
    }

    // Transfer form field data to workflow settings map
    Map<String, Object> settings = new HashMap<>();

    for (BasicField field : form.fields) {
      settings.put(field.name, field.value());
    }

    settings.putAll(settingsFromConfig(form));

    // Update the workflow model object and persist to the db
    Workflow workflow = Workflow.find.where().eq("name", form.name).findUnique();

    if (workflow == null) {
      workflow = new Workflow();
    }

    workflow.name = form.name;
    workflow.title = form.title;
    workflow.yamlFile = form.yamlFile;

    workflow.save();

    // Run the workflow
    ObjectNode response = runYamlWorkflow(form.yamlFile, workflow, settings);

    return redirect(routes.Application.index());
  }
示例#2
0
 public FieldBuilder validator(FieldValidator validator) {
   field.validator = validator;
   return this;
 }
示例#3
0
 public FieldBuilder secret(boolean secret) {
   field.secret = secret;
   return this;
 }
示例#4
0
 public FieldBuilder values(List<Entry> values) {
   field.values = values;
   return this;
 }
示例#5
0
 public FieldBuilder hidden(boolean hidden) {
   field.hidden = hidden;
   return this;
 }
示例#6
0
 public FieldBuilder required(boolean required) {
   field.required = required;
   return this;
 }
示例#7
0
 public FieldBuilder fieldType(FieldType fieldType) {
   field.fieldType = fieldType;
   return this;
 }
示例#8
0
 public FieldBuilder placeholder(String placeholder) {
   field.placeholder = placeholder;
   return this;
 }
示例#9
0
 public FieldBuilder label(String label) {
   field.label = label;
   return this;
 }