Package gri.gridp.modules

Examples of gri.gridp.modules.Module


      elem.addContent(functionsElem);
    }
  }

  public Module readModule(Element element) throws IOException {
    Module module = new Module();

    String id = element.getAttributeValue("id");
    if (id != null)
      module.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")) {
        ModuleInfo info = modInfoSerializer.readModuleInfo(child);
        if (info != null)
          module.setModuleInfo(info);
      }

      else if (name.equals("parameters")) {
        List parameters = paramSerializer.readList(child);
        for (int j = 0; j < parameters.size(); j++) {
          Parameter param = (Parameter)parameters.get(j);
          module.addParameter(param);
        }
      }

      else if (name.equals("outputs")) {
        List outputs = new ListSerializer(outputSerializer, "output").readList(child);
        for (int j=0; j<outputs.size(); j++)
          module.addOutput((Output)outputs.get(j));
      }

      else if (name.equals("functions")) {
        ListSerializer serializer = new ListSerializer(
            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


      //String file = "C:\\Program Files\\GRI\\JServer\\modules\\echo.xml";

      String dir = "C:\\Documents and Settings\\dan.rogers\\Desktop\\Gridp\\Module Collection";
      File file = new File(dir, "OpenEye\\eon.xml");

      Module mod = new test().parseFromFile(file);
      System.out.println(mod.toString());

      File file2 = new File(dir, "OpenEye\\test.xml");
      new test().write(mod, file2);
    }
    catch(Exception e) {
View Full Code Here

   * Returns the Module that corresponds with the given name.  This
   * will be obtained from cache if available, or created and cached
   * at this time.
   */
  public Module getModule(String name) {
    Module module = (Module)this.moduleCache.get(name);
    if (module == null) {
      try {
        module = createModule(name);
        this.moduleCache.put(name, module);
      }
View Full Code Here

    }

    //ModuleParser parser = new ModuleParser();
    ModuleSerializer serializer = new ModuleSerializer();
   
    Module module;
    try {
      //module = parser.parseFromFile(moduleFile);
      module = (Module) IO.read(moduleFile, serializer);
    }
    catch(Exception e) {
View Full Code Here

    String xml = output.outputString(doc);
    cachedXML.put(name, xml);

    // return module:       
    ModuleParser parser = new ModuleParser();
    Module module;
    try {
      module = parser.parseFromFile(moduleFile);
    }
    catch(Exception e) {
      logger.error("Error loading AppXML: " + moduleFile.getAbsolutePath(), e);
View Full Code Here

    in.close();

    System.out.println("Module");
    System.out.println("------------------------------");

    Module module = manager.getModule(moduleName);
    System.out.println(module.toString());
  }
View Full Code Here

    String [] moduleIds = moduleManager.listModules();
    List taskNames = new ArrayList();

    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());
View Full Code Here

   * with the Module and Function for the indicated task.
   */
  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.Module

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.