PageRenderTime 35ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/pomotodo-3/src/main/java/net/juancarlosfernandez/pomotodo/toodledo/data/Todo.java

https://github.com/jferna57/PomoTodo
Java | 485 lines | 220 code | 83 blank | 182 comment | 1 complexity | 47512b73ebe388b76788a80a2267a82e MD5 | raw file
  1. /*
  2. * Copyright 2011 www.juancarlosfernadez.net
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package net.juancarlosfernandez.pomotodo.toodledo.data;
  18. import net.juancarlosfernandez.pomotodo.toodledo.util.TdDate;
  19. import net.juancarlosfernandez.pomotodo.toodledo.util.TdDateTime;
  20. /**
  21. * This class maps all the components of a toodledo task.
  22. * <p/>
  23. * For more info go to http://api.toodledo.com/2/tasks/index.php
  24. *
  25. * @author juancarlosf
  26. */
  27. public class Todo {
  28. /**
  29. * The server id number for this task. It is guaranteed to be unique per
  30. * account, but two different accounts may have two different tasks with the
  31. * same id number.
  32. */
  33. private int id = -1;
  34. /**
  35. * A string for the name of the task. Up to 255 characters. When setting,
  36. * please encode the & character as %26 and the ; character as %3B.
  37. */
  38. private String title;
  39. /**
  40. * A comma separated string listing the tags assigned to this task. Up to 64
  41. * characters. When setting, please encode the & character as %26 and the ;
  42. * character as %3B.
  43. */
  44. private String tag;
  45. /**
  46. * The id number of the folder. Omit this field or set it to 0 to leave the
  47. * task unassigned to a folder.
  48. */
  49. private int folder;
  50. /**
  51. * The id number of the context. Omit this field or set it to 0 to leave the
  52. * task unassigned to a context.
  53. */
  54. private int context;
  55. /**
  56. * The id number of the goal. Omit this field or set it to 0 to leave the
  57. * task unassigned to a goal.
  58. */
  59. private int goal;
  60. /**
  61. * The id number of the location. Omit this field or set it to 0 to leave
  62. * the task unassigned to a location.
  63. */
  64. private int location;
  65. /**
  66. * This is used on Pro accounts that have access to subtasks. To create a
  67. * subtask, set this to the id number of the parent task. The default is 0,
  68. * which creates a normal task.
  69. */
  70. private int parent;
  71. /**
  72. * This is used on Pro accounts that have access to subtasks. This will
  73. * indicate the number of child tasks that this task has. This will be 0 for
  74. * subtasks or for regular tasks without subtasks.
  75. */
  76. private int children;
  77. /**
  78. * This is used on Pro accounts that have access to subtasks. This is an
  79. * integer that indicates the manual order of subtasks within the parent
  80. * task. Currently this is read-only.
  81. */
  82. private int order;
  83. /**
  84. * A GMT unix timestamp for when the task is due. The time component of this
  85. * timestamp will always be noon.
  86. */
  87. private TdDate dueDate;
  88. /**
  89. * An integer representing the due date modifier.
  90. * <p/>
  91. * 0 = Due By 1 = Due On (=) 2 = Due After (>) 3 = Optionally (?)
  92. */
  93. private int dueDateMod;
  94. /**
  95. * A GMT unix timestamp for when the task starts. The time component of this
  96. * timestamp will always be noon.
  97. */
  98. private TdDate startDate;
  99. /**
  100. * A GMT unix timestamp for when the task is due. If the task does not have
  101. * a time set, then this will be 0. If the task has a duetime without a
  102. * duedate set, then the date component of this timestamp will be Jan 1,
  103. * 1970.
  104. */
  105. private TdDateTime dueTime;
  106. /**
  107. * A GMT unix timestamp for when the task starts. If the task does not have
  108. * a time set, then this will be 0. If the task has a starttime without a
  109. * startdate set, then the date component of this timestamp will be Jan 1,
  110. * 1970.
  111. */
  112. private TdDateTime startTime;
  113. /**
  114. * An integer that represents the number of minutes prior to the
  115. * duedate/time that a reminder will be sent. Set it to 0 for no reminder.
  116. * Values will be constrained to this list of valid numbers (0, 1, 15, 30,
  117. * 45, 60, 90, 120, 180, 240, 1440, 2880, 4320, 5760, 7200, 8640, 10080,
  118. * 20160, 43200). Additionally, if the user does not have a Pro account, the
  119. * only valid numbers are 0,60. If you submit an invalid number, it will be
  120. * rounded up or down to a valid non zero value.
  121. */
  122. private int remind;
  123. /**
  124. * A string indicating how the task repeats. For example: "Every 1 Week" or
  125. * "On the 2nd Friday". Please read our "repeat format faq for details about
  126. * valid values. When a task is rescheduled, it is moved forward to the new
  127. * date. For record keeping purposes, a completed copy of this task will be
  128. * added to the user's list. It will have a new ID number and will be
  129. * already completed. To unset this value, set it to an empty string.
  130. */
  131. private Repeat repeat;
  132. /**
  133. * Indicates how tasks repeat. It will be 0 to repeat from the due-date or 1
  134. * to repeat from the completion date.
  135. */
  136. private int repeatFrom;
  137. /**
  138. * An integer that represents the status of the task.
  139. * <p/>
  140. * 0 = None 1 = Next Action 2 = Active 3 = Planning 4 = Delegated 5 =
  141. * Waiting 6 = Hold 7 = Postponed 8 = Someday 9 = Canceled 10 = Reference
  142. */
  143. private Status status;
  144. /**
  145. * An integer representing the number of minutes that the task will take to
  146. * complete.
  147. */
  148. private int length;
  149. /**
  150. * An integer that represents the priority.
  151. * <p/>
  152. * -1 = Negative 0 = Low 1 = Medium 2 = High 3 = Top
  153. */
  154. private Priority priority;
  155. /**
  156. * A boolean (0 or 1) that indicates if the task has a star or not.
  157. */
  158. private boolean star;
  159. /**
  160. * A GMT unix timestamp for when the task was last modified.
  161. */
  162. private TdDateTime modified;
  163. /**
  164. * A GMT unix timestamp for when the task was completed. If the task is not
  165. * completed, the value will be 0. Toodledo does not track the time that a
  166. * task was completed, so tasks will always appear to be completed at noon.
  167. */
  168. private TdDate completed;
  169. /**
  170. * A GMT unix timestamp for when the task was added. Toodledo does not track
  171. * the time that a task was added, so tasks will always appear to be added
  172. * at noon.
  173. */
  174. private TdDate added;
  175. /**
  176. * The value in the timer field indicates the number of seconds that have
  177. * elapsed for the timer not including the current session.
  178. */
  179. private int timer;
  180. /**
  181. * If the timer is currently on, this will contain a unix timestamp
  182. * indicating the last time that the timer was started. Therefore, if the
  183. * timer is currently on, you will need to calculate the elapsed time when
  184. * you present it to the user. This calculation is: Total
  185. * Time=timer+(now-timeron). Where "now" is a unix timestamp for the current
  186. * time.
  187. */
  188. private TdDateTime timerOn;
  189. /**
  190. * A text string up to 32,000 bytes long. When setting, please encode the &
  191. * character as %26 and the ; character as %3B.
  192. */
  193. private String note;
  194. /**
  195. * A text string up to 255 bytes long for storing metadata about the task.
  196. * This is useful for syncing data that cannot otherwise be synced to
  197. * Toodledo. This data is unique per task ID. When a task is rescheduled, a
  198. * new This data is private to your App ID. Neither the user, nor other App
  199. * IDs can see the data that you put in here. Because of an implementation
  200. * detail, using the meta field introduces extra latency to each API call,
  201. * so you should only use this field when necessary.
  202. */
  203. private String meta;
  204. /**
  205. * Is task selected?
  206. */
  207. private int isSelected;
  208. public Todo() {
  209. }
  210. /**
  211. * @return the title
  212. */
  213. public String getTitle() {
  214. return title;
  215. }
  216. /**
  217. * Sets the title for the task.
  218. *
  219. * @param title the title to set. If the title is longer than 255 charts it
  220. * will be cropped.
  221. */
  222. public void setTitle(String title) {
  223. if (title.length() > 255)
  224. this.title = title.substring(0, 255);
  225. else
  226. this.title = title;
  227. }
  228. public int getId() {
  229. return id;
  230. }
  231. public void setId(int id) {
  232. this.id = id;
  233. }
  234. public String getTag() {
  235. return tag;
  236. }
  237. public void setTag(String tag) {
  238. this.tag = tag;
  239. }
  240. public int getFolder() {
  241. return folder;
  242. }
  243. public void setFolder(int folder) {
  244. this.folder = folder;
  245. }
  246. public int getContext() {
  247. return context;
  248. }
  249. public void setContext(int context) {
  250. this.context = context;
  251. }
  252. public int getGoal() {
  253. return goal;
  254. }
  255. public void setGoal(int goal) {
  256. this.goal = goal;
  257. }
  258. public int getLocation() {
  259. return location;
  260. }
  261. public void setLocation(int location) {
  262. this.location = location;
  263. }
  264. public int getParent() {
  265. return parent;
  266. }
  267. public void setParent(int parent) {
  268. this.parent = parent;
  269. }
  270. public int getChildren() {
  271. return children;
  272. }
  273. public void setChildren(int children) {
  274. this.children = children;
  275. }
  276. public int getOrder() {
  277. return order;
  278. }
  279. public void setOrder(int order) {
  280. this.order = order;
  281. }
  282. public TdDate getDueDate() {
  283. return dueDate;
  284. }
  285. public void setDueDate(TdDate dueDate) {
  286. this.dueDate = dueDate;
  287. }
  288. public int getDueDateMod() {
  289. return dueDateMod;
  290. }
  291. public void setDueDateMod(int dueDateMod) {
  292. this.dueDateMod = dueDateMod;
  293. }
  294. public TdDate getStartDate() {
  295. return startDate;
  296. }
  297. public void setStartDate(TdDate startDate) {
  298. this.startDate = startDate;
  299. }
  300. public TdDateTime getDueTime() {
  301. return dueTime;
  302. }
  303. public void setDueTime(TdDateTime dueTime) {
  304. this.dueTime = dueTime;
  305. }
  306. public TdDateTime getStartTime() {
  307. return startTime;
  308. }
  309. public void setStartTime(TdDateTime startTime) {
  310. this.startTime = startTime;
  311. }
  312. public int getRemind() {
  313. return remind;
  314. }
  315. public void setRemind(int remind) {
  316. this.remind = remind;
  317. }
  318. public Repeat getRepeat() {
  319. return repeat;
  320. }
  321. public void setRepeat(Repeat repeat) {
  322. this.repeat = repeat;
  323. }
  324. public int getRepeatFrom() {
  325. return repeatFrom;
  326. }
  327. public void setRepeatFrom(int repeatFrom) {
  328. this.repeatFrom = repeatFrom;
  329. }
  330. public Status getStatus() {
  331. return status;
  332. }
  333. public void setStatus(Status status) {
  334. this.status = status;
  335. }
  336. public int getLength() {
  337. return length;
  338. }
  339. public void setLength(int length) {
  340. this.length = length;
  341. }
  342. public Priority getPriority() {
  343. return priority;
  344. }
  345. public void setPriority(Priority priority) {
  346. this.priority = priority;
  347. }
  348. public boolean isStar() {
  349. return star;
  350. }
  351. public void setStar(boolean star) {
  352. this.star = star;
  353. }
  354. public TdDateTime getModified() {
  355. return modified;
  356. }
  357. public void setModified(TdDateTime modified) {
  358. this.modified = modified;
  359. }
  360. public TdDate getCompleted() {
  361. return completed;
  362. }
  363. public void setCompleted(TdDate completed) {
  364. this.completed = completed;
  365. }
  366. public TdDate getAdded() {
  367. return added;
  368. }
  369. public void setAdded(TdDate added) {
  370. this.added = added;
  371. }
  372. public int getTimer() {
  373. return timer;
  374. }
  375. public void setTimer(int timer) {
  376. this.timer = timer;
  377. }
  378. public TdDateTime getTimerOn() {
  379. return timerOn;
  380. }
  381. public void setTimerOn(TdDateTime timerOn) {
  382. this.timerOn = timerOn;
  383. }
  384. public String getNote() {
  385. return note;
  386. }
  387. public void setNote(String note) {
  388. this.note = note;
  389. }
  390. public String getMeta() {
  391. return meta;
  392. }
  393. public void setMeta(String meta) {
  394. this.meta = meta;
  395. }
  396. public int getIsSelected() {
  397. return isSelected;
  398. }
  399. public void setIsSelected(int isSelected) {
  400. this.isSelected = isSelected;
  401. }
  402. }