daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Feb 18th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package models;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.List;
  6. import java.util.Set;
  7. import java.util.TreeSet;
  8.  
  9. import play.data.binding.As;
  10. import play.data.validation.MaxSize;
  11. import play.data.validation.Required;
  12. import play.modules.morphia.Model;
  13.  
  14. import com.google.code.morphia.annotations.Embedded;
  15. import com.google.code.morphia.annotations.Entity;
  16. import com.google.code.morphia.annotations.Reference;
  17.  
  18. @Entity(value="Publication", noClassnameStored=true)
  19. public class Publication extends Model  {
  20.  
  21.     @MaxSize(10000)
  22.         @com.google.code.morphia.annotations.Property(value="contenido")
  23.     public String contenido;
  24.  
  25.     @Required
  26.     @Reference
  27.     public User autor;
  28.  
  29.     @Required @As("yyyy-MM-dd")
  30.     public Date fecha; 
  31.  
  32.     @Embedded
  33.     public List<ComentToPublication> comentarios;
  34.  
  35.  
  36.         public Publication( String publicaxion, User user)  {
  37.         contenido = publicaxion;
  38.         autor = user;
  39.         fecha = new Date();
  40.     }
  41.  
  42.  
  43.         /* about COMENTS*/
  44.     public Publication addComentario(User user, String body){
  45.         ComentToPublication comentToPublication = new ComentToPublication(user,this,body);
  46.         this.save();
  47.         return this;
  48.     }
  49.  
  50.     public List<ComentToPublication> getComentarios (){
  51.         if (null == comentarios){
  52.             comentarios = new ArrayList<ComentToPublication>();
  53.         }
  54.         return comentarios;
  55.     }
  56.  
  57.     void addComentario(ComentToPublication comentary){
  58.         if (null == comentarios){
  59.             comentarios = new ArrayList<ComentToPublication>();
  60.         }
  61.         comentarios.add(comentary);
  62.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top