// if a task is selected, saves note for task selected by the user // if task not selected by a user, function does nothing public void saveCurrentSelectedTaskNote() { Task selectedTask = incompleteTaskListView.getSelectionModel().getSelectedItem(); if (selectedTask != null) { selectedTask.setNote(taskNoteTextArea.getText()); } }
// adding setOnMouseClicked event handler for incompleteTaskListView and completeTaskListView so // that a task can be marked as // complete or incomplete // if a task in the incompleteTaskListView is double clicked, it will be marked as completed and // moved to completeTaskListView and vice versa private void setTaskCompleteOrIncomplete() { incompleteTaskListView.setOnMouseClicked( event -> { if (event.getClickCount() >= 2) { int selectedToDoList_Index = todoListView.getSelectionModel().getSelectedIndex(); int selectedTaskEvent_Index = incompleteTaskListView.getSelectionModel().getSelectedIndex(); if (selectedToDoList_Index >= 0 && selectedTaskEvent_Index >= 0) { Task selectedTask = toDoListModel .get(selectedToDoList_Index) .getIncompleteTaskList() .get(selectedTaskEvent_Index); toDoListModel .get(selectedToDoList_Index) .getIncompleteTaskList() .remove(selectedTaskEvent_Index); selectedTask.setComplete(true); toDoListModel.get(selectedToDoList_Index).getCompleteTaskList().add(0, selectedTask); } } }); completeTaskListView.setOnMouseClicked( event -> { if (event.getClickCount() >= 2) { int selectedToDoList_Index = todoListView.getSelectionModel().getSelectedIndex(); int selectedTaskEvent_Index = completeTaskListView.getSelectionModel().getSelectedIndex(); if (selectedToDoList_Index >= 0 && selectedTaskEvent_Index >= 0) { Task selectedTask = toDoListModel .get(selectedToDoList_Index) .getCompleteTaskList() .get(selectedTaskEvent_Index); toDoListModel .get(selectedToDoList_Index) .getCompleteTaskList() .remove(selectedTaskEvent_Index); selectedTask.setComplete(false); toDoListModel .get(selectedToDoList_Index) .getIncompleteTaskList() .add(0, selectedTask); } } }); }
protected Task identifyTaskFromID(int id) { for (int i = 0; i < this.savedState.size(); i++) { Task t = this.savedState.get(i); if (t.getId() == id) { this.index = i; return t; } } return null; }
public void addTasks(List<Task> tasks) { listModel = new DefaultListModel(); if (tasks == null || tasks.size() == 0) { this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.setModel(listModel); return; } else { for (Task t : tasks) { listModel.addElement(t.getTitle()); } } this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.setModel(listModel); }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); Task task = new Gson().fromJson(readPostData(request), Task.class); if (task.getScript() != null) { int id = DatabaseHandler.getInstance().addNewTask(task.getScript()); task.setIdentifier(id); TaskExecutionHelper.getInstance().addTask(task); response .getWriter() .println("{\"status\":\"Task received\"," + "\"identifier\":\"" + id + "\"}"); } else { response.getWriter().println("{\"error\":\"Wrong format\"}"); } }
@Test public void testEditCommand() { String newPayload = null; try { Memory memory = Memory.getMemory(); Task t = new Task(); memory.addToDoItem(t); memory.editToDoItem(1, "test edit item was null"); Task editedTask = memory.fetchMemory().get(0); newPayload = editedTask.getPayload(); memory.clearItems(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertEquals("test edit item was null", newPayload); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi; vi = LayoutInflater.from(getContext()); v = vi.inflate(R.layout.tasks_list_view, null); } Task t = getItem(position); if (t != null) { TextView tt1 = (TextView) v.findViewById(R.id.task_text); if (tt1 != null) { tt1.setText(t.getName()); } } return v; }
// sets data for taskInfoVBox's nodes/components using task's data (passed as argument) private void setTaskInfoVBoxData( Task task, ChangeListener<? super LocalDate> dateChangeListener) { saveNewTaskNameButton.disableProperty().setValue(true); taskNameTextField.setText(task.getTaskTitle()); if (task.getTaskDueDate() != null) { taskDueDatePicker.setValue(task.getTaskDueDate()); } taskDueDatePicker.valueProperty().addListener(dateChangeListener); int taskPriority = task.getPriority(); switch (taskPriority) { case 1: { lowPriorityToggle.setSelected(true); break; } case 2: { mediumPriorityToggle.setSelected(true); break; } case 3: { highPriorityToggle.setSelected(true); break; } } subTaskListView.setItems(task.getSubTasks()); taskNoteTextArea.setText(task.getNote()); }
// saves the task information from taskInfoVBox form to the task passed in as argument private void saveTaskInfo(Task task) { // to track if the task's attributes have been changed boolean differentTaskName = false, differentDueDate = false, differentPriority = false; if (task == null) { return; } // if different title if (!task.getTaskTitle().equals(taskNameTextField.getText())) differentTaskName = true; // if different due date if (task.getTaskDueDate() == null) { if (taskDueDatePicker.getValue() != null) { differentDueDate = true; } } else { if (taskDueDatePicker.getValue() == null) { differentDueDate = true; } if (taskDueDatePicker.getValue() != null) { if (!(task.getTaskDueDate().isEqual(taskDueDatePicker.getValue()))) differentDueDate = true; } } int currentTaskPriority = task.getPriority(); // if no priority selected for the task if (priority_toggle_group.getSelectedToggle() == null) { if (currentTaskPriority != 0) { differentPriority = true; } } else { // if different priority if (currentTaskPriority != (int) priority_toggle_group.getSelectedToggle().getUserData()) differentPriority = true; } // if task attributes have been changed, replace current task with new task with updated task // attributes if (differentTaskName || differentDueDate || differentPriority) { Task replacementTask = new Task(); replacementTask.setTaskTitle(taskNameTextField.getText()); replacementTask.setTaskDueDate(taskDueDatePicker.getValue()); if (priority_toggle_group.getSelectedToggle() == null) { replacementTask.setPriority(0); } else { replacementTask.setPriority((int) priority_toggle_group.getSelectedToggle().getUserData()); } replacementTask.setSubTasks(task.getSubTasks()); replacementTask.setNote(taskNoteTextArea.getText()); int currentListIndex = -1, currentTaskIndex = -1; // to track current index int replacementListIndex = -1, replacementTaskIndex = -1; // to track index where replacement task will placed at found: { for (ToDoList currentList : toDoListModel) { currentListIndex++; currentTaskIndex = -1; for (Task currentTask : currentList.getIncompleteTaskList()) { currentTaskIndex++; // if task's unique ID matches current task, assign the current task's list index and // task index to the replacement index variables // and break out of the loop if (currentTask.getUniqueID() == task.getUniqueID()) { replacementListIndex = currentListIndex; replacementTaskIndex = currentTaskIndex; break found; } } } } // if found the task to replace with if (replacementListIndex != -1 && replacementTaskIndex != -1) { toDoListModel .get(replacementListIndex) .getIncompleteTaskList() .set(replacementTaskIndex, replacementTask); // if task to be replaced is the first task in the first to do list, select the replaced // task and update // incompleteTaskListView // code below help to get around a bug in selection model for list view if (replacementListIndex == 0 && replacementTaskIndex == 0) { todoListView.getSelectionModel().select(replacementListIndex); incompleteTaskListView.getSelectionModel().select(replacementListIndex); } } } // if task's priority, name and due date have not been changed, then only update the task's (one // that is passed in as argument) note else { task.setNote(taskNoteTextArea.getText()); } }
private void updateViewModel() { setText(null); setGraphic(null); if (getItem() != null) { BorderPane mainBox = new BorderPane(); mainBox.setPadding(new Insets(3.0, 5.0, 3.0, 3.0)); VBox taskNameDisplay = new VBox(); taskNameDisplay.setAlignment(Pos.CENTER_LEFT); Text taskNameText = new Text(); taskNameDisplay.getChildren().addAll(taskNameText); HBox priorityDueDateDisplay = new HBox(); priorityDueDateDisplay.setAlignment(Pos.CENTER_RIGHT); Text taskPriorityText = new Text(); Text taskDueDateText = new Text(); taskPriorityText.setScaleX(1.25); taskPriorityText.setScaleY(1.25); priorityDueDateDisplay.setSpacing(40); priorityDueDateDisplay.getChildren().addAll(taskDueDateText, taskPriorityText); mainBox.leftProperty().set(taskNameDisplay); mainBox.rightProperty().set(priorityDueDateDisplay); mainBox.setMargin(mainBox.getLeft(), new Insets(0, 20, 0, 0)); Task currentTask = getItem(); int currentTaskPriority = currentTask.getPriority(); // setting task name to be displayed by the cell taskNameText.setText(currentTask.getTaskTitle()); // setting task due date to be displayed by the cell if (currentTask.getTaskDueDate() != null) { LocalDate currentDueDate = currentTask.getTaskDueDate(); taskDueDateText.setText( currentDueDate.getMonthValue() + "/" + currentDueDate.getDayOfMonth() + "/" + currentDueDate.getYear()); } // setting task priority to be displayed by the cell switch (currentTaskPriority) { case 1: { taskPriorityText.setText("!"); taskPriorityText.setFill(Color.web("#28ae33")); break; } case 2: { taskPriorityText.setText("!!"); taskPriorityText.setFill(Color.web("#babf23")); break; } case 3: { taskPriorityText.setText("!!!"); taskPriorityText.setFill(Color.web("#ee0606")); break; } default: { } } if (!currentTask.getComplete()) { taskNameText.setStrikethrough(false); } else { // if task is completed, strike out the task name mainBox.setOpacity(0.5); taskNameText.setStrikethrough(true); } setText(null); setGraphic(mainBox); } }
public boolean removeTask(Task task) { return listModel.removeElement(task.getTitle()); }
public void addTask(Task task) { listModel.addElement(task.getTitle()); }
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String username = (String) session.getAttribute("username"); String curCategId = (String) session.getAttribute("curCategId"); response.setContentType("text/html;charset=UTF-8"); String action = request.getParameter("action"); PrintWriter out = response.getWriter(); System.out.println("Action = " + action); if (action.equalsIgnoreCase("showCategory")) { ArrayList<Category> categories = new ArrayList<Category>(joinOp.GetCategByUsername(username)); out.println("<div class='kategori'>"); out.println("<div id='categoryAll' onclick='showTaskList(0);'>All</div>"); out.println("</div>"); for (Category categ : categories) { out.println("<div class='kategori'>"); out.println( "<div id='category" + categ.getId_category() + "'" + "onclick='showTaskList(" + categ.getId_category() + ");'>" + categ.getName() + "</div>"); if (username.equals(categ.getCateg_creator())) { out.println( "<div class='removeCategory' id='removeCateg" + categ.getId_category() + "' onclick='return removeCategory(" + categ.getId_category() + ");'>x</div>"); } out.println("</div>"); } } else if (action.equalsIgnoreCase("addCategory")) { String categName = request.getParameter("name"); String[] authUsers = request.getParameter("authUsers").split(","); categoryOp.InsertNewCategory(new Category("", categName, username)); String newCategId = categoryOp.FetchIdByName(categName); caurelationOp.InsertCaurelation(new Caurelation("", newCategId, username)); ucrelationOp.InsertUcrelation(new Ucrelation("", username, newCategId)); if (authUsers.length != 0) { for (String authUser : authUsers) { if (userOp.ListAllUsernames().contains(authUser)) { ucrelationOp.InsertUcrelation(new Ucrelation("", authUser.trim(), newCategId)); caurelationOp.InsertCaurelation(new Caurelation("", newCategId, authUser)); } } } } else if (action.equalsIgnoreCase("removeCategory")) { String categId = request.getParameter("code"); ArrayList<String> taskIds = new ArrayList<String>(taskOp.FetchIdsByCategId(categId)); for (String taskId : taskIds) { ttrelationOp.DeleteByTaskId(taskId); utrelationOp.DeleteByTaskId(taskId); tarelationOp.DeleteTarelationByTaskId(taskId); commentOp.DeleteCommentByTaskId(taskId); taskOp.DeleteById(taskId); } ucrelationOp.DeleteByCategId(categId, username); caurelationOp.DeleteCaurelationByCategId(categId); categoryOp.DeleteCategoryById(categId); } else if (action.equalsIgnoreCase("showTaskList")) { String categId = request.getParameter("code"); session.setAttribute("curCategId", categId); ArrayList<Task> tasks = new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(username, categId)); ArrayList<String> tags; int i = 0; for (Task task : tasks) { i = 0; out.println("<div class='listTugas'>"); out.println( "<a class='listname' id='task" + task.getId_task() + "'" + "onclick='showRinci(" + task.getId_task() + ");'>" + task.getName() + "</a>"); out.println("<div class='listdeadline'>Deadline: " + task.getDeadline() + "</div>"); tags = new ArrayList<String>(joinOp.GetTagNamesByTaskId(task.getId_task())); out.println("<div class='listtag'>Tag: "); while (i < tags.size()) { out.print(tags.get(i)); i++; if (i < tags.size()) { out.print(", "); } } out.println("</div>"); out.println("<div class='liststatus' id='statusTask'>"); if (task.getStatus().equals("T")) { out.println( "<input type='checkbox' id='checkboxTask" + task.getId_task() + "' onclick='changeTaskStatus(" + task.getId_task() + ", this.checked);' checked>"); } else if (task.getStatus().equals("F")) { out.println( "<input type='checkbox' id='checkboxTask" + task.getId_task() + "' onclick='changeTaskStatus(" + task.getId_task() + ", this.checked);'>"); } out.println("Done</div>"); if (username.equals(taskOp.FetchCreatorById(task.getId_task()))) { out.println( "<div class='removeTask'><input type='submit' id='removeTaskBtn" + task.getId_task() + "' onclick='removeTask(" + curCategId + "," + task.getId_task() + ");' value='Remove Task'/></div>"); } out.println("</div>"); } if (caurelationOp.FetchAuthUsersByCategId(categId).contains(username)) { out.println("<a onclick='showBuat();' class='addTask'>+task</a>"); } } else if (action.equalsIgnoreCase("showTaskDetail")) { String taskId = request.getParameter("code"); Task task = taskOp.SelectById(taskId); out.println("<div id='taskdetail'>"); // NAME out.println("<div id='taskdetail_name'>" + task.getName() + "</div><br>"); // STATUS out.println("<br><div>=======================================================</div>"); if (task.getStatus().equalsIgnoreCase("T")) { out.println( "<div id='taskdetail_status'><em>Status : </em>Done " + "<input type='checkbox' onclick='changeTaskStatus(" + task.getId_task() + ", this.checked);' checked/>" + "</div>"); } else { out.println( "<div id='taskdetail_status'>Status : Done " + "<input type='checkbox' onclick='changeTaskStatus(" + task.getId_task() + ", this.checked);'/>" + "</div>"); } // ATTACHMENT ArrayList<Attachment> attachments = joinOp.GetAttachmentFromId_task(task.getId_task()); int extensionIdx; String extension, filename; out.println("<br><div>=======================================================</div>"); out.println("<div><em>Attachment: </em></div>"); out.println("<div id='taskdetail_attachment'>"); for (Attachment item : attachments) { extensionIdx = item.getPath().lastIndexOf('.'); if (extensionIdx > 0) { filename = item.getPath().substring(item.getPath().lastIndexOf('/') + 1); extension = item.getPath().substring(extensionIdx + 1); System.out.println(item.getPath() + " has extension " + extension); // jika gambar if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("png") || extension.equalsIgnoreCase("gif")) { System.out.println(filename); out.println("<img src='" + item.getPath() + "' height=\"100\" width=\"100\"/><br>"); out.println("<a href='" + item.getPath() + "'>" + filename + "</a><br>"); // jika video } else if (extension.equalsIgnoreCase("mp4") || extension.equalsIgnoreCase("webm") || extension.equalsIgnoreCase("ogg")) { out.println("<video width=\"320\" height=\"240\" controls>"); out.println("<source src='" + item.getPath() + "' type='video/" + extension + "'>"); out.println("</video><br>"); out.println("<a href='" + item.getPath() + "'>" + filename + "</a><br>"); } else { out.println("<a href='" + item.getPath() + "'>" + filename + "</a><br>"); } } } out.println("</div>"); // DEADLINE out.println("<br><div>=======================================================</div>"); out.println( "<div id='taskdetail_deadline'><em>Deadline: </em>" + task.getDeadline() + "</div>"); // ASSIGNEE out.println("<br><div>=======================================================</div>"); ArrayList<String> assignees = utrelationOp.FetchAssigneeByTaskId(task.getId_task()); out.println("<div id='taskdetail_assignee'><em>Assignee: </em>"); int i = 0; while (i < assignees.size()) { out.println( "<a href='profile.jsp?userprofile=" + assignees.get(i) + "'>" + assignees.get(i) + "</a>"); i++; if (i < assignees.size()) { out.print("; "); } } out.println("</div>"); // KOMENTAR out.println("<br><div>=======================================================</div>"); out.println("<div><em>Comment: </em></div>"); User user; String[] timesplit; ArrayList<Comment> comments = commentOp.FetchCommentByTaskId(task.getId_task()); out.println("<div id='ctotal'>" + comments.size() + " comment(s)</div>"); out.println("<div id='taskdetail_comment'>"); out.println("<div id='commentlist'>"); for (Comment item : comments) { out.println("<div id='comment" + item.getId_comment() + "'>"); user = userOp.SelectUserInfoByUsername(item.getUsername()); timesplit = item.getTimestamp().split(":"); System.out.println("LALALALALA" + timesplit.length); out.println( "<img class='cavatar' src='" + user.getAvatar() + "' style='width:30px; height:30px;'/>"); out.println( "<div class='ctimestamp'>" + timesplit[3] + ":" + timesplit[4] + " - " + timesplit[2] + "/" + timesplit[1] + "</div>"); out.println("<div class='ccontent'>" + item.getContent() + "</div>"); if (username.equals(user.getUsername())) { out.println( "<input type='button' value='Delete' class='cdelete' onclick='delComment(" + item.getId_comment() + ");'/>"); } out.println("</div>"); } out.println("</div>"); out.println("<div id='commentbox'>"); out.println("<textarea id='cbox'></textarea></br>"); out.println("<input type='button' value='Submit' onclick='addComment(" + taskId + ");'/>"); out.println("</div>"); out.println("</div>"); // TAG out.println("<br><div>=======================================================</div>"); ArrayList<Tag> tags = joinOp.GetTagFromId_task(task.getId_task()); out.println("<div id='taskdetail_tag'><em>Tag: </em>"); i = 0; while (i < tags.size()) { out.println(tags.get(i).getName()); i++; if (i < tags.size()) { out.print("; "); } } out.println("</div>"); if (utrelationOp.IsTaskEditable(username, taskId)) { out.println( "<input type='button' value='Edit task' onclick='editTaskDetail(" + task.getId_task() + ");'/>"); } out.println("<input type='button' value='Back' onclick='restore2();'/>"); out.println("</div>"); } else if (action.equalsIgnoreCase("editTaskDetail")) { String taskId = request.getParameter("code"); Task task = taskOp.SelectById(taskId); out.println("<div id='editdetail'>"); out.println("<form>"); out.println("<big style='font-size: 20pt;'>" + task.getName() + "</big><br/>"); out.println( "<br/>Deadline: <input type='date' id='editDeadline' name='editDeadline' value='" + task.getDeadline() + "'><br/>"); out.println( "<br/><div class='assignee'>Assignee: <input type='text' id='editAssignee'" + "name='editAssignee' value='"); ArrayList<String> authUsers = new ArrayList<String>(utrelationOp.FetchAssigneeByTaskId(taskId)); int i = 0; while (i < authUsers.size()) { out.print(authUsers.get(i)); i++; if (i < authUsers.size()) { out.print(","); } } out.print( "' onkeyup=\"multiAutocomp(this, 'getAllUser.jsp');\" onfocusin='multiAutocompClearAll();'></div><br/>"); out.println("<div class='tag'>Tag: <input type='text' id='editTag' name='editTag' value='"); ArrayList<String> tags = new ArrayList<String>(joinOp.GetTagNamesByTaskId(task.getId_task())); i = 0; while (i < tags.size()) { out.print(tags.get(i)); i++; if (i < tags.size()) { out.print(","); } } out.print( "' onkeyup=\"multiAutocomp(this, 'getAllTag.jsp');\" onfocusin='multiAutocompClearAll();'></div><br/>"); out.println("</form><br/>"); if (username.equals(taskOp.FetchCreatorById(task.getId_task()))) { out.println( "<input type='button' id='editremove' onclick='removeTask(" + curCategId + ", " + task.getId_task() + ");' class='button' value='Remove Task'/><br>"); } else if (utrelationOp.FetchAssigneeByTaskId(task.getId_task()).contains(username)) { out.println( "<input type='button' id='editremove' onclick='removeReference(" + curCategId + ", " + task.getId_task() + ");' class='button' value='Remove me from this task'/><br>"); } out.println( "<input type='button' id='editsave' onclick='saveTaskDetail(" + task.getId_task() + ");' class='button' value='Save'/>"); out.println( "<input type='button' id='editback' onclick='restore4();' class='button' value='Back'/>"); out.println("</div>"); } else if (action.equalsIgnoreCase("changeTaskStatus")) { String taskId = request.getParameter("code"); String newStatus = request.getParameter("chkYesNo"); if (newStatus.equals("0")) { taskOp.UpdateStatusWithId("F", taskId); } else if (newStatus.equals("1")) { taskOp.UpdateStatusWithId("T", taskId); } out.println("<div>"); if (newStatus.equals("0")) { out.println( "<input type='checkbox' id='checkboxTask" + taskId + "' " + "onclick='changeTaskStatus(" + taskId + ", this.checked);' checked>"); } else if (newStatus.equals("1")) { out.println( "<input type='checkbox' id='checkboxTask" + taskId + "' " + "onclick='changeTaskStatus(" + taskId + ", this.checked);'>"); } out.println("Done</div>"); } else if (action.equalsIgnoreCase("saveTaskDetail")) { String taskId = request.getParameter("code"); String deadline = request.getParameter("newDeadline"); String[] assignees = request.getParameter("newAssignees").split(","); String[] tags = request.getParameter("newTags").split(","); ArrayList<String> oldAssignees = new ArrayList<String>(utrelationOp.FetchAssigneeByTaskId(taskId)); ArrayList<String> oldTagIds = new ArrayList<String>(joinOp.GetTagsIdByTaskId(taskId)); taskOp.UpdateDeadlineById(deadline, taskId); for (String oldAssignee : oldAssignees) { utrelationOp.DeleteByTaskIdAndUsername(taskId, oldAssignee); } for (String oldTagId : oldTagIds) { ttrelationOp.DeleteByTagId(oldTagId); } for (String assignee : assignees) { if (userOp.ListAllUsernames().contains(assignee.trim())) { utrelationOp.InsertUtrelation(new Utrelation("", taskId, assignee.trim())); if (ucrelationOp.CheckIfUcrelationExists(assignee.trim(), curCategId) == 0) { ucrelationOp.InsertUcrelation(new Ucrelation("", assignee.trim(), curCategId)); } } } for (String tag : tags) { if (tagOp.CheckIfTagExists(tag.trim()) == 0) { tagOp.InsertTag(tag.trim()); } ttrelationOp.InsertTtrelation(new Ttrelation("", taskId, tagOp.SelectIdByName(tag.trim()))); } ArrayList<Task> temp; for (String oldAssignee : oldAssignees) { temp = new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(oldAssignee, curCategId)); if (temp.isEmpty()) { ucrelationOp.DeleteByCategId(curCategId, oldAssignee); } } for (String oldTagId : oldTagIds) { if (joinOp.CheckTtrelationByTagId(oldTagId) == 0) { tagOp.DeleteById(oldTagId); } } } else if (action.equalsIgnoreCase("addTask")) { String[] assignees = request.getParameter("newTaskAssignee").split(","); String[] tags = request.getParameter("newTaskTags").split(","); String name = request.getParameter("newTaskName"); } else if (action.equalsIgnoreCase("removeTask")) { String taskId = request.getParameter("code"); tarelationOp.DeleteTarelationByTaskId(taskId); ttrelationOp.DeleteByTaskId(taskId); commentOp.DeleteCommentByTaskId(taskId); utrelationOp.DeleteByTaskId(taskId); taskOp.DeleteById(taskId); ArrayList<String> allUsers = new ArrayList<String>(userOp.ListAllUsernames()); ArrayList<Task> temp; for (String user : allUsers) { if (!user.equals(username)) { temp = new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(user, curCategId)); if (temp.isEmpty()) { ucrelationOp.DeleteByCategId(curCategId, username); } } } } else if (action.equalsIgnoreCase("removeReference")) { String taskId = request.getParameter("code"); utrelationOp.DeleteByTaskId(taskId); ArrayList<Task> temp = new ArrayList<Task>(joinOp.GetTasksByUsernameAndCategoryId(username, curCategId)); if (temp.isEmpty()) { ucrelationOp.DeleteByCategId(curCategId, username); } } else if (action.equalsIgnoreCase("addComment")) { String idtask = request.getParameter("it"); String content = request.getParameter("c"); DateFormat dateFormat = new SimpleDateFormat("yyyy:MM:dd:HH:mm"); Date date = new Date(); String timestamp = dateFormat.format(date).toString(); String avatar = userOp.SelectUserInfoByUsername(username).getAvatar(); commentOp.InsertComment(idtask, username, dateFormat.format(date).toString(), content); String idcomment = commentOp.GetIdByOtherAttributes(idtask, username, content); String message = avatar + ":" + timestamp + ":" + content + ":" + idcomment; out.println(message); } else if (action.equalsIgnoreCase("delComment")) { String idcomment = request.getParameter("ic"); commentOp.DeleteCommentByCommentId(idcomment); out.println(idcomment); } else { System.out.println("No command existed"); } out.close(); }