public static void sendModeration(String name, float point) { Task t = new Task(name, point); t.status = TaskStatus.PENDING; t.suggestedBy = SUser.findByEmail(Auth.connected()); t.save(); thanks(); }
@Override public boolean onContextItemSelected(MenuItem item) { Task actual; actual = this.tasksList.get(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position); final int pos = tasks.this.tasksList.indexOf(actual); switch (item.getItemId()) { case R.id.taskContextMenuOpt1: Intent intentModifyTask = new Intent(this, ModifyTask.class); intentModifyTask.putExtra("taskName", actual.getTaskName()); intentModifyTask.putExtra("taskDescription", actual.getTaskDescription()); intentModifyTask.putExtra("taskDeadline", actual.getTaskDeadline()); intentModifyTask.putExtra("subjectName", this.sN); startActivity(intentModifyTask); break; case R.id.taskContextMenuOpt2: tasks.this.tasksList.remove(pos); Package p = new Package(); p.setT(actual); p.setOldSubject(this.sN); p.setOption(9); new InsertManager(this.getApplicationContext()).execute(p); tasks.this.tasksListAdapter.notifyDataSetChanged(); break; } return true; }
/** * Delete a task * * @param storyId * @param taskId */ public static void delete(Long storyId, long taskId) { Task toDelete = Task.findById(taskId); if (toDelete != null) { toDelete.delete(); } renderJSON(UserMessage.SUCCESSFUL); }
/** Create a task */ public static Task create(Integer project, String folder, String title) { Task task = new Task(); task.project = Project.find.ref(project); task.folder = folder; task.title = title; task.save(); return task; }
public static Result newTask() { Form<Task> filledForm = taskForm.bindFromRequest(); if (filledForm.hasErrors()) return badRequest(views.html.task.render(Task.all(), filledForm)); else { Task.createTask(filledForm.get()); return redirect(routes.Application.getTasks()); } }
public Result index(Integer projectid) { project = Project.find.byId(projectid); for (Task task : project.getTasks()) { if (folders.containsKey(task.getFolder())) folders.get(task.getFolder()).add(task); else folders.put(task.getFolder(), new ArrayList<Task>(Arrays.asList(task))); } return ok(this); }
public static Result newTask() { User user = loadUser(); Form<Task> filledForm = taskForm.bindFromRequest(); if (filledForm.hasErrors()) { flash("error", "The task could not be saved."); return badRequest(main.render("Tasks", null, tasks.render(user.tasks, filledForm))); } else { Task task = filledForm.get(); task.owner = user; task.save(); return created(main.render("Tasks", null, tasks.render(user.tasks, taskForm))); } }
private static void updateElement(Long storyId, JsonElement element) { if (element.isJsonObject()) { JsonObject jsonObject = element.getAsJsonObject(); JsonElement jsonElement = jsonObject.get("id"); if (jsonElement != null) { Task toUpdate = Task.findById(jsonElement.getAsLong()); doUpdate(toUpdate, jsonObject); } } }
/** * Show statistics REQ-7.1, REQ-7.2 * * @param id */ public static void statistics(Long id) { Task task = Task.findById(id); notFoundIfNull(task); Collection<SystemReplyResult> systemReplyStatistics = new SystemReplyStatistics().getStatistics(task); Collection<ContestantResult> contestantStatistics = new ContestantStatistics().getStatistics(task, 10); render(task, systemReplyStatistics, contestantStatistics); }
/** * Update files before save * * @param id * @param inputData * @param outputData * @param removeOutputData * @throws IOException */ @Before(only = "save") public static void beforeSave( Long id, java.io.File inputData, java.io.File outputData, boolean removeOutputData) throws IOException { models.Task task = models.Task.findById(id); notFoundIfNull(task); if (removeOutputData) { task.deleteOutputData(); } if (inputData != null) { InputFile inputFile = new InputFile(inputData); inputFile.save(); params.put("object.inputData.id", inputFile.getId().toString()); } if (outputData != null) { OutputFile outputFile = new OutputFile(outputData); outputFile.save(); params.put("object.outputData.id", outputFile.getId().toString()); } }
/** * Remove all evaluations from single solutions of this task * * @param id */ public static void unevaluate(Long id) { Task task = Task.findById(id); notFoundIfNull(task); List<models.Solution> solutions = models.Solution.find("task=?", task).fetch(); for (models.Solution solution : solutions) { solution.unevaluate(); solution.save(); } Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("search_task", task.id); redirect(Router.getFullUrl("admin.Solutions.list", parameters)); }
/** * Check for delete constraints * * @param id */ @Before(only = {"delete"}) public static void beforeDelete(Long id) { Task task = Task.findById(id); notFoundIfNull(task); if (!task.competitions.isEmpty()) { flash.error( "Can't delete task! Is used in " + task.competitions.size() + " competition" + (task.competitions.size() > 1 ? "s" : "") + ": " + task.competitions.get(0).name + (task.competitions.size() > 1 ? ", ..." : "")); redirect(request.controller + ".show", id); } }
public static Result deleteTask(Long id) { Task.delete(id); return redirect(routes.Application.tasks()); }
public static Result tasks() { return ok(views.html.index.render(Task.all(), taskForm)); }
public static Task create(Task task, Long project, String folder) { task.project = Project.find.ref(project); task.folder = folder; task.save(); return task; }
/** * Saves a task * * @param storyId */ public static void save(String storyId, JsonObject body) { Task task = gson.fromJson(body, Task.class); task.story = new Key<Story>(Story.class, Long.valueOf(storyId)); task.save(); renderText(gson.toJson(task)); }
// This is actually performing the update and save the object private static void doUpdate(Task toUpdate, JsonObject body) { if (toUpdate != null) { workUnit.updateObject(toUpdate, body); toUpdate.save(); } }
public static Result getTasks() { return ok(task.render(Task.all(), taskForm)); }
public Result renameFolder(Integer project, String folder, @Bind("name") String name) { Task.renameFolder(project, folder, name); return ok(); }
public Result add(Integer project, String folder, @Bind("title") String title) { task = Task.create(project, folder, title); editable = true; return ok(Item.class); }
/** * Updates a single task data * * @param storyId * @param taskId * @param body */ public static void update(Long storyId, Long taskId, JsonObject body) { Task toUpdate = Task.findById(taskId); doUpdate(toUpdate, body); renderText(gson.toJson(toUpdate)); }
/** * gets all the tasks for a story * * @param storyId */ public static void byStory(long storyId) { List<Task> byStory = Task.findAllByStory(storyId); renderText(gson.toJson(byStory)); }
public static void create(Task task) { task.save(); }
public static void proposals() { List<Task> tasks = Task.findProposed(); render(tasks); }
/** * gets all the tasks for a story * * @param storyId */ public static void byId(long storyId, long taskId) { Task byId = Task.findById(taskId); renderText(gson.toJson(byId)); }
public Result update(Integer id, @Bind("done") Boolean done) { Task.markAsDone(id, done); return ok(); }
public static Result deleteTask(Long id) { Task.delete(id); return redirect(routes.TaskController.tasks()); }
public static void main(String args[]) { try { // IP address of the server, InetAddress serverAddress = InetAddress.getByName("localhost"); // Open a socket for communication. Socket socket = new Socket(serverAddress, 7896); // Create a data output stream (for sending messages) DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); System.out.println("Client is connecting to server..."); // Create Datainputstreeam (for receiving messages from server. DataInputStream dis = new DataInputStream(socket.getInputStream()); // Create an objectinputstream ( for receiving objects ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); // Create ObjectOutputStream ObjectOutputStream ous = new ObjectOutputStream(socket.getOutputStream()); // __________________________________________________________________________________ String message = "GET"; dos.writeUTF(message); System.out.println("Client: requesting " + message); // Blocking call, String response = dis.readUTF(); System.out.println("Client: server response : " + response); if (response.equals(message)) { // request a Task object String id = "approve-01"; dos.writeUTF(id); System.out.println("Client: requesting Task object"); Task t = (Task) ois.readObject(); // BLOCKING ? System.out.println("Client: Object received '" + t.name + "'"); } else { System.out.println("Client: the server did not acknowledge the request. Aborting"); } // __________________________________________________________________________________ message = "POST"; // message System.out.println("Client: requesting " + message); dos.writeUTF(message); // send it response = dis.readUTF(); // BLOCKING Task t = new Task(); t.name = "Tut les circles"; t.id = "one more cup of coffe"; t.date = "15-09-2013"; t.description = "recondre"; t.status = "mais jai le plus grande maillot du monde"; t.attendants = "bjarne, lise, hans, jimmy"; if (response.equals(message)) { System.out.println("Client: server accepted. Sending object"); ous.writeObject(t); } else { System.out.println("Client: the server did not acknowledge the object. Aborting."); } response = dis.readUTF(); System.out.println("Client: server response : " + response); // __________________________________________________________________________________ message = "PUT"; System.out.println("Client: requesting " + message); dos.writeUTF(message); // send message response = dis.readUTF(); // BLOCKING t.description = "recondre les roix"; if (response.equals(message)) { System.out.println("Client: server accepted. Sending object"); ous.writeObject(t); } else { System.out.println("Client: the server did not acknowledge the object. Aborting."); } response = dis.readUTF(); System.out.println("Client: server response : " + response); // ___________________________________________________________________________________ message = "DELETE"; System.out.println("Client: requesting " + message); dos.writeUTF(message); // send it response = dis.readUTF(); // BLOCKING if (response.equals(message)) { System.out.println("Client: server accepted. Sending parameter"); dos.writeUTF("Task 246.789.87"); } else { System.out.println("Client: the server did not acknowledge the request. Aborting."); } response = dis.readUTF(); System.out.println("Client: server response : " + response); // ___________________________________________________________________________________ // QUIT. Note: the client should not close the connection. The server does that dos.writeUTF("quit"); System.out.println("Client signed out."); } catch (IOException ex) { Logger.getLogger(TCPClient.class.getName()).log(Level.SEVERE, null, ex); System.out.println("error message: " + ex.getMessage()); } catch (ClassNotFoundException e) { Logger.getLogger(TCPClient.class.getName()).log(Level.SEVERE, null, e); System.out.println("error message: " + e.getMessage()); } }
public void execute() { task.execute(); }