示例#1
0
  @Security.Authenticated
  public Result deletePackage(String name) {
    boolean success = ConfigManager.getInstance().deletePacakge(name);

    if (success) {
      flash("message", "Successfully deleted package " + name);
    } else {
      flash("error", "Unable to delete package " + name);
    }
    return redirect(routes.Workflows.deploy());
  }
示例#2
0
  @Security.Authenticated(Secured.class)
  public Result deploy() {
    Http.MultipartFormData body = request().body().asMultipartFormData();
    Http.MultipartFormData.FilePart filePart = body.getFile("filename");

    if (filePart != null) {
      ConfigManager configManager = ConfigManager.getInstance();
      try {
        configManager.unpack((File) filePart.getFile());
      } catch (Exception e) {
        flash("error", "Could not verify package.");
        return redirect(routes.Workflows.uploadWorkflow());
      }

      flash("message", "Packages zip file was successfully deployed");
      return redirect(routes.Workflows.uploadWorkflow());
    } else {
      flash("error", "Missing file");
      return badRequest();
    }
  }
示例#3
0
  @Security.Authenticated(Secured.class)
  public Result uploadWorkflow() {
    List<PackageData> packages = ConfigManager.getInstance().listPackages();

    return ok(deploy.render(packages));
  }
示例#4
0
  /**
   * Utility method loads all of the workflow form definitions from yaml files contained in the
   * workflow directory.
   *
   * @return
   */
  public static List<FormDefinition> loadWorkflowFormDefinitions() {
    //        List<FormDefinition> formDefs = new ArrayList<>();
    //
    //        URL path = Play.application().classloader().getResource(WORKFLOWS_PATH);
    //        try {
    //            File dir = new File(path.toURI());
    //
    //            File[] workflows = dir.listFiles(new FilenameFilter() {
    //                public boolean accept(File dir, String name) {
    //                    return name.toLowerCase().endsWith(".yaml");
    //                }
    //            });
    //
    //            for (File file : workflows) {
    //                formDefs.add(loadFormDefinition(file.getAbsolutePath()));
    //            }
    //        } catch (URISyntaxException e) { /* Should not occur */ }

    List<FormDefinition> formDefs = new ArrayList<>();

    Collection<config.WorkflowConfig> workflows = ConfigManager.getInstance().getWorkflowConfigs();

    for (config.WorkflowConfig workflow : workflows) {
      FormDefinition formDef = new FormDefinition();
      formDef.name = workflow.getName();
      formDef.title = workflow.getTitle();
      formDef.yamlFile = workflow.getYaml();
      formDef.documentation = workflow.getDocumentation();
      formDef.instructions = workflow.getInstructions();
      formDef.summary = workflow.getSummary();

      for (ParameterConfig parameter : workflow.getParameters()) {
        if (parameter.isTyped()) {
          String type = parameter.getType();

          switch (type) {
            case "text":
              TextField textField = new TextField();
              textField.name = parameter.getName();
              textField.label = parameter.getLabel();
              textField.tooltip = parameter.getDescription();
              formDef.addField(textField);
              break;
            case "select":
              SelectField selectField = new SelectField();
              selectField.name = parameter.getName();
              selectField.label = parameter.getLabel();
              selectField.options = parameter.getOptions();
              selectField.tooltip = parameter.getDescription();
              formDef.addField(selectField);
              break;
            case "upload":
              FileInput fileInput = new FileInput();
              fileInput.name = parameter.getName();
              fileInput.label = parameter.getLabel();
              fileInput.tooltip = parameter.getDescription();
              formDef.addField(fileInput);
              break;
          }
        }
      }

      formDefs.add(formDef);
    }
    return formDefs;
  }