/** * 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()); }
public FieldBuilder validator(FieldValidator validator) { field.validator = validator; return this; }
public FieldBuilder secret(boolean secret) { field.secret = secret; return this; }
public FieldBuilder values(List<Entry> values) { field.values = values; return this; }
public FieldBuilder hidden(boolean hidden) { field.hidden = hidden; return this; }
public FieldBuilder required(boolean required) { field.required = required; return this; }
public FieldBuilder fieldType(FieldType fieldType) { field.fieldType = fieldType; return this; }
public FieldBuilder placeholder(String placeholder) { field.placeholder = placeholder; return this; }
public FieldBuilder label(String label) { field.label = label; return this; }