Permalink
Browse files

upgrade to 2.1 driver

  • Loading branch information...
1 parent 076429e commit 2aefa64b3a81906cf30f156cde7538330a392bb7 Mark Priatel committed Aug 27, 2010
View
@@ -1,3 +1,5 @@
target
stacktrace.log
*.zip
+.idea
+*.iml
@@ -4,11 +4,11 @@ import com.iolog.mongodbtools.MongoMapperModel
import com.mongodb.BasicDBObject
import com.iolog.mongodbtools.MongoDbWrapper
import com.iolog.mongodbtools.MongoMapperField
-import com.mongodb.ObjectId
+import org.bson.types.ObjectId
class MongodbToolsGrailsPlugin
{
- def version = "0.1"
+ def version = "0.1x"
def grailsVersion = "1.2.0 > *"
def dependsOn = [:]
def pluginExcludes = [
View
@@ -1,6 +1,7 @@
#Grails Metadata file
-#Fri Feb 26 23:53:23 EST 2010 !
-app.grails.version=1.2.1
+#Tue Jul 13 15:59:15 EDT 2010
+app.grails.version=1.3.3
app.name=mongodb-tools
-plugins.hibernate=1.2.1
-plugins.tomcat=1.2.1
+plugins.hibernate=1.3.3
+plugins.maven-publisher=0.6
+plugins.tomcat=1.3.3
@@ -2,6 +2,7 @@ grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
//grails.project.war.file = "target/${appName}-${appVersion}.war"
+
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits( "global" ) {
@@ -10,13 +11,14 @@ grails.project.dependency.resolution = {
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
- grailsPlugins()
+ grailsPlugins()
grailsHome()
mavenCentral()
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
- runtime 'org.mongodb:mongo-java-driver:1.4'
+ runtime 'org.mongodb:mongo-java-driver:2.1'
}
}
+
@@ -5,3 +5,7 @@ mongo {
}
}
}
+
+// The following properties have been added by the Upgrade process...
+grails.views.default.codec="none" // none, html, base64
+grails.views.gsp.encoding="UTF-8"
@@ -1,8 +1,7 @@
package com.acme
-import com.mongodb.ObjectId
-
import com.iolog.mongodbtools.*
+import org.bson.types.ObjectId
@MongoCollection('annotatedWidget')
class AnnotatedWidget {
@@ -11,10 +10,10 @@ class AnnotatedWidget {
String _id
@MongoField('sc')
- int stockCount
+ Integer stockCount
@MongoField('l')
- double length
+ Double length
@MongoField('d')
String description
@@ -1,12 +1,10 @@
package com.acme
-import com.mongodb.ObjectId
-
class MappedWidget {
String _id
int stockCount
- double length
+ Double length
String description
Date createDate
boolean active
View
@@ -1,4 +1,4 @@
-<plugin name='mongodb-tools' version='0.1' grailsVersion='1.2.0 &gt; *'>
+<plugin name='mongodb-tools' version='0.1y' grailsVersion='1.2.0 &gt; *'>
<author>Mark Priatel</author>
<authorEmail>mpriatel@gmail.com</authorEmail>
<title>MongoDB Tools</title>
@@ -17,12 +17,6 @@
<resource>com.acme.AnnotatedWidget</resource>
<resource>com.acme.MappedWidget</resource>
</resources>
- <dependencies>
- <resolvers>
- <resolver type='grailsPlugins' name='grailsPlugins' />
- <resolver type='mavenCentral' />
- </resolvers>
- <dependency group='org.mongodb' name='mongo-java-driver' version='1.4' conf='runtime' transitive='true' />
- </dependencies>
+ <dependencies />
<behavior />
</plugin>
@@ -27,12 +27,13 @@ import com.mongodb.BasicDBObject
import com.mongodb.BasicDBList
import com.mongodb.DBCollection
import org.codehaus.groovy.grails.commons.GrailsClassUtils
-import com.mongodb.ObjectId
+
import com.mongodb.gridfs.GridFS
import com.mongodb.DB
import org.springframework.web.multipart.commons.CommonsMultipartFile
import com.mongodb.gridfs.GridFSInputFile
import com.mongodb.DBObject
+import org.bson.types.ObjectId
/**
* <p>The MongoDbWrapper is exposed to Grails applications as a Spring bean called 'mongo'.
@@ -64,7 +65,7 @@ import com.mongodb.DBObject
*
* <p>The above example registers two different database hosts which can then be accessed using the mongo
* bean: <code>mongo.server1.&lt;dbname&gt;.&lt;collection&gt;</code>. 'dbname' and 'collection' will
- * return the corrisponding Java MongoDB driver equivalents (DB, DBCollection).
+ * return the corrisponding Java MongoDB driver equivalents (DB, DBCollection).
*
* <h3>Shortcuts</h3>
*
@@ -218,23 +219,23 @@ public class MongoDbWrapper implements InitializingBean
mongos.put(name, mongo)
return mongo
}
-
+
def isMappedByFieldMap = { clazz ->
return GrailsClassUtils.getStaticPropertyValue(clazz, "mongoTypeName") != null
}
-
+
def mapByFieldMap = { clazz ->
def typeName = GrailsClassUtils.getStaticPropertyValue(clazz, "mongoTypeName")
def mongoFields = GrailsClassUtils.getStaticPropertyValue(clazz, "mongoFields")
def mmm = new MongoMapperModel(clazz, mongoFields)
mmm.setTypeName(typeName)
this.addMapperModel(typeName, mmm)
}
-
- def isMappedByAnnotations = { clazz ->
+
+ def isMappedByAnnotations = { clazz ->
return clazz.isAnnotationPresent(MongoCollection.class)
}
-
+
def mapByAnnotations = { clazz ->
def typeName = clazz.getAnnotation(MongoCollection.class).value()
def fields = clazz.declaredFields
@@ -294,7 +295,7 @@ public class MongoDbWrapper implements InitializingBean
}
clazz.metaClass.getByMongoId = { id, coll = false ->
- coll.find( [_id: new ObjectId(delegate._id) ] as BasicDBObject )
+ coll.findOne( [_id: new ObjectId(delegate._id) ] as BasicDBObject )
}
@@ -375,7 +376,7 @@ public class MongoDbWrapper implements InitializingBean
DBCollection.metaClass.findById = { String id ->
BasicDBObject query = new BasicDBObject();
query.put('_id' , new ObjectId(id) )
- return delegate.findOne( query )
+ return delegate.findOne( query )
}
BasicDBList.metaClass.toObject = {
@@ -431,7 +432,7 @@ public class MongoDbWrapper implements InitializingBean
switch (mmf.fieldType)
{
-
+
case List:
BasicDBList mongoList = (BasicDBList) _self.get(mmf.mongoFieldName)
if (!mongoList)
@@ -444,7 +445,7 @@ public class MongoDbWrapper implements InitializingBean
}
break
-
+
case Map:
BasicDBObject mongoMap = (BasicDBObject) _self.get(mmf.mongoFieldName)
if (!mongoMap)
@@ -455,9 +456,9 @@ public class MongoDbWrapper implements InitializingBean
{
obj."${mmf.domainFieldName}" = mongoMap.toMap()
}
-
+
break
-
+
default:
obj."${mmf.domainFieldName}" = _self.get(mmf.mongoFieldName)
}
@@ -484,7 +485,7 @@ public class MongoDbWrapper implements InitializingBean
if ( bucket ) gridFS = new GridFS(db,bucket)
else gridFS = new GridFS(db)
-
+
fileGrids.put( id, gridFS )
}
Oops, something went wrong.

0 comments on commit 2aefa64

Please sign in to comment.