Package com.pt.domain

Examples of com.pt.domain.Thought


     
      Person owner = new Person();
      owner.setName(name);
      dataService.createPerson(owner);
     
      Thought thought = new Thought();
      thought.setCreatedOn(Calendar.getInstance().getTime());
      thought.setThought(new Text(userThought));
      thought.setOwner(owner);
      thought.setThumbnail(new Text(String.format("data:%s;base64,%s", contentType, encodedIcon)));
     
      dataService.createThought(thought);
     
      model.addAttribute("successMessage", "Thought created successfully.");
      model.addAttribute("thoughs", dataService.getAllThought());
View Full Code Here


        model.addAttribute("errorMessage", "Invalid thought ID.");
        model.addAttribute("thoughs", dataService.getAllThought());
        return "home";
      }
     
      Thought thought = dataService.getThought(id);
      if (thought == null) {
        model.addAttribute("errorMessage", String.format("Nothing to update. Thought with ID %s not found.", id));
        model.addAttribute("thoughs", dataService.getAllThought());
        return "home";
      }
     
      if (isEmpty(contentType) || isEmpty(name) || isEmpty(userThought))  {
        model.addAttribute("errorMessage", "Name, your thoughts and a picture are required.");
            return show("write");
      }
     
      String encodedIcon = null;
      if (image != null) {
        encodedIcon = Base64.encodeBase64String(image);
      }
     
      if (isEmpty(encodedIcon) && thought.getThumbnail() == null) {
        model.addAttribute("errorMessage", "Name, your thoughts and a picture are required.");
            return show("write");
      }
     
      Person owner = thought.getOwner();
      if (!owner.getName().equals(name)) {
        owner.setName(name);
        dataService.updatePerson(owner);
      }
     
      thought.setThought(new Text(userThought));
      thought.setOwner(owner);
     
      if (StringUtils.isNotEmpty(encodedIcon)) {
        thought.setThumbnail(new Text(String.format("data:%s;base64,%s", contentType, encodedIcon)));
      }
     
      dataService.updateThought(thought);
     
      model.addAttribute("successMessage", "Thought updated successfully.");
View Full Code Here

      model.addAttribute("errorMessage", "Invalid thought ID.");
      model.addAttribute("thoughs", dataService.getAllThought());
      return "home";
    }
   
    Thought thought = dataService.getThought(id);
    if (thought == null) {
      model.addAttribute("errorMessage", String.format("Nothing to update. Thought with ID %s not found.", id));
      model.addAttribute("thoughs", dataService.getAllThought());
      return "home";
    }
View Full Code Here

      model.addAttribute("errorMessage", "Invalid thought ID.");
      model.addAttribute("thoughs", dataService.getAllThought());
      return "home";
    }
   
    Thought thought = dataService.getThought(id);
    if (thought == null) {
      model.addAttribute("errorMessage", String.format("Nothing to delete. Thuoght with ID %s not found.", id));
      model.addAttribute("thoughs", dataService.getAllThought());
      return "home";
    }
View Full Code Here

      model.addAttribute("errorMessage", "Invalid thought ID.");
      model.addAttribute("thoughs", dataService.getAllThought());
      return "home";
    }
   
    Thought thought = dataService.getThought(id);
    if (thought == null) {
      model.addAttribute("errorMessage", String.format("Nothing to delete. Thuoght with ID %s not found.", id));
      model.addAttribute("thoughs", dataService.getAllThought());
      return "home";
    }
   
    switch (type) {
      case "up":
        thought.incrementThumbsUp();
        break;
      case "down":
        thought.incrementThumbsDown();
        break;
      default:
        model.addAttribute("errorMessage", "Wrong update type.");
        model.addAttribute("thoughs", dataService.getAllThought());
        return "home";
View Full Code Here

TOP

Related Classes of com.pt.domain.Thought

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.