Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Revert "whitespace, javadoc, cleanup""

This reverts commit 3d63fc1.
  • Loading branch information...
commit 214c9e3d1eb0d0acb8f428c9e88399d141dc956d 1 parent 7d63276
graemerocher graemerocher authored
Showing with 275 additions and 330 deletions.
  1. +10 −17 build.gradle
  2. +4 −4 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/cache/TPCacheAdapter.java
  3. +7 −7 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/cache/TPCacheAdapterRepository.java
  4. +0 −3  grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java
  5. +1 −2  grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractPersistentEntity.java
  6. +0 −1  ...ore-core/src/main/groovy/org/grails/datastore/mapping/model/config/DefaultMappingConfigurationStrategy.java
  7. +1 −2  ...astore-core/src/main/groovy/org/grails/datastore/mapping/model/config/GormMappingConfigurationStrategy.java
  8. +4 −3 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/validation/ValidatingEventListener.java
  9. +2 −2 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/DynamoDBDatastore.java
  10. +3 −3 ...-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/engine/DynamoDBTableResolver.java
  11. +2 −2 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/query/DynamoDBQuery.java
  12. +13 −13 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBTemplate.java
  13. +0 −44 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBTemplateImpl.java
  14. +4 −4 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBUtil.java
  15. +5 −4 grails-datastore-gorm-mongo/src/test/groovy/grails/gorm/tests/DirtyCheckEmbeddedCollectionSpec.groovy
  16. +7 −5 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/CustomTypeMarshallingSpec.groovy
  17. +6 −4 ...store-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/EmbeddedHasManyWithBeforeUpdateSpec.groovy
  18. +5 −4 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/GeospacialQuerySpec.groovy
  19. +0 −4 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/OneToOneIntegritySpec.groovy
  20. +9 −5 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ConstraintsSpec.groovy
  21. +10 −8 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/GormDatastoreSpec.groovy
  22. +8 −3 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/NamedQuerySpec.groovy
  23. +0 −4 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OneToOneSpec.groovy
  24. +6 −1 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OptimisticLockingSpec.groovy
  25. +57 −61 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/PersistenceEventListenerSpec.groovy
  26. +6 −5 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/PropertyComparisonQuerySpec.groovy
  27. +15 −15 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/RangeQuerySpec.groovy
  28. +3 −1 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/TestEntity.groovy
  29. +22 −20 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/UniqueConstraintSpec.groovy
  30. +6 −3 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/UpdateWithProxyPresentSpec.groovy
  31. +4 −4 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ValidationSpec.groovy
  32. +5 −4 ...astore-gorm-test/src/test/groovy/org/grails/datastore/gorm/BidirectionalOneToManyWithInheritanceSpec.groovy
  33. +3 −2 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/CircularManyToManySpec.groovy
  34. +5 −5 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/CustomTypeMarshallingSpec.groovy
  35. +5 −4 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DeindexingSpec.groovy
  36. +1 −2  grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DistinctProjectionSpec.groovy
  37. +6 −4 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedAssociationSpec.groovy
  38. +5 −4 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedNonEntityAssociationSpec.groovy
  39. +0 −2  grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy
  40. +14 −19 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormInstanceApi.groovy
  41. +7 −20 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormStaticApi.groovy
  42. +1 −1  grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormValidationApi.groovy
  43. +1 −2  grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/config/GrailsDomainClassPersistentEntity.java
  44. +0 −1  ...-datastore-jpa/src/main/groovy/org/grails/datastore/mapping/jpa/config/JpaMappingConfigurationStrategy.java
  45. +2 −2 grails-plugins/redis/build.gradle
27 build.gradle
View
@@ -95,7 +95,6 @@ subprojects {
def isGormDatasource = project.name.startsWith("grails-datastore-gorm-") && !project.name.endsWith("tck") && !project.name.endsWith("plugin-support")
def isDocumentationProject = project.name.startsWith("grails-documentation")
-
dependencies {
if (isStandardGroovyMavenProject) {
groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: groovyVersion
@@ -110,8 +109,8 @@ subprojects {
compile spockDependency
}
}
-
- if(isDocumentationProject) {
+
+ if (isDocumentationProject) {
configurations {
documentation
}
@@ -121,7 +120,7 @@ subprojects {
documentation "org.slf4j:jcl-over-slf4j:$slf4jVersion"
documentation "org.slf4j:slf4j-api:$slf4jVersion"
documentation "org.slf4j:slf4j-simple:$slf4jVersion"
- }
+ }
task docs << {
ant.taskdef (name: 'docs', classname : 'grails.doc.ant.DocPublisherTask') {
classpath {
@@ -131,7 +130,7 @@ subprojects {
}
}
- ant.docs(src:"src/docs", dest:destinationDir, properties:"src/docs/doc.properties")
+ ant.docs(src:"src/docs", dest:destinationDir, properties:"src/docs/doc.properties")
}
docs.ext.destinationDir = "${buildDir}/docs"
@@ -139,8 +138,6 @@ subprojects {
task clean << {
ant.delete(dir:buildDir)
}
-
-
}
if (isGormDatasource) {
@@ -204,7 +201,6 @@ subprojects {
from javadoc.destinationDir
}
-
artifacts {
archives jar
archives sourcesJar
@@ -326,17 +322,16 @@ task allDocs(dependsOn: getTasksByName("docs", true)) << {
for(task in docTasks) {
def dir = task.destinationDir
def projectName = task.project.name
- if(projectName.endsWith("core")) {
+ if (projectName.endsWith("core")) {
mkdir "$allDocsDir/manual"
fileTree { from dir }.copy { into "$allDocsDir/manual" }
def groovydocTask = groovydocTasks.find { it.project.name.endsWith "core" }
- if(groovydocTask != null) {
+ if (groovydocTask != null) {
mkdir "$allDocsDir/api"
groovydocTask.actions.each { it.execute(groovydocTask) }
fileTree { from groovydocTask.destinationDir }.copy { into "$allDocsDir/api"}
}
-
}
else {
def storeName = projectName["grails-documentation-".size()..-1]
@@ -344,8 +339,8 @@ task allDocs(dependsOn: getTasksByName("docs", true)) << {
def docsDir = "$allDocsDir/$storeName"
mkdir docsDir
def groovydocTask = groovydocTasks.find { it.project.name == "grails-datastore-$storeName" }
- if(groovydocTask == null) groovydocTask = groovydocTasks.find { it.project.name == "grails-datastore-gorm-$storeName" }
- if(groovydocTask != null) {
+ if (groovydocTask == null) groovydocTask = groovydocTasks.find { it.project.name == "grails-datastore-gorm-$storeName" }
+ if (groovydocTask != null) {
mkdir "$docsDir/api"
groovydocTask.actions.each { it.execute(groovydocTask) }
fileTree { from groovydocTask.destinationDir }.copy { into "$docsDir/api"}
@@ -353,7 +348,7 @@ task allDocs(dependsOn: getTasksByName("docs", true)) << {
mkdir "$docsDir/manual"
fileTree { from dir }.copy { into "$docsDir/manual" }
}
-
+
def engine = new groovy.text.SimpleTemplateEngine()
def binding = [
datastores:stores.collect { "<li><a href=\"$it/index.html\">GORM for ${it[0].toUpperCase()}${it[1..-1]}</a></li>" }.join(System.getProperty("line.separator"))
@@ -369,11 +364,10 @@ task allDocs(dependsOn: getTasksByName("docs", true)) << {
]
template = engine.createTemplate(new File("src/docs/resources/datastore.template")).make( binding )
new File(index).text = template.toString()
-
}
}
-
}
+
task test(dependsOn: getTasksByName("test", true)) << {
def reportsDir = "${buildDir}/reports"
@@ -422,4 +416,3 @@ task test(dependsOn: getTasksByName("test", true)) << {
ant."clover-html-report"(initstring: mergedDb, outdir:"${cloverReportsDir}/html")
}
}
-
8 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/cache/TPCacheAdapter.java
View
@@ -30,16 +30,16 @@
* In cases when there is no transaction or no transactional support by the implementation, if there are any problems
* storing the entry the caller is notified about it via exception in the calling thread; also, if this method returns
* successfully it means that the logistics of putting the specified value in the cache are fully done.
- * @param key
- * @param entry
+ * @param key the entry key
+ * @param entry the entry
* @throws CacheException runtime exception indicating any cache-related problems
*/
void cacheEntry(Serializable key, T entry) throws CacheException;
/**
* Returns the stored value for the specified key.
- * @param key
- * @return
+ * @param key the entry key
+ * @return the entry
* @throws CacheException runtime exception indicating any cache-related problems
*/
T getCachedEntry(Serializable key) throws CacheException;
14 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/cache/TPCacheAdapterRepository.java
View
@@ -10,7 +10,7 @@
public interface TPCacheAdapterRepository<T> {
/**
* Returns {@link TPCacheAdapter} for the specified {@link PersistentEntity}.
- * @param entity
+ * @param entity the entity
* @return null if no {@link TPCacheAdapter} is found for the specified entity
*/
TPCacheAdapter<T> getTPCacheAdapter(PersistentEntity entity);
@@ -18,24 +18,24 @@
/**
* Sets {@link TPCacheAdapter} for the specified {@link PersistentEntity}.
* If the specified entity had another cache adapter before, the old one is ignored after this call.
- * @param entity
- * @param cacheAdapter
+ * @param entity the entity
+ * @param cacheAdapter the adapter
*/
void setTPCacheAdapter(PersistentEntity entity, TPCacheAdapter<T> cacheAdapter);
/**
* Sets {@link TPCacheAdapter} for the specified java class of {@link PersistentEntity}.
* If the specified entity had another cache adapter before, the old one is ignored after this call.
- * @param entityJavaClass equivalent to {@link PersistentEntity.getJavaClass()}
- * @param cacheAdapter
+ * @param entityJavaClass equivalent to {@link PersistentEntity#getJavaClass()}
+ * @param cacheAdapter the adapter
*/
void setTPCacheAdapter(@SuppressWarnings("rawtypes") Class entityJavaClass, TPCacheAdapter<T> cacheAdapter);
/**
* Sets {@link TPCacheAdapter} for the specified FQN java class of {@link PersistentEntity}.
* If the specified entity had another cache adapter before, the old one is ignored after this call.
- * @param entityJavaClassFQN equivalent to {@link PersistentEntity.getJavaClass().getName()}
- * @param cacheAdapter
+ * @param entityJavaClassFQN equivalent to {@link PersistentEntity#getJavaClass().getName()}
+ * @param cacheAdapter the adapter
*/
void setTPCacheAdapter(String entityJavaClassFQN, TPCacheAdapter<T> cacheAdapter);
}
3  grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java
View
@@ -167,7 +167,6 @@ public PersistentEntity addPersistentEntity(Class javaClass, boolean override) {
return addPersistentEntity(javaClass);
}
- @Override
public Collection<PersistentEntity> addPersistentEntities(Class... javaClasses) {
Collection<PersistentEntity> entities = new ArrayList<PersistentEntity>();
@@ -235,7 +234,6 @@ private void registerEntityWithContext(PersistentEntity entity) {
persistentEntitiesByName.put(entity.getName(), entity);
}
- @Override
public void initialize() {
for(PersistentEntity entity : persistentEntities) {
initializePersistentEntity(entity);
@@ -243,7 +241,6 @@ public void initialize() {
this.initialized = true;
}
- @Override
public boolean isInitialized() {
return initialized;
}
3  grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractPersistentEntity.java
View
@@ -72,9 +72,8 @@ public MappingContext getMappingContext() {
return context;
}
- @Override
public boolean isInitialized() {
- return this.initialized;
+ return initialized;
}
public void initialize() {
1  ...-core/src/main/groovy/org/grails/datastore/mapping/model/config/DefaultMappingConfigurationStrategy.java
View
@@ -129,7 +129,6 @@ public IdentityMapping getIdentityMapping(ClassMapping classMapping) {
return getDefaultIdentityMapping(classMapping);
}
- @Override
public void setCanExpandMappingContext(boolean canExpandMappingContext) {
// noop
}
3  ...ore-core/src/main/groovy/org/grails/datastore/mapping/model/config/GormMappingConfigurationStrategy.java
View
@@ -88,7 +88,6 @@ public GormMappingConfigurationStrategy(MappingFactory propertyFactory) {
/**
* Whether the strategy can add new entities to the mapping context
*/
- @Override
public void setCanExpandMappingContext(boolean canExpandMappingContext) {
this.canExpandMappingContext = canExpandMappingContext;
}
@@ -633,7 +632,7 @@ else if (!embedded && Collection.class.isAssignableFrom(relatedClassPropertyType
* check if mappedBy is set explicitly to null for the given property.
* @param property
* @param mappedBy
- * @return
+ * @return true if mappedBy is set explicitly to null
*/
private boolean forceUnidirectional(PropertyDescriptor property, Map mappedBy) {
return mappedBy.containsKey(property.getName()) && (mappedBy.get(property.getName())==null);
7 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/validation/ValidatingEventListener.java
View
@@ -14,11 +14,14 @@
*/
package org.grails.datastore.mapping.validation;
+import javax.persistence.FlushModeType;
+
import org.grails.datastore.mapping.core.Datastore;
import org.grails.datastore.mapping.core.Session;
import org.grails.datastore.mapping.engine.EntityAccess;
import org.grails.datastore.mapping.engine.event.AbstractPersistenceEvent;
import org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener;
+import org.grails.datastore.mapping.engine.event.PersistenceEventListener;
import org.grails.datastore.mapping.engine.event.PreInsertEvent;
import org.grails.datastore.mapping.engine.event.PreUpdateEvent;
import org.grails.datastore.mapping.model.PersistentEntity;
@@ -26,10 +29,8 @@
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
-import javax.persistence.FlushModeType;
-
/**
- * An {@link org.grails.datastore.mapping.engine.EntityInterceptor} that uses
+ * A {@link PersistenceEventListener} that uses
* Spring's validation mechanism to evict objects if an error occurs
*
* @author Graeme Rocher
4 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/DynamoDBDatastore.java
View
@@ -180,7 +180,7 @@ public DynamoDBAssociationInfo getAssociationInfo(Association<?> association) {
/**
* Returns table resolver for the specified entity.
* @param entity
- * @return
+ * @return the resolver
*/
public DynamoDBTableResolver getEntityDomainResolver(PersistentEntity entity) {
return entityDomainResolverMap.get(entity);
@@ -189,7 +189,7 @@ public DynamoDBTableResolver getEntityDomainResolver(PersistentEntity entity) {
/**
* Returns id generator for the specified entity.
* @param entity
- * @return
+ * @return the generator
*/
public DynamoDBIdGenerator getEntityIdGenerator(PersistentEntity entity) {
return entityIdGeneratorMap.get(entity);
6 ...tastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/engine/DynamoDBTableResolver.java
View
@@ -33,8 +33,8 @@
/**
* Returns domain name for the specified primary key value.
*
- * @param id
- * @return
+ * @param id the id
+ * @return the domain name
*/
String resolveTable(String id);
@@ -42,7 +42,7 @@
* Returns all domain names for this type of entity. Without sharding this
* list contains always one element.
*
- * @return
+ * @return the names
*/
List<String> getAllTablesForEntity();
}
4 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/query/DynamoDBQuery.java
View
@@ -408,7 +408,7 @@ private boolean validateProjectionsAndCheckIfCountIsPresent(List<Projection> pro
* (a and b) or c = dis(con(a,b), c) ==> [ [a,b], [c] ] //2 queries
*
* @param criteria
- * @return
+ * @return the results
*/
private List<List<PropertyCriterion>> flattenAndReplaceDisjunction(Junction criteria) {
List<List<PropertyCriterion>> result = new ArrayList<List<PropertyCriterion>>();
@@ -534,7 +534,7 @@ protected static String extractPropertyKey(String propertyName, PersistentEntity
*
* @param entity
* @param propertyName
- * @return
+ * @return the key
*/
protected static String getKey(PersistentEntity entity, String propertyName) {
return extractPropertyKey(propertyName, entity);
26 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBTemplate.java
View
@@ -49,7 +49,7 @@
* Same as get but with consistent read flag.
* @param tableName complete name of the table in DynamoDB, will be used as-is
* @param key the key for which to retrieve the data
- * @return
+ * @return null if the item is not found
* @throws org.springframework.dao.DataAccessException
*/
Map<String,AttributeValue> getConsistent(String tableName, Key key) throws DataAccessException;
@@ -74,9 +74,9 @@
* http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/LowLevelJavaItemCRUD.html#PutLowLevelAPIJava
* @param tableName complete name of the table in DynamoDB, will be used as-is
* @param key
- *@param attributes
+ * @param attributes
* @param expectedVersion
- * @throws org.springframework.dao.DataAccessException
+ * @throws org.springframework.dao.DataAccessException
*/
void putItemVersioned(String tableName, Key key, Map<String, AttributeValue> attributes, String expectedVersion, PersistentEntity persistentEntity) throws DataAccessException;
@@ -116,7 +116,7 @@
/**
* Returns true if any item was deleted, in other words if domain was empty it returns false.
* @param tableName complete name of the table in DynamoDB, will be used as-is
- * @return
+ * @return true if any item was deleted
* @throws org.springframework.dao.DataAccessException
*/
boolean deleteAllItems(String tableName) throws DataAccessException;
@@ -124,7 +124,7 @@
/**
* Executes scan Dynamo DB operation (note this operation does not scale well with the growth of the table).
* @param max maximum amount of items to return (inclusive)
- * @return
+ * @return the scan results
* @throws org.springframework.dao.DataAccessException
*/
List<Map<String, AttributeValue>> scan(String tableName, Map<String, Condition> filter, int max) throws DataAccessException;
@@ -132,9 +132,9 @@
/**
* Executes scan Dynamo DB operation and returns the count of matched items
* (note this operation does not scale well with the growth of the table)
- * @param tableName
- * @param filter
- * @return
+ * @param tableName the table name
+ * @param filter filters
+ * @return the count of matched items
*/
int scanCount(String tableName, Map<String, Condition> filter);
@@ -148,17 +148,17 @@
/**
* Blocking call - internally will wait until the table is successfully created and is in ACTIVE state.
- * @param tableName
- * @param ks
- * @param provisionedThroughput
+ * @param tableName the table name
+ * @param ks the schema
+ * @param provisionedThroughput the throughput
* @throws DataAccessException
*/
void createTable(String tableName, KeySchema ks, ProvisionedThroughput provisionedThroughput) throws DataAccessException;
/**
* Returns table description object containing throughput and key scheme information
- * @param tableName
- * @return
+ * @param tableName the table name
+ * @return the description
* @throws org.springframework.dao.DataAccessException
*/
TableDescription describeTable(String tableName) throws DataAccessException;
44 ...-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBTemplateImpl.java
View
@@ -128,13 +128,6 @@ public DynamoDBTemplateImpl(String accessKey, String secretKey) {
}
}
- /**
- * Executes 'put' Dynamo DB command, replacing all existing attributes if they exist.
- *
- * @param tableName complete name of the table in DynamoDB, will be used as-is
- * @param attributes
- * @throws DataAccessException
- */
public void putItem(String tableName, Map<String, AttributeValue> attributes) throws DataAccessException {
putItemInternal(tableName, attributes, 1);
}
@@ -157,18 +150,6 @@ private void putItemInternal(String tableName, Map<String, AttributeValue> attri
}
}
- /**
- * Executes 'put' Dynamo DB command, replacing all existing attributes if they exist.
- * Put is conditioned on the specified version - used for optimistic
- * locking. If the specified expectedVersion does not match what is in
- * dynamoDB, exception is thrown and no changes are made to the dynamoDB
- *
- * @param tableName complete name of the table in DynamoDB, will be used as-is
- * @param key
- * @param attributes
- * @param expectedVersion
- * @throws DataAccessException
- */
public void putItemVersioned(String tableName, Key key, Map<String, AttributeValue> attributes, String expectedVersion, PersistentEntity persistentEntity) throws DataAccessException {
putItemVersionedInternal(tableName, key, attributes, expectedVersion, persistentEntity, 1);
}
@@ -193,14 +174,6 @@ private void putItemVersionedInternal(String tableName, Key key, Map<String, Att
}
}
- /**
- * Executes 'update' Dynamo DB command, which can be used to add/replace/delete specified attributes.
- *
- * @param tableName complete name of the table in DynamoDB, will be used as-is
- * @param key
- * @param attributes
- * @throws DataAccessException
- */
public void updateItem(String tableName, Key key, Map<String, AttributeValueUpdate> attributes) throws DataAccessException {
updateItemInternal(tableName, key, attributes, 1);
}
@@ -223,17 +196,6 @@ private void updateItemInternal(String tableName, Key key, Map<String, Attribute
}
}
- /**
- * Executes 'update' Dynamo DB command, which can be used to add/replace/delete specified attributes.
- * Update is conditioned on the specified version - used for optimistic
- * locking. If the specified expectedVersion does not match what is in
- * dynamoDB, exception is thrown and no changes are made to the dynamoDB
- *
- * @param tableName complete name of the table in DynamoDB, will be used as-is
- * @param key
- * @param attributes
- * @throws DataAccessException
- */
public void updateItemVersioned(String tableName, Key key, Map<String, AttributeValueUpdate> attributes, String expectedVersion, PersistentEntity persistentEntity) throws DataAccessException {
updateItemVersionedInternal(tableName, key, attributes, expectedVersion, persistentEntity, 1);
}
@@ -415,12 +377,6 @@ public void createTable(String tableName, KeySchema ks, ProvisionedThroughput pr
}
}
- /**
- * Returns table description object containing throughput and key scheme information
- * @param tableName
- * @return
- * @throws DataAccessException
- */
public TableDescription describeTable(String tableName) throws DataAccessException{
TableDescription tableDescription = ddb.describeTable(new DescribeTableRequest().withTableName(tableName)).getTable();
return tableDescription;
8 grails-datastore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBUtil.java
View
@@ -49,7 +49,7 @@
*
* @param tableName
* @param tableNamePrefix
- * @return
+ * @return prefixed table name
*/
public static String getPrefixedTableName(String tableNamePrefix, String tableName) {
if (tableNamePrefix != null) {
@@ -62,7 +62,7 @@ public static String getPrefixedTableName(String tableNamePrefix, String tableNa
* Returns mapped table name (*unprefixed*) for the specified @{link PersistentEntity}.
*
* @param entity
- * @return
+ * @return mapped table name
*/
public static String getMappedTableName(PersistentEntity entity) {
@SuppressWarnings("unchecked")
@@ -88,7 +88,7 @@ private static String getFamily(PersistentEntity persistentEntity, DynamoDBDomai
*
* @param entity
* @param datastore
- * @return
+ * @return ProvisionedThroughput
*/
public static ProvisionedThroughput getProvisionedThroughput(PersistentEntity entity, DynamoDBDatastore datastore) {
@SuppressWarnings("unchecked")
@@ -122,7 +122,7 @@ public static ProvisionedThroughput getProvisionedThroughput(PersistentEntity en
*
* @param entity
* @param datastore
- * @return
+ * @return KeySchema
*/
public static KeySchema getKeySchema(PersistentEntity entity, DynamoDBDatastore datastore) {
return DynamoDBUtil.createIdKeySchema(); //current implementation does not handle composite keys //TODO
9 grails-datastore-gorm-mongo/src/test/groovy/grails/gorm/tests/DirtyCheckEmbeddedCollectionSpec.groovy
View
@@ -6,10 +6,6 @@ import org.bson.types.ObjectId
class DirtyCheckEmbeddedCollectionSpec extends GormDatastoreSpec {
- static {
- TEST_CLASSES << Foo << Bar
- }
-
def "Test that changes to basic collections are detected"() {
given:"A valid bar instance"
def bar = createBar()
@@ -70,6 +66,11 @@ class DirtyCheckEmbeddedCollectionSpec extends GormDatastoreSpec {
foo.bars.add(bar)
foo.save(flush:true)
}
+
+ @Override
+ List getDomainClasses() {
+ [Foo, Bar]
+ }
}
@Entity
12 ...ls-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/CustomTypeMarshallingSpec.groovy
View
@@ -1,14 +1,11 @@
package org.grails.datastore.gorm.mongo
import grails.gorm.tests.GormDatastoreSpec
-import org.bson.types.ObjectId
import grails.persistence.Entity
-class CustomTypeMarshallingSpec extends GormDatastoreSpec {
+import org.bson.types.ObjectId
- static {
- TEST_CLASSES << Person
- }
+class CustomTypeMarshallingSpec extends GormDatastoreSpec {
void "Test basic crud with custom types"() {
given: "A custom type registered for the Birthday class"
@@ -40,6 +37,11 @@ class CustomTypeMarshallingSpec extends GormDatastoreSpec {
p != null
p2 == null
}
+
+ @Override
+ List getDomainClasses() {
+ [Person]
+ }
}
@Entity
10 ...re-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/EmbeddedHasManyWithBeforeUpdateSpec.groovy
View
@@ -1,14 +1,11 @@
package org.grails.datastore.gorm.mongo
import grails.gorm.tests.GormDatastoreSpec
+
import org.bson.types.ObjectId
class EmbeddedHasManyWithBeforeUpdateSpec extends GormDatastoreSpec {
- static {
- TEST_CLASSES << User << UserAddress
- }
-
void "Test embedded hasMany with beforeUpdate event"() {
given:
def user = User.findByName("Ratler")
@@ -39,6 +36,11 @@ class EmbeddedHasManyWithBeforeUpdateSpec extends GormDatastoreSpec {
user.addresses.size() == 1
user.addresses[0].type == 'home'
}
+
+ @Override
+ List getDomainClasses() {
+ [User, UserAddress]
+ }
}
class User {
9 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/GeospacialQuerySpec.groovy
View
@@ -5,10 +5,6 @@ import grails.persistence.Entity
class GeospacialQuerySpec extends GormDatastoreSpec {
- static {
- GormDatastoreSpec.TEST_CLASSES << Hotel
- }
-
void "Test geolocation with BigDecimal values"() {
given:"Some entities stored with BigDecimal locations"
new Hotel(name:"Hilton", location:[50.34d, 50.12d]).save()
@@ -123,6 +119,11 @@ class GeospacialQuerySpec extends GormDatastoreSpec {
h != null
h.name == "Raddison"
}
+
+ @Override
+ List getDomainClasses() {
+ [Hotel]
+ }
}
@Entity
4 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/OneToOneIntegritySpec.groovy
View
@@ -8,10 +8,6 @@ import grails.gorm.tests.Pet
class OneToOneIntegritySpec extends GormDatastoreSpec {
- static {
- TEST_CLASSES << Face << Nose
- }
-
def "Test persist and retrieve unidirectional many-to-one"() {
given:"A domain model with a many-to-one"
def person = new Person(firstName:"Fred", lastName: "Flintstone")
14 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ConstraintsSpec.groovy
View
@@ -1,10 +1,8 @@
package grails.gorm.tests
-class ConstraintsSpec extends GormDatastoreSpec {
+import grails.persistence.Entity
- static {
- TEST_CLASSES << ConstrainedEntity
- }
+class ConstraintsSpec extends GormDatastoreSpec {
void "Test constraints with static default values"() {
given: "A Test class with static constraint values"
@@ -16,11 +14,17 @@ class ConstraintsSpec extends GormDatastoreSpec {
then:
ce.hasErrors() == false
}
+
+ @Override
+ List getDomainClasses() {
+ [ConstrainedEntity]
+ }
}
+@Entity
class ConstrainedEntity implements Serializable {
- static final MAX_VALUE = 1000
+ static final int MAX_VALUE = 1000
static final List<String> ALLOWABLE_VALUES = ['ABC','DEF','GHI']
Long id
18 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/GormDatastoreSpec.groovy
View
@@ -3,7 +3,8 @@ package grails.gorm.tests
import org.grails.datastore.mapping.core.DatastoreUtils
import org.grails.datastore.mapping.core.Session
-import spock.lang.*
+import spock.lang.Shared
+import spock.lang.Specification
/**
* A Spec base class that manages a Session for each feature as well as
@@ -21,11 +22,10 @@ abstract class GormDatastoreSpec extends Specification {
static final SETUP_CLASS_NAME = 'org.grails.datastore.gorm.Setup'
static final TEST_CLASSES = [
- Task, Person, ModifyPerson, Pet, PetType, PersonEvent, Book, Highway,
- TestEntity, ChildEntity, CommonTypes, Location, City, Country, Plant,
- PlantCategory, Publication, OptLockVersioned, OptLockNotVersioned,
- ClassWithNoArgBeforeValidate, ClassWithListArgBeforeValidate,
- ClassWithOverloadedBeforeValidate, EnumThing]
+ Book, ChildEntity, City, ClassWithListArgBeforeValidate, ClassWithNoArgBeforeValidate,
+ ClassWithOverloadedBeforeValidate, CommonTypes, Country, EnumThing, Face, Highway,
+ Location, ModifyPerson, Nose, OptLockNotVersioned, OptLockVersioned, Person, PersonEvent,
+ Pet, PetType, Plant, PlantCategory, Publication, Task, TestEntity]
@Shared Class setupClass
@@ -47,8 +47,10 @@ abstract class GormDatastoreSpec extends Specification {
}
def cleanup() {
- session?.disconnect()
- DatastoreUtils.unbindSession(session)
+ if (session) {
+ session.disconnect()
+ DatastoreUtils.unbindSession session
+ }
try {
setupClass.destroy()
} catch(e) {
11 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/NamedQuerySpec.groovy
View
@@ -1,5 +1,7 @@
package grails.gorm.tests
+import grails.persistence.Entity
+
import spock.lang.Ignore
/**
@@ -285,7 +287,7 @@ class NamedQuerySpec extends GormDatastoreSpec {
'Some Recent Book' == publications[2].title
}
- @spock.lang.Ignore // queries on associations not yet supported
+ @Ignore // queries on associations not yet supported
void "Test named query with relationships in criteria"() {
given:
@@ -328,7 +330,7 @@ class NamedQuerySpec extends GormDatastoreSpec {
'groovy' == results[0].name
}
- @spock.lang.Ignore // queries on associations not yet supported
+ @Ignore // queries on associations not yet supported
void "Test list distinct entities"() {
given:
@@ -360,7 +362,7 @@ class NamedQuerySpec extends GormDatastoreSpec {
true == 'orange' in names
}
- @spock.lang.Ignore // queries on associations not yet supported
+ @Ignore // queries on associations not yet supported
void "Another test on listing distinct entities"() {
given:
new PlantCategory(name:"leafy")
@@ -1016,6 +1018,7 @@ class NamedQuerySpec extends GormDatastoreSpec {
}
}
+@Entity
class PlantCategory implements Serializable {
Long id
Long version
@@ -1042,6 +1045,7 @@ class PlantCategory implements Serializable {
}
}
+@Entity
class Plant implements Serializable {
Long id
Long version
@@ -1054,6 +1058,7 @@ class Plant implements Serializable {
}
}
+@Entity
class Publication implements Serializable {
Long id
Long version
4 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OneToOneSpec.groovy
View
@@ -4,10 +4,6 @@ import grails.persistence.Entity
class OneToOneSpec extends GormDatastoreSpec {
- static {
- TEST_CLASSES << Face << Nose
- }
-
def "Test persist and retrieve unidirectional many-to-one"() {
given:"A domain model with a many-to-one"
def person = new Person(firstName:"Fred", lastName: "Flintstone")
7 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OptimisticLockingSpec.groovy
View
@@ -1,5 +1,7 @@
package grails.gorm.tests
+import grails.persistence.Entity
+
import org.grails.datastore.mapping.core.OptimisticLockingException
import org.grails.datastore.mapping.core.Session
@@ -49,6 +51,7 @@ class OptimisticLockingSpec extends GormDatastoreSpec {
Thread.start {
OptLockVersioned.withNewSession { s ->
def reloaded = OptLockVersioned.get(o.id)
+ assert reloaded
reloaded.name += ' in new session'
reloaded.save(flush: true)
}
@@ -70,7 +73,7 @@ class OptimisticLockingSpec extends GormDatastoreSpec {
then:
ex instanceof OptimisticLockingException
- o.version == 1
+ o.version == 1
o.name == 'locked in new session'
}
@@ -111,6 +114,7 @@ class OptimisticLockingSpec extends GormDatastoreSpec {
}
}
+@Entity
class OptLockVersioned implements Serializable {
Long id
Long version
@@ -118,6 +122,7 @@ class OptLockVersioned implements Serializable {
String name
}
+@Entity
class OptLockNotVersioned implements Serializable {
Long id
118 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/PersistenceEventListenerSpec.groovy
View
@@ -2,14 +2,15 @@ package grails.gorm.tests
import grails.gorm.DetachedCriteria
import grails.persistence.Entity
+
import org.grails.datastore.mapping.core.Datastore
import org.grails.datastore.mapping.engine.event.AbstractPersistenceEvent
import org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener
-import org.springframework.context.ApplicationEvent
import org.grails.datastore.mapping.engine.event.EventType
-import org.grails.datastore.mapping.engine.event.ValidationEvent
-import org.grails.datastore.mapping.engine.event.PreDeleteEvent
import org.grails.datastore.mapping.engine.event.PostDeleteEvent
+import org.grails.datastore.mapping.engine.event.PreDeleteEvent
+import org.grails.datastore.mapping.engine.event.ValidationEvent
+import org.springframework.context.ApplicationEvent
/**
* @author Tom Widmer
@@ -38,15 +39,15 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
p = Simples.get(p.id)
then:
- 0 == listener.PreDelete
- 0 == listener.PostDelete
+ 0 == listener.PreDeleteCount
+ 0 == listener.PostDeleteCount
when:
p.delete(flush: true)
then:
- 1 == listener.PreDelete
- 1 == listener.PostDelete
+ 1 == listener.PreDeleteCount
+ 1 == listener.PostDeleteCount
0 < listener.events.size()
p == listener.events[-1].entityObject
listener.events[-1].eventType == EventType.PostDelete
@@ -67,8 +68,8 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
3 == freds.size()
- 0 == listener.PreDelete
- 0 == listener.PostDelete
+ 0 == listener.PreDeleteCount
+ 0 == listener.PostDeleteCount
when:
new DetachedCriteria(Simples).build {
@@ -82,8 +83,8 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
// conditional assertions because in the case of batch DML statements neither Hibernate nor JPA triggers delete events for individual entities
if (!session.getClass().simpleName in ['JpaSession', 'HibernateSession']) {
- 3 == listener.PreDelete
- 3 == listener.PostDelete
+ 3 == listener.PreDeleteCount
+ 3 == listener.PostDeleteCount
}
}
@@ -100,8 +101,8 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Fred" == p.name
- 0 == listener.PreUpdate
- 0 == listener.PostUpdate
+ 0 == listener.PreUpdateCount
+ 0 == listener.PostUpdateCount
when:
p.name = "Bob"
@@ -111,8 +112,8 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Bob" == p.name
- 1 == listener.PreUpdate
- 1 == listener.PostUpdate
+ 1 == listener.PreUpdateCount
+ 1 == listener.PostUpdateCount
}
void "Test insert events"() {
@@ -128,10 +129,10 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Fred" == p.name
- 0 == listener.PreUpdate
- 1 == listener.PreInsert
- 0 == listener.PostUpdate
- 1 == listener.PostInsert
+ 0 == listener.PreUpdateCount
+ 1 == listener.PreInsertCount
+ 0 == listener.PostUpdateCount
+ 1 == listener.PostInsertCount
when:
p.name = "Bob"
@@ -141,10 +142,10 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Bob" == p.name
- 1 == listener.PreUpdate
- 1 == listener.PreInsert
- 1 == listener.PostUpdate
- 1 == listener.PostInsert
+ 1 == listener.PreUpdateCount
+ 1 == listener.PreInsertCount
+ 1 == listener.PostUpdateCount
+ 1 == listener.PostInsertCount
}
void "Test load events"() {
@@ -162,9 +163,9 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
"Fred" == p.name
if (!'JpaSession'.equals(session.getClass().simpleName)) {
// JPA doesn't seem to support a pre-load event
- 1 == listener.PreLoad
+ 1 == listener.PreLoadCount
}
- 1 == listener.PostLoad
+ 1 == listener.PostLoadCount
}
void "Test multi-load events"() {
@@ -181,42 +182,40 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
3 == freds.size()
if (!'JpaSession'.equals(session.getClass().simpleName)) {
// JPA doesn't seem to support a pre-load event
- 3 == listener.PreLoad
+ 3 == listener.PreLoadCount
}
- 3 == listener.PostLoad
+ 3 == listener.PostLoadCount
}
void "Test validation events"() {
given:
- def p = new Simples()
+ def p = new Simples()
- p.name = "Fred"
+ p.name = "Fred"
when:
- p.validate()
+ p.validate()
then:
- 1 == listener.Validation
- listener.events.size() == 1
- p == listener.events[0].entityObject
- listener.events[0] instanceof ValidationEvent
- null == listener.events[0].validatedFields
+ 1 == listener.ValidationCount
+ listener.events.size() == 1
+ p == listener.events[0].entityObject
+ listener.events[0] instanceof ValidationEvent
+ null == listener.events[0].validatedFields
when:
- p.name = null
- p.validate(['name'])
+ p.name = null
+ p.validate(['name'])
then:
- 2 == listener.Validation
- listener.events.size() == 2
- p == listener.events[1].entityObject
- listener.events[1] instanceof ValidationEvent
- ['name'] == listener.events[1].validatedFields
-
+ 2 == listener.ValidationCount
+ listener.events.size() == 2
+ p == listener.events[1].entityObject
+ listener.events[1] instanceof ValidationEvent
+ ['name'] == listener.events[1].validatedFields
}
}
-
class SpecPersistenceListener extends AbstractPersistenceEventListener {
SpecPersistenceListener(Datastore datastore) {
@@ -225,32 +224,29 @@ class SpecPersistenceListener extends AbstractPersistenceEventListener {
List<AbstractPersistenceEvent> events = []
- int PreDelete,
- PreInsert,
- PreUpdate,
- PostUpdate,
- PostDelete,
- PostInsert,
- PreLoad,
- PostLoad,
- SaveOrUpdate,
- Validation
+ int PreDeleteCount,
+ PreInsertCount,
+ PreUpdateCount,
+ PostUpdateCount,
+ PostDeleteCount,
+ PostInsertCount,
+ PreLoadCount,
+ PostLoadCount,
+ SaveOrUpdateCount,
+ ValidationCount
@Override
protected void onPersistenceEvent(AbstractPersistenceEvent event) {
- def typeName = event.eventType.name()
- this."$typeName"++
+ String typeName = event.eventType.name()
+ this."${typeName}Count"++
events << event
}
- @Override
- boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
- return true
- }
+ boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { true }
}
@Entity
-class Simples implements Serializable{
+class Simples implements Serializable {
Long id
String name
}
11 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/PropertyComparisonQuerySpec.groovy
View
@@ -5,11 +5,7 @@ import grails.persistence.Entity
/**
* Tests for criteria queries that compare two properties
*/
-class PropertyComparisonQuerySpec extends GormDatastoreSpec{
-
- static {
- TEST_CLASSES << Dog
- }
+class PropertyComparisonQuerySpec extends GormDatastoreSpec {
void "Test geProperty query"() {
given:"Some dead and alive dogs"
@@ -124,6 +120,11 @@ class PropertyComparisonQuerySpec extends GormDatastoreSpec{
results.size() == 1
results[0].name == "Fred"
}
+
+ @Override
+ List getDomainClasses() {
+ [Dog]
+ }
}
@Entity
30 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/RangeQuerySpec.groovy
View
@@ -28,7 +28,7 @@ class RangeQuerySpec extends GormDatastoreSpec {
void "Test between query"() {
given:
- def age = 40
+ int age = 40
["Bob", "Fred", "Barney", "Frank", "Joe", "Ernie"].each { new TestEntity(name:it, age: age--, child:new ChildEntity(name:"$it Child")).save() }
when:
@@ -43,9 +43,9 @@ class RangeQuerySpec extends GormDatastoreSpec {
then:
3 == results.size()
- results.find{ it.name == "Bob" } != null
- results.find{ it.name == "Fred" } != null
- results.find{ it.name == "Barney" } != null
+ results.find { it.name == "Bob" } != null
+ results.find { it.name == "Fred" } != null
+ results.find { it.name == "Barney" } != null
when:
results = TestEntity.findAllByAgeBetweenOrName(38, 40, "Ernie")
@@ -57,7 +57,7 @@ class RangeQuerySpec extends GormDatastoreSpec {
void "Test greater than or equal to and less than or equal to queries"() {
given:
- def age = 40
+ int age = 40
["Bob", "Fred", "Barney", "Frank", "Joe", "Ernie"].each { new TestEntity(name:it, age: age--, child:new ChildEntity(name:"$it Child")).save() }
when:
@@ -88,33 +88,33 @@ class RangeQuerySpec extends GormDatastoreSpec {
new Person(firstName: 'Zack', lastName: 'Galifianakis', age: 41).save()
when:
- def cnt = Person.countByAgeInRange(14..41)
+ int count = Person.countByAgeInRange(14..41)
then:
- 3 == cnt
+ 3 == count
when:
- cnt = Person.countByAgeInRange(41..14)
+ count = Person.countByAgeInRange(41..14)
then:
- 3 == cnt
+ 3 == count
when:
- cnt = Person.countByAgeInRange(14..<30)
+ count = Person.countByAgeInRange(14..<30)
then:
- 1 == cnt
+ 1 == count
when:
- cnt = Person.countByAgeInRange(14..<42)
+ count = Person.countByAgeInRange(14..<42)
then:
- 3 == cnt
+ 3 == count
when:
- cnt = Person.countByAgeInRange(15..40)
+ count = Person.countByAgeInRange(15..40)
then:
- 0 == cnt
+ 0 == count
}
}
4 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/TestEntity.groovy
View
@@ -1,9 +1,11 @@
package grails.gorm.tests
+import grails.persistence.Entity
+
/**
* @author graemerocher
*/
-@grails.persistence.Entity
+@Entity
class TestEntity implements Serializable {
Long id
Long version
42 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/UniqueConstraintSpec.groovy
View
@@ -4,13 +4,15 @@ import grails.persistence.Entity
import org.codehaus.groovy.grails.commons.GrailsDomainConfigurationUtil
import org.codehaus.groovy.grails.validation.ConstrainedProperty
+import org.grails.datastore.mapping.model.MappingContext
+import org.grails.datastore.mapping.model.PersistentEntity
import org.springframework.validation.Errors
import org.springframework.validation.Validator
/**
* Tests the unique constraint
*/
-class UniqueConstraintSpec extends GormDatastoreSpec{
+class UniqueConstraintSpec extends GormDatastoreSpec {
void "Test simple unique constraint"() {
given:"A validator that uses the unique constraint"
@@ -48,23 +50,23 @@ class UniqueConstraintSpec extends GormDatastoreSpec{
protected void setupValidator() {
def groupValidator = [supports: {Class cls -> true},
- validate: {Object target, Errors errors ->
- def constrainedProperties = GrailsDomainConfigurationUtil.evaluateConstraints(UniqueGroup)
- for (ConstrainedProperty cp in constrainedProperties.values()) {
- cp.validate(target, target[cp.propertyName], errors)
- }
- }] as Validator
-
- def groupWithinValidator = [supports: {Class cls -> true},
- validate: {Object target, Errors errors ->
- def constrainedProperties = GrailsDomainConfigurationUtil.evaluateConstraints(GroupWithin)
- for (ConstrainedProperty cp in constrainedProperties.values()) {
- cp.validate(target, target[cp.propertyName], errors)
- }
- }] as Validator
-
- final context = session.datastore.mappingContext
- final entity = context.getPersistentEntity(UniqueGroup.name)
+ validate: {Object target, Errors errors ->
+ def constrainedProperties = GrailsDomainConfigurationUtil.evaluateConstraints(UniqueGroup)
+ for (ConstrainedProperty cp in constrainedProperties.values()) {
+ cp.validate(target, target[cp.propertyName], errors)
+ }
+ }] as Validator
+
+ def groupWithinValidator = [supports: {Class cls -> true},
+ validate: {Object target, Errors errors ->
+ def constrainedProperties = GrailsDomainConfigurationUtil.evaluateConstraints(GroupWithin)
+ for (ConstrainedProperty cp in constrainedProperties.values()) {
+ cp.validate(target, target[cp.propertyName], errors)
+ }
+ }] as Validator
+
+ final MappingContext context = session.datastore.mappingContext
+ final PersistentEntity entity = context.getPersistentEntity(UniqueGroup.name)
context.addEntityValidator(entity, groupValidator)
entity = context.getPersistentEntity(GroupWithin.name)
context.addEntityValidator(entity, groupWithinValidator)
@@ -77,7 +79,7 @@ class UniqueConstraintSpec extends GormDatastoreSpec{
}
@Entity
-class UniqueGroup implements Serializable{
+class UniqueGroup implements Serializable {
Long id
String name
static constraints = {
@@ -86,7 +88,7 @@ class UniqueGroup implements Serializable{
}
@Entity
-class GroupWithin implements Serializable{
+class GroupWithin implements Serializable {
Long id
String name
String org
9 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/UpdateWithProxyPresentSpec.groovy
View
@@ -4,12 +4,10 @@ import grails.persistence.Entity
import org.grails.datastore.gorm.proxy.GroovyProxyFactory
import org.grails.datastore.gorm.query.transform.ApplyDetachedCriteriaTransform
-import grails.gorm.DetachedCriteria
/**
* @author graemerocher
*/
-@ApplyDetachedCriteriaTransform
class UpdateWithProxyPresentSpec extends GormDatastoreSpec {
void "Test update entity with association proxies"() {
@@ -38,6 +36,11 @@ class UpdateWithProxyPresentSpec extends GormDatastoreSpec {
personPet.type.name == 'snake'
personPet.type.id == petType.id
}
+
+ @Override
+ List getDomainClasses() {
+ [Pet, Person, PetType]
+ }
}
@Entity
@@ -58,7 +61,7 @@ class Pet implements Serializable {
static constraints = {
owner nullable:true
age nullable: true
- face nulable:true
+ face nullable:true
}
}
8 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ValidationSpec.groovy
View
@@ -18,8 +18,8 @@ class ValidationSpec extends GormDatastoreSpec {
when:
t.errors.reject 'foo'
- def isValid = t.validate()
- def errorCount = t.errors.errorCount
+ boolean isValid = t.validate()
+ int errorCount = t.errors.errorCount
then:
!isValid
@@ -36,7 +36,7 @@ class ValidationSpec extends GormDatastoreSpec {
when:
t = new TestEntity(name:"", child:new ChildEntity(name:"child"))
- def validationResult = t.validate()
+ boolean validationResult = t.validate()
def errors = t.errors
then:
@@ -60,7 +60,7 @@ class ValidationSpec extends GormDatastoreSpec {
when:
t = new TestEntity(name:"")
- def validationResult = t.validate()
+ boolean validationResult = t.validate()
def errors = t.errors
then:
9 ...ore-gorm-test/src/test/groovy/org/grails/datastore/gorm/BidirectionalOneToManyWithInheritanceSpec.groovy
View
@@ -5,10 +5,6 @@ import grails.gorm.tests.GormDatastoreSpec
*/
class BidirectionalOneToManyWithInheritanceSpec extends GormDatastoreSpec {
- static {
- GormDatastoreSpec.TEST_CLASSES << ConfigurationItem << Documentation << ChangeRequest
- }
-
void "Test a bidirectional one-to-many association with inheritance"() {
given:
@@ -25,6 +21,11 @@ class BidirectionalOneToManyWithInheritanceSpec extends GormDatastoreSpec {
then:
2 == doc.configurationItems.size()
}
+
+ @Override
+ List getDomainClasses() {
+ [ConfigurationItem, Documentation, ChangeRequest]
+ }
}
class ConfigurationItem {
5 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/CircularManyToManySpec.groovy
View
@@ -26,6 +26,7 @@ class CircularManyToManySpec extends GormDatastoreSpec {
p1 = CircularPerson.findByName("Fred")
p2 = CircularPerson.findByName("Bob")
+
then:"The persisted model is correct"
p1.name == "Fred"
p1.friends.size() == 2
@@ -51,8 +52,8 @@ class CircularPerson {
List<CircularPerson> friends = []
static hasMany = [
- friends: CircularPerson,
- enemies: CircularPerson
+ friends: CircularPerson,
+ enemies: CircularPerson
]
static mapping = {
10 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/CustomTypeMarshallingSpec.groovy
View
@@ -7,10 +7,6 @@ import spock.lang.Shared
class CustomTypeMarshallingSpec extends GormDatastoreSpec {
- static {
- TEST_CLASSES << Person
- }
-
@Shared Date now = new Date()
def setup() {
@@ -107,6 +103,11 @@ class CustomTypeMarshallingSpec extends GormDatastoreSpec {
session.clear()
Person.countByBirthdayIsNull() == 1
}
+
+ @Override
+ List getDomainClasses() {
+ [Person]
+ }
}
class Person {
@@ -133,7 +134,6 @@ class Birthday implements Comparable {
obj instanceof Birthday && date == obj.date
}
- @Override
int compareTo(t) {
date.compareTo(t.date)
}
9 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DeindexingSpec.groovy
View
@@ -7,10 +7,6 @@ import grails.gorm.tests.GormDatastoreSpec
*/
class DeindexingSpec extends GormDatastoreSpec {
- static {
- TEST_CLASSES << AuthorWithPseudonym
- }
-
def 'Null is de-indexed'() {
def author = new AuthorWithPseudonym(name: 'Samuel Clemens').save(failOnError: true)
author.pseudonym = 'Mark Twain'
@@ -19,6 +15,11 @@ class DeindexingSpec extends GormDatastoreSpec {
expect:
!AuthorWithPseudonym.findByPseudonymIsNull()
}
+
+ @Override
+ List getDomainClasses() {
+ [AuthorWithPseudonym]
+ }
}
class AuthorWithPseudonym {
3  grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DistinctProjectionSpec.groovy
View
@@ -3,7 +3,7 @@ package org.grails.datastore.gorm
import grails.gorm.tests.GormDatastoreSpec
import grails.gorm.tests.Person
-class DistinctProjectionSpec extends GormDatastoreSpec{
+class DistinctProjectionSpec extends GormDatastoreSpec {
def "Test that using the distinct projection returns distinct results"() {
given:"Some people with the same last names"
@@ -20,6 +20,5 @@ class DistinctProjectionSpec extends GormDatastoreSpec{
then:"The correct results are returned"
results == ['Rubble', 'Simpson']
-
}
}
10 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedAssociationSpec.groovy
View
@@ -2,14 +2,11 @@ package org.grails.datastore.gorm
import grails.gorm.tests.GormDatastoreSpec
import grails.persistence.Entity
+
import spock.lang.Shared
class EmbeddedAssociationSpec extends GormDatastoreSpec {
- static {
- GormDatastoreSpec.TEST_CLASSES << Individual << Address
- }
-
@Shared Date now = new Date()
void "Test persistence of embedded entities"() {
@@ -29,6 +26,11 @@ class EmbeddedAssociationSpec extends GormDatastoreSpec {
i.address.postCode == '30483'
i.bio.birthday.date == now
}
+
+ @Override
+ List getDomainClasses() {
+ [Individual, Address]
+ }
}
@Entity
9 ...ls-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedNonEntityAssociationSpec.groovy
View
@@ -5,10 +5,6 @@ import grails.persistence.Entity
class EmbeddedNonEntityAssociationSpec extends GormDatastoreSpec {
- static {
- GormDatastoreSpec.TEST_CLASSES << Being
- }
-
void "Test persistence of embedded entities"() {
given:
def i = new Being(name:"Bob", address: new ResidentialAddress(postCode:"30483"))
@@ -25,6 +21,11 @@ class EmbeddedNonEntityAssociationSpec extends GormDatastoreSpec {
i.address != null
i.address.postCode == '30483'
}
+
+ @Override
+ List getDomainClasses() {
+ [Being]
+ }
}
@Entity
2  grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy
View
@@ -49,6 +49,4 @@ class OrderBySpec extends GormDatastoreSpec {
then:
45 == results[0].age
}
-
}
-
33 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormInstanceApi.groovy
View
@@ -14,14 +14,13 @@
*/
package org.grails.datastore.gorm
-import static org.grails.datastore.mapping.validation.ValidatingEventListener.*
+import grails.validation.ValidationException
import org.grails.datastore.mapping.core.Datastore
import org.grails.datastore.mapping.core.Session
import org.grails.datastore.mapping.core.SessionCallback
import org.grails.datastore.mapping.core.VoidSessionCallback
import org.grails.datastore.mapping.proxy.EntityProxy
-import grails.validation.ValidationException
/**
* Instance methods of the GORM API.
@@ -38,16 +37,12 @@ class GormInstanceApi<D> extends AbstractGormApi<D> {
super(persistentClass, datastore)
}
- protected Class<Exception> getValidationException() {
- this.validationException
- }
-
/**
* Proxy aware instanceOf implementation.
*/
boolean instanceOf(o, Class cls) {
if (o instanceof EntityProxy) {
- return cls.isInstance(o.getTarget())
+ o = o.getTarget()
}
return cls.isInstance(o)
}
@@ -58,8 +53,8 @@ class GormInstanceApi<D> extends AbstractGormApi<D> {
*/
D lock(instance) {
execute({ Session session ->
- session.lock(instance)
- return instance
+ session.lock(instance)
+ return instance
} as SessionCallback)
}
@@ -71,13 +66,13 @@ class GormInstanceApi<D> extends AbstractGormApi<D> {
*/
def mutex(instance, Closure callable) {
execute({ Session session ->
- try {
- session.lock(instance)
- callable?.call()
- }
- finally {
- session.unlock(instance)
- }
+ try {
+ session.lock(instance)
+ callable?.call()
+ }
+ finally {
+ session.unlock(instance)
+ }
} as SessionCallback)
}
@@ -88,8 +83,8 @@ class GormInstanceApi<D> extends AbstractGormApi<D> {
*/
D refresh(instance) {
execute({ Session session ->
- session.refresh instance
- return instance
+ session.refresh instance
+ return instance
} as SessionCallback)
}
@@ -140,7 +135,7 @@ class GormInstanceApi<D> extends AbstractGormApi<D> {
*/
D save(instance, Map params) {
execute({ Session session ->
- doSave instance, params, session
+ doSave instance, params, session
} as SessionCallback)
}
27 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormStaticApi.groovy
View
@@ -49,8 +49,9 @@ import org.springframework.validation.Errors
*/
class GormStaticApi<D> extends AbstractGormApi<D> {
- private List<FinderMethod> dynamicFinders
- private PlatformTransactionManager transactionManager
+ List<FinderMethod> gormDynamicFinders
+
+ PlatformTransactionManager transactionManager
GormStaticApi(Class<D> persistentClass, Datastore datastore, List<FinderMethod> finders) {
this(persistentClass, datastore, finders, null)
@@ -58,29 +59,15 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
GormStaticApi(Class<D> persistentClass, Datastore datastore, List<FinderMethod> finders, PlatformTransactionManager transactionManager) {
super(persistentClass, datastore)
- this.dynamicFinders = finders
- this.transactionManager = transactionManager
- }
-
- /**
- * Sets the {@link PlatformTransactionManager} to use
- */
- void setTransactionManager(PlatformTransactionManager transactionManager) {
+ gormDynamicFinders = finders
this.transactionManager = transactionManager
}
/**
- * @return The FinderMethods for this class
- */
- List<FinderMethod> getGormDynamicFinders() {
- this.dynamicFinders
- }
-
- /**
* @return The PersistentEntity for this class
*/
PersistentEntity getGormPersistentEntity() {
- this.persistentEntity
+ persistentEntity
}
/**
@@ -91,7 +78,7 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
* @return The result of the method call
*/
def methodMissing(String methodName, args) {
- def method = dynamicFinders.find { FinderMethod f -> f.isMethodMatch(methodName) }
+ def method = gormDynamicFinders.find { FinderMethod f -> f.isMethodMatch(methodName) }
def cls = persistentClass
if (!method) {
throw new MissingMethodException(methodName, cls, args)
@@ -755,7 +742,7 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
* @return the map
*/
Map<D, Boolean> getValidationSkipMap() {
- AbstractDatastore.getValidationErrorsMap()
+ AbstractDatastore.getValidationSkipMap()
}
// TODO: In the first version no support will exist for String-based queries
2  grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormValidationApi.groovy
View
@@ -17,13 +17,13 @@ package org.grails.datastore.gorm
import org.codehaus.groovy.grails.validation.CascadingValidator
import org.grails.datastore.gorm.support.BeforeValidateHelper
import org.grails.datastore.mapping.core.Datastore
+import org.grails.datastore.mapping.engine.event.ValidationEvent
import org.grails.datastore.mapping.model.MappingContext
import org.grails.datastore.mapping.validation.ValidationErrors
import org.springframework.validation.Errors
import org.springframework.validation.FieldError
import org.springframework.validation.ObjectError
import org.springframework.validation.Validator
-import org.grails.datastore.mapping.engine.event.ValidationEvent
/**
* Methods used for validating GORM instances.
3  ...s-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/config/GrailsDomainClassPersistentEntity.java
View
@@ -65,9 +65,8 @@ public GrailsDomainClass getDomainClass() {
return domainClass;
}
- @Override
public boolean isInitialized() {
- return this.initialized;
+ return initialized;
}
public void initialize() {
1  ...tastore-jpa/src/main/groovy/org/grails/datastore/mapping/jpa/config/JpaMappingConfigurationStrategy.java
View
@@ -212,7 +212,6 @@ public IdentityMapping getIdentityMapping(ClassMapping classMapping) {
return getDefaultIdentityMapping(classMapping);
}
- @Override
public void setCanExpandMappingContext(boolean canExpandMappingContext) {
// noop
}
4 grails-plugins/redis/build.gradle
View
@@ -38,6 +38,6 @@ dependencies {
runtime "org.slf4j:slf4j-simple:1.5.8",
"hsqldb:hsqldb:1.8.0.5",
"net.sf.ehcache:ehcache-core:1.7.1"
- compile "org.grails:grails-crud:1.3.4",
- "org.grails:grails-gorm:1.3.4"
+ compile "org.grails:grails-crud:$grailsVersion",
+ "org.grails:grails-gorm:$grailsVersion"
}
Please sign in to comment.
Something went wrong with that request. Please try again.