Permalink
Browse files

refactor to lay the groundwork and structure for #64, #59 and #58

  • Loading branch information...
1 parent f5e0e45 commit 37db3bc3c3a7eea549b34e0f2d229c8d98c0f014 @fommil fommil committed Mar 19, 2013
Showing with 744 additions and 931 deletions.
  1. +6 −3 build.sbt
  2. +8 −7 src/main/scala/org/cakesolutions/scalad/{mongo → experimental}/MongoNativeRestrictions.scala
  3. +3 −1 src/main/scala/org/cakesolutions/scalad/{ → experimental}/querydsl.scala
  4. +3 −2 src/main/scala/org/cakesolutions/scalad/mongo/MongoSearch.scala
  5. +0 −346 src/main/scala/org/cakesolutions/scalad/mongo/SprayJsonSupport.scala
  6. +3 −7 src/main/scala/org/cakesolutions/scalad/mongo/package.scala
  7. +89 −0 src/main/scala/org/cakesolutions/scalad/mongo/sprayjson/SprayJsonSupport.scala
  8. +2 −0 src/main/scala/org/cakesolutions/scalad/mongo/sprayjson/crud.scala
  9. +3 −5 src/main/scala/org/cakesolutions/scalad/{jsondsl.scala → mongo/sprayjson/dsl.scala}
  10. +171 −0 src/main/scala/org/cakesolutions/scalad/mongo/sprayjson/marshalling.scala
  11. +86 −0 src/main/scala/org/cakesolutions/scalad/mongo/sprayjson/serialisation.scala
  12. +29 −0 src/main/scala/org/cakesolutions/scalad/mongo/support.scala
  13. +3 −2 src/test/scala/org/cakesolutions/scalad/{ → experimental}/RestrictionsSpec.scala
  14. +0 −339 src/test/scala/org/cakesolutions/scalad/mongo/SprayJsonSupportSpec.scala
  15. +0 −128 src/test/scala/org/cakesolutions/scalad/mongo/mongodbprofiling.scala
  16. +24 −89 src/test/scala/org/cakesolutions/scalad/mongo/mongodbtests.scala
  17. +4 −2 src/test/scala/org/cakesolutions/scalad/{ → mongo/sprayjson}/JsonDslSpec.scala
  18. +45 −0 src/test/scala/org/cakesolutions/scalad/mongo/sprayjson/PersistenceSpec.scala
  19. +231 −0 src/test/scala/org/cakesolutions/scalad/mongo/sprayjson/SerialisationSpec.scala
  20. +34 −0 src/test/scala/org/cakesolutions/scalad/mongo/sprayjson/support.scala
View
@@ -38,11 +38,14 @@ credentials += Credentials(Path.userHome / ".artifactory" / ".credentials")
libraryDependencies <<= scalaVersion { scala_version =>
Seq(
+ "com.github.fommil" % "java-logging" % "1.0",
+ "com.typesafe.akka" %% "akka-actor" % "2.1.2",
+ "com.typesafe.akka" %% "akka-contrib" % "2.1.2" intransitive(), // JUL only
"org.mongodb" % "mongo-java-driver" % "2.10.1",
"com.typesafe" % "config" % "1.0.0",
- "io.spray" %% "spray-json" % "1.2.3",
- "org.specs2" %% "specs2" % "1.13" % "test",
- "org.scalacheck" %% "scalacheck" % "1.10.0" % "test"
+ "io.spray" %% "spray-json" % "1.2.3",
+ "org.specs2" %% "specs2" % "1.13" % "test",
+ "org.scalacheck" %% "scalacheck" % "1.10.0" % "test"
)
}
@@ -1,8 +1,9 @@
-package org.cakesolutions.scalad.mongo
+package org.cakesolutions.scalad.experimental
-import spray.json.{JsString, JsObject}
import org.cakesolutions.scalad._
import com.mongodb.{BasicDBObjectBuilder, DBObject}
+import mongo.MongoSerializer
+import mongo.sprayjson.SprayJsonSerializers
/**
* Native restrictions for JsObject and MongoDB
@@ -13,10 +14,10 @@ trait MongoJsonNativeRestrictions extends NativeRestrictions with MongoNativeRes
def convertToNative(restriction: Restriction) = {
def convert0(builder: BasicDBObjectBuilder, r: Restriction) {
r match {
- case EqualsRestriction(path: String, value) => builder.add(path, value)
+ case EqualsRestriction(path: String, value) => builder.add(path, value)
case NotEqualsRestriction(path: String, value) => builder.add(path, value)
- case ConjunctionRestriction(lhs, rhs) => convert0(builder, lhs); convert0(builder, rhs)
- case DisjunctionRestriction(lhs, rhs) => convert0(builder, lhs); convert0(builder, rhs)
+ case ConjunctionRestriction(lhs, rhs) => convert0(builder, lhs); convert0(builder, rhs)
+ case DisjunctionRestriction(lhs, rhs) => convert0(builder, lhs); convert0(builder, rhs)
// ...
}
}
@@ -28,9 +29,9 @@ trait MongoJsonNativeRestrictions extends NativeRestrictions with MongoNativeRes
}
-private[mongo] trait MongoNativeRestrictionMarshallers extends SprayJsonSerializers {
+private[experimental] trait MongoNativeRestrictionMarshallers extends SprayJsonSerializers {
- implicit def getNativeRestrictionsMarshaller[A : MongoSerializer]: NativeRestrictionsMarshaller[A] = new NativeRestrictionsMarshaller[A] {
+ implicit def getNativeRestrictionsMarshaller[A: MongoSerializer]: NativeRestrictionsMarshaller[A] = new NativeRestrictionsMarshaller[A] {
val serializer = implicitly[MongoSerializer[A]]
type NativeRestrictionValue = DBObject
@@ -1,4 +1,6 @@
-package org.cakesolutions.scalad
+package org.cakesolutions.scalad.experimental
+
+import scala.language.implicitConversions
sealed trait Restriction
case class EqualsRestriction[A, Path](path: Path, value: A) extends Restriction with RestrictionOps
@@ -3,6 +3,7 @@ package org.cakesolutions.scalad.mongo
import com.mongodb.DBObject
import concurrent.{ExecutionContext, Future}
import java.util.logging.Level
+import akka.contrib.jul.JavaLogging
/** Search returned too many results.
*/
@@ -16,7 +17,7 @@ case class TooManyResults(query: DBObject) extends Exception
* Implicit conversions from JSON syntax or DSLs bring these methods within reach of
* most users.
*/
-trait MongoSearch extends J2SELogging {
+trait MongoSearch extends JavaLogging {
/** @return the first result from the result of the query, or `None` if nothing found. */
def searchFirst[T: CollectionProvider : MongoSerializer](query: DBObject): Option[T] = {
@@ -52,7 +53,7 @@ trait MongoSearch extends J2SELogging {
cursor.close()
}
}.onFailure {
- case t => log.log(Level.WARNING, "Future failed", t)
+ case t => log.error(t, "Future failed")
}
iterable
Oops, something went wrong.

0 comments on commit 37db3bc

Please sign in to comment.