Package gri.gridp.modules

Examples of gri.gridp.modules.Function


    }

  }

  public Function readFunction(Element element) throws IOException {
    Function function = new Function();

    String id = element.getAttributeValue("id");
    if (id == null)
      throw new InvalidModuleException("Function definition missing required 'id' attribute");
    function.setId(id);

    List children = element.getChildren();
    for (int i=0; i<children.size(); i++) {
      Element child = (Element)children.get(i);
      String name = child.getName().toLowerCase();

      if (name.equals("info"))
        function.setInfo(infoSerializer.readFunctionInfo(child));

      else if (name.equals("parameters"))
        function.setParameters(paramListSerializer.readList(child));

      else if (name.equals("outputs")) {
        List outputs = new ListSerializer(outputSerializer, "output").readList(child);
        function.setOutputs(outputs);
      }

      else if (name.equals("script")) {
        Script script = scriptSerializer.readScript(child);
        if (script != null)
          function.addScript(script);
      }

    }

    // validate (set function title to id if absent):
    if (function.getInfo() == null)
      function.setInfo(new FunctionInfo());
    //if (function.getInfo().getTitle() == null)
    //    function.getInfo().setTitle(function.getId());

    return function;
  }
View Full Code Here


            new FunctionSerializer(
                module.getParameterMap(), module.getOutputMap()),
        "function");
        List functions = serializer.readList(child);
        for (int functionIndex=0; functionIndex<functions.size(); functionIndex++) {
          Function function = (Function)functions.get(functionIndex);   
          module.addFunction(function);
        }
      }

      /*
      else if (name.equals("function")) {
    Function f = new FunctionSerializer(module.getParameterMap()).readFunction(elem);
    if (f != null)
        module.addFunction(f);
      }*/

    }

    //validate:
    if (module.getModuleInfo() == null)
      module.setModuleInfo(new ModuleInfo("unknown program"));

    //name functions:
    List functions = module.getFunctionList();
    Function func;
    for (int i=0; i<functions.size(); i++) {
      func = (Function)functions.get(i);
      if (func.getInfo().getTitle() == null) {
        String suffix = (i == 0) ?
            "" : " (" + String.valueOf(i+1) + ")";

        func.getInfo().setTitle(module.getModuleInfo().getTitle() + suffix);
      }
    }

    return module;
  }
View Full Code Here

      p.setParameterType("string");

      gri.gridp.modules.Script script = new gri.gridp.modules.Script();
      script.setText("myprogram $param");

      Function f = new Function();
      f.addParameter(p);
      f.addScript(script);

      GridpScriptAssistant assist = new GridpScriptAssistant(f, new File("."));
      Map inputs = new HashMap();
      inputs.put("param", "value");
      String s = assist.prepareScript(inputs);
View Full Code Here

    for (int i=0; i<moduleIds.length; i++) {
      String moduleId = moduleIds[i];
      Module module = moduleManager.getModule(moduleId);

      List functions = module.getFunctionList();
      Function function;
      for (int j=0; j<functions.size(); j++) {
        function = (Function)functions.get(j);

        String taskName = createTaskName(moduleId, function.getId());
        taskNames.add(taskName);
      }
    }

    return (String [])taskNames.toArray(new String [] {});
View Full Code Here

   */
  public ModuleFunction getModuleFunction(String taskName) {
    String [] parts = splitTaskName(taskName);

    Module module = moduleManager.getModule(parts[0]);
    Function function = module.getFunction(parts[1]);

    return new ModuleFunction(module, function);
  }
View Full Code Here

TOP

Related Classes of gri.gridp.modules.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.