Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 1 commit
  • 2 files changed
  • 0 comments
  • 1 contributor
Aug 25, 2012
dvir fucked up 8489d4e
33  tsk-mng-parent/tsk-mng-backend/src/main/java/org/tsk/mng/backend/Impl/UserManagementBEServiceImpl.java
@@ -69,23 +69,44 @@ public UserBE addSuperiorToUser(UserBE superior, UserBE worker) throws Operation
69 69
 				throw new OperationFailureException("no mail in superior/worker");
70 70
 			}
71 71
 
  72
+			//
72 73
 			UserDT workerDT = userDao.getByPK(workerPK);
73 74
 			UserDT superiorDT = userDao.getByPK(superiorPK);
74 75
 			if (!isUserExistInTheSystem(workerDT)) {
75  
-				throw new OperationFailureException("worker " + workerPK + " is not exist in the system");
  76
+				throw new OperationFailureException("worker " + worker + " does not exist in the system");
76 77
 			}
77 78
 			if (!isUserExistInTheSystem(superiorDT)) {
78  
-				throw new OperationFailureException("superior " + superiorPK + "is not exist in the system");
  79
+				throw new OperationFailureException("superior " + superior + "does not exist in the system");
  80
+			}
  81
+			logger.info("Worker: " + worker + " and Superior: " + superior + " were found");
  82
+			
  83
+			//adding superior to the worker and either adding worker to superior
  84
+			
  85
+			//check whether the Worker has Superior already
  86
+			UserDT currentSuperior = workerDT.getSuperior();
  87
+			if (currentSuperior != null) {
  88
+				String msg = "Suprior: " + currentSuperior.getNickName() + " already setted as Superior of " + worker;
  89
+				logger.info(msg);
  90
+				throw new OperationFailureException(msg);
79 91
 			}
80 92
 
81  
-			workerDT.setSuperior(superiorDT);
  93
+			//setting the superior as superior of the worker
  94
+			worker.setSuperior(superior);
  95
+			//adding the worker to superior workers list
  96
+			superior.addWorker(worker);
  97
+			
  98
+			workerDT = TransformerUtil.dozerConvert(worker, UserDT.class);
  99
+			superiorDT = TransformerUtil.dozerConvert(superior, UserDT.class);
82 100
 
83 101
 			if (!userDao.updateUserAndVerify(workerDT)) {
84  
-				throw new OperationFailureException("error occuer when tryied to save user " + workerPK);
  102
+				throw new OperationFailureException("error occuer when tryied to save user " + worker);
  103
+			}
  104
+			if (!userDao.updateUserAndVerify(superiorDT)) {
  105
+				throw new OperationFailureException("error occuer when tryid to save user " + superiorPK);
85 106
 			}
86  
-			logger.info(superiorPK + " has added as superior of " + workerPK + ", the changes been updated in DB");
  107
+			logger.info(superiorPK + " has added as superior of " + worker + ", the changes been updated in DB");
87 108
 
88  
-			retValue = TransformerUtil.dozerConvert(workerDT, UserBE.class);
  109
+			retValue = worker;
89 110
 
90 111
 		} catch (Exception e) {
91 112
 			logger.error(e.getMessage(),e);
28  tsk-mng-parent/tsk-mng-backend/src/main/java/org/tsk/mng/backend/service/TaskMangementBEService.java
@@ -5,13 +5,41 @@
5 5
 
6 6
 public interface TaskMangementBEService {
7 7
 
  8
+	/**
  9
+	 * 
  10
+	 * @param user
  11
+	 * @param task
  12
+	 * @return
  13
+	 */
8 14
 	UserBE assignUserToTask(UserBE user, TaskBE task);
9 15
 	
  16
+	/**
  17
+	 * 
  18
+	 * @param user
  19
+	 * @return
  20
+	 */
10 21
 	TaskBE getUserTasks(UserBE user);
11 22
 	
  23
+	/**
  24
+	 * 
  25
+	 * @param user
  26
+	 * @param task
  27
+	 * @return
  28
+	 */
12 29
 	TaskBE removeTaskFromUser(UserBE user, TaskBE task);
13 30
 	
  31
+	/**
  32
+	 * 
  33
+	 * @param task
  34
+	 * @return
  35
+	 */
14 36
 	TaskBE updateTask(TaskBE task);
15 37
 	
  38
+	/**
  39
+	 * 
  40
+	 * @param task
  41
+	 * @param dependentTask
  42
+	 * @return
  43
+	 */
16 44
 	UserBE addDependencyToTask(TaskBE task, TaskBE dependentTask);
17 45
 }

No commit comments for this range

Something went wrong with that request. Please try again.