Skip to content

Commit

Permalink
Integration test fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bflorian committed Mar 22, 2012
1 parent 9455b29 commit 9e4e4b8
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 379 deletions.
9 changes: 8 additions & 1 deletion CassandraOrmGrailsPlugin.groovy
@@ -1,3 +1,5 @@
import com.reachlocal.grails.plugins.cassandra.mapping.OrmUtility

/*
* Copyright 2012 ReachLocal Inc.
*
Expand Down Expand Up @@ -47,7 +49,12 @@ Brief description of the plugin.
}

def doWithDynamicMethods = { ctx ->
// TODO Implement registering dynamic methods to classes (optional)
application.allClasses.each {clazz ->
if (OrmUtility.isMappedClass(clazz)) {
log.info "Mapping ${clazz.name} for Casssandra ORM"
OrmUtility.addDynamicMethods(clazz, ctx)
}
}
}

def doWithApplicationContext = { applicationContext ->
Expand Down
Expand Up @@ -19,22 +19,25 @@ package com.reachlocal.grails.plugins.cassandra.orm
import org.springframework.beans.factory.InitializingBean
import org.codehaus.groovy.grails.commons.ConfigurationHolder
import com.reachlocal.grails.plugins.cassandra.mapping.DataMapping
import org.springframework.context.ApplicationContextAware
import org.springframework.context.ApplicationContext

/**
* @author: Bob Florian
*/
class CassandraOrmService implements InitializingBean
class CassandraOrmService implements InitializingBean, ApplicationContextAware
{
boolean transactional = false
def applicationContext

ApplicationContext applicationContext

def ormClientServiceName = ConfigurationHolder.config?.cassandra?.ormClientServiceName ?: "astyanaxService"

def client
def persistence
def mapping
void afterPropertiesSet ()

void afterPropertiesSet ()
{
client = applicationContext.getBean(ormClientServiceName)
persistence = client.orm
Expand Down

This file was deleted.

Expand Up @@ -18,7 +18,6 @@ package com.reachlocal.grails.plugins.cassandra.mapping

import grails.converters.JSON
import java.nio.ByteBuffer
import com.reachlocal.grails.plugins.cassandra.OrmPersistenceMethods

/**
* @author: Bob Florian
Expand All @@ -28,8 +27,9 @@ class DataMapping
static final CLASS_NAME_KEY = '_class_name_'
static final KEY_SUFFIX = InstanceMethods.KEY_SUFFIX
static final DIRTY_SUFFIX = InstanceMethods.DIRTY_SUFFIX
static final GLOBAL_TRANSIENTS = ["class","id","cassandra","indexColumnFamily","columnFamily","metaClass","keySpace"] as Set

OrmPersistenceMethods persistence
def persistence

def dataProperties(data)
{
Expand All @@ -48,13 +48,16 @@ class DataMapping
map[CLASS_NAME_KEY] = clazz.getName()
data.metaClass.properties.each() {
if (!it.name.endsWith(DIRTY_SUFFIX)) {

def prop = data.getProperty(it.name)
if (prop != null &&
it.getter &&
!it.getter.isStatic() &&
!transients.contains(it.name) &&
!GLOBAL_TRANSIENTS.contains(it.name) &&
!hasMany[it.name])
{
println it.name
if (MappingUtils.isMappedClass(prop.class)) {
map["${it.name}${KEY_SUFFIX}"] = prop.id
}
Expand Down Expand Up @@ -124,7 +127,7 @@ class DataMapping
def newObject(cols)
{
def obj = null
if (cols.size()) {
if (cols) {
def className = persistence.stringValue(persistence.getColumn(cols, CLASS_NAME_KEY))
def asClass = Class.forName(className, false, DataMapping.class.classLoader)
obj = asClass.newInstance()
Expand Down
Expand Up @@ -14,21 +14,21 @@
* limitations under the License.
*/

package com.reachlocal.grails.plugins.cassandra.test.orm
package com.reachlocal.grails.plugins.cassandra.mapping

/**
* @author: Bob Florian
*/
class Person
class OrmUtility
{
String emailAddress
String firstName
String lastName
Car firstCar
Car secondCar
static void addDynamicMethods(clazz, ctx)
{
ClassMethods.addDynamicOrmMethods(clazz, ctx)
InstanceMethods.addDynamicOrmMethods(clazz, ctx)
}

static cassandraMapping = [
primaryKey: 'emailAddress',
explicitIndexes: ["firstCar","secondCar"]
]
static boolean isMappedClass(clazz)
{
MappingUtils.isMappedClass(clazz)
}
}
Expand Up @@ -16,12 +16,10 @@

package com.reachlocal.grails.plugins.cassandra.test

import com.reachlocal.grails.plugins.cassandra.OrmPersistenceMethods

/**
* @author: Bob Florian
*/
class MockPersistenceMethods implements OrmPersistenceMethods
class MockPersistenceMethods
{
def CLASSES = [
MockUser_CFO: 'com.reachlocal.grails.plugins.cassandra.test.orm.User',
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 9e4e4b8

Please sign in to comment.