예제 #1
0
  public String runExpandedTemplate(
      String origtplid,
      String templatejson,
      String consjson,
      String seedjson,
      String seedconsjson,
      ServletContext context) {
    Gson json = JsonHandler.createTemplateGson();
    Template xtpl = JsonHandler.getTemplateFromJSON(json, templatejson, consjson);
    Template seedtpl = JsonHandler.getTemplateFromJSON(json, seedjson, seedconsjson);

    String requestid = UuidGen.generateAUuid("");
    WorkflowGenerationAPI wg =
        new WorkflowGenerationKB(
            props,
            DataFactory.getReasoningAPI(props),
            ComponentFactory.getReasoningAPI(props),
            ResourceFactory.getAPI(props),
            requestid);
    ExecutionPlan plan = wg.getExecutionPlan(xtpl);

    if (plan != null) {
      synchronized (WriteLock.Lock) {
        // Save the expanded template, seeded template and plan
        if (!xtpl.save()) return "";
        if (!seedtpl.save()) return "";
        plan.save();
      }
      RuntimePlan rplan = new RuntimePlan(plan);
      rplan.setExpandedTemplateID(xtpl.getID());
      rplan.setOriginalTemplateID(origtplid);
      rplan.setSeededTemplateId(seedtpl.getID());
      this.runExecutionPlan(rplan, context);
      return rplan.getID();
    }
    return "";
  }