[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model ...
Christian Bauer
christian at hibernate.org
Wed Jan 2 13:59:47 EST 2008
User: cbauer
Date: 08/01/02 13:59:47
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/model
WikiDirectory.java Feed.java
Added: examples/wiki/src/main/org/jboss/seam/wiki/core/model
WikiFeed.java
Log:
Make feed domain model extensible, preparation for aggregator
Revision Changes Path
1.4 +3 -3 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDirectory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WikiDirectory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDirectory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- WikiDirectory.java 30 Dec 2007 02:33:21 -0000 1.3
+++ WikiDirectory.java 2 Jan 2008 18:59:47 -0000 1.4
@@ -28,7 +28,7 @@
@OneToOne(fetch = FetchType.EAGER, mappedBy = "directory", cascade = CascadeType.PERSIST)
@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.JOIN)
- private Feed feed;
+ private WikiFeed feed;
@Embedded
private NestedSetNodeInfo<WikiDirectory> nodeInfo;
@@ -55,8 +55,8 @@
public WikiFile getDefaultFile() { return defaultFile; }
public void setDefaultFile(WikiFile defaultFile) { this.defaultFile = defaultFile; }
- public Feed getFeed() { return feed; }
- public void setFeed(Feed feed) { this.feed = feed; }
+ public WikiFeed getFeed() { return feed; }
+ public void setFeed(WikiFeed feed) { this.feed = feed; }
public void flatCopy(WikiDirectory original, boolean copyLazyProperties) {
super.flatCopy(original, copyLazyProperties);
1.9 +32 -14 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Feed.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Feed.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Feed.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- Feed.java 19 Dec 2007 04:29:20 -0000 1.8
+++ Feed.java 2 Jan 2008 18:59:47 -0000 1.9
@@ -13,6 +13,9 @@
@Entity
@Table(name = "FEED")
@org.hibernate.annotations.BatchSize(size = 10)
+ at Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+ at DiscriminatorColumn(name = "FEED_TYPE", length = 255)
+ at DiscriminatorValue("EXTERNAL")
public class Feed implements Serializable {
@Id
@@ -20,6 +23,9 @@
@Column(name = "FEED_ID")
private Long id;
+ @Column(name = "FEED_LINK", nullable = false)
+ private String link;
+
@Column(name = "TITLE", nullable = false)
private String title;
@@ -32,12 +38,6 @@
@Column(name = "PUBLISHED_ON", nullable = false, updatable = false)
private Date publishedDate = new Date();
- @OneToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "DIRECTORY_ID", nullable = false, updatable = false, unique = true)
- @org.hibernate.annotations.ForeignKey(name = "FK_FEED_WIKI_DIRECTORY_ID")
- @org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE)
- private WikiDirectory directory;
-
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
name = "FEED_FEEDENTRY",
@@ -56,6 +56,14 @@
// Mutable properties
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
public String getTitle() {
return title;
}
@@ -88,14 +96,6 @@
this.publishedDate = publishedDate;
}
- public WikiDirectory getDirectory() {
- return directory;
- }
-
- public void setDirectory(WikiDirectory directory) {
- this.directory = directory;
- }
-
public SortedSet<FeedEntry> getFeedEntries() {
return feedEntries;
}
@@ -104,6 +104,24 @@
this.feedEntries = feedEntries;
}
+ public int getReadAccessLevel() {
+ return 0; // No restrictions
+ }
+
+ // Need this for JSF EL expressions
+ public boolean isInstance(String className) {
+ try {
+ Class clazz = Class.forName(getClass().getPackage().getName() + "." + className);
+ return isInstance(clazz);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public boolean isInstance(Class clazz) {
+ return clazz.isAssignableFrom(this.getClass());
+ }
+
public String toString() {
return "Feed: " + getId();
}
1.1 date: 2008/01/02 18:59:47; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiFeed.java
Index: WikiFeed.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.seam.wiki.core.model;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author Christian Bauer
*/
@Entity
@DiscriminatorValue("INTERNAL")
public class WikiFeed extends Feed implements Serializable {
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DIRECTORY_ID", nullable = true, updatable = false, unique = true)
@org.hibernate.annotations.ForeignKey(name = "FK_FEED_WIKI_DIRECTORY_ID")
@org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE)
private WikiDirectory directory;
public WikiFeed() {
super();
}
public WikiDirectory getDirectory() {
return directory;
}
public void setDirectory(WikiDirectory directory) {
this.directory = directory;
}
public int getReadAccessLevel() {
return getDirectory().getReadAccessLevel();
}
}
More information about the jboss-cvs-commits
mailing list