コード例 #1
0
ファイル: App.java プロジェクト: xMIFx/Corporate_Messenger
 private static void deleteWorkerFromAnywhere(String workerName) {
   Worker workerForDel = workerDAO.getByName(workerName);
   Department depForUpdate = departmentDAO.getByWorker(workerForDel);
   if (depForUpdate != null) {
     depForUpdate.removeWorker(workerForDel);
     departmentDAO.update(depForUpdate);
   }
   workerDAO.remove(workerForDel);
 }
コード例 #2
0
ファイル: App.java プロジェクト: xMIFx/Corporate_Messenger
 private static void deleteDepartmentAndRelocateWorkersToNullDep(
     String departmentName, Department nullDepartment) {
   Department depForDel = departmentDAO.getByName(departmentName);
   if (depForDel != null) {
     nullDepartment.getWorkers().addAll(depForDel.getWorkers());
     departmentDAO.remove(depForDel);
     departmentDAO.update(nullDepartment);
   }
 }
コード例 #3
0
ファイル: App.java プロジェクト: xMIFx/Corporate_Messenger
 private static void deleteWorkerFromHisDepartmentAndRelocateHimToNullDep(
     String workerName, Department nullDepartment) {
   Worker workerForDel = workerDAO.getByName(workerName);
   Department depForUpdate = departmentDAO.getByWorker(workerForDel);
   if (depForUpdate != null) {
     depForUpdate.removeWorker(workerForDel);
     nullDepartment.addWorker(workerForDel);
     departmentDAO.update(depForUpdate);
     departmentDAO.update(nullDepartment);
   }
 }
コード例 #4
0
ファイル: App.java プロジェクト: xMIFx/Corporate_Messenger
  private static Worker getWorkOrCreate(
      Department currentDepartment, Department nullDepartment, String workerName) {
    Worker w = workerDAO.getByName(workerName);
    if (w == null) {
      w = new Worker(workerName);
      workerDAO.save(w);
    } else {
      Department oldWorkerDep = departmentDAO.getByWorker(w);
      if (oldWorkerDep != null) {
        oldWorkerDep.removeWorker(w);
        departmentDAO.update(oldWorkerDep);
      }
    }

    if (currentDepartment != null) {
      currentDepartment.addWorker(w);
      departmentDAO.update(currentDepartment);
    } else {
      nullDepartment.addWorker(w);
      departmentDAO.update(nullDepartment);
    }

    return w;
  }