Beispiel #1
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);
 }
Beispiel #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);
 }
Beispiel #3
0
 /**
  * set the workers by refi-ing to the workers {@link List}.
  *
  * @param aWorkersList the {@link List} of workers.
  */
 public void setWorkers(List<Worker> aWorkersList) {
   Repl.workersList = aWorkersList;
   Repl.workers = new HashMap<String, Worker>();
   for (Worker worker : aWorkersList) {
     Repl.workers.put(worker.getName(), worker);
   }
 }
Beispiel #4
0
 private static String workerArr2Str(Collection<Worker> collection) {
   if (collection.size() == 0) {
     return "None.";
   } else {
     String ret = "";
     for (Worker worker : collection) {
       ret += worker.getName() + ", ";
     }
     return ret.substring(0, ret.length() - 2); // remove the last comma
     // and space (", ").
   }
 }
Beispiel #5
0
 private static void addWorker(Vector<String> vec) {
   if (vec.size() != (1 + 2)) {
     System.out.println("USAGE: 'addWorker' takes exactly 3 arguments. " + vec.size() + " given.");
   } else {
     String name = vec.elementAt(0);
     String types = vec.elementAt(1);
     List<WorkerSpecialty> specs = new ArrayList<WorkerSpecialty>();
     for (String s : types.replaceAll(" ", "").split(",")) {
       specs.add(new WorkerSpecialty(s));
     }
     int workHours = Integer.parseInt(vec.elementAt(2));
     Worker worker = new Worker(name, workHours, specs, Repl.workingBoard, Repl.warehouse);
     worker.setLogger(Repl.logger);
     Repl.workersList.add(worker);
     Repl.workers.put(worker.getName(), worker);
     Repl.logger.info(worker.getName() + "started working at " + Helpers.staticTimeNow());
     Repl.workersExecutorService.execute(worker);
   }
   Repl.nextCommand(Repl.commands, Repl.SC);
 }
Beispiel #6
0
 private static void worker(Vector<String> vec) {
   if (vec.size() != 1) {
     System.out.println("USAGE: 'worker' takes exactly 1 argument. " + vec.size() + " given.");
   } else {
     if (!Repl.workers.containsKey(vec.elementAt(0))) {
       System.out.println(vec.elementAt(0) + " is not a valid worker!");
     } else {
       Worker worker = Repl.workers.get(vec.elementAt(0));
       String status;
       if (worker.getCurrentTask() == null) status = "looking for a task";
       else status = "working on task: " + worker.getCurrentTask().getName();
       List<String> resources = worker.getWorkerResources();
       String ress = "";
       if (resources != null) {
         for (String s : resources) {
           ress += s + " ";
         }
       }
       if (ress == "") ress = "none";
       System.out.println("Current Status: " + status + "\n" + "Resources: " + ress);
     }
   }
   Repl.nextCommand(Repl.commands, Repl.SC);
 }