Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "whitespace, javadoc, cleanup"

This reverts commit e7ae440.
  • Loading branch information...
commit 3d63fc17fdda1637f645d60b8fb84ed6c653f2e1 1 parent 48ec401
@graemerocher graemerocher authored
Showing with 330 additions and 275 deletions.
  1. +17 −10 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. +3 −0  grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java
  5. +2 −1  grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractPersistentEntity.java
  6. +1 −0  ...ore-core/src/main/groovy/org/grails/datastore/mapping/model/config/DefaultMappingConfigurationStrategy.java
  7. +2 −1  ...astore-core/src/main/groovy/org/grails/datastore/mapping/model/config/GormMappingConfigurationStrategy.java
  8. +3 −4 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. +44 −0 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. +4 −5 grails-datastore-gorm-mongo/src/test/groovy/grails/gorm/tests/DirtyCheckEmbeddedCollectionSpec.groovy
  16. +5 −7 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/CustomTypeMarshallingSpec.groovy
  17. +4 −6 ...store-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/EmbeddedHasManyWithBeforeUpdateSpec.groovy
  18. +4 −5 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/GeospacialQuerySpec.groovy
  19. +4 −0 grails-datastore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/OneToOneIntegritySpec.groovy
  20. +5 −9 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ConstraintsSpec.groovy
  21. +8 −10 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/GormDatastoreSpec.groovy
  22. +3 −8 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/NamedQuerySpec.groovy
  23. +4 −0 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OneToOneSpec.groovy
  24. +1 −6 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OptimisticLockingSpec.groovy
  25. +61 −57 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/PersistenceEventListenerSpec.groovy
  26. +5 −6 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. +1 −3 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/TestEntity.groovy
  29. +20 −22 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/UniqueConstraintSpec.groovy
  30. +3 −6 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. +4 −5 ...astore-gorm-test/src/test/groovy/org/grails/datastore/gorm/BidirectionalOneToManyWithInheritanceSpec.groovy
  33. +2 −3 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. +4 −5 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DeindexingSpec.groovy
  36. +2 −1  grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DistinctProjectionSpec.groovy
  37. +4 −6 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedAssociationSpec.groovy
  38. +4 −5 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedNonEntityAssociationSpec.groovy
  39. +2 −0  grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy
  40. +19 −14 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormInstanceApi.groovy
  41. +20 −7 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. +2 −1  grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/config/GrailsDomainClassPersistentEntity.java
  44. +1 −0  ...-datastore-jpa/src/main/groovy/org/grails/datastore/mapping/jpa/config/JpaMappingConfigurationStrategy.java
  45. +2 −2 grails-plugins/redis/build.gradle
View
27 build.gradle
@@ -95,6 +95,7 @@ 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
@@ -109,8 +110,8 @@ subprojects {
compile spockDependency
}
}
-
- if (isDocumentationProject) {
+
+ if(isDocumentationProject) {
configurations {
documentation
}
@@ -120,7 +121,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 {
@@ -130,7 +131,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"
@@ -138,6 +139,8 @@ subprojects {
task clean << {
ant.delete(dir:buildDir)
}
+
+
}
if (isGormDatasource) {
@@ -201,6 +204,7 @@ subprojects {
from javadoc.destinationDir
}
+
artifacts {
archives jar
archives sourcesJar
@@ -322,16 +326,17 @@ 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]
@@ -339,8 +344,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"}
@@ -348,7 +353,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"))
@@ -364,10 +369,11 @@ 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"
@@ -416,3 +422,4 @@ task test(dependsOn: getTasksByName("test", true)) << {
ant."clover-html-report"(initstring: mergedDb, outdir:"${cloverReportsDir}/html")
}
}
+
View
8 grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/cache/TPCacheAdapter.java
@@ -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 the entry key
- * @param entry the entry
+ * @param key
+ * @param 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 the entry key
- * @return the entry
+ * @param key
+ * @return
* @throws CacheException runtime exception indicating any cache-related problems
*/
T getCachedEntry(Serializable key) throws CacheException;
View
14 ...ore-core/src/main/groovy/org/grails/datastore/mapping/cache/TPCacheAdapterRepository.java
@@ -10,7 +10,7 @@
public interface TPCacheAdapterRepository<T> {
/**
* Returns {@link TPCacheAdapter} for the specified {@link PersistentEntity}.
- * @param entity the entity
+ * @param 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 the entity
- * @param cacheAdapter the adapter
+ * @param entity
+ * @param cacheAdapter
*/
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 the adapter
+ * @param entityJavaClass equivalent to {@link PersistentEntity.getJavaClass()}
+ * @param cacheAdapter
*/
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 the adapter
+ * @param entityJavaClassFQN equivalent to {@link PersistentEntity.getJavaClass().getName()}
+ * @param cacheAdapter
*/
void setTPCacheAdapter(String entityJavaClassFQN, TPCacheAdapter<T> cacheAdapter);
}
View
3  ...store-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java
@@ -167,6 +167,7 @@ public PersistentEntity addPersistentEntity(Class javaClass, boolean override) {
return addPersistentEntity(javaClass);
}
+ @Override
public Collection<PersistentEntity> addPersistentEntities(Class... javaClasses) {
Collection<PersistentEntity> entities = new ArrayList<PersistentEntity>();
@@ -234,6 +235,7 @@ private void registerEntityWithContext(PersistentEntity entity) {
persistentEntitiesByName.put(entity.getName(), entity);
}
+ @Override
public void initialize() {
for(PersistentEntity entity : persistentEntities) {
initializePersistentEntity(entity);
@@ -241,6 +243,7 @@ public void initialize() {
this.initialized = true;
}
+ @Override
public boolean isInitialized() {
return initialized;
}
View
3  ...ore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractPersistentEntity.java
@@ -72,8 +72,9 @@ public MappingContext getMappingContext() {
return context;
}
+ @Override
public boolean isInitialized() {
- return initialized;
+ return this.initialized;
}
public void initialize() {
View
1  ...groovy/org/grails/datastore/mapping/model/config/DefaultMappingConfigurationStrategy.java
@@ -129,6 +129,7 @@ public IdentityMapping getIdentityMapping(ClassMapping classMapping) {
return getDefaultIdentityMapping(classMapping);
}
+ @Override
public void setCanExpandMappingContext(boolean canExpandMappingContext) {
// noop
}
View
3  ...in/groovy/org/grails/datastore/mapping/model/config/GormMappingConfigurationStrategy.java
@@ -88,6 +88,7 @@ public GormMappingConfigurationStrategy(MappingFactory propertyFactory) {
/**
* Whether the strategy can add new entities to the mapping context
*/
+ @Override
public void setCanExpandMappingContext(boolean canExpandMappingContext) {
this.canExpandMappingContext = canExpandMappingContext;
}
@@ -632,7 +633,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 true if mappedBy is set explicitly to null
+ * @return
*/
private boolean forceUnidirectional(PropertyDescriptor property, Map mappedBy) {
return mappedBy.containsKey(property.getName()) && (mappedBy.get(property.getName())==null);
View
7 ...core/src/main/groovy/org/grails/datastore/mapping/validation/ValidatingEventListener.java
@@ -14,14 +14,11 @@
*/
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;
@@ -29,8 +26,10 @@
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
+import javax.persistence.FlushModeType;
+
/**
- * A {@link PersistenceEventListener} that uses
+ * An {@link org.grails.datastore.mapping.engine.EntityInterceptor} that uses
* Spring's validation mechanism to evict objects if an error occurs
*
* @author Graeme Rocher
View
4 ...ore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/DynamoDBDatastore.java
@@ -180,7 +180,7 @@ public DynamoDBAssociationInfo getAssociationInfo(Association<?> association) {
/**
* Returns table resolver for the specified entity.
* @param entity
- * @return the resolver
+ * @return
*/
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 the generator
+ * @return
*/
public DynamoDBIdGenerator getEntityIdGenerator(PersistentEntity entity) {
return entityIdGeneratorMap.get(entity);
View
6 ...b/src/main/groovy/org/grails/datastore/mapping/dynamodb/engine/DynamoDBTableResolver.java
@@ -33,8 +33,8 @@
/**
* Returns domain name for the specified primary key value.
*
- * @param id the id
- * @return the domain name
+ * @param id
+ * @return
*/
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 the names
+ * @return
*/
List<String> getAllTablesForEntity();
}
View
4 ...e-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/query/DynamoDBQuery.java
@@ -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 the results
+ * @return
*/
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 the key
+ * @return
*/
protected static String getKey(PersistentEntity entity, String propertyName) {
return extractPropertyKey(propertyName, entity);
View
26 ...dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBTemplate.java
@@ -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 null if the item is not found
+ * @return
* @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 true if any item was deleted
+ * @return
* @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 the scan results
+ * @return
* @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 the table name
- * @param filter filters
- * @return the count of matched items
+ * @param tableName
+ * @param filter
+ * @return
*/
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 the table name
- * @param ks the schema
- * @param provisionedThroughput the throughput
+ * @param tableName
+ * @param ks
+ * @param provisionedThroughput
* @throws DataAccessException
*/
void createTable(String tableName, KeySchema ks, ProvisionedThroughput provisionedThroughput) throws DataAccessException;
/**
* Returns table description object containing throughput and key scheme information
- * @param tableName the table name
- * @return the description
+ * @param tableName
+ * @return
* @throws org.springframework.dao.DataAccessException
*/
TableDescription describeTable(String tableName) throws DataAccessException;
View
44 ...modb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBTemplateImpl.java
@@ -128,6 +128,13 @@ 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);
}
@@ -150,6 +157,18 @@ 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);
}
@@ -174,6 +193,14 @@ 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);
}
@@ -196,6 +223,17 @@ 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);
}
@@ -377,6 +415,12 @@ 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;
View
8 ...ore-dynamodb/src/main/groovy/org/grails/datastore/mapping/dynamodb/util/DynamoDBUtil.java
@@ -49,7 +49,7 @@
*
* @param tableName
* @param tableNamePrefix
- * @return prefixed table name
+ * @return
*/
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 mapped table name
+ * @return
*/
public static String getMappedTableName(PersistentEntity entity) {
@SuppressWarnings("unchecked")
@@ -88,7 +88,7 @@ private static String getFamily(PersistentEntity persistentEntity, DynamoDBDomai
*
* @param entity
* @param datastore
- * @return ProvisionedThroughput
+ * @return
*/
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 KeySchema
+ * @return
*/
public static KeySchema getKeySchema(PersistentEntity entity, DynamoDBDatastore datastore) {
return DynamoDBUtil.createIdKeySchema(); //current implementation does not handle composite keys //TODO
View
9 ...tore-gorm-mongo/src/test/groovy/grails/gorm/tests/DirtyCheckEmbeddedCollectionSpec.groovy
@@ -6,6 +6,10 @@ 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()
@@ -66,11 +70,6 @@ class DirtyCheckEmbeddedCollectionSpec extends GormDatastoreSpec {
foo.bars.add(bar)
foo.save(flush:true)
}
-
- @Override
- List getDomainClasses() {
- [Foo, Bar]
- }
}
@Entity
View
12 ...rm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/CustomTypeMarshallingSpec.groovy
@@ -1,12 +1,15 @@
package org.grails.datastore.gorm.mongo
import grails.gorm.tests.GormDatastoreSpec
-import grails.persistence.Entity
-
import org.bson.types.ObjectId
+import grails.persistence.Entity
class CustomTypeMarshallingSpec extends GormDatastoreSpec {
+ static {
+ TEST_CLASSES << Person
+ }
+
void "Test basic crud with custom types"() {
given: "A custom type registered for the Birthday class"
final now = new Date()
@@ -37,11 +40,6 @@ class CustomTypeMarshallingSpec extends GormDatastoreSpec {
p != null
p2 == null
}
-
- @Override
- List getDomainClasses() {
- [Person]
- }
}
@Entity
View
10 ...rc/test/groovy/org/grails/datastore/gorm/mongo/EmbeddedHasManyWithBeforeUpdateSpec.groovy
@@ -1,11 +1,14 @@
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")
@@ -36,11 +39,6 @@ class EmbeddedHasManyWithBeforeUpdateSpec extends GormDatastoreSpec {
user.addresses.size() == 1
user.addresses[0].type == 'home'
}
-
- @Override
- List getDomainClasses() {
- [User, UserAddress]
- }
}
class User {
View
9 ...ore-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/GeospacialQuerySpec.groovy
@@ -5,6 +5,10 @@ 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()
@@ -119,11 +123,6 @@ class GeospacialQuerySpec extends GormDatastoreSpec {
h != null
h.name == "Raddison"
}
-
- @Override
- List getDomainClasses() {
- [Hotel]
- }
}
@Entity
View
4 ...e-gorm-mongo/src/test/groovy/org/grails/datastore/gorm/mongo/OneToOneIntegritySpec.groovy
@@ -8,6 +8,10 @@ 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")
View
14 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ConstraintsSpec.groovy
@@ -1,9 +1,11 @@
package grails.gorm.tests
-import grails.persistence.Entity
-
class ConstraintsSpec extends GormDatastoreSpec {
+ static {
+ TEST_CLASSES << ConstrainedEntity
+ }
+
void "Test constraints with static default values"() {
given: "A Test class with static constraint values"
def ce = new ConstrainedEntity(num:1000, str:"ABC")
@@ -14,17 +16,11 @@ class ConstraintsSpec extends GormDatastoreSpec {
then:
ce.hasErrors() == false
}
-
- @Override
- List getDomainClasses() {
- [ConstrainedEntity]
- }
}
-@Entity
class ConstrainedEntity implements Serializable {
- static final int MAX_VALUE = 1000
+ static final MAX_VALUE = 1000
static final List<String> ALLOWABLE_VALUES = ['ABC','DEF','GHI']
Long id
View
18 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/GormDatastoreSpec.groovy
@@ -3,8 +3,7 @@ package grails.gorm.tests
import org.grails.datastore.mapping.core.DatastoreUtils
import org.grails.datastore.mapping.core.Session
-import spock.lang.Shared
-import spock.lang.Specification
+import spock.lang.*
/**
* A Spec base class that manages a Session for each feature as well as
@@ -22,10 +21,11 @@ abstract class GormDatastoreSpec extends Specification {
static final SETUP_CLASS_NAME = 'org.grails.datastore.gorm.Setup'
static final TEST_CLASSES = [
- 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]
+ Task, Person, ModifyPerson, Pet, PetType, PersonEvent, Book, Highway,
+ TestEntity, ChildEntity, CommonTypes, Location, City, Country, Plant,
+ PlantCategory, Publication, OptLockVersioned, OptLockNotVersioned,
+ ClassWithNoArgBeforeValidate, ClassWithListArgBeforeValidate,
+ ClassWithOverloadedBeforeValidate, EnumThing]
@Shared Class setupClass
@@ -47,10 +47,8 @@ abstract class GormDatastoreSpec extends Specification {
}
def cleanup() {
- if (session) {
- session.disconnect()
- DatastoreUtils.unbindSession session
- }
+ session?.disconnect()
+ DatastoreUtils.unbindSession(session)
try {
setupClass.destroy()
} catch(e) {
View
11 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/NamedQuerySpec.groovy
@@ -1,7 +1,5 @@
package grails.gorm.tests
-import grails.persistence.Entity
-
import spock.lang.Ignore
/**
@@ -287,7 +285,7 @@ class NamedQuerySpec extends GormDatastoreSpec {
'Some Recent Book' == publications[2].title
}
- @Ignore // queries on associations not yet supported
+ @spock.lang.Ignore // queries on associations not yet supported
void "Test named query with relationships in criteria"() {
given:
@@ -330,7 +328,7 @@ class NamedQuerySpec extends GormDatastoreSpec {
'groovy' == results[0].name
}
- @Ignore // queries on associations not yet supported
+ @spock.lang.Ignore // queries on associations not yet supported
void "Test list distinct entities"() {
given:
@@ -362,7 +360,7 @@ class NamedQuerySpec extends GormDatastoreSpec {
true == 'orange' in names
}
- @Ignore // queries on associations not yet supported
+ @spock.lang.Ignore // queries on associations not yet supported
void "Another test on listing distinct entities"() {
given:
new PlantCategory(name:"leafy")
@@ -1018,7 +1016,6 @@ class NamedQuerySpec extends GormDatastoreSpec {
}
}
-@Entity
class PlantCategory implements Serializable {
Long id
Long version
@@ -1045,7 +1042,6 @@ class PlantCategory implements Serializable {
}
}
-@Entity
class Plant implements Serializable {
Long id
Long version
@@ -1058,7 +1054,6 @@ class Plant implements Serializable {
}
}
-@Entity
class Publication implements Serializable {
Long id
Long version
View
4 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OneToOneSpec.groovy
@@ -4,6 +4,10 @@ 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")
View
7 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/OptimisticLockingSpec.groovy
@@ -1,7 +1,5 @@
package grails.gorm.tests
-import grails.persistence.Entity
-
import org.grails.datastore.mapping.core.OptimisticLockingException
import org.grails.datastore.mapping.core.Session
@@ -51,7 +49,6 @@ 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)
}
@@ -73,7 +70,7 @@ class OptimisticLockingSpec extends GormDatastoreSpec {
then:
ex instanceof OptimisticLockingException
- o.version == 1
+ o.version == 1
o.name == 'locked in new session'
}
@@ -114,7 +111,6 @@ class OptimisticLockingSpec extends GormDatastoreSpec {
}
}
-@Entity
class OptLockVersioned implements Serializable {
Long id
Long version
@@ -122,7 +118,6 @@ class OptLockVersioned implements Serializable {
String name
}
-@Entity
class OptLockNotVersioned implements Serializable {
Long id
View
118 ...-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/PersistenceEventListenerSpec.groovy
@@ -2,15 +2,14 @@ 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.PostDeleteEvent
-import org.grails.datastore.mapping.engine.event.PreDeleteEvent
import org.grails.datastore.mapping.engine.event.ValidationEvent
-import org.springframework.context.ApplicationEvent
+import org.grails.datastore.mapping.engine.event.PreDeleteEvent
+import org.grails.datastore.mapping.engine.event.PostDeleteEvent
/**
* @author Tom Widmer
@@ -39,15 +38,15 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
p = Simples.get(p.id)
then:
- 0 == listener.PreDeleteCount
- 0 == listener.PostDeleteCount
+ 0 == listener.PreDelete
+ 0 == listener.PostDelete
when:
p.delete(flush: true)
then:
- 1 == listener.PreDeleteCount
- 1 == listener.PostDeleteCount
+ 1 == listener.PreDelete
+ 1 == listener.PostDelete
0 < listener.events.size()
p == listener.events[-1].entityObject
listener.events[-1].eventType == EventType.PostDelete
@@ -68,8 +67,8 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
3 == freds.size()
- 0 == listener.PreDeleteCount
- 0 == listener.PostDeleteCount
+ 0 == listener.PreDelete
+ 0 == listener.PostDelete
when:
new DetachedCriteria(Simples).build {
@@ -83,8 +82,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.PreDeleteCount
- 3 == listener.PostDeleteCount
+ 3 == listener.PreDelete
+ 3 == listener.PostDelete
}
}
@@ -101,8 +100,8 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Fred" == p.name
- 0 == listener.PreUpdateCount
- 0 == listener.PostUpdateCount
+ 0 == listener.PreUpdate
+ 0 == listener.PostUpdate
when:
p.name = "Bob"
@@ -112,8 +111,8 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Bob" == p.name
- 1 == listener.PreUpdateCount
- 1 == listener.PostUpdateCount
+ 1 == listener.PreUpdate
+ 1 == listener.PostUpdate
}
void "Test insert events"() {
@@ -129,10 +128,10 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Fred" == p.name
- 0 == listener.PreUpdateCount
- 1 == listener.PreInsertCount
- 0 == listener.PostUpdateCount
- 1 == listener.PostInsertCount
+ 0 == listener.PreUpdate
+ 1 == listener.PreInsert
+ 0 == listener.PostUpdate
+ 1 == listener.PostInsert
when:
p.name = "Bob"
@@ -142,10 +141,10 @@ class PersistenceEventListenerSpec extends GormDatastoreSpec {
then:
"Bob" == p.name
- 1 == listener.PreUpdateCount
- 1 == listener.PreInsertCount
- 1 == listener.PostUpdateCount
- 1 == listener.PostInsertCount
+ 1 == listener.PreUpdate
+ 1 == listener.PreInsert
+ 1 == listener.PostUpdate
+ 1 == listener.PostInsert
}
void "Test load events"() {
@@ -163,9 +162,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.PreLoadCount
+ 1 == listener.PreLoad
}
- 1 == listener.PostLoadCount
+ 1 == listener.PostLoad
}
void "Test multi-load events"() {
@@ -182,40 +181,42 @@ 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.PreLoadCount
+ 3 == listener.PreLoad
}
- 3 == listener.PostLoadCount
+ 3 == listener.PostLoad
}
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.ValidationCount
- listener.events.size() == 1
- p == listener.events[0].entityObject
- listener.events[0] instanceof ValidationEvent
- null == listener.events[0].validatedFields
+ 1 == listener.Validation
+ 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.ValidationCount
- listener.events.size() == 2
- p == listener.events[1].entityObject
- listener.events[1] instanceof ValidationEvent
- ['name'] == listener.events[1].validatedFields
+ 2 == listener.Validation
+ 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) {
@@ -224,29 +225,32 @@ class SpecPersistenceListener extends AbstractPersistenceEventListener {
List<AbstractPersistenceEvent> events = []
- int PreDeleteCount,
- PreInsertCount,
- PreUpdateCount,
- PostUpdateCount,
- PostDeleteCount,
- PostInsertCount,
- PreLoadCount,
- PostLoadCount,
- SaveOrUpdateCount,
- ValidationCount
+ int PreDelete,
+ PreInsert,
+ PreUpdate,
+ PostUpdate,
+ PostDelete,
+ PostInsert,
+ PreLoad,
+ PostLoad,
+ SaveOrUpdate,
+ Validation
@Override
protected void onPersistenceEvent(AbstractPersistenceEvent event) {
- String typeName = event.eventType.name()
- this."${typeName}Count"++
+ def typeName = event.eventType.name()
+ this."$typeName"++
events << event
}
- boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { true }
+ @Override
+ boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
+ return true
+ }
}
@Entity
-class Simples implements Serializable {
+class Simples implements Serializable{
Long id
String name
}
View
11 ...s-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/PropertyComparisonQuerySpec.groovy
@@ -5,7 +5,11 @@ import grails.persistence.Entity
/**
* Tests for criteria queries that compare two properties
*/
-class PropertyComparisonQuerySpec extends GormDatastoreSpec {
+class PropertyComparisonQuerySpec extends GormDatastoreSpec{
+
+ static {
+ TEST_CLASSES << Dog
+ }
void "Test geProperty query"() {
given:"Some dead and alive dogs"
@@ -120,11 +124,6 @@ class PropertyComparisonQuerySpec extends GormDatastoreSpec {
results.size() == 1
results[0].name == "Fred"
}
-
- @Override
- List getDomainClasses() {
- [Dog]
- }
}
@Entity
View
30 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/RangeQuerySpec.groovy
@@ -28,7 +28,7 @@ class RangeQuerySpec extends GormDatastoreSpec {
void "Test between query"() {
given:
- int age = 40
+ def 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:
- int age = 40
+ def 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:
- int count = Person.countByAgeInRange(14..41)
+ def cnt = Person.countByAgeInRange(14..41)
then:
- 3 == count
+ 3 == cnt
when:
- count = Person.countByAgeInRange(41..14)
+ cnt = Person.countByAgeInRange(41..14)
then:
- 3 == count
+ 3 == cnt
when:
- count = Person.countByAgeInRange(14..<30)
+ cnt = Person.countByAgeInRange(14..<30)
then:
- 1 == count
+ 1 == cnt
when:
- count = Person.countByAgeInRange(14..<42)
+ cnt = Person.countByAgeInRange(14..<42)
then:
- 3 == count
+ 3 == cnt
when:
- count = Person.countByAgeInRange(15..40)
+ cnt = Person.countByAgeInRange(15..40)
then:
- 0 == count
+ 0 == cnt
}
}
View
4 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/TestEntity.groovy
@@ -1,11 +1,9 @@
package grails.gorm.tests
-import grails.persistence.Entity
-
/**
* @author graemerocher
*/
-@Entity
+@grails.persistence.Entity
class TestEntity implements Serializable {
Long id
Long version
View
42 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/UniqueConstraintSpec.groovy
@@ -4,15 +4,13 @@ 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"
@@ -50,23 +48,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 MappingContext context = session.datastore.mappingContext
- final PersistentEntity 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 context = session.datastore.mappingContext
+ final entity = context.getPersistentEntity(UniqueGroup.name)
context.addEntityValidator(entity, groupValidator)
entity = context.getPersistentEntity(GroupWithin.name)
context.addEntityValidator(entity, groupWithinValidator)
@@ -79,7 +77,7 @@ class UniqueConstraintSpec extends GormDatastoreSpec {
}
@Entity
-class UniqueGroup implements Serializable {
+class UniqueGroup implements Serializable{
Long id
String name
static constraints = {
@@ -88,7 +86,7 @@ class UniqueGroup implements Serializable {
}
@Entity
-class GroupWithin implements Serializable {
+class GroupWithin implements Serializable{
Long id
String name
String org
View
9 ...ls-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/UpdateWithProxyPresentSpec.groovy
@@ -4,10 +4,12 @@ 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"() {
@@ -36,11 +38,6 @@ class UpdateWithProxyPresentSpec extends GormDatastoreSpec {
personPet.type.name == 'snake'
personPet.type.id == petType.id
}
-
- @Override
- List getDomainClasses() {
- [Pet, Person, PetType]
- }
}
@Entity
@@ -61,7 +58,7 @@ class Pet implements Serializable {
static constraints = {
owner nullable:true
age nullable: true
- face nullable:true
+ face nulable:true
}
}
View
8 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/ValidationSpec.groovy
@@ -18,8 +18,8 @@ class ValidationSpec extends GormDatastoreSpec {
when:
t.errors.reject 'foo'
- boolean isValid = t.validate()
- int errorCount = t.errors.errorCount
+ def isValid = t.validate()
+ def errorCount = t.errors.errorCount
then:
!isValid
@@ -36,7 +36,7 @@ class ValidationSpec extends GormDatastoreSpec {
when:
t = new TestEntity(name:"", child:new ChildEntity(name:"child"))
- boolean validationResult = t.validate()
+ def validationResult = t.validate()
def errors = t.errors
then:
@@ -60,7 +60,7 @@ class ValidationSpec extends GormDatastoreSpec {
when:
t = new TestEntity(name:"")
- boolean validationResult = t.validate()
+ def validationResult = t.validate()
def errors = t.errors
then:
View
9 ...rc/test/groovy/org/grails/datastore/gorm/BidirectionalOneToManyWithInheritanceSpec.groovy
@@ -5,6 +5,10 @@ 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:
@@ -21,11 +25,6 @@ class BidirectionalOneToManyWithInheritanceSpec extends GormDatastoreSpec {
then:
2 == doc.configurationItems.size()
}
-
- @Override
- List getDomainClasses() {
- [ConfigurationItem, Documentation, ChangeRequest]
- }
}
class ConfigurationItem {
View
5 ...tastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/CircularManyToManySpec.groovy
@@ -26,7 +26,6 @@ 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
@@ -52,8 +51,8 @@ class CircularPerson {
List<CircularPerson> friends = []
static hasMany = [
- friends: CircularPerson,
- enemies: CircularPerson
+ friends: CircularPerson,
+ enemies: CircularPerson
]
static mapping = {
View
10 ...tore-gorm-test/src/test/groovy/org/grails/datastore/gorm/CustomTypeMarshallingSpec.groovy
@@ -7,6 +7,10 @@ import spock.lang.Shared
class CustomTypeMarshallingSpec extends GormDatastoreSpec {
+ static {
+ TEST_CLASSES << Person
+ }
+
@Shared Date now = new Date()
def setup() {
@@ -103,11 +107,6 @@ class CustomTypeMarshallingSpec extends GormDatastoreSpec {
session.clear()
Person.countByBirthdayIsNull() == 1
}
-
- @Override
- List getDomainClasses() {
- [Person]
- }
}
class Person {
@@ -134,6 +133,7 @@ class Birthday implements Comparable {
obj instanceof Birthday && date == obj.date
}
+ @Override
int compareTo(t) {
date.compareTo(t.date)
}
View
9 grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DeindexingSpec.groovy
@@ -7,6 +7,10 @@ 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'
@@ -15,11 +19,6 @@ class DeindexingSpec extends GormDatastoreSpec {
expect:
!AuthorWithPseudonym.findByPseudonymIsNull()
}
-
- @Override
- List getDomainClasses() {
- [AuthorWithPseudonym]
- }
}
class AuthorWithPseudonym {
View
3  ...tastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/DistinctProjectionSpec.groovy
@@ -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,5 +20,6 @@ class DistinctProjectionSpec extends GormDatastoreSpec {
then:"The correct results are returned"
results == ['Rubble', 'Simpson']
+
}
}
View
10 ...astore-gorm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedAssociationSpec.groovy
@@ -2,11 +2,14 @@ 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"() {
@@ -26,11 +29,6 @@ class EmbeddedAssociationSpec extends GormDatastoreSpec {
i.address.postCode == '30483'
i.bio.birthday.date == now
}
-
- @Override
- List getDomainClasses() {
- [Individual, Address]
- }
}
@Entity
View
9 ...rm-test/src/test/groovy/org/grails/datastore/gorm/EmbeddedNonEntityAssociationSpec.groovy
@@ -5,6 +5,10 @@ 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"))
@@ -21,11 +25,6 @@ class EmbeddedNonEntityAssociationSpec extends GormDatastoreSpec {
i.address != null
i.address.postCode == '30483'
}
-
- @Override
- List getDomainClasses() {
- [Being]
- }
}
@Entity
View
2  grails-datastore-gorm-test/src/test/groovy/org/grails/datastore/gorm/OrderBySpec.groovy
@@ -49,4 +49,6 @@ class OrderBySpec extends GormDatastoreSpec {
then:
45 == results[0].age
}
+
}
+
View
33 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormInstanceApi.groovy
@@ -14,13 +14,14 @@
*/
package org.grails.datastore.gorm
-import grails.validation.ValidationException
+import static org.grails.datastore.mapping.validation.ValidatingEventListener.*
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.
@@ -37,12 +38,16 @@ 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) {
- o = o.getTarget()
+ return cls.isInstance(o.getTarget())
}
return cls.isInstance(o)
}
@@ -53,8 +58,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)
}
@@ -66,13 +71,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)
}
@@ -83,8 +88,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)
}
@@ -135,7 +140,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)
}
View
27 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormStaticApi.groovy
@@ -49,9 +49,8 @@ import org.springframework.validation.Errors
*/
class GormStaticApi<D> extends AbstractGormApi<D> {
- List<FinderMethod> gormDynamicFinders
-
- PlatformTransactionManager transactionManager
+ private List<FinderMethod> dynamicFinders
+ private PlatformTransactionManager transactionManager
GormStaticApi(Class<D> persistentClass, Datastore datastore, List<FinderMethod> finders) {
this(persistentClass, datastore, finders, null)
@@ -59,15 +58,29 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
GormStaticApi(Class<D> persistentClass, Datastore datastore, List<FinderMethod> finders, PlatformTransactionManager transactionManager) {
super(persistentClass, datastore)
- gormDynamicFinders = finders
+ this.dynamicFinders = finders
+ this.transactionManager = transactionManager
+ }
+
+ /**
+ * Sets the {@link PlatformTransactionManager} to use
+ */
+ void setTransactionManager(PlatformTransactionManager transactionManager) {
this.transactionManager = transactionManager
}
/**
+ * @return The FinderMethods for this class
+ */
+ List<FinderMethod> getGormDynamicFinders() {
+ this.dynamicFinders
+ }
+
+ /**
* @return The PersistentEntity for this class
*/
PersistentEntity getGormPersistentEntity() {
- persistentEntity
+ this.persistentEntity
}
/**
@@ -78,7 +91,7 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
* @return The result of the method call
*/
def methodMissing(String methodName, args) {
- def method = gormDynamicFinders.find { FinderMethod f -> f.isMethodMatch(methodName) }
+ def method = dynamicFinders.find { FinderMethod f -> f.isMethodMatch(methodName) }
def cls = persistentClass
if (!method) {
throw new MissingMethodException(methodName, cls, args)
@@ -742,7 +755,7 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
* @return the map
*/
Map<D, Boolean> getValidationSkipMap() {
- AbstractDatastore.getValidationSkipMap()
+ AbstractDatastore.getValidationErrorsMap()
}
// TODO: In the first version no support will exist for String-based queries
View
2  grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormValidationApi.groovy
@@ -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.
View
3  ...m/src/main/groovy/org/grails/datastore/gorm/config/GrailsDomainClassPersistentEntity.java
@@ -65,8 +65,9 @@ public GrailsDomainClass getDomainClass() {
return domainClass;
}
+ @Override
public boolean isInitialized() {
- return initialized;
+ return this.initialized;
}
public void initialize() {
View
1  .../main/groovy/org/grails/datastore/mapping/jpa/config/JpaMappingConfigurationStrategy.java
@@ -212,6 +212,7 @@ public IdentityMapping getIdentityMapping(ClassMapping classMapping) {
return getDefaultIdentityMapping(classMapping);
}
+ @Override
public void setCanExpandMappingContext(boolean canExpandMappingContext) {
// noop
}
View
4 grails-plugins/redis/build.gradle
@@ -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:$grailsVersion",
- "org.grails:grails-gorm:$grailsVersion"
+ compile "org.grails:grails-crud:1.3.4",
+ "org.grails:grails-gorm:1.3.4"
}
Please sign in to comment.
Something went wrong with that request. Please try again.