Examples of Thought


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

Examples of com.pt.domain.Thought

        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

Examples of com.pt.domain.Thought

      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

Examples of com.pt.domain.Thought

      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

Examples of com.pt.domain.Thought

      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

Examples of org.lexev.bestwisethoughts.client.data.Thought

      final RequestAction requestAction) {
   
    SwingWorker<Thought, Void> swingWorker = new SwingWorker<Thought, Void>() {
            @Override
            public Thought doInBackground() throws IOException{
              Thought thoughtToShow = null;
        if (cachedReceivedThoughts.size() == 0){ 
          ThoughtList thoughtsFromServer = webServiceREST.getRandomThoughts();           
          cachedReceivedThoughts.addAll(thoughtsFromServer.getThoughtsList());       
        }
        thoughtToShow = cachedReceivedThoughts.poll();
        cachedLastThoughts.addAndSaveToFile(thoughtToShow.getID(), new Thought(thoughtToShow));
                return thoughtToShow;
            }

            @Override
            public void done() {       
                try {
                  Thought thoughtAcquired = get();
                  if (actionRequester == null){
                toaster.showToaster(thoughtAcquired);
                  } else {
                    actionRequester.completeBackgroundAction(
                        Status.OK,
View Full Code Here

Examples of org.lexev.bestwisethoughts.client.data.Thought

            public Long doInBackground() throws NotRegisteredException, IOException{
              String resultString = null;
              if (webServiceREST.isUserRegistered()){
              //sending request to server
              resultString = webServiceREST.sendFavoriteRequest(thought);
                Thought modifiedThought = new Thought(thought);
                modifiedThought.setFavorite(!thought.isFavorite());
                //update cached last thoughts
                if (cachedLastThoughts.getMap().containsKey(thought.getID())){
                  cachedLastThoughts.getMap().get(thought.getID()).setFavorite(modifiedThought.isFavorite());
                    cachedLastThoughts.saveToFile()
                } else {
                  //Nothing to do
                }
                //update cached favorite thoughts
                if (modifiedThought.isFavorite()){
                  cachedFavoriteThought.addAndSaveToFile(modifiedThought.getID(), modifiedThought);
                } else {
                  cachedFavoriteThought.getMap().remove(thought.getID());
                }
                 
              } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.