Package com.tmm.enterprise.microblog.domain

Examples of com.tmm.enterprise.microblog.domain.ToDo


  @Transactional
  public ToDo createToDo(String title, String description, String userName) throws ButterflyException {
    Account acc = accountService.loadAccountByUserName(userName);
    Person currentUser = acc.getUserProfile();
    if (currentUser!=null){
      ToDo todo = new ToDo();
      todo.setTitle(title);
      todo.setDetails(description);
      todo.setRaisedBy(currentUser);
      todo.setAssignedTo(currentUser);
      currentUser.addTodoItem(todo);
      todoDao.persist(todo);
      return todo;
    }
    throw new ButterflyException(ButterflyExceptionCode.USER003_INVALIDUSER, "Unable to create new ToDo - Account does not have associated Person");
View Full Code Here


  @Transactional
  public void execute() throws Exception {
    setCredentials();
    Person belongsTo = getContactableService().loadPerson(50);

    ToDo todo = new ToDo();
    todo.setAssignedTo(belongsTo);
    todo.setDetails("its a todo item!");
    todo.setTitle("new todo..");
    getActivityService().getEntityManager().persist(todo);
    Account acc = getAccount();

    // TODO persist activity here..
View Full Code Here

    throw new ButterflyException(ButterflyExceptionCode.USER003_INVALIDUSER, "Unable to create new ToDo - Account does not have associated Person");
  }
 
  @Transactional
  public void updateToDoCompletion(long id, boolean completed){   
    ToDo todo = getEntityManager().find(ToDo.class, id);
    if (todo!=null){
      todo.setCompleted(completed);
    }
  }
View Full Code Here

    }
  }

  @Transactional
  public void removeTodo(long id) {
    ToDo todo = getEntityManager().find(ToDo.class, id);
    Contactable raiser = todo.getRaisedBy();
    List<ToDo> todos = raiser.getTodoItems();
    todos.remove(todo);
    todo.setRaisedBy(null);
  }
View Full Code Here

  @RequestMapping("/createTodo")
  public ModelAndView createTodo(HttpServletRequest request, HttpServletResponse response)  {
    String title = request.getParameter("title");
    String body = request.getParameter("body");
    String userName = request.getRemoteUser();
    ToDo todo = null;
    try {
      todo = todoService.createToDo(title, body, userName);
    } catch (ButterflyException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Map<String, String> model = Maps.newHashMap();
    model.put("id", "" + todo.getId());
    model.put("title", todo.getTitle());
    model.put("body", todo.getDetails());
    model.put("displayDate", DateHelper.getTimeAgo(todo.getCreationDate()));
    return new ModelAndView("ajax_todo_created", model);
  }
View Full Code Here

  public JsonObject render(Notification renderTarget) {

    // FIXME - just put in to get web running.. will need more thought on
    // the rendering approach
    JsonObject n = new JsonObject();
    ToDo todo = (ToDo) (renderTarget.getActivity());
    n.addProperty("read", renderTarget.isRead());
    String msg = todo.getTitle() == null ? (todo.getDetails().length() > 100 ? todo.getDetails().substring(0, 100) : todo.getDetails()) : (todo
        .getTitle().length() > 100 ? todo.getTitle().substring(0, 100) : todo.getTitle());
    String from = "you created a ToDo Item " + (todo.getDeadline() == null ? "" : todo.getDeadline().toString());
    n.addProperty("body", msg);
    n.addProperty("from", from);
    n.addProperty("activityId", todo.getId());
    n.addProperty("activityType", "ToDo");

    return n;
  }
View Full Code Here

TOP

Related Classes of com.tmm.enterprise.microblog.domain.ToDo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.