Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:SpringSource/grails-data-mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Dec 1, 2011
2 parents 36071cf + 09f37ec commit f50b5db
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 65 deletions.
Expand Up @@ -26,6 +26,7 @@ import org.grails.datastore.mapping.query.Restrictions
import org.grails.datastore.mapping.query.Query.PropertyCriterion
import org.grails.datastore.mapping.model.PersistentProperty
import org.grails.datastore.mapping.query.projections.ManualProjections
import org.grails.datastore.mapping.model.types.Association

/**
* perform criteria queries on a Neo4j backend
Expand Down Expand Up @@ -196,6 +197,60 @@ class Neo4jQuery extends Query {
result
}

boolean matchesCriterionNotEqualsProperty(Node node, Query.NotEqualsProperty criterion) {
getNodeProperty(node, criterion.property) != getNodeProperty(node, criterion.otherProperty)
}

boolean matchesCriterionEqualsProperty(Node node, Query.EqualsProperty criterion) {
getNodeProperty(node, criterion.property) == getNodeProperty(node, criterion.otherProperty)
}

boolean matchesCriterionGreaterThanEqualsProperty(Node node, Query.GreaterThanEqualsProperty criterion) {
getNodeProperty(node, criterion.property) >= getNodeProperty(node, criterion.otherProperty)
}

boolean matchesCriterionGreaterThanProperty(Node node, Query.GreaterThanProperty criterion) {
getNodeProperty(node, criterion.property) > getNodeProperty(node, criterion.otherProperty)
}

boolean matchesCriterionLessThanEqualsProperty(Node node, Query.LessThanEqualsProperty criterion) {
getNodeProperty(node, criterion.property) <= getNodeProperty(node, criterion.otherProperty)
}

boolean matchesCriterionLessThanProperty(Node node, Query.LessThanProperty criterion) {
getNodeProperty(node, criterion.property) < getNodeProperty(node, criterion.otherProperty)
}

boolean matchesCriterionSizeLessThanEquals(Node node, Query.SizeLessThanEquals criterion) {
countRelationshipsForProperty(node, criterion.property) <= criterion.value
}

boolean matchesCriterionSizeLessThan(Node node, Query.SizeLessThan criterion) {
countRelationshipsForProperty(node, criterion.property) < criterion.value
}

boolean matchesCriterionSizeGreaterThanEquals(Node node, Query.SizeGreaterThanEquals criterion) {
countRelationshipsForProperty(node, criterion.property) >= criterion.value
}

boolean matchesCriterionSizeGreaterThan(Node node, Query.SizeGreaterThan criterion) {
countRelationshipsForProperty(node, criterion.property) > criterion.value
}

boolean matchesCriterionSizeEquals(Node node, Query.SizeEquals criterion) {
countRelationshipsForProperty(node, criterion.property) == criterion.value
}

boolean matchesCriterionSizeNotEquals(Node node, Query.SizeNotEquals criterion) {
countRelationshipsForProperty(node, criterion.property) != criterion.value
}

protected int countRelationshipsForProperty(Node node, String propertyName) {
Association association = entity.getPropertyByName(propertyName)
def (relationshipType, direction) = Neo4jUtils.relationTypeAndDirection(association)
node.getRelationships(relationshipType, direction).iterator().size()
}

protected getNodePropertyAsType(Node node, String propertyName, Class targetClass) {
def val = getNodeProperty(node, propertyName)
session.mappingContext.conversionService.convert(val, targetClass)
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -8,42 +8,42 @@ import grails.gorm.tests.*
@RunWith(Suite)
@SuiteClasses([

//AttachMethodSpec,
//CircularOneToManySpec,
//CommonTypesPersistenceSpec,
//CriteriaBuilderSpec,
//CrudOperationsSpec,
//DetachedCriteriaSpec,
//DomainEventsSpec,
EnumSpec
//FindByExampleSpec,
//FindByMethodSpec,
//FindOrCreateWhereSpec,
//FindOrSaveWhereSpec,
//GormEnhancerSpec,
//GroovyProxySpec,
//InheritanceSpec,
//ListOrderBySpec,
//NamedQuerySpec,
//NegationSpec,
//OneToManySpec,
//OneToOneSpec,
//OptimisticLockingSpec,
//OrderBySpec,
//PropertyComparisonQuerySpec,
//ProxyLoadingSpec,
//QueryAfterPropertyChangeSpec,
//QueryByAssociationSpec,
//RangeQuerySpec,
//SaveAllSpec,
//SizeQuerySpec,
//UpdateWithProxyPresentSpec,
//ValidationSpec,
//WithTransactionSpec,
//
//ApiExtensionsSpec,
//ManyToManySpec,
//MiscSpec
AttachMethodSpec,
CircularOneToManySpec,
CommonTypesPersistenceSpec,
CriteriaBuilderSpec,
CrudOperationsSpec,
DetachedCriteriaSpec,
DomainEventsSpec,
EnumSpec,
FindByExampleSpec,
FindByMethodSpec,
FindOrCreateWhereSpec,
FindOrSaveWhereSpec,
GormEnhancerSpec,
GroovyProxySpec,
InheritanceSpec,
ListOrderBySpec,
NamedQuerySpec,
NegationSpec,
OneToManySpec,
OneToOneSpec,
OptimisticLockingSpec,
OrderBySpec,
PropertyComparisonQuerySpec,
ProxyLoadingSpec,
QueryAfterPropertyChangeSpec,
QueryByAssociationSpec,
RangeQuerySpec,
SaveAllSpec,
SizeQuerySpec,
UpdateWithProxyPresentSpec,
ValidationSpec,
WithTransactionSpec,

ApiExtensionsSpec,
ManyToManySpec,
MiscSpec

])
class Neo4jSuite {
Expand Down

0 comments on commit f50b5db

Please sign in to comment.