Ejemplo n.º 1
0
 private static void abortProject(Vector<String> vec) {
   if (vec.size() != 1) {
     System.out.println(
         "USAGE: 'abortProject' takes exactly 1 argument. " + vec.size() + " given.");
   } else {
     if (!Repl.projects.containsKey(vec.elementAt(0))) {
       System.out.println(vec.elementAt(0) + " is not a valid project!");
     } else {
       ProjectImpl project = Repl.projects.get(vec.elementAt(0));
       Repl.logger.finer(
           "trying to abort project " + project.getName() + " at " + Helpers.staticTimeNow());
       if (!Repl.completedProjectsSet.contains(project)) {
         // the project hasn't been completed yet.
         if (Repl.executingProjects.containsKey(project)) {
           // someone is working on this project
           Task task = project.getNextTask();
           project.abortProject();
           task.abortTask();
         } else { // the project is pending
           Repl.managerBoard
               .getProjectBox(project.getNextManagerSpecializtion())
               .getProject(project);
         }
       } else {
       }
     }
   }
   Repl.nextCommand(Repl.commands, Repl.SC);
 }
Ejemplo n.º 2
0
 private static void departmentManager(Vector<String> vec) {
   if (vec.size() != 1) {
     System.out.println(
         "USAGE: 'departmentManager' takes exactly 1 argument. " + vec.size() + " given.");
   } else {
     if (!Repl.managers.containsKey(vec.elementAt(0))) {
       System.out.println(vec.elementAt(0) + " is not a valid manager!");
     } else {
       Manager manager = Repl.managers.get(vec.elementAt(0));
       Project currentProject = manager.getCurrentProject();
       String projectName;
       if (currentProject == null) {
         System.out.println("Current Project: None.");
         Repl.nextCommand(Repl.commands, Repl.SC);
         return;
       }
       projectName = currentProject.getName();
       System.out.println("Current Project: " + projectName + ".");
       Task curTask = currentProject.getNextTask();
       System.out.println("Current Task Info: ");
       System.out.print("\tworkers: ");
       for (Worker w : curTask.getWorkers()) {
         System.out.print(w.getName() + " ");
       }
       System.out.println(
           "\n\tAmount of work still needed: " + curTask.getHoursStillNeeded() + " hours.");
       System.out.println("\tTotal Work for this Task: " + curTask.getSize() + " hours.");
     }
   }
   Repl.nextCommand(Repl.commands, Repl.SC);
 }
Ejemplo n.º 3
0
 private static String taskArr2Str(List<Task> completedTasks) {
   if (completedTasks.size() == 0) {
     return "None.";
   } else {
     String ret = "";
     for (Task task : completedTasks) {
       ret += task.getName() + ", ";
     }
     return ret.substring(0, ret.length() - 1); // remove the last comma
     // (,)
   }
 }
Ejemplo n.º 4
0
 private static void project(Vector<String> vec) {
   if (vec.size() != 1) {
     System.out.println("USAGE: 'project' takes exactly 1 argument. " + vec.size() + " given.");
   } else {
     if (!Repl.projects.containsKey(vec.elementAt(0))) {
       System.out.println(vec.elementAt(0) + " is not a valid project!");
     } else {
       ProjectImpl project = Repl.projects.get(vec.elementAt(0));
       List<Task> completed = project.getCompletedTasks();
       System.out.println(
           "Current Task: " + project.getNextTask().getName() + "\nCompleted Tasks:");
       for (Task t : completed) {
         System.out.print(t.getName() + ": ");
         System.out.println("\tpublisher: " + t.getManagerName());
         System.out.print("\tworkers: ");
         for (Worker w : t.getWorkers()) {
           System.out.print(w.getName() + " ");
         }
         System.out.println("\n\tresources used: ");
         for (Resource r : t.getNeededResources()) {
           System.out.print(r.getName() + " ");
         }
         System.out.println("\n\twork needed: " + t.getSize() + " hours.");
       }
     }
   }
   Repl.nextCommand(Repl.commands, Repl.SC);
 }