Permalink
Browse files

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...
1 parent c6a9d08 commit 7d95aa824b56cdcb19aa8f81fc4ff009c27ae201 @esseguin committed Mar 26, 2012
View
11 README
@@ -1,3 +1,14 @@
A basic Todo List application using the Play! Framework.
A live version of the site is available at http://eseguin.dyndns.org:9000
+
+
+----------------------------------------------
+Setup
+----------------------------------------------
+The app/models directory requires a siena.properties file with credentials to connect to Amazon AWS.
+
+A sample properties file might look like this:
+implementation=siena.sdb.SdbPersistenceManager
+awsAccessKeyId=XXXXXXXXXXXXXXXXXXXXXXXXX
+awsSecretAccessKey=YYYYYYYYYYYYYYYYYYYYYYY
@@ -1,11 +1,11 @@
package controllers;
-import play.*;
-import play.mvc.*;
-import play.data.*;
+import java.util.UUID;
-import views.html.*;
import models.Task;
+import play.data.Form;
+import play.mvc.Controller;
+import play.mvc.Result;
public class Application extends Controller {
@@ -44,8 +44,8 @@ public static Result newTask() {
*
* @param id The ID of the task to delete
*/
- public static Result deleteTask(Long id) {
- Task.delete(id);
+ public static Result deleteTask(String id) {
+ Task.delete(UUID.fromString(id));
return redirect(routes.Application.tasks());
}
View
@@ -1,34 +1,62 @@
package models;
-import java.util.*;
+import java.util.List;
+import java.util.UUID;
-import play.db.ebean.*;
-import play.data.validation.Constraints.*;
+import siena.Column;
+import siena.Entity;
+import siena.Generator;
+import siena.Id;
+import siena.Max;
+import siena.Model;
+import siena.NotNull;
-import javax.persistence.*;
@Entity
public class Task extends Model {
- @Id
- public Long id;
+ @Id(Generator.UUID)
+ public UUID id;
- @Required
+ /**
+ * The task label/description.
+ */
+ @Column("Label")
+ @Max(500) @NotNull
public String label;
- public static Finder<Long,Task> find = new Finder(
- Long.class, Task.class
- );
-
+// /**
+// * The date that the task was added.
+// */
+// @Column("AddedDate")
+// @Max(100) @NotNull
+// public String addedDate;
+//
+// /**
+// * Optional - The date that the task is due.
+// */
+// @Column("DueDate")
+// @Max(100)
+// public String dueDate;
+
+ /**
+ * Optional - The user's phone number.
+ */
+ @Column("PhoneNumber")
+ @Max(32)
+ public String phone;
+
public static List<Task> all() {
- return find.all();
+ return Model.all(Task.class).fetch();
}
public static void create(Task task) {
task.save();
}
- public static void delete(Long id) {
- find.ref(id).delete();
+ public static void delete(UUID id) {
+ Task task = new Task();
+ task.id = id;
+ task.delete();
}
}
@@ -15,7 +15,7 @@
<div class="task">
<div class="taskLabel">@task.label</div>
- @form(routes.Application.deleteTask(task.id), args ='class -> "deleteform") {
+ @form(routes.Application.deleteTask(task.id.toString), args ='class -> "deleteform") {
<input type="submit" value="Delete">
}
</div>
View
@@ -22,8 +22,10 @@ application.langs="en"
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
- db.default.driver=org.h2.Driver
- db.default.url="jdbc:h2:mem:play"
+#db=sdb
+
+# db.default.driver=org.h2.Driver
+# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=
#
@@ -40,7 +42,7 @@ application.langs="en"
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
#
- ebean.default="models.*"
+# ebean.default="models.*"
# Logger
# ~~~~~
View
@@ -7,7 +7,7 @@ GET / controllers.Application.index()
GET /tasks controllers.Application.tasks()
POST /tasks controllers.Application.newTask()
-POST /tasks/:id/delete controllers.Application.deleteTask(id: Long)
+POST /tasks/:id/delete controllers.Application.deleteTask(id: String)
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
View
Binary file not shown.
View
@@ -8,7 +8,7 @@ object ApplicationBuild extends Build {
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
- // Add your project dependencies here,
+ "com.amazonaws" % "aws-java-sdk" % "1.3.6"
)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(

0 comments on commit 7d95aa8

Please sign in to comment.