Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed the application to use SimpleDB. Some bugs exist in the UI no…

…w due

to the implicit asynchronicity of SimpleDB. Will be fixed soon.
  • Loading branch information...
commit 7d95aa824b56cdcb19aa8f81fc4ff009c27ae201 1 parent c6a9d08
Evan Seguin authored March 25, 2012
11  README
... ...
@@ -1,3 +1,14 @@
1 1
 A basic Todo List application using the Play! Framework.
2 2
 
3 3
 A live version of the site is available at http://eseguin.dyndns.org:9000
  4
+
  5
+
  6
+----------------------------------------------
  7
+Setup
  8
+----------------------------------------------
  9
+The app/models directory requires a siena.properties file with credentials to connect to Amazon AWS.
  10
+
  11
+A sample properties file might look like this:
  12
+implementation=siena.sdb.SdbPersistenceManager
  13
+awsAccessKeyId=XXXXXXXXXXXXXXXXXXXXXXXXX
  14
+awsSecretAccessKey=YYYYYYYYYYYYYYYYYYYYYYY
12  app/controllers/Application.java
... ...
@@ -1,11 +1,11 @@
1 1
 package controllers;
2 2
 
3  
-import play.*;
4  
-import play.mvc.*;
5  
-import play.data.*;
  3
+import java.util.UUID;
6 4
 
7  
-import views.html.*;
8 5
 import models.Task;
  6
+import play.data.Form;
  7
+import play.mvc.Controller;
  8
+import play.mvc.Result;
9 9
 
10 10
 public class Application extends Controller {
11 11
   
@@ -44,8 +44,8 @@ public static Result newTask() {
44 44
      *
45 45
      * @param id The ID of the task to delete
46 46
      */
47  
-    public static Result deleteTask(Long id) {
48  
-        Task.delete(id);
  47
+    public static Result deleteTask(String id) {
  48
+        Task.delete(UUID.fromString(id));
49 49
         return redirect(routes.Application.tasks());
50 50
     }
51 51
   
56  app/models/Task.java
... ...
@@ -1,34 +1,62 @@
1 1
 package models;
2 2
 
3  
-import java.util.*;
  3
+import java.util.List;
  4
+import java.util.UUID;
4 5
 
5  
-import play.db.ebean.*;
6  
-import play.data.validation.Constraints.*;
  6
+import siena.Column;
  7
+import siena.Entity;
  8
+import siena.Generator;
  9
+import siena.Id;
  10
+import siena.Max;
  11
+import siena.Model;
  12
+import siena.NotNull;
7 13
 
8  
-import javax.persistence.*;
9 14
 
10 15
 @Entity
11 16
 public class Task extends Model {
12 17
     
13  
-	@Id
14  
-	public Long id;
  18
+	@Id(Generator.UUID)
  19
+	public UUID id;
15 20
 
16  
-	@Required
  21
+	/**
  22
+	 * The task label/description.
  23
+	 */
  24
+	@Column("Label")
  25
+    @Max(500) @NotNull
17 26
 	public String label;
18 27
 	
19  
-	public static Finder<Long,Task> find = new Finder(
20  
-		Long.class, Task.class
21  
-	);
22  
-  
  28
+//	/**
  29
+//	 * The date that the task was added.
  30
+//	 */
  31
+//	@Column("AddedDate")
  32
+//    @Max(100) @NotNull
  33
+//	public String addedDate;
  34
+//	
  35
+//	/**
  36
+//	 * Optional - The date that the task is due.
  37
+//	 */
  38
+//	@Column("DueDate")
  39
+//    @Max(100)
  40
+//	public String dueDate;
  41
+	
  42
+	/**
  43
+	 * Optional - The user's phone number.
  44
+	 */
  45
+	@Column("PhoneNumber")
  46
+    @Max(32)
  47
+	public String phone;
  48
+	
23 49
 	public static List<Task> all() {
24  
-		return find.all();
  50
+		return Model.all(Task.class).fetch();
25 51
 	}
26 52
   
27 53
 	public static void create(Task task) {
28 54
 		task.save();
29 55
 	}
30 56
   
31  
-	public static void delete(Long id) {
32  
-		find.ref(id).delete();
  57
+	public static void delete(UUID id) {
  58
+		Task task = new Task();
  59
+		task.id = id;
  60
+		task.delete();
33 61
 	}  
34 62
 }
2  app/views/index.scala.html
@@ -15,7 +15,7 @@
15 15
             <div class="task">
16 16
                 <div class="taskLabel">@task.label</div>
17 17
                 
18  
-                @form(routes.Application.deleteTask(task.id), args ='class -> "deleteform") {
  18
+                @form(routes.Application.deleteTask(task.id.toString), args ='class -> "deleteform") {
19 19
                     <input type="submit" value="Delete">
20 20
                 }
21 21
             </div>
8  conf/application.conf
@@ -22,8 +22,10 @@ application.langs="en"
22 22
 # You can declare as many datasources as you want.
23 23
 # By convention, the default datasource is named `default`
24 24
 #
25  
- db.default.driver=org.h2.Driver
26  
- db.default.url="jdbc:h2:mem:play"
  25
+#db=sdb
  26
+
  27
+# db.default.driver=org.h2.Driver
  28
+# db.default.url="jdbc:h2:mem:play"
27 29
 # db.default.user=sa
28 30
 # db.default.password=
29 31
 #
@@ -40,7 +42,7 @@ application.langs="en"
40 42
 # You can declare as many Ebean servers as you want.
41 43
 # By convention, the default server is named `default`
42 44
 #
43  
- ebean.default="models.*"
  45
+# ebean.default="models.*"
44 46
 
45 47
 # Logger
46 48
 # ~~~~~
2  conf/routes
@@ -7,7 +7,7 @@ GET     /                           controllers.Application.index()
7 7
 
8 8
 GET     /tasks                      controllers.Application.tasks()
9 9
 POST    /tasks                      controllers.Application.newTask()
10  
-POST    /tasks/:id/delete           controllers.Application.deleteTask(id: Long)
  10
+POST    /tasks/:id/delete           controllers.Application.deleteTask(id: String)
11 11
 
12 12
 # Map static resources from the /public folder to the /assets URL path
13 13
 GET     /assets/*file               controllers.Assets.at(path="/public", file)
BIN  lib/siena-1.0.0-b6.jar
Binary file not shown
2  project/Build.scala
@@ -8,7 +8,7 @@ object ApplicationBuild extends Build {
8 8
     val appVersion      = "1.0-SNAPSHOT"
9 9
 
10 10
     val appDependencies = Seq(
11  
-      // Add your project dependencies here,
  11
+      "com.amazonaws" % "aws-java-sdk" % "1.3.6"
12 12
     )
13 13
 
14 14
     val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(

0 notes on commit 7d95aa8

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