[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model ...

Christian Bauer christian at hibernate.org
Fri Nov 9 10:08:25 EST 2007


  User: cbauer  
  Date: 07/11/09 10:08:25

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/core/model        
                        Comment.java Node.java User.java Role.java
                        UserProfile.java DatabaseObjects.hbm.xml
                        Document.java File.java
  Log:
  Various updates to core classes and views, required for forum plugin
  
  Revision  Changes    Path
  1.9       +17 -2     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Comment.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Comment.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Comment.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- Comment.java	12 Oct 2007 16:31:25 -0000	1.8
  +++ Comment.java	9 Nov 2007 15:08:25 -0000	1.9
  @@ -27,6 +27,8 @@
           properties = {"subject", "text"}
       )
   )
  +// TODO: We should have a CHECK constraint here that fails if (FROM_USER_ID is null and FROM_USER_NAME is null)
  +// However, MySQL doesn't support constraints properly...
   public class Comment implements Serializable {
   
       @Id
  @@ -49,7 +51,12 @@
       @org.hibernate.search.annotations.Field(index = org.hibernate.search.annotations.Index.TOKENIZED)
       private String subject;
   
  -    @Column(name = "FROM_USER_NAME", nullable = false)
  +    @ManyToOne(fetch = FetchType.LAZY)
  +    @JoinColumn(name = "FROM_USER_ID", nullable = true)
  +    @org.hibernate.annotations.ForeignKey(name = "FK_COMMENT_FROM_USER_ID")
  +    private User fromUser;
  +
  +    @Column(name = "FROM_USER_NAME", nullable = true)
       @Length(min = 3, max = 100)
       private String fromUserName;
   
  @@ -63,7 +70,7 @@
       private String fromUserHomepage;
   
       @Column(name = "COMMENT_TEXT", nullable = false)
  -    @Length(min = 1, max = 8192)
  +    @Length(min = 1, max = 32768)
       @org.hibernate.search.annotations.Field(index = org.hibernate.search.annotations.Index.TOKENIZED)
       private String text;
   
  @@ -112,6 +119,14 @@
           this.subject = subject;
       }
   
  +    public User getFromUser() {
  +        return fromUser;
  +    }
  +
  +    public void setFromUser(User fromUser) {
  +        this.fromUser = fromUser;
  +    }
  +
       public String getFromUserName() {
           return fromUserName;
       }
  
  
  
  1.27      +6 -2      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Node.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Node.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Node.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -b -r1.26 -r1.27
  --- Node.java	12 Oct 2007 16:31:25 -0000	1.26
  +++ Node.java	9 Nov 2007 15:08:25 -0000	1.27
  @@ -319,7 +319,8 @@
               "areaNumber", "createdBy", "createdOn", "lastModifiedBy", "lastModifiedOn", "menuItem", "name", "displayPosition", 
               "readAccessLevel", "revision", "wikiname", "writeAccessLevel", "tags",
               "contentType", "filename", "filesize", "imageMetaInfo.sizeX", "imageMetaInfo.sizeY", "imageMetaInfo.thumbnail", "imageMetaInfo.thumbnailData",
  -            "defaultDocument", "description", "enableComments", "enableCommentForm", "nameAsTitle", "pluginsUsed"
  +            "defaultDocument", "description",
  +            "enableComments", "enableCommentForm", "enableCommentsOnFeeds", "nameAsTitle", "macros"
           };
       }
   
  @@ -383,4 +384,7 @@
           return tags;
       }
       
  +    public boolean isInstance(Class clazz) {
  +        return clazz.isAssignableFrom(this.getClass());
  +    }
   }
  
  
  
  1.13      +13 -0     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/User.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: User.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/User.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- User.java	22 Oct 2007 05:12:16 -0000	1.12
  +++ User.java	9 Nov 2007 15:08:25 -0000	1.13
  @@ -17,6 +17,7 @@
   
   @Entity
   @Table(name = "USERS")
  + at org.hibernate.annotations.BatchSize(size = 20)
   public class User implements Serializable {
   
       @Id
  @@ -72,6 +73,12 @@
       @Column(name = "CREATED_ON", nullable = false, updatable = false)
       private Date createdOn = new Date();
   
  +    @Column(name = "LAST_LOGIN_ON", nullable = true)
  +    private Date lastLoginOn = new Date();
  +
  +    @Transient
  +    private Date previousLastLoginOn = new Date();
  +
       @ManyToMany(fetch = FetchType.LAZY) // Lazy so our @OrderBy works
       @JoinTable(
           name = "USER_ROLE",
  @@ -135,6 +142,12 @@
       public boolean isActivated() { return activated; }
       public void setActivated(boolean activated) { this.activated = activated; }
   
  +    public Date getLastLoginOn() { return lastLoginOn; }
  +    public void setLastLoginOn(Date lastLoginOn) { this.lastLoginOn = lastLoginOn; }
  +
  +    public Date getPreviousLastLoginOn() { return previousLastLoginOn; }
  +    public void setPreviousLastLoginOn(Date previousLastLoginOn) { this.previousLastLoginOn = previousLastLoginOn; }
  +
       public String getActivationCode() { return activationCode; }
       public void setActivationCode(String activationCode) { this.activationCode = activationCode; }
   
  
  
  
  1.7       +1 -0      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Role.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Role.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Role.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- Role.java	17 Aug 2007 13:00:24 -0000	1.6
  +++ Role.java	9 Nov 2007 15:08:25 -0000	1.7
  @@ -33,6 +33,7 @@
       private String displayName;
   
       @Column(name = "ACCESS_LEVEL", nullable = false)
  +    // TODO: This is of course completely ignored by MySQL, see http://dev.mysql.com/doc/refman/5.1/de/create-table.html
       @org.hibernate.annotations.Check(
           constraints = "ACCESS_LEVEL <= 1000"
       )
  
  
  
  1.2       +1 -0      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/UserProfile.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UserProfile.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/UserProfile.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- UserProfile.java	17 Aug 2007 13:00:24 -0000	1.1
  +++ UserProfile.java	9 Nov 2007 15:08:25 -0000	1.2
  @@ -13,6 +13,7 @@
   
   @Entity
   @Table(name = "USER_PROFILE")
  + at org.hibernate.annotations.BatchSize(size = 20)
   public class UserProfile {
   
       @Id
  
  
  
  1.7       +24 -0     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/DatabaseObjects.hbm.xml
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DatabaseObjects.hbm.xml
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/DatabaseObjects.hbm.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- DatabaseObjects.hbm.xml	31 Aug 2007 17:54:37 -0000	1.6
  +++ DatabaseObjects.hbm.xml	9 Nov 2007 15:08:25 -0000	1.7
  @@ -152,6 +152,15 @@
   
       <database-object>
           <create>
  +            alter table COMMENTS drop constraint FK_COMMENT_FROM_USER_ID;
  +            alter table COMMENTS add constraint FK_COMMENT_FROM_USER_ID foreign key (FROM_USER_ID) references USERS on delete cascade;
  +        </create>
  +        <drop></drop>
  +        <dialect-scope name="org.hibernate.dialect.HSQLDialect"/>
  +    </database-object>
  +
  +    <database-object>
  +        <create>
               create index IDX_COMPONENT_NAME on PREFERENCE (COMPONENT_NAME);
           </create>
           <drop>
  @@ -397,6 +406,21 @@
   
       <database-object>
           <create>
  +            alter table COMMENTS drop foreign key FK_COMMENT_FROM_USER_ID;
  +        </create>
  +        <drop></drop>
  +        <dialect-scope name="org.hibernate.dialect.MySQL5InnoDBDialect"/>
  +    </database-object>
  +    <database-object>
  +        <create>
  +            alter table COMMENTS add constraint FK_COMMENT_FROM_USER_ID foreign key (FROM_USER_ID) references USERS (USER_ID) on delete cascade;
  +        </create>
  +        <drop></drop>
  +        <dialect-scope name="org.hibernate.dialect.MySQL5InnoDBDialect"/>
  +    </database-object>
  +
  +    <database-object>
  +        <create>
               create index IDX_COMPONENT_NAME on PREFERENCE (COMPONENT_NAME);
           </create>
           <drop>
  
  
  
  1.17      +37 -11    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Document.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Document.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Document.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- Document.java	30 Aug 2007 16:50:58 -0000	1.16
  +++ Document.java	9 Nov 2007 15:08:25 -0000	1.17
  @@ -8,6 +8,7 @@
   
   import org.hibernate.validator.Length;
   import org.jboss.seam.wiki.core.search.annotations.Searchable;
  +import org.jboss.seam.wiki.core.search.annotations.SearchableType;
   
   import javax.persistence.*;
   import javax.persistence.Entity;
  @@ -15,6 +16,7 @@
   import java.util.ArrayList;
   
   @Entity
  + at Inheritance(strategy = InheritanceType.SINGLE_TABLE)
   @DiscriminatorValue("DOCUMENT")
   @org.hibernate.search.annotations.Indexed
   @Searchable(description = "Documents")
  @@ -36,23 +38,29 @@
       @Searchable(description = "Content")
       private String content;
   
  -    @Column(table = "NODE_DOCUMENT", name = "NAME_AS_TITLE")
  +    @Column(table = "NODE_DOCUMENT", name = "NAME_AS_TITLE", nullable = false)
       private Boolean nameAsTitle = true;
   
  -    @Column(table = "NODE_DOCUMENT", name = "ENABLE_COMMENTS")
  +    @Column(table = "NODE_DOCUMENT", name = "ENABLE_COMMENTS", nullable = false)
       private Boolean enableComments = false;
   
  -    @Column(table = "NODE_DOCUMENT", name = "ENABLE_COMMENT_FORM")
  +    @Column(table = "NODE_DOCUMENT", name = "ENABLE_COMMENT_FORM", nullable = false)
       private Boolean enableCommentForm = true;
   
  +    @Column(table = "NODE_DOCUMENT", name = "ENABLE_COMMENTS_ON_FEEDS", nullable = false)
  +    private Boolean enableCommentsOnFeeds = false;
  +
       @OneToMany(mappedBy = "document", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
       @org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE)
       @org.hibernate.annotations.OrderBy(clause = "CREATED_ON desc")
       @org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.EXTRA)
       private List<Comment> comments = new ArrayList<Comment>();
   
  -    @Column(table = "NODE_DOCUMENT", name = "PLUGINS_USED", nullable = false)
  -    private String pluginsUsed = "";
  +    @Column(table = "NODE_DOCUMENT", name = "MACROS", nullable = false)
  +    //@org.hibernate.search.annotations.Field(index = org.hibernate.search.annotations.Index.UN_TOKENIZED)
  +    //@Searchable(description = "Macro", type = SearchableType.PHRASE)
  +    @org.hibernate.annotations.Index(name = "IDX_DOCUMENT_MACROS")
  +    private String macros = "";
   
       public Document() {
           super("New Document");
  @@ -63,10 +71,16 @@
           super(name);
       }
   
  -    public Document(Document original) {
  +    public Document(Document original, boolean copyLazyProperties) {
           super(original);
  +        if (copyLazyProperties) {
           this.content = original.content;
       }
  +        this.nameAsTitle = original.nameAsTitle;
  +        this.enableComments = original.enableComments;
  +        this.enableCommentForm = original.enableCommentForm;
  +        this.macros = original.macros;
  +    }
   
       // Mutable properties
   
  @@ -101,16 +115,24 @@
           this.enableCommentForm = enableCommentForm;
       }
   
  +    public Boolean getEnableCommentsOnFeeds() {
  +        return enableCommentsOnFeeds;
  +    }
  +
  +    public void setEnableCommentsOnFeeds(Boolean enableCommentsOnFeeds) {
  +        this.enableCommentsOnFeeds = enableCommentsOnFeeds;
  +    }
  +
       public List<Comment> getComments() {
           return comments;
       }
   
  -    public String getPluginsUsed() {
  -        return pluginsUsed;
  +    public String getMacros() {
  +        return macros;
       }
   
  -    public void setPluginsUsed(String pluginsUsed) {
  -        this.pluginsUsed = pluginsUsed;
  +    public void setMacros(String macros) {
  +        this.macros = macros;
       }
   
       public void addChild(Node child) {
  @@ -125,4 +147,8 @@
           super.rollback(revision);
           this.content = ((Document)revision).content;
       }
  +
  +    public boolean macroPresent(String macro) {
  +        return getMacros().contains(macro);
  +    }
   }
  
  
  
  1.13      +8 -2      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/File.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: File.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/File.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- File.java	29 Aug 2007 00:29:22 -0000	1.12
  +++ File.java	9 Nov 2007 15:08:25 -0000	1.13
  @@ -61,8 +61,15 @@
           super(name);
       }
   
  -    public File(File original) {
  +    public File(File original, boolean copyLazyProperties) {
           super(original);
  +        if (copyLazyProperties) {
  +            this.data = original.getData();
  +        }
  +        this.filename = original.getFilename();
  +        this.filesize = original.getFilesize();
  +        this.contentType = original.getContentType();
  +        this.imageMetaInfo = original.getImageMetaInfo();
       }
   
       // Mutable properties
  @@ -129,5 +136,4 @@
               return null;
           }
       }
  -
   }
  
  
  



More information about the jboss-cvs-commits mailing list