From 9a863890e4c8920410e014f07561c4f76087de27 Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Mon, 4 Apr 2011 18:55:39 +0200 Subject: [PATCH] updated documentation - removed Finder refrences, updated version number --- README.md | 2 +- changelog.txt | 7 +- .../programming-model/annotations.xml | 194 ------------------ .../reference/programming-model/indexing.xml | 8 +- .../programming-model/programming-model.xml | 3 +- src/docbkx/reference/setup.xml | 10 +- src/docbkx/tutorial/annotations.xml | 2 +- src/docbkx/tutorial/indexing.xml | 4 +- src/docbkx/tutorial/spring-data-graph.xml | 2 +- 9 files changed, 19 insertions(+), 213 deletions(-) delete mode 100644 src/docbkx/reference/programming-model/annotations.xml diff --git a/README.md b/README.md index f2d5f48df..7061d17c4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ For more detailed questions, use the [forum](http://forum.springsource.org/forum org.springframework.data spring-data-neo4j - 1.0.0.M5 + 1.0.0.RC1 diff --git a/changelog.txt b/changelog.txt index 3a77418cc..8d01fffb7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,11 +1,12 @@ Spring Data Graph Changelog -============================================= +=========================== -Changes in version 1.0.0.RC1 (2011-04-01) +Changes in version 1.0.0.RC1 (2011-04-04) ---------------------------------------- * replaced finders with composable spring-data-commons repositories -* added rest-client support for consuming Neo4j-REST servier with Spring Data Graph +* added rest-client support for consuming Neo4j-REST server with Spring Data Graph +* re-added OSGi bundlor metainformation * relationship entity creation aligned to node entity creation * added TypeRepresentation Strategies for Relationships, enabling RelationshipEntity-Repositories * lots of performance improvements diff --git a/src/docbkx/reference/programming-model/annotations.xml b/src/docbkx/reference/programming-model/annotations.xml deleted file mode 100644 index 56fb59573..000000000 --- a/src/docbkx/reference/programming-model/annotations.xml +++ /dev/null @@ -1,194 +0,0 @@ - - -
- Using annotations to define POJO entities and relationships - Entities are declared using the @NodeEntity annotation. Relationship entities use the - @RelationshipEntity - annotation. - -
- @NodeEntity: The basic building block - - The @NodeEntity annotation is used to declare a POJO entity to be backed by a node in the - graph store. Simple fields on the entity are mapped by default to properties of the node. Object - references to other NodeEntities (whether single or Collection) are mapped via relationships. If - the annotation parameter useShortNames is set to false, the properties and relationship - names used will be prepended with the class name of the entity. - - If the partial - parameter is set to true, this entity takes part in a cross-store setting /) - where only the specifically annotated parts of the entity not handled by JPA will be mapped to the graph store. - - Entity fields can be annotated with @GraphProperty, @RelatedTo, @RelatedToVia, @Indexed, @GraphId and - @GraphTraversal. - - -
- -
- @RelatedTo: Connecting NodeEntities - - Relationships to other NodeEntities are mapped to graph relationships. Those can either be single - relationships (1:1) or multiple relationships (1:N). In most cases single relationships to other - node entities don't have to be annotated as Spring Data Graph can extract all necessary information - from the field using reflection. In the case of multiple relationships, the elementClass - parameter of @RelatedTo must be specified because of type erasure. The direction - (default OUTGOING) and type (inferred from field name) parameters of the annotation are - optional. - - - Single Relationships to other node entities are created when setting the field and deleted when setting it to - null. For multi-relationships the field provides a managed collection (Set) that handles addition and - removal of node entities and reflects those in the graph relationships. - - - @RelatedTo also ensures that there is only one relationship of the given type between two - given entities. - - - By setting direction to BOTH, relationships are created in the outgoing direction, but when the 1:N field - is read, it will include relationships in both directions. - - movies; -} -]]> -
- -
- @RelationshipEntity: Rich relationships - - To access the full data model of graph relationships, POJOs can also be annotated with - @RelationshipEntity. Relationship entities can not be instantiated directly but are rather accessed via - node entities, either by @RelatedToVia fields or by the relateTo or - getRelationshipTo methods . - - Relationship entities may contain fields that are mapped to properties and two special fields that are - annotated with @StartNode and @EndNode which point to the start and end node entities respectively. These - fields are treated as read only fields. - - -
- -
- @RelatedToVia: Connecting NodeEntitites via RelationshipEntities - - To provide easy programmatic access to the richer relationship entities of the data model a different - annotation @RelatedToVia can be declared on fields of Iterables of the relationship entity type. These - Iterables then provide read only access to instances of the entity that backs the relationship of this - relationship type. Those instances are initialized with the properties of the relationship and the start - and end node. - - roles; - - public Role playedIn(Movie movie, String title) { - Role role=relateTo(movie,Role.class,"ACTS_IN"); - role.setTitle(title); - return role; - } -} -]]> -
-
- @StartNode: Starting NodeEntity of RelationshipEntity - Annotation for the start node of a relationship entity, read only. -
-
- @EndNode: Ending NodeEntity of RelationshipEntity - Annotation for the end node of a relationship entity, read only. -
- -
- @Indexed: Making entities searchable by field value - The @Indexed annotation can be declared on fields that are intended to be indexed by the Neo4j - indexing facilities, triggered by value modification. - The resulting index can be used to later retrieve nodes or relationships that contain a certain property - value (for example a name). Often an index is used to establish the start node for a traversal. - Indexes are accessed by a Finder for a particular node or relationship entity, created via a - FinderFactory. - - - GraphDatabaseContext exposes the indexes for Nodes and Relationships via the getIndex method. - Index names default to the domain class - name, but can also be named (indexName attribute)individually to reflect domain concepts. - be named, for instance to keep separate domain concepts in separate indexes. - - - Numerical values are indexed as such by default, allowing for range queries. - Fulltext indexing is also possible by setting the fulltext attribute to true. For details see - the indexing section . - -
- -
- @GraphTraversal - The @GraphTraversal annotation leverages the delegation infrastructure used by the Spring Data Graph - aspects. It provides dynamic fields which, when accessed, return an Iterable of NodeEntities that are - the result of a traversal starting at the current NodeEntity. The TraversalDescription used for this - is created by a TraversalDescriptionBuilder whose class is referred to by the traversalBuilder - attribute of the annotation. The class of the expected NodeEntities is provided with the - elementClass attribute. - people; - - private static class PeopleTraversalBuilder implements FieldTraversalDescriptionBuilder { - @Override - public TraversalDescription build(NodeBacked start, Field field, String...params) { - return new TraversalDescriptionImpl() - .relationships(DynamicRelationshipType.withName(params[0])) - .filter(Traversal.returnAllButStartNode()); - } - } -} -]]> - -
- -
- @GraphProperty: Cross-store persisted fields - It is not necessary to annotate fields as they are persisted by default; all fields that contain primitive - values are persisted directly to the graph. All fields - convertible to String using the Spring conversion services will be stored as a string. - (Spring Data Graph adds a custom conversion factory that comes with converters for Enums and Dates). - Transient fields are not persisted. - This annotation is mainly used for cross-store persistence. - -
- -
\ No newline at end of file diff --git a/src/docbkx/reference/programming-model/indexing.xml b/src/docbkx/reference/programming-model/indexing.xml index bb9c4fe4b..974e94f4b 100644 --- a/src/docbkx/reference/programming-model/indexing.xml +++ b/src/docbkx/reference/programming-model/indexing.xml @@ -26,7 +26,7 @@ for a single index query. - Query access to the index happens with the Node- and RelationshipFinders that are created via an instance of + Query access to the index happens with the Node- and Relationship-Repostories that are created via an instance of org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory. The methods findByPropertyValue and findAllByPropertyValue work on the exact indexes and return the first or all matches. To do range queries, use findAllByRange (please note that @@ -44,7 +44,7 @@ class Person { } -NodeFinder graphRepository = graphRepositoryFactory.createNodeEntityFinder(Person.class); +NodeGraphRepository graphRepository = graphRepositoryFactory.createNodeEntityRepository(Person.class); // exact graphRepository Person mark = graphRepository.findByProperyValue("people","name","mark"); @@ -64,7 +64,7 @@ for (Person middleAgedDeveloper : graphRepository.findAllByRange(null, "age", 20 as the fulltext-configuration is stored in the index itself. - Access to the fulltext index is provided by the findAllByQuery method of the finders. Wildcard + Access to the fulltext index is provided by the findAllByQuery method of the repositories. Wildcard like * are allowed. Otherwise the fulltext querying rules of the underlying index provider apply. (In most cases this will be lucene. @@ -76,7 +76,7 @@ class Person { String name; } -NodeFinder graphRepository = graphRepositoryFactory.createNodeEntityFinder(Person.class); +NodeGraphRepository graphRepository = graphRepositoryFactory.createNodeEntityRepository(Person.class); // exact graphRepository Person mark = graphRepository.findAllByQuery("people-search","name","ma*"); diff --git a/src/docbkx/reference/programming-model/programming-model.xml b/src/docbkx/reference/programming-model/programming-model.xml index 176847751..5d3b09264 100644 --- a/src/docbkx/reference/programming-model/programming-model.xml +++ b/src/docbkx/reference/programming-model/programming-model.xml @@ -9,7 +9,8 @@ Spring Data Graph examples. - + + diff --git a/src/docbkx/reference/setup.xml b/src/docbkx/reference/setup.xml index 51ad95a8c..cd69e3639 100644 --- a/src/docbkx/reference/setup.xml +++ b/src/docbkx/reference/setup.xml @@ -36,7 +36,7 @@ org.springframework.data spring-data-neo4j - 1.0.0.M5 + 1.0.0.RC1 @@ -98,11 +98,10 @@
Setting Up Spring Data Graph - Spring Configuration - Out of date - should we even have this section? The concrete configuration for Spring Data Graph is quite verbose as there is no autowiring involved. It sets up the following parts. - GraphDatabaseService, IndexManager for the embedded Neo4j storage engine + GraphDatabaseService for the embedded Neo4j storage engine Spring transaction manager, Neo4j transaction manager @@ -111,14 +110,13 @@ aspects and instantiators for node and relationship entities - EntityState and FieldAccessFactories needed for the different field handling - + EntityState and FieldAccessFactories needed for the different field handling Conversion services - Finder factory + Repository support TypeRepresentationStrategies diff --git a/src/docbkx/tutorial/annotations.xml b/src/docbkx/tutorial/annotations.xml index 59908fe3d..b79d4f93a 100644 --- a/src/docbkx/tutorial/annotations.xml +++ b/src/docbkx/tutorial/annotations.xml @@ -8,7 +8,7 @@ Relationships got their own annotation named @RelationshipEntity. Property fields are taken care of automatically. It's time to put this to a test. How can we be assured that a field is persisted to the graph store? There seemed to be two possibilities. First was to get a - GraphDatabaseContext injected and use its getById() method. The other one was a Finder approach. But let's try to keep things simple. + GraphDatabaseContext injected and use its getById() method. The other one was a Repository approach. But let's try to keep things simple. How can we persist an entity and how to get its id? Looking at the documentation revealed that there are a bunch of methods introduced to the entities by the aspects. That's not obvious, but we found the two that would help here - entity.persist() and entity.getNodeId(). diff --git a/src/docbkx/tutorial/indexing.xml b/src/docbkx/tutorial/indexing.xml index 1d0bcd02f..66300e46b 100644 --- a/src/docbkx/tutorial/indexing.xml +++ b/src/docbkx/tutorial/indexing.xml @@ -23,9 +23,9 @@ class Movie { @Test [@Transactional] public void persistedMovieShouldBeRetrievableFromGraphDb() { int id=1; Movie forrestGump = new Movie(id, "Forrest Gump", 1994).persist(); - NodeGraphRepository movieFinder = graphRepositoryFactory.createNodeEntityRepository(Movie.class); + NodeGraphRepository movieRepository = graphRepositoryFactory.createNodeEntityRepository(Movie.class); // REMINDER, the "null" stands for an optional index name - Movie retrievedMovie = movieFinder.findByPropertyValue(null, "id",id); + Movie retrievedMovie = movieRepository.findByPropertyValue(null, "id",id); assertEqual("retrieved movie matches persisted one",forrestGump,retrievedMovie); assertEqual("retrieved movie title matches","Forrest Gump",retrievedMovie.getTitle()); } diff --git a/src/docbkx/tutorial/spring-data-graph.xml b/src/docbkx/tutorial/spring-data-graph.xml index 4372e57fd..224a1291c 100644 --- a/src/docbkx/tutorial/spring-data-graph.xml +++ b/src/docbkx/tutorial/spring-data-graph.xml @@ -21,7 +21,7 @@ org.springframework.data spring-data-neo4j - 1.0.0.M5 + 1.0.0.RC1