summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKjetil Ørbekk <orbekk@pvv.ntnu.no>2010-09-02 02:04:15 -0400
committerKjetil Ørbekk <orbekk@pvv.ntnu.no>2010-09-02 02:04:15 -0400
commitea2cfcff9f4f5b8d06e2d8954e7e732119b6c0b8 (patch)
tree32a4d9ba180cdd30ccf511e8da206e8cbaa52ea6 /src
parent699b451675830da041d09a6e32045772788ad66e (diff)
Add data classes
Diffstat (limited to 'src')
-rw-r--r--src/lq/PMF.java16
-rw-r--r--src/lq/Quote.java58
-rw-r--r--src/lq/Vote.java40
3 files changed, 114 insertions, 0 deletions
diff --git a/src/lq/PMF.java b/src/lq/PMF.java
new file mode 100644
index 0000000..25ffde6
--- /dev/null
+++ b/src/lq/PMF.java
@@ -0,0 +1,16 @@
+package lq;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManagerFactory;
+
+// Based on: http://code.google.com/appengine/docs/java/datastore/usingjdo.html
+public final class PMF {
+ private static final PersistenceManagerFactory pmfInstance =
+ JDOHelper.getPersistenceManagerFactory("transactions-optional");
+
+ private PMF() {}
+
+ public static PersistenceManagerFactory get() {
+ return pmfInstance;
+ }
+}
diff --git a/src/lq/Quote.java b/src/lq/Quote.java
new file mode 100644
index 0000000..7475ba0
--- /dev/null
+++ b/src/lq/Quote.java
@@ -0,0 +1,58 @@
+package lq;
+
+import java.util.Date;
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.PersistenceCapable;
+import javax.jdo.annotations.Persistent;
+import javax.jdo.annotations.PrimaryKey;
+
+@PersistenceCapable(identityType = IdentityType.APPLICATION)
+public class Quote {
+ @PrimaryKey
+ @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
+ private Long id;
+
+ @Persistent
+ private Date timestamp;
+
+ @Persistent
+ private Boolean approved;
+
+ @Persistent
+ private Date quoteDate;
+
+ @Persistent
+ private String author;
+
+ @Persistent
+ private String content;
+
+ @Persistent
+ private String ip;
+
+ public Quote(Date quoteDate, String author, String content, String ip) {
+ this.quoteDate = quoteDate;
+ this.author = author;
+ this.content = content;
+ this.ip = ip;
+
+ this.timestamp = new Date();
+ }
+
+ public Long getId() { return id; }
+ public Date getTimestamp() { return timestamp; }
+ public Boolean getApproved() { return approved; }
+ public Date getQuoteDate() { return quoteDate; }
+ public String getAuthor() { return author; }
+ public String getContent() { return content; }
+ public String getIp() { return ip; }
+
+ public void setId(Long id) { this.id = id; }
+ public void setTimestamp(Date timestamp) { this.timestamp = timestamp; }
+ public void setApproved(Boolean approved) { this.approved = approved; }
+ public void setQuoteDate(Date quoteDate) { this.quoteDate = quoteDate; }
+ public void setAuthor(String author) { this.author = author; }
+ public void setContent(String content) { this.content = content; }
+ public void setIp(String ip) { this.ip = ip; }
+}
diff --git a/src/lq/Vote.java b/src/lq/Vote.java
new file mode 100644
index 0000000..0d3c9ac
--- /dev/null
+++ b/src/lq/Vote.java
@@ -0,0 +1,40 @@
+package lq;
+
+import java.util.Date;
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.PersistenceCapable;
+import javax.jdo.annotations.Persistent;
+import javax.jdo.annotations.PrimaryKey;
+
+@PersistenceCapable(identityType = IdentityType.APPLICATION)
+public class Vote {
+ @PrimaryKey
+ @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
+ private Long id;
+
+ @Persistent
+ private Quote quote;
+
+ @Persistent
+ private Date timestamp;
+
+ @Persistent
+ private String ip;
+
+ public Vote(Quote quote, String ip) {
+ this.quote = quote;
+ this.ip = ip;
+ timestamp = new Date();
+ }
+
+ public Long getId() { return id; }
+ public Quote getQuote() { return quote; }
+ public Date getTimestamp() { return timestamp; }
+ public String getIp() { return ip; }
+
+ public void setId(Long id) { this.id = id; }
+ public void setQuote(Quote quote) { this.quote = quote; }
+ public void setTimestamp(Date timestamp) { this.timestamp = timestamp; }
+ public void setIp(String ip) { this.ip = ip; }
+}