Beispiel #1
0
  public void execute() throws Exception {
    getNewCount();
    File executable = new File(getEXEPath());
    if (!executable.exists())
      throw new FileNotFoundException("executable file does not exist! " + executable);
    workingDir = getWorkingDirectory(executable);
    initExecution();

    instruction = getInstructionFileName(workingDir);
    output = getOutputFileName(workingDir);
    createInstructionFile(instruction);
    // Profiler pofiler = new Profiler();
    // profiler.start("exec-ilink-search " + xmlFileName, "exec-ilink-search " + xmlFileName);
    ExecShell shell = new ExecShell();
    shell.setExecutable(executable.getAbsolutePath());
    shell.setWorkingDirectory(workingDir);
    setArguments(shell);
    shell.addCommandLineArgument(executable.getParent());
    shell.execute();

    // profiler.start("exec-ilink-search " + xmlFileName, "shell-wait-for");
    exitCode = shell.timeout(timeout);
    // profiler.stop("exec-ilink-search " + xmlFileName, "shell-wait-for");
    // instructionFile.delete();
    handleResponse(output);
    finishExecution();
    if (zws.Server.debugMode()) return;
    // cleanup
    File[] contents = workingDir.listFiles();
    for (int idx = 0; idx < contents.length; contents[idx++].delete()) ;
    workingDir.delete();
  }
  /** Writes the data provenance into xml formatted file */
  public void writeXML() throws IOException {
    FileWriter fw;
    if (file.exists() == true) {
      file.delete();
      file = new File(fileDir + File.separator + fileName);
    }

    try {

      fw = new FileWriter(file);
      bw = new BufferedWriter(fw);

      Vector<XMLAttributes> atVector = new Vector<XMLAttributes>();

      bw.write(XML_HEADER);
      bw.newLine();
      bw.write(DATA_PROVENANCE);
      bw.newLine();

      openTag("provenance", true);

      int numEntries = pHolder.size();

      ProvenanceEntry entry;

      for (int i = 0; i < numEntries; i++) {
        entry = pHolder.elementAt(i);

        openTag("processStep", true);

        atVector.add(new XMLAttributes("version", entry.getMipavVersion()));
        this.closedTag("program", entry.getProgramName(), atVector);

        atVector.add(new XMLAttributes("inputs", entry.getProgramInputs()));
        closedTag("programArguments", entry.getAction(), atVector);

        closedTag("timeStamp", entry.getTimeStamp());

        closedTag("user", entry.getUser());

        closedTag("hostName", entry.getHostName());

        closedTag("architecture", entry.getArchitecture());

        atVector.add(new XMLAttributes("version", entry.getPlatformVersion()));
        closedTag("platform", entry.getPlatform(), atVector);

        atVector.add(new XMLAttributes("version", entry.getJavaVersion()));
        closedTag("compiler", "java", atVector);

        openTag("processStep", false);
      }

      openTag("provenance", false);
      bw.close();
    } catch (Exception e) {
      System.err.println("CAUGHT EXCEPTION WITHIN writeXML() of FileDataProvenance");
      e.printStackTrace();
    }
  }
Beispiel #3
0
  /**
   * EPML2PNML
   *
   * @param args String[]
   */
  private static void EPML2PNML(String[] args) {
    if (args.length != 2) {
      System.out.println("���ṩEPML�ļ�·����PNML���Ŀ¼!");
      System.exit(-1);
    }
    epmlImport epml = new epmlImport();
    // load the single epml file
    String filename = args[0];
    try {
      EPCResult epcRes = (EPCResult) epml.importFile(new FileInputStream(filename));
      // convert all epc models to pnml files
      ArrayList<ConfigurableEPC> alEPCs = epcRes.getAllEPCs();
      PnmlExport export = new PnmlExport();
      for (ConfigurableEPC epc : alEPCs) {
        String id = epc.getIdentifier();
        if (id.equals("1An_klol")
            || id.equals("1An_l1y8")
            || id.equals("1Ex_dzq9")
            || id.equals("1Ex_e6dx")
            || id.equals("1Ku_9soy")
            || id.equals("1Ku_a4cg")
            || id.equals("1Or_lojl")
            || id.equals("1Pr_d1ur")
            || id.equals("1Pr_djki")
            || id.equals("1Pr_dkfa")
            || id.equals("1Pr_dl73")
            || id.equals("1Ve_musj")
            || id.equals("1Ve_mvwz")) continue;
        // save pnml files to the same folder
        File outFile = new File(args[1] + "/" + id + ".pnml");
        if (outFile.exists()) continue;
        FileOutputStream fos = new FileOutputStream(outFile);
        PetriNet petri = AMLtoPNML.convert(epc);
        try {
          export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos);
        } catch (Exception ex1) {
          ex1.printStackTrace(System.out);
        }
      }
    } catch (IOException ex) {
      ex.printStackTrace(System.out);
    }

    System.out.println("EPML Conversion Done");
  }
Beispiel #4
0
 private static InputSource getConfigSource(Class pAppClass) throws DataNotFoundException {
   URL resource = pAppClass.getResource(CONFIG_FILE_NAME);
   String resourceFileName = resource.toExternalForm();
   File resourceFile = new File(resourceFileName);
   InputStream configResourceStream = pAppClass.getResourceAsStream(CONFIG_FILE_NAME);
   if (null == configResourceStream) {
     throw new DataNotFoundException(
         "unable to find XML configuration file resource: "
             + CONFIG_FILE_NAME
             + " for class: "
             + pAppClass.getName());
   }
   InputSource inputSource = new InputSource(configResourceStream);
   if (!resourceFile.exists()) {
     inputSource.setSystemId(resourceFileName);
   }
   return (inputSource);
 }
Beispiel #5
0
  public static AppConfig get(Class pAppClass, String pAppDir)
      throws DataNotFoundException, InvalidInputException, FileNotFoundException {

    AppConfig appConfig = null;
    if (null == pAppDir) {
      // we don't know where we are installed, so punt and look for
      // the config file as a class resource:
      appConfig = new AppConfig(pAppClass);
    } else {
      File appDirFile = new File(pAppDir);
      if (!appDirFile.exists()) {
        throw new DataNotFoundException("could not find application directory: " + pAppDir);
      }
      String configFileName =
          appDirFile.getAbsolutePath() + "/config/" + AppConfig.CONFIG_FILE_NAME;
      appConfig = new AppConfig(new File(configFileName));
    }
    return appConfig;
  }
Beispiel #6
0
 private void execExtractor() throws Exception {
   ExecShell shell = new ExecShell();
   File f = new File(Config.getProperty(Config.EXE_ILINK_SEARCH));
   if (!f.exists())
     throw new Exception(
         "executable file does not exist! " + Config.getProperty(Config.EXE_ILINK_SEARCH));
   shell.setExecutable(f.getAbsolutePath());
   shell.setWorkingDirectory(f.getParent());
   shell.addCommandLineArgument(criteria);
   shell.addCommandLineArgument(String.valueOf(maxCount));
   shell.addCommandLineArgument(releaseLevel);
   shell.addCommandLineArgument(metadataSpec);
   shell.addCommandLineArgument(username);
   shell.addCommandLineArgument(password);
   shell.addCommandLineArgument(outputFile);
   shell.addCommandLineArgument(proiTkEnv);
   shell.execute();
   exitCode = shell.waitFor();
 }
Beispiel #7
0
 private File getWorkingDirectory(File f) {
   try {
     File workingDir =
         new File(
             Properties.get(Names.WORKING_DIR)
                 + Names.PATH_SEPARATOR
                 + getOpType()
                 + Names.PATH_SEPARATOR
                 + "work"
                 + getNewCount());
     if (!workingDir.exists()) workingDir.mkdirs();
     FileUtil.deleteContents(workingDir);
     return workingDir;
   } catch (Exception ignore) {
     // ++ notify of error - maybe out of disk space
     ignore.printStackTrace();
     return null;
   }
 }