1 18 19 package sync4j.exchange.items.task.manager; 20 21 import java.io.IOException ; 22 23 import sync4j.exchange.items.task.dao.TaskDAO; 24 import sync4j.exchange.items.task.model.Task; 25 import sync4j.exchange.DataAccessException; 26 import sync4j.exchange.xml.XmlParser; 27 import java.util.Date ; 28 29 37 public class TaskManager { 38 39 41 43 TaskDAO td = null ; 44 45 47 public TaskManager(String exchangeServerHost , 48 int exchangeServerPort) 49 throws DataAccessException { 50 51 this.td = new TaskDAO (exchangeServerHost , 52 exchangeServerPort); 53 54 } 55 56 58 69 public Task[] getAllTasks(String username , 70 String credentials , 71 String exchangeFolder ) 72 throws DataAccessException { 73 74 return this.td.getTasks(username , 75 credentials , 76 new String [0] , 77 exchangeFolder ); 78 } 79 80 92 public Task[] getTasks(String username , 93 String credentials , 94 String [] ids , 95 String exchangeFolder ) 96 throws DataAccessException { 97 98 return this.td.getTasks(username , 99 credentials , 100 ids , 101 exchangeFolder ); 102 103 } 104 105 116 public Task getTaskById(String username , 117 String credentials , 118 String id , 119 String exchangeFolder ) 120 throws DataAccessException { 121 122 Task[] tasks = null; 123 124 tasks = this.td.getTasks(username , 125 credentials , 126 new String [] {id} , 127 exchangeFolder ); 128 129 if (tasks == null || !(tasks.length > 0)) { 130 return null; 131 } 132 133 return tasks[0]; 134 135 } 136 137 138 150 public Task getTaskTwin(Task task, 151 String username, 152 String credentials, 153 String exchangeFolder) 154 throws DataAccessException { 155 156 Task[] tasks = null; 157 158 String subject = null; 159 Date date = null; 160 Date dueDate = null; 161 162 try { 163 164 subject = task.getSubject(); 165 date = task.getDate(); 166 dueDate = task.getDueDate(); 167 168 } catch (Exception e) { 169 throw new DataAccessException(e.getMessage()); 170 } 171 172 String [] fields = { 173 TaskDAO.TAG_SUBJECT, 174 TaskDAO.TAG_DATE, 175 TaskDAO.TAG_DUE_DATE 176 }; 177 178 Object [] values = { 179 subject, 180 date, 181 dueDate 182 }; 183 184 tasks = this.td.getTasks(username, 185 credentials, 186 fields, 187 values, 188 exchangeFolder); 189 190 if (tasks == null || !(tasks.length > 0)) { 191 return null; 192 } 193 194 return tasks[0]; 195 } 196 197 209 public Task setTask(Task task , 210 String username , 211 String credentials , 212 String exchangeFolder ) 213 throws DataAccessException { 214 215 return this.td.setTask(task , 216 username , 217 credentials , 218 exchangeFolder ); 219 220 } 221 222 232 public void removeTask(Task task , 233 String username , 234 String principal , 235 String exchangeFolder ) 236 throws DataAccessException { 237 238 this.td.removeTask(task, username, principal, exchangeFolder); 239 240 } 241 242 243 } 244 | Popular Tags |