public void updatePastJobs() {
    GregorianCalendar currentDate = new GregorianCalendar();
    long currentTime = currentDate.getTimeInMillis() + 2670040009l;

    for (Job job : myJobList.getJobList()) {
      if (currentTime > job.getStartDate().getTimeInMillis()) {
        job.setInPast(true);
      }
    }
  }
  /**
   * Find the job associated with the jobID; null if one does not exist.
   *
   * @param theJobID is the jobs ID
   */
  private Job findJob(int theJobID) {
    // Get an actual reference to the JobList.
    List<Job> editableJobList = myJobList.getJobList();

    Job returnJob = null;

    // Search for the Job in the JobList.
    for (int i = 0; i < editableJobList.size(); i++) {
      if (editableJobList.get(i).getJobID() == theJobID) {
        returnJob = editableJobList.get(i);
      }
    }
    return returnJob;
  }
  public static void generateXML(ArrayList<SMJob> l) throws JAXBException {

    // JAXBContext context = JAXBContext.newInstance("generated");
    JobList jl = (JobList) new JobList();
    jl.addJobs(l);
    JAXBContext context =
        JAXBContext.newInstance(new Class[] {com.fifthfloor.smreader.JobList.class});
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
    // SMJob element = (SMJob) l.get(0);
    FileOutputStream fos = null;
    try {
      fos = new FileOutputStream("test.xml");
    } catch (FileNotFoundException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    marshaller.marshal(jl, fos);

    // FTPTest ftp = new FTPTest();
    // ftp.setUser("*****@*****.**");
    // boolean b = ftp.connect();
    // System.out.println("connection is "+b);
    // ftp.uploadFile("test.xml");
    FTPClient client = new FTPClient();
    try {
      client.connect("ftp.andrewscarpetcleaning.com");
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (FTPIllegalReplyException e) {
      e.printStackTrace();
    } catch (FTPException e) {
      e.printStackTrace();
    }
    try {
      client.login("*****@*****.**", "4uypxNCdQz7W");
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (FTPIllegalReplyException e) {
      e.printStackTrace();
    } catch (FTPException e) {
      e.printStackTrace();
    }
    try {
      client.changeDirectory("/public_html/");
      client.upload(new java.io.File("test.xml"));
      System.out.println("Uploaded file test.xml");
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (FTPIllegalReplyException e) {
      e.printStackTrace();
    } catch (FTPException e) {
      e.printStackTrace();
    } catch (FTPDataTransferException e) {
      e.printStackTrace();
    } catch (FTPAbortedException e) {
      e.printStackTrace();
    }
  }
 /**
  * Adds the information for the presentation to a build tree.
  *
  * @param tabLevel the tab level that should be used
  * @param buildTree the build tree to which the info should be added
  */
 public void createBuildTree(int tabLevel, BuildTree buildTree) {
   super.createBuildTree(tabLevel, buildTree);
   subJobs.createBuildTree(tabLevel + 1, buildTree);
 }
 /**
  * Adds a regular job as a subjob
  *
  * @param regularJobName the name of the subjob
  */
 public void addRegularJob(String regularJobName) {
   subJobs.addRegularJob(regularJobName);
 }
 /**
  * Adds a flow job as a sub job
  *
  * @param flowJobName the name of the subjob
  */
 public void addFlowJob(String flowJobName) {
   subJobs.addFlowJob(flowJobName);
 }
  /**
   * Receive a job and add it to the master JobList if its data is valid.
   *
   * @param theJob the Job to potentially add to Schedule's List of Jobs.
   * @return true if theJob was added; false otherwise.
   */
  public boolean receiveJob(Job theJob) throws IllegalArgumentException {

    /*
     * We subject both the Job and JobList to a wide variety of tests.
     * If all of the tests are passed, then we add the Job to the JobList.
     */
    boolean addFlag = true;

    if (theJob == null) addFlag = false;

    // Check to ensure that the total number of pending jobs is less than 30.
    else if (!(new BusinessRule1().test(myJobList))) {
      throw new IllegalArgumentException(
          "Sorry, but the limit of 30 pending jobs has already been reached.");
    }

    /*
     * Check to ensure that the total number of Jobs for the week that this Job is to occur is
     * less than 5.
     * A week is defined as 3 days before a Job's Start Date and 3 days after its End Date.
     */
    else if (!(new BusinessRule2().test(theJob, myJobList))) {
      throw new IllegalArgumentException(
          "Sorry, but the limit of 5 jobs has already been reached for the week that "
              + "this job was scheduled.");
    }

    // Check that the Job is not scheduled to last longer than two days.
    else if (!(new BusinessRule4().test(theJob))) {
      throw new IllegalArgumentException("Sorry, but a job cannot last any longer than two days.");
    }

    // Check that a Job is scheduled to begin after the current date.
    else if (!(new BusinessRule5().pastTest(theJob))) {
      throw new IllegalArgumentException(
          "Sorry but the date you entered for this " + "job has already passed.");
    }

    // Check that a Job is scheduled to begin within the next three months.
    else if (!(new BusinessRule5().futureTest(theJob))) {
      throw new IllegalArgumentException(
          "Sorry but the date you entered is too far "
              + "into the future. \nAll jobs must be scheduled within the next 3 months.");
    }

    // Check that the Start Date and End Date are not swapped.
    else if (theJob.getStartDate().after(theJob.getEndDate())) {
      throw new IllegalArgumentException(
          "Sorry, but the Start Date must come before or on the same date as the End Date.");
    }

    // Check that the Job ID is valid.
    else if (theJob.getJobID() < 0 || theJob.getJobID() > Job.MAX_NUM_JOBS) {
      throw new IllegalArgumentException("Error: Invalid Job ID. Please logout and try again.");
    }

    // Check that the Volunteer List is not null.
    else if (theJob.getVolunteerList() == null) {
      throw new IllegalArgumentException(
          "Error: Null Volunteer List. Please logout and try again.");
    }

    // Check that the Volunteer List is empty.
    else if (!theJob.getVolunteerList().isEmpty()) {
      throw new IllegalArgumentException(
          "Error: Non-empty Volunteer List. Please logout and try again.");
    }

    // Check that there is at least one slot available for a Volunteer to sign up for.
    else if (!theJob.hasLightRoom() && !theJob.hasMediumRoom() && !theJob.hasHeavyRoom()) {
      throw new IllegalArgumentException(
          "Sorry, but a slot in at least one Volunteer Grade must be available.");
    }

    // Check that none of the slots are set to negative numbers.
    else if (theJob.getLightCurrent() > theJob.getLightMax()
        || theJob.getMediumCurrent() > theJob.getMediumMax()
        || theJob.getHeavyCurrent() > theJob.getHeavyMax()) {
      throw new IllegalArgumentException(
          "Sorry, but the number of slots for a Volunteer Grade cannot be negative.");
    }

    // Check that the Park for the Job is not null.
    else if (theJob.getPark() == null) {
      throw new IllegalArgumentException("Error: Null Park. Please logout and try again.");
    }

    // Check that the ParkManager for the Job is not null.
    else if (theJob.getManager() == null) {
      throw new IllegalArgumentException("Error: Null ParkManager. Please logout and try again.");
    }

    // If all tests passed, then we add the Job to the Schedule.
    if (addFlag) {
      // To get the master job list which is editable
      List<Job> editableJobList = myJobList.getJobList();
      editableJobList.add(theJob); // add valid job to list
    } else {
      // If we somehow got here without throwing an exception, and the Job is not valid, then we
      // throw a general exception.
      throw new IllegalArgumentException(
          "Error: Job data is invalid for unknown reasons. Please logout and try again.");
    }

    return addFlag;
  }
 /** Return the JobList. */
 public List<Job> getJobList() {
   return myJobList.getJobList();
 }