Skip to content
Browse files

TU for issue #2 with checking

  • Loading branch information...
1 parent f2f41f6 commit 8e6413bf9482baeefac3da3c0ea622387a43e7db @sim51 sim51 committed Jul 30, 2011
View
130 samples-and-tests/logisima-play-yml-test/.classpath
@@ -5,60 +5,80 @@
<classpathentry kind="src" path="crud"/>
<classpathentry kind="src" path="logisima-play-yml"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/play-1.2.1.jar"/>
- <classpathentry kind="lib" path="/home/bsimard/workspace_logisima/logisima-play-yml/lib/logisima-play-yml.jar" sourcepath="/logisima-play-yml"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-logging-1.1.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-email-1.2.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jj-simplecaptcha.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/hibernate-core-3.6.1.Final.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jamon-2.7.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/mail-1.4.3.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/h2-1.3.149.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/org.eclipse.jdt.core-3.6.0.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/memcached-2.4.2.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-fileupload-1.2.2.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/xstream-1.3.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/slf4j-log4j12-1.6.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jaxen-1.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jsr107cache-1.0.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-collections-3.2.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/c3p0-0.9.1.2.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/dom4j-1.6.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/mysql-connector-java-5.1.13.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/log4j-1.2.15.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/gson-1.6.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/slf4j-api-1.6.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/javax.inject-1.0.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-beanutils-1.8.3.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/async-http-client-1.6.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/geronimo-servlet_2.5_spec-1.2.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/joda-time-1.6.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/ivy-2.2.0.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/javassist-3.9.0.GA.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/bcprov-jdk15-1.45.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jta-1.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jregex-1.2_01.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/oval-1.50.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/asm-all-3.3.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/ezmorph-1.0.3.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-lang-2.6.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/snakeyaml-1.7.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/antlr-2.7.6.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jj-textile.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/hibernate-commons-annotations-3.2.0.Final.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/netty-3.2.4.Final.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/activation-1.1.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-codec-1.4.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/junit-4.8.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/groovy-all-1.7.7.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jj-wikitext.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/jj-imaging.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/hibernate-entitymanager-3.6.0.Final.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/cglib-nodep-2.2.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-io-2.0.1.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/commons-javaflow-1066591.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/ehcache-core-2.0.0.jar"/>
- <classpathentry kind="lib" path="/usr/local/play/play-1.2.1/framework/lib/signpost-core-1.2.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/play-1.2.2.jar" sourcepath="/usr/local/play/play-1.2.2/framework/src"/>
+ <classpathentry kind="lib" path="/home/bsimard/workspace_logisima/logisima-play-yml/lib/logisima-play-yml.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-logging-1.1.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-email-1.2.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jj-simplecaptcha.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/hibernate-core-3.6.1.Final.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="http://docs.jboss.org/hibernate/core/3.6/javadocs/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jamon-2.7.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/mail-1.4.3.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/h2-1.3.149.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/org.eclipse.jdt.core-3.6.0.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/memcached-2.4.2.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-fileupload-1.2.2.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/xstream-1.3.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/slf4j-log4j12-1.6.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jaxen-1.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jsr107cache-1.0.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-collections-3.2.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/c3p0-0.9.1.2.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/dom4j-1.6.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/mysql-connector-java-5.1.13.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/log4j-1.2.15.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="http://logging.apache.org/log4j/1.2/apidocs/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/slf4j-api-1.6.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/javax.inject-1.0.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-beanutils-1.8.3.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/geronimo-servlet_2.5_spec-1.2.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/joda-time-1.6.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/ivy-2.2.0.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/javassist-3.9.0.GA.jar" sourcepath="/home/bsimard/.m2/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/bcprov-jdk15-1.45.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="http://download.oracle.com/javaee/6/api/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/async-http-client-1.6.3.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jta-1.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jregex-1.2_01.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/oval-1.50.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/asm-all-3.3.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/ezmorph-1.0.3.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-lang-2.6.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/snakeyaml-1.7.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/antlr-2.7.6.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jj-textile.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/hibernate-commons-annotations-3.2.0.Final.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="http://docs.jboss.org/hibernate/annotations/3.5/api/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/netty-3.2.4.Final.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/activation-1.1.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-codec-1.4.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/junit-4.8.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/groovy-all-1.7.7.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jj-wikitext.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/jj-imaging.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/hibernate-entitymanager-3.6.0.Final.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="http://docs.jboss.org/hibernate/entitymanager/3.6/javadocs/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/cglib-nodep-2.2.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-io-2.0.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/gson-1.7.1.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/commons-javaflow-1066591.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/ehcache-core-2.0.0.jar"/>
+ <classpathentry kind="lib" path="/usr/local/play/play-1.2.2/framework/lib/signpost-core-1.2.jar"/>
<classpathentry kind="output" path="eclipse/classes"/>
</classpath>
View
6 samples-and-tests/logisima-play-yml-test/.project
@@ -15,9 +15,9 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.playframework.playclipse.playNature</nature>
</natures>
- <linkedResources><link><name>crud</name><type>2</type><location>/usr/local/play/play-1.2.1/modules/crud/app</location></link>
-<link><name>conf/crud</name><type>2</type><location>/usr/local/play/play-1.2.1/modules/crud/conf</location></link>
-<link><name>public/crud</name><type>2</type><location>/usr/local/play/play-1.2.1/modules/crud/public</location></link>
+ <linkedResources><link><name>crud</name><type>2</type><location>/usr/local/play/play-1.2.2/modules/crud/app</location></link>
+<link><name>conf/crud</name><type>2</type><location>/usr/local/play/play-1.2.2/modules/crud/conf</location></link>
+<link><name>public/crud</name><type>2</type><location>/usr/local/play/play-1.2.2/modules/crud/public</location></link>
<link><name>logisima-play-yml</name><type>2</type><location>/home/bsimard/workspace_logisima/logisima-play-yml/app</location></link>
</linkedResources>
</projectDescription>
View
22 samples-and-tests/logisima-play-yml-test/app/models/Address.java
@@ -14,4 +14,26 @@
public String city;
public String country;
+
+ public int compareTo(Address adr) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.number.equals(adr.number)) {
+ return NOT_EQUAL;
+ }
+ if (!this.street.equals(adr.street)) {
+ return NOT_EQUAL;
+ }
+ if (!this.zip.equals(adr.zip)) {
+ return NOT_EQUAL;
+ }
+ if (!this.city.equals(adr.city)) {
+ return NOT_EQUAL;
+ }
+ if (!this.country.equals(adr.country)) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
}
View
58 samples-and-tests/logisima-play-yml-test/app/models/Comment.java
@@ -1,38 +1,48 @@
package models;
-
-import java.util.*;
-import javax.persistence.*;
-
-import play.db.jpa.*;
-import play.data.validation.*;
-
+
+import javax.persistence.Entity;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+
+import play.data.validation.MaxSize;
+import play.data.validation.Required;
+import play.db.jpa.Model;
+
@Entity
public class Comment extends Model {
-
+
@Required
public String author;
-
+
@Required
- public Date postedAt;
-
+ public Date postedAt;
+
@Lob
@Required
@MaxSize(10000)
public String content;
-
+
@ManyToOne
@Required
- public Post post;
-
- public Comment(Post post, String author, String content) {
- this.post = post;
- this.author = author;
- this.content = content;
- this.postedAt = new Date();
+ public Post post;
+
+ public int compareTo(Comment comment) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.author.equals(comment.author)) {
+ return NOT_EQUAL;
+ }
+ if (!this.postedAt.equals(comment.postedAt)) {
+ return NOT_EQUAL;
+ }
+ if (!this.content.equals(comment.content)) {
+ return NOT_EQUAL;
+ }
+ if (post.compareTo(comment.post) != 0) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
}
-
- public String toString() {
- return content.length() > 50 ? content.substring(0, 50) + "..." : content;
- }
-
+
}
View
32 samples-and-tests/logisima-play-yml-test/app/models/Date.java
@@ -27,9 +27,35 @@
@Temporal(TemporalType.DATE)
public Calendar cal2;
- // @Temporal(TemporalType.TIME)
- // public Calendar cal3;
-
@Temporal(TemporalType.TIMESTAMP)
public Calendar cal4;
+
+ public int compareTo(Date date) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.date1.equals(date.date1)) {
+ return NOT_EQUAL;
+ }
+ if (!this.date2.equals(date.date2)) {
+ return NOT_EQUAL;
+ }
+ if (!this.date3.equals(date.date3)) {
+ return NOT_EQUAL;
+ }
+ if (!this.date4.equals(date.date4)) {
+ return NOT_EQUAL;
+ }
+ if (!this.cal1.equals(date.cal1)) {
+ return NOT_EQUAL;
+ }
+ if (!this.cal2.equals(date.cal2)) {
+ return NOT_EQUAL;
+ }
+ if (!this.cal4.equals(date.cal4)) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+
}
View
25 samples-and-tests/logisima-play-yml-test/app/models/Post.java
@@ -34,4 +34,29 @@
@ManyToMany(cascade = CascadeType.PERSIST)
public Set<Tag> tags;
+ public int compareTo(Post post) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.title.equals(post.title)) {
+ return NOT_EQUAL;
+ }
+ if (!this.postedAt.equals(post.postedAt)) {
+ return NOT_EQUAL;
+ }
+ if (!this.content.equals(post.content)) {
+ return NOT_EQUAL;
+ }
+ if (!this.author.equals(post.author)) {
+ return NOT_EQUAL;
+ }
+ if (this.comments.size() != post.comments.size()) {
+ return NOT_EQUAL;
+ }
+ if (this.tags.size() != post.tags.size()) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+
}
View
10 samples-and-tests/logisima-play-yml-test/app/models/Tag.java
@@ -9,4 +9,14 @@
public String name;
+ public int compareTo(Tag tag) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.name.equals(tag.name)) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+
}
View
21 samples-and-tests/logisima-play-yml-test/app/models/User.java
@@ -21,4 +21,25 @@
public boolean isAdmin;
+ public int compareTo(User user) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.email.equals(user.email)) {
+ return NOT_EQUAL;
+ }
+ if (!this.password.equals(user.password)) {
+ return NOT_EQUAL;
+ }
+ if (!this.fullname.equals(user.fullname)) {
+ return NOT_EQUAL;
+ }
+ if (this.isAdmin != user.isAdmin) {
+ return NOT_EQUAL;
+ }
+ if (this.addess.compareTo(user.addess) != 0) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
}
View
39 samples-and-tests/logisima-play-yml-test/app/models/test/Address2.java
@@ -0,0 +1,39 @@
+package models.test;
+
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class Address2 {
+
+ public Integer number;
+
+ public String street;
+
+ public Integer zip;
+
+ public String city;
+
+ public String country;
+
+ public int compareTo(Address2 adr) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.number.equals(adr.number)) {
+ return NOT_EQUAL;
+ }
+ if (!this.street.equals(adr.street)) {
+ return NOT_EQUAL;
+ }
+ if (!this.zip.equals(adr.zip)) {
+ return NOT_EQUAL;
+ }
+ if (!this.city.equals(adr.city)) {
+ return NOT_EQUAL;
+ }
+ if (!this.country.equals(adr.country)) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+}
View
48 samples-and-tests/logisima-play-yml-test/app/models/test/Comment2.java
@@ -0,0 +1,48 @@
+package models.test;
+
+import javax.persistence.Entity;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+
+import play.data.validation.MaxSize;
+import play.data.validation.Required;
+import play.db.jpa.Model;
+
+@Entity
+public class Comment2 extends Model {
+
+ @Required
+ public String author;
+
+ @Required
+ public Date2 postedAt;
+
+ @Lob
+ @Required
+ @MaxSize(10000)
+ public String content;
+
+ @ManyToOne
+ @Required
+ public Post2 post;
+
+ public int compareTo(Comment2 comment) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.author.equals(comment.author)) {
+ return NOT_EQUAL;
+ }
+ if (!this.postedAt.equals(comment.postedAt)) {
+ return NOT_EQUAL;
+ }
+ if (!this.content.equals(comment.content)) {
+ return NOT_EQUAL;
+ }
+ if (post.compareTo(comment.post) != 0) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+
+}
View
61 samples-and-tests/logisima-play-yml-test/app/models/test/Date2.java
@@ -0,0 +1,61 @@
+package models.test;
+
+import java.util.Calendar;
+
+import javax.persistence.Entity;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import play.db.jpa.Model;
+
+@Entity
+public class Date2 extends Model {
+
+ public java.util.Date date1;
+
+ @Temporal(TemporalType.DATE)
+ public java.util.Date date2;
+
+ @Temporal(TemporalType.TIME)
+ public java.util.Date date3;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ public java.util.Date date4;
+
+ public Calendar cal1;
+
+ @Temporal(TemporalType.DATE)
+ public Calendar cal2;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ public Calendar cal4;
+
+ public int compareTo(Date2 date) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.date1.equals(date.date1)) {
+ return NOT_EQUAL;
+ }
+ if (!this.date2.equals(date.date2)) {
+ return NOT_EQUAL;
+ }
+ if (!this.date3.equals(date.date3)) {
+ return NOT_EQUAL;
+ }
+ if (!this.date4.equals(date.date4)) {
+ return NOT_EQUAL;
+ }
+ if (!this.cal1.equals(date.cal1)) {
+ return NOT_EQUAL;
+ }
+ if (!this.cal2.equals(date.cal2)) {
+ return NOT_EQUAL;
+ }
+ if (!this.cal4.equals(date.cal4)) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+
+}
View
62 samples-and-tests/logisima-play-yml-test/app/models/test/Post2.java
@@ -0,0 +1,62 @@
+package models.test;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.Lob;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+
+import play.data.validation.MaxSize;
+import play.db.jpa.Model;
+
+@Entity
+public class Post2 extends Model {
+
+ public String title;
+
+ public Date postedAt;
+
+ @Lob
+ @MaxSize(1000)
+ public String content;
+
+ @ManyToOne
+ public User2 author;
+
+ @OneToMany(mappedBy = "post", cascade = CascadeType.ALL)
+ public List<Comment2> comments;
+
+ @ManyToMany(cascade = CascadeType.PERSIST)
+ public Set<Tag2> tags;
+
+ public int compareTo(Post2 post) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.title.equals(post.title)) {
+ return NOT_EQUAL;
+ }
+ if (!this.postedAt.equals(post.postedAt)) {
+ return NOT_EQUAL;
+ }
+ if (!this.content.equals(post.content)) {
+ return NOT_EQUAL;
+ }
+ if (!this.author.equals(post.author)) {
+ return NOT_EQUAL;
+ }
+ if (this.comments.size() != post.comments.size()) {
+ return NOT_EQUAL;
+ }
+ if (this.tags.size() != post.tags.size()) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+
+}
View
22 samples-and-tests/logisima-play-yml-test/app/models/test/Tag2.java
@@ -0,0 +1,22 @@
+package models.test;
+
+import javax.persistence.Entity;
+
+import play.db.jpa.Model;
+
+@Entity
+public class Tag2 extends Model {
+
+ public String name;
+
+ public int compareTo(Tag2 tag) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.name.equals(tag.name)) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+
+}
View
45 samples-and-tests/logisima-play-yml-test/app/models/test/User2.java
@@ -0,0 +1,45 @@
+package models.test;
+
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import play.db.jpa.GenericModel;
+
+@Entity
+public class User2 extends GenericModel {
+
+ @Id
+ public String email;
+
+ public String password;
+
+ public String fullname;
+
+ @Embedded
+ public Address2 addess;
+
+ public boolean isAdmin;
+
+ public int compareTo(User2 user) {
+ final int NOT_EQUAL = -1;
+ final int EQUAL = 0;
+
+ if (!this.email.equals(user.email)) {
+ return NOT_EQUAL;
+ }
+ if (!this.password.equals(user.password)) {
+ return NOT_EQUAL;
+ }
+ if (!this.fullname.equals(user.fullname)) {
+ return NOT_EQUAL;
+ }
+ if (this.isAdmin != user.isAdmin) {
+ return NOT_EQUAL;
+ }
+ if (this.addess.compareTo(user.addess) != 0) {
+ return NOT_EQUAL;
+ }
+ return EQUAL;
+ }
+}
View
1 samples-and-tests/logisima-play-yml-test/conf/application.conf
@@ -79,6 +79,7 @@ date.format=yyyy-MM-dd
# - mem : for a transient in memory database (H2 in memory)
# - fs : for a simple file written database (H2 file stored)
db=fs
+%test2.db=mem
jpa.dialect=org.hibernate.dialect.H2Dialect
#
# To connect to a local MySQL5 database, use:
View
182 src/play/modules/yml/YmlExtractorUtil.java
@@ -25,6 +25,7 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
@@ -40,6 +41,7 @@
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
import javax.persistence.PersistenceException;
import org.apache.log4j.Level;
@@ -54,6 +56,7 @@
import play.classloading.ApplicationClasses.ApplicationClass;
import play.db.DB;
import play.db.DBPlugin;
+import play.db.jpa.GenericModel;
import play.db.jpa.JPABase;
import play.db.jpa.JPAPlugin;
import play.db.jpa.Model;
@@ -184,7 +187,7 @@ public static YmlObject object2YmlObject(JPABase jpaBase) throws IllegalArgument
for (int i = 0; i < myList.size(); i++) {
tmpValues[i] = getObjectId(myList.get(i));
// if myObj is an entity, we add it to children
- if (Model.class.isInstance(myList.get(i))) {
+ if (GenericModel.class.isInstance(myList.get(i))) {
ymlObject.getChildren().add(getObjectId(myList.get(i)));
}
}
@@ -205,7 +208,7 @@ public static YmlObject object2YmlObject(JPABase jpaBase) throws IllegalArgument
Object myObj = it.next();
tmpValues[i] = getObjectId(myObj);
// if myObj is an entity, we add it to children
- if (myObj != null && Model.class.isInstance(myObj)) {
+ if (myObj != null && GenericModel.class.isInstance(myObj)) {
if (getObjectId(myObj) != null) {
ymlObject.getChildren().add(getObjectId(myObj));
}
@@ -229,7 +232,7 @@ public static YmlObject object2YmlObject(JPABase jpaBase) throws IllegalArgument
Object myObj = it.next();
tmpValues[i] = getObjectId(myObj);
// if myObj is an entity, we add it to children
- if (myObj != null && Model.class.isInstance(myObj)) {
+ if (myObj != null && GenericModel.class.isInstance(myObj)) {
if (getObjectId(myObj) != null) {
ymlObject.getChildren().add(getObjectId(myObj));
}
@@ -250,22 +253,27 @@ public static YmlObject object2YmlObject(JPABase jpaBase) throws IllegalArgument
valueIsSet = Boolean.TRUE;
}
- // if field is an object that extend Model
- if (jpaBase != null && Model.class.isInstance(field.get(jpaBase))) {
+ // if field is an object that extend GenericModel
+ if (jpaBase != null && GenericModel.class.isInstance(field.get(jpaBase))) {
Logger.debug("Field " + name + " type is a Model");
- ymlObject.getChildren().add(getObjectId(field.get(jpaBase)));
- data.put(name, getObjectId(field.get(jpaBase)));
+ if (!field.isAnnotationPresent(ManyToOne.class)) {
+ ymlObject.getChildren().add(getObjectId(field.get(jpaBase)));
+ data.put(name, getObjectId(field.get(jpaBase)));
+ }
valueIsSet = Boolean.TRUE;
}
// if field is a date
- if (Date.class.isInstance(field.get(jpaBase))) {
+ if (Date.class.isInstance(field.get(jpaBase)) | Calendar.class.isInstance(field.get(jpaBase))) {
Logger.debug("Field " + name + " type is Date");
- // TODO: in case of temporal JPA annotation
-
- SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd hh:mm:ss");
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
- Date myDate = (Date) sdf.parse(field.get(jpaBase).toString());
+ Date myDate = null;
+ if (Date.class.isInstance(field.get(jpaBase))) {
+ myDate = (Date) field.get(jpaBase);
+ }
+ else {
+ myDate = ((Calendar) field.get(jpaBase)).getTime();
+ }
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
data.put(name, df.format(myDate));
valueIsSet = Boolean.TRUE;
}
@@ -358,93 +366,67 @@ public static String getDefaultDialect(String driver) {
if (dialect != null) {
return dialect;
}
- else
- if (driver.equals("org.h2.Driver")) {
- return "org.hibernate.dialect.H2Dialect";
- }
- else
- if (driver.equals("org.hsqldb.jdbcDriver")) {
- return "org.hibernate.dialect.HSQLDialect";
- }
- else
- if (driver.equals("com.mysql.jdbc.Driver")) {
- return "play.db.jpa.MySQLDialect";
- }
- else
- if (driver.equals("org.postgresql.Driver")) {
- return "org.hibernate.dialect.PostgreSQLDialect";
- }
- else
- if (driver.toLowerCase().equals("com.ibm.db2.jdbc.app.DB2Driver")) {
- return "org.hibernate.dialect.DB2Dialect";
- }
- else
- if (driver.equals("com.ibm.as400.access.AS400JDBCDriver")) {
- return "org.hibernate.dialect.DB2400Dialect";
- }
- else
- if (driver.equals("com.ibm.as400.access.AS390JDBCDriver")) {
- return "org.hibernate.dialect.DB2390Dialect";
- }
- else
- if (driver.equals("oracle.jdbc.driver.OracleDriver")) {
- return "org.hibernate.dialect.Oracle9iDialect";
- }
- else
- if (driver.equals("com.sybase.jdbc2.jdbc.SybDriver")) {
- return "org.hibernate.dialect.SybaseAnywhereDialect";
- }
- else
- if ("com.microsoft.jdbc.sqlserver.SQLServerDriver".equals(driver)) {
- return "org.hibernate.dialect.SQLServerDialect";
- }
- else
- if ("com.sap.dbtech.jdbc.DriverSapDB".equals(driver)) {
- return "org.hibernate.dialect.SAPDBDialect";
- }
- else
- if ("com.informix.jdbc.IfxDriver".equals(driver)) {
- return "org.hibernate.dialect.InformixDialect";
- }
- else
- if ("com.ingres.jdbc.IngresDriver".equals(driver)) {
- return "org.hibernate.dialect.IngresDialect";
- }
- else
- if ("progress.sql.jdbc.JdbcProgressDriver"
- .equals(driver)) {
- return "org.hibernate.dialect.ProgressDialect";
- }
- else
- if ("com.mckoi.JDBCDriver".equals(driver)) {
- return "org.hibernate.dialect.MckoiDialect";
- }
- else
- if ("InterBase.interclient.Driver"
- .equals(driver)) {
- return "org.hibernate.dialect.InterbaseDialect";
- }
- else
- if ("com.pointbase.jdbc.jdbcUniversalDriver"
- .equals(driver)) {
- return "org.hibernate.dialect.PointbaseDialect";
- }
- else
- if ("com.frontbase.jdbc.FBJDriver"
- .equals(driver)) {
- return "org.hibernate.dialect.FrontbaseDialect";
- }
- else
- if ("org.firebirdsql.jdbc.FBDriver"
- .equals(driver)) {
- return "org.hibernate.dialect.FirebirdDialect";
- }
- else {
- throw new UnsupportedOperationException(
- "I do not know which hibernate dialect to use with "
- + driver
- + " and I cannot guess it, use the property jpa.dialect in config file");
- }
+ else if (driver.equals("org.h2.Driver")) {
+ return "org.hibernate.dialect.H2Dialect";
+ }
+ else if (driver.equals("org.hsqldb.jdbcDriver")) {
+ return "org.hibernate.dialect.HSQLDialect";
+ }
+ else if (driver.equals("com.mysql.jdbc.Driver")) {
+ return "play.db.jpa.MySQLDialect";
+ }
+ else if (driver.equals("org.postgresql.Driver")) {
+ return "org.hibernate.dialect.PostgreSQLDialect";
+ }
+ else if (driver.toLowerCase().equals("com.ibm.db2.jdbc.app.DB2Driver")) {
+ return "org.hibernate.dialect.DB2Dialect";
+ }
+ else if (driver.equals("com.ibm.as400.access.AS400JDBCDriver")) {
+ return "org.hibernate.dialect.DB2400Dialect";
+ }
+ else if (driver.equals("com.ibm.as400.access.AS390JDBCDriver")) {
+ return "org.hibernate.dialect.DB2390Dialect";
+ }
+ else if (driver.equals("oracle.jdbc.driver.OracleDriver")) {
+ return "org.hibernate.dialect.Oracle9iDialect";
+ }
+ else if (driver.equals("com.sybase.jdbc2.jdbc.SybDriver")) {
+ return "org.hibernate.dialect.SybaseAnywhereDialect";
+ }
+ else if ("com.microsoft.jdbc.sqlserver.SQLServerDriver".equals(driver)) {
+ return "org.hibernate.dialect.SQLServerDialect";
+ }
+ else if ("com.sap.dbtech.jdbc.DriverSapDB".equals(driver)) {
+ return "org.hibernate.dialect.SAPDBDialect";
+ }
+ else if ("com.informix.jdbc.IfxDriver".equals(driver)) {
+ return "org.hibernate.dialect.InformixDialect";
+ }
+ else if ("com.ingres.jdbc.IngresDriver".equals(driver)) {
+ return "org.hibernate.dialect.IngresDialect";
+ }
+ else if ("progress.sql.jdbc.JdbcProgressDriver".equals(driver)) {
+ return "org.hibernate.dialect.ProgressDialect";
+ }
+ else if ("com.mckoi.JDBCDriver".equals(driver)) {
+ return "org.hibernate.dialect.MckoiDialect";
+ }
+ else if ("InterBase.interclient.Driver".equals(driver)) {
+ return "org.hibernate.dialect.InterbaseDialect";
+ }
+ else if ("com.pointbase.jdbc.jdbcUniversalDriver".equals(driver)) {
+ return "org.hibernate.dialect.PointbaseDialect";
+ }
+ else if ("com.frontbase.jdbc.FBJDriver".equals(driver)) {
+ return "org.hibernate.dialect.FrontbaseDialect";
+ }
+ else if ("org.firebirdsql.jdbc.FBDriver".equals(driver)) {
+ return "org.hibernate.dialect.FirebirdDialect";
+ }
+ else {
+ throw new UnsupportedOperationException("I do not know which hibernate dialect to use with " + driver
+ + " and I cannot guess it, use the property jpa.dialect in config file");
+ }
}
public static Boolean isFieldHasMappedByInAnnotation(Field field) {

0 comments on commit 8e6413b

Please sign in to comment.
Something went wrong with that request. Please try again.