Example #1
0
  public JobItem resumeJob(JobItem item) {
    // String rootPathForDownload = getServletContext().getRealPath(File.separator);
    String statusDirectory = suspendConstant;

    String fileName = item.getJobName();
    String projectName = item.getProjectName();
    String userName = item.getUsername();

    String rootPath =
        path
            + userName
            + File.separator
            + projectConstant
            + File.separator
            + projectName
            + File.separator;
    // rootPathForDownload = rootPathForDownload + path1 + File.separator + userName +
    // File.separator + projectConstant + File.separator + projectName + File.separator;
    String pathForDownload =
        path1
            + File.separator
            + userName
            + File.separator
            + projectConstant
            + File.separator
            + projectName
            + File.separator;

    ResumeJobsImpl resume = new ResumeJobsImpl();
    Map<Integer, String[]> outputFiles = new HashMap<Integer, String[]>();
    // if(resume.checkAndMoveFile(statusDirectory, fileName, rootPath, rootPathForDownload))
    if (resume.checkAndMoveFile(statusDirectory, fileName, rootPath)) {
      String filePath = rootPath + queueConstant + File.separator + fileName;
      String newPath = rootPath + constants.getString("Figures") + File.separator;
      String[] fileData = new String[3];
      fileData[0] = fileName;
      fileData[1] = pathForDownload + queueConstant + File.separator + fileName;
      fileData[2] = filePath;
      System.out.println("Path to download: " + fileData[1] + " " + pathForDownload);
      outputFiles.put(1, fileData);

      GetJobDetails jobDetails = new GetJobDetails();
      outputFiles = jobDetails.getOutputFiles(newPath, fileName, outputFiles, pathForDownload);
      item.setStatus("Queued");
      item.setOutputFiles(outputFiles);
    }
    System.out.println(
        "Output files after resume: "
            + item.getOutputFiles().size()
            + " Status: "
            + item.getStatus()
            + " Job: "
            + item);
    return item;
  }
Example #2
0
  public List<JobItem> suspendJobs(
      ArrayList<JobItem> jobs,
      int start,
      int length,
      boolean ascend,
      String status,
      int from,
      int tab) {
    List<JobItem> jobList = null;
    int count = jobs.size();
    String fileName;
    String projectName = null;
    String userName = null;
    System.out.println("Status: " + status);

    String[] statusDirectory = new String[2];
    statusDirectory[0] = "JobIn";
    statusDirectory[1] = "JobRunning";

    for (int index = 0; index < count; index++) {
      JobItem item = jobs.get(index);
      fileName = item.getJobName();
      projectName = item.getProjectName();
      userName = item.getUsername();

      String rootPath =
          path
              + userName
              + File.separator
              + projectConstant
              + File.separator
              + projectName
              + File.separator;

      for (int i = 0; i < 2; i++) {
        if (checkAndMoveFile(statusDirectory[i], fileName, rootPath)) {
          break;
        }
      }
    }
    if (from == 0) {
      GetPageImpl getJobs = new GetPageImpl();
      jobList = getJobs.getPage(start, start + length, ascend, status, userName, projectName, tab);
    }
    return jobList;
  }