Permalink
Browse files

Designer Friendly Templates

  • Loading branch information...
1 parent 536a919 commit 22add5868572d47eba2b792cfcb4acc0944f8b45 unknown committed Jan 7, 2011
Showing with 1,390 additions and 2,158 deletions.
  1. +4 −0 .gitignore
  2. +2 −30 README
  3. +22 −2 pom.xml
  4. +14 −7 spa/pom.xml
  5. +2 −12 spa/src/main/resources/META-INF/persistence.xml
  6. +0 −3 spa/src/main/scala/TravelCompanionScala/model/BlogEntry.scala
  7. +2 −2 spa/src/main/scala/TravelCompanionScala/model/Member.scala
  8. +0 −3 spa/src/main/scala/TravelCompanionScala/model/Tour.scala
  9. +25 −26 spa/src/test/scala/TravelCompanionScala/model/TestJPAWeb.scala
  10. +8 −115 web/pom.xml
  11. +2 −0 web/src/main/resources/Picture_de.properties
  12. +2 −0 web/src/main/resources/Picture_en.properties
  13. +2 −2 web/src/main/resources/TravelCompanion_de.properties
  14. +2 −2 web/src/main/resources/TravelCompanion_en.properties
  15. +2 −2 web/src/main/resources/default.props
  16. +50 −49 web/src/main/scala/TravelCompanionScala/api/GridAPI.scala
  17. +1 −1 web/src/main/scala/TravelCompanionScala/api/PCData.scala
  18. +23 −92 web/src/main/scala/TravelCompanionScala/api/RestAPI.scala
  19. +16 −87 web/src/main/scala/TravelCompanionScala/comet/DynamicBlogViews.scala
  20. +17 −52 web/src/main/scala/TravelCompanionScala/controller/BlogCache.scala
  21. +21 −53 web/src/main/scala/TravelCompanionScala/model/EntityConverter.scala
  22. +14 −24 web/src/main/scala/TravelCompanionScala/model/GeoCoder.scala
  23. +6 −31 web/src/main/scala/TravelCompanionScala/model/ImageLogic.scala
  24. +17 −30 web/src/main/scala/TravelCompanionScala/model/Model.scala
  25. +27 −82 web/src/main/scala/TravelCompanionScala/model/UserManagement.scala
  26. +24 −0 web/src/main/scala/TravelCompanionScala/model/Util.scala
  27. +157 −311 web/src/main/scala/TravelCompanionScala/snippet/BlogSnippet.scala
  28. +8 −17 web/src/main/scala/TravelCompanionScala/snippet/Language.scala
  29. +62 −110 web/src/main/scala/TravelCompanionScala/snippet/PictureSnippet.scala
  30. +22 −0 web/src/main/scala/TravelCompanionScala/snippet/PropsView.scala
  31. +48 −75 web/src/main/scala/TravelCompanionScala/snippet/StageSnippet.scala
  32. +6 −13 web/src/main/scala/TravelCompanionScala/snippet/TableSorter.scala
  33. +39 −73 web/src/main/scala/TravelCompanionScala/snippet/TourSnippet.scala
  34. +6 −10 web/src/main/scala/TravelCompanionScala/snippet/TravelDistance.scala
  35. +9 −27 web/src/main/scala/TravelCompanionScala/snippet/UsrMgtHelper.scala
  36. +6 −23 web/src/main/scala/TravelCompanionScala/widget/Gauge.scala
  37. +55 −42 web/src/main/scala/bootstrap/liftweb/Boot.scala
  38. +8 −6 web/src/main/webapp/accessrestricted.html
  39. +21 −0 web/src/main/webapp/blog/_chooseCommentForm.html
  40. +31 −0 web/src/main/webapp/blog/_chooseComments.html
  41. +35 −0 web/src/main/webapp/blog/_chooseEntry.html
  42. +35 −0 web/src/main/webapp/blog/_chooseForm.html
  43. +88 −243 web/src/main/webapp/blog/list.html
  44. +51 −60 web/src/main/webapp/blog/view.html
  45. +6 −7 web/src/main/webapp/index.html
  46. +33 −38 web/src/main/webapp/picture/create.html
  47. +86 −87 web/src/main/webapp/picture/list.html
  48. +12 −11 web/src/main/webapp/picture/view.html
  49. +1 −1 web/src/main/webapp/scripts/jquery.jqGrid.min.js
  50. +18 −28 web/src/main/webapp/templates-hidden/default.html
  51. +37 −40 web/src/main/webapp/tour/edit.html
  52. +34 −39 web/src/main/webapp/tour/list.html
  53. +42 −45 web/src/main/webapp/tour/stage/edit.html
  54. +32 −33 web/src/main/webapp/tour/stage/view.html
  55. +97 −112 web/src/main/webapp/tour/view.html
View
@@ -0,0 +1,4 @@
+*.iml
+*.ipr
+.idea
+target
View
@@ -1,35 +1,7 @@
-Welcome to TravelCompanion in Scala / Lift.
+Welcome to the Lift JPA Archetype. To run the sample app:
-This project was created during the bachelor thesis by Ralf Muri and Daniel Hobi in spring 2010.
-
-The following technical aspects are implemented:
-- JPA (based on lift-jpa-archetype)
-- User Management (copy & paste from ProtoUser without mapper functionality)
-- Validating (JSR 303)
-- GUI Widgets (DistanceTraveler)
-- Ajax & Comet (Blog as Single Page Application)
-- REST
-
-Please feel free to download & study our document in the "doc" directory (german!)
-You will get some additional stuff like:
-- Best practices in Lift & HowTos
-- Working with IntelliJ IDEA & github.com
-- General information about TravelCompanion
-- Experience made by the authors
-
-A running demo is deployed on stax.net:
-http://travelcompanion.ralfmuri.staxapps.net
-
-To run the app:
mvn install
cd web
mvn jetty:run
-Then point your favorite browser to http://localhost:9090/
-
-To create an offline version of the app (web/target/TravelCompanionScala-offline-1.0/):
-mvn install
-cd web
-mvn package -Pjetty-offline
-
-Notice: TravelCompanion is intended for demo purposes only.
+Then point your favorite browser to http://localhost:9090/
View
@@ -11,7 +11,7 @@
<packaging>pom</packaging>
<inceptionYear>2010</inceptionYear>
<properties>
- <scala.version>2.8.0.RC5</scala.version>
+ <scala.version>2.8.1</scala.version>
</properties>
<!-- Set up repo for ScalaJPA -->
@@ -64,12 +64,32 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.4.2.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
</dependencies>
<build>
View
@@ -28,15 +28,20 @@
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>2.1.0</version>
<scope>runtime</scope>
</dependency>
+ <!--<dependency>-->
+ <!--<groupId>javax.persistence</groupId>-->
+ <!--<artifactId>persistence-api</artifactId>-->
+ <!--<version>1.0</version>-->
+ <!--</dependency>-->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.2.GA</version>
@@ -48,11 +53,13 @@
<version>1.0.1B-rc4</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.0.8</version>
- </dependency>
+ <!--<dependency>-->
+ <!--<groupId>org.slf4j</groupId>-->
+ <!--<artifactId>slf4j-simple</artifactId>-->
+ <!--<version>1.4.2</version>-->
+ <!--<scope>runtime</scope>-->
+ <!--</dependency>-->
+
</dependencies>
@@ -11,23 +11,13 @@
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
-
- <!--Configuration for deployment on stax.net on MySql database-->
- <!--<property name="javax.persistence.jdbc.password" value="tc"/>-->
- <!--<property name="javax.persistence.jdbc.user" value="tc"/> -->
- <!--<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>-->
- <!--<property name="javax.persistence.jdbc.url"
- value="jdbc:mysql://ec2-75-101-156-134.compute-1.amazonaws.com:3306/travelcompanion"/> -->
- <!--stax.net deployment configuration end-->
-
- <!--Configuration for local file based H2 Database-->
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.H2Platform"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:h2:file:~/TravelCompanion;FILE_LOCK=NO"/>
- <!--H2 configuration end-->
-
+ <!--<property name="eclipselink.jdbc.url" value="jdbc:h2:tcp://localhost/~/aulaweb/db/database"/>-->
+ <!--<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />-->
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
<!-- To print SQL statements -->
@@ -46,9 +46,6 @@ class BlogEntry {
@OneToMany(mappedBy = "blogEntry", cascade = Array(CascadeType.ALL), targetEntity = classOf[Comment])
var comments: java.util.List[Comment] = new ArrayList[Comment]()
-
- @OneToMany(mappedBy = "blogEntry", cascade = Array(CascadeType.ALL), targetEntity = classOf[Picture])
- var pictures: java.util.List[Picture] = new ArrayList[Picture]()
}
}
@@ -15,7 +15,7 @@ import org.hibernate.validator.constraints._
@Entity
@Table(name = "members")
-class Member {
+class Member() {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
var id: Long = _
@@ -57,7 +57,7 @@ class Member {
val pictures: List[Picture] = new ArrayList[Picture]()
@ManyToMany(cascade = Array(CascadeType.ALL))
- @JoinTable(name = "member_roles", joinColumns = Array(new JoinColumn(name = "member", referencedColumnName = "ID")), inverseJoinColumns = Array(new JoinColumn(name = "roles", referencedColumnName = "ID")))
+ @JoinTable(name = "member_roles", joinColumns = Array(new JoinColumn(name = "member", referencedColumnName = "id")), inverseJoinColumns = Array(new JoinColumn(name = "roles", referencedColumnName = "id")))
val roles: List[Role] = new ArrayList[Role]()
override def equals(that: Any): Boolean = that match {
@@ -38,9 +38,6 @@ class Tour {
@OneToMany(mappedBy = "tour", cascade = Array(CascadeType.ALL), targetEntity = classOf[BlogEntry])
var blogEntries: List[BlogEntry] = new ArrayList[BlogEntry]()
- @OneToMany(mappedBy = "tour", cascade = Array(CascadeType.ALL), targetEntity = classOf[Picture])
- var pictures: List[Picture] = new ArrayList[Picture]()
-
}
@@ -45,50 +45,47 @@ class TestJPAWeb {
def save_stuff () = {
var em = emf.createEntityManager()
- em.getTransaction.begin
+ val tx = em.getTransaction()
- //Member
+ tx.begin()
val member = new Member
- member.name = "supertestuser111"
- member.password = "1234"
- member.email = "dhobi@hsr.ch"
- member.forename = "Hobi"
+ member.name = "Hobi"
em.persist(member)
-
- ///Tour
-
val tour = new Tour
tour.name = "My Travel"
tour.description = "description"
tour.owner = member
em.persist(tour)
- em.getTransaction.commit
- em.close
+
+ tx.commit()
+
+ em.close()
/////assert
em = emf.createEntityManager()
- em.getTransaction.begin
val retrieved = em.createQuery("SELECT t from Tour t where t.name = :name").setParameter("name","My Travel").getResultList.asInstanceOf[java.util.List[Tour]]
assertEquals("My Travel", retrieved.get(0).name)
println("Found " + retrieved.get(0).name)
- assertEquals("Hobi",retrieved.get(0).owner.forename)
- println("Found member " + retrieved.get(0).owner.forename)
-
- //cleanup
+ assertEquals("Hobi",retrieved.get(0).owner.name)
+ println("Found member " + retrieved.get(0).owner.name)
+ ///clenaup
+ em.getTransaction().begin()
- em.remove(em.getReference(classOf[Member],member.id))
em.remove(em.getReference(classOf[Tour],tour.id))
- em.getTransaction.commit
- em.close
+ em.remove(em.getReference(classOf[Member],member.id))
+
+ em.getTransaction().commit()
+
+ em.close()
}
@Test
@@ -100,10 +97,7 @@ class TestJPAWeb {
tx.begin()
val member = new Member
- member.forename = "Hobi2"
- member.name = "supertestuser111"
- member.password = "1234"
- member.email = "dhobi@hsr.ch"
+ member.name = "Hobi2"
em.persist(member)
@@ -126,10 +120,14 @@ class TestJPAWeb {
///assert
em = emf.createEntityManager()
- val retrieved = em.createQuery("SELECT m from Member m where m.forename = :forename").setParameter("forename","Hobi2").getResultList.asInstanceOf[java.util.List[Member]]
- assertEquals("Hobi2", retrieved.get(0).forename)
- println("Found " + retrieved.get(0).forename)
+ val retrieved = em.createQuery("SELECT m from Member m where m.name = :name").setParameter("name","Hobi2").getResultList.asInstanceOf[java.util.List[Member]]
+
+ assertEquals("Hobi2", retrieved.get(0).name)
+ println("Found " + retrieved.get(0).name)
+
+// assertEquals("Hobi2",retrieved.get(1).name)
+// println("Found member " + retrieved.get(1).name)
///cleanup
em.getTransaction().begin()
@@ -142,6 +140,7 @@ class TestJPAWeb {
em.close()
}
+
}
}
Oops, something went wrong. Retry.

0 comments on commit 22add58

Please sign in to comment.