Re: [Neo4j] Any webservice based spring data graph example

2011-08-16 Thread Vipul Gupta
)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at
org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at
org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
at
org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:371)
at
org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:307)
at
org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:203)
at
org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

On Tue, Aug 16, 2011 at 5:59 AM, Andreas Kollegger 
andreas.kolleg...@neotechnology.com wrote:

 Hi Vipul,

 What was the trouble you were having with Apache CXF? Were you deploying
 Neo4j as an embedded database, intending to use CXF to expose an interface?
 Or were you accessing Neo4j Server's REST api from Apache CXF?

 I'm not aware of any example projects that have used Apache CXF, but am
 pretty interested to hear about your experiences.

 Cheers,
 Andreas

 On Aug 15, 2011, at 8:07 AM, Vipul Gupta wrote:

  I was having some trouble integrating Apache CXF with Spring data graph
  container.
  So I am wondering if there is any webservice based spring data graph
 example
  for which I can look at the source code.
 
  Please let me know
 
  Thanks
  ___
  Neo4j mailing list
  User@lists.neo4j.org
  https://lists.neo4j.org/mailman/listinfo/user

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Any webservice based spring data graph example

2011-08-16 Thread Vipul Gupta
 nested exception for cause of
error
at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 80 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class [org.neo4j.kernel.EmbeddedGraphDatabase]: Constructor
threw ex
ception; nested exception is org.neo4j.graphdb.TransactionFailureException:
Could not create data source [nioneodb], see nested exception for cause of
error
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)
at
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 89 more
Caused by: org.neo4j.graphdb.TransactionFailureException: Could not create
data source [nioneodb], see nested exception for cause of error
at
org.neo4j.kernel.impl.transaction.TxModule.registerDataSource(TxModule.java:153)
at org.neo4j.kernel.GraphDbInstance.start(GraphDbInstance.java:111)
at
org.neo4j.kernel.EmbeddedGraphDbImpl.init(EmbeddedGraphDbImpl.java:189)
at
org.neo4j.kernel.EmbeddedGraphDatabase.init(EmbeddedGraphDatabase.java:79)
at
org.neo4j.kernel.EmbeddedGraphDatabase.init(EmbeddedGraphDatabase.java:63)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 91 more
Caused by: java.lang.IllegalStateException: Unable to lock store
[\neo4j\db\project\graph-project\neostore], this is usually a result of some
other Neo4j kernel
 running using the same store.
at
org.neo4j.kernel.impl.nioneo.store.CommonAbstractStore.checkStorage(CommonAbstractStore.java:266)
at
org.neo4j.kernel.impl.nioneo.store.CommonAbstractStore.init(CommonAbstractStore.java:169)
at
org.neo4j.kernel.impl.nioneo.store.AbstractStore.init(AbstractStore.java:120)
at
org.neo4j.kernel.impl.nioneo.store.NeoStore.init(NeoStore.java:65)
at
org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource.init(NeoStoreXaDataSource.java:134)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.neo4j.kernel.impl.transaction.XaDataSourceManager.create(XaDataSourceManager.java:75)
at
org.neo4j.kernel.impl.transaction.TxModule.registerDataSource(TxModule.java:147)


On Tue, Aug 16, 2011 at 10:09 PM, Michael Hunger 
michael.hun...@neotechnology.com wrote:

 do you by chance have different version of spring on your classpath?

 mvn dependency:tree

 helps to figure that out



 mobile mail please excuse brevity and typos

 Am 16.08.2011 um 17:53 schrieb Vipul Gupta vipulgupta...@gmail.com:

  Hi Andreas,
 
  Yes, I have been trying to run  Neo4j as an embedded database, with CXF
  exposing a WSDL interface. I was having a number of issues in terms of
  setting these 2 together.
  Standalone test cases for just the neo4j graph and internal API works
 fine.
 
  I even migrated to 1.1.0.RELEASE and made relevant changes. Here

Re: [Neo4j] Any webservice based spring data graph example

2011-08-16 Thread Vipul Gupta
Thanks Sujit and Saikat.
I managed to get it up and running now.

Regarding the 2 process issue - I have a homegrown ApplicationContext loader
which was loading graph context twice. Managed to figure it out after
Sujit's suggestion.

On Tue, Aug 16, 2011 at 11:18 PM, Sujit Pal sujit@comcast.net wrote:

 Hi Vipul,

 I saw the same issue when trying to expose an embedded Neo4j database
 (plus some other things) via a Spring webapp.

 *Caused by: java.lang.IllegalStateException: Unable to lock store
 [\neo4j\db\project\graph-project\neostore], this is usually a result of
 some other Neo4j kernel** running using the same store. *

 The problem was that I was trying to instantiate the
 GraphDatabaseService from two components with a new().

 I ended up building a factory that instantiates a singleton and returns
 a reference to the same GraphDatabaseService using a getInstance()
 method to all the components that need a handle to it.

 In my spring config I declare the bean containing the
 GraphDatabaseService (nodeService) like so:

  bean id=nodeService class=...NodeServiceFactory
factory-method=getInstance destroy-method=destroy/

 where the NodeServiceFactory exposes 2 static methods getInstance() that
 returns the singleton reference and destroy which closes the reference
 on application shutdown.

 In the app, where I was doing a nodeService = new NodeService(), I
 replaced with nodeService = NodeService.getInstance().

 -sujit


 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Any webservice based spring data graph example

2011-08-15 Thread Vipul Gupta
I was having some trouble integrating Apache CXF with Spring data graph
container.
So I am wondering if there is any webservice based spring data graph example
for which I can look at the source code.

Please let me know

Thanks
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Spring Data Graph 1.1.0.M1 milestone released

2011-06-16 Thread Vipul Gupta
please give the maven repository information from where it can be downloaded.


On Thu, Jun 16, 2011 at 6:50 PM, Michael Hunger
michael.hun...@neotechnology.com wrote:
 You could just use the direct repository factory for that.

 directGraphRepositoryFactory.createGraphRepository(clazz).findAll()


 normally you would have a

 interface PersonRepository extends GraphRepositoryPerson {}

 and get this injected.

 @Autowired PersonRepository personRepository;

 personRepository.findAll();

 Cheers

 Michael

 Today I discussed some nice derived-method for cypher queries.
 See: 
 https://github.com/SpringSource/spring-data-graph/wiki/Repository-query-methods


 Am 16.06.2011 um 14:30 schrieb Alfredas Chmieliauskas:

 Dear Michael,

 sounds great! Especially the annotated repository methods. That was
 something *really* desirable and now its there. Fantastischt!

 One question though. Before the upgrade i used to have a handy method
 to find all things of a type (Class) by using a method like

 public T extends NodeBacked IterableT findAll(ClassT clazz) {
   finderFactory.createNodeEntityFinder(clazz).findAll();
 }

 is there a good way to replicate such functionality in the current release?

 Alfredas

 P.S. we're delayed with publishing our energy simulations (bureaucracy
 problems more than technical or conceptual). but i'm still determined
 to make it happen (publish the thing online) before summer end.

 On Wed, Jun 15, 2011 at 10:17 AM, Michael Hunger
 michael.hun...@neotechnology.com wrote:
 Dear Graphistas,

 After some quiet time that I spend on other important issues, we're back on 
 our regular release cycle/rhythm.

 We discussed the future SDG roadmap with our CEO Emil and decided to work 
 first on the issues that were
 reported by our users here on the mailing list, on the spring forums and on 
 twitter.

 So primarily we updated the dependencies to Neo4j 1.4.M04 and AspectJ 
 (1.6.12.M1), the latter fixing some issues.

 With the new Neo4j release we are also able to start working some important 
 new features.

 The most interesting one is the adoption of the query language cypher 
 which is now accessible from NodeEntities (dynamic annotated fields, 
 introduced methods) and repositories (annotated repository interface 
 methods).
 (https://jira.springsource.org/browse/DATAGRAPH-91)

 Example, NodeEntity-field:

 @GraphQuery(start me=(%d) match 
 (me)-[:works_at]-(company)-[:works_at]-(colleague) return colleague)
 IterablePerson colleagues;

 Example, Repository:

 interface PersonRepository extends GraphRepositoryPerson {
   @GraphQuery(start person=(%d) match (person)-[:boss]-(boss) return 
 boss)
   Person findBoss(Person developer);
 }

 We also accommodate for the change of allowing self-relationships.

 Another annoyance for SDG users - the need to specify an elementClass on 
 @RelatedTo annotations has also been removed this change will also be added 
 to the other annotations that we use.

 We would like to get your feedback on those changes and also on Spring Data 
 Graph in general, so please check it out and get back to us.

 And please spread the word: 
 http://twitter.com/#!/neo4j/statuses/80503228319547392

 Cheers

 Michael

 Announcement: http://www.springsource.org/node/3152
 JIRA: https://jira.springsource.org/browse/DATAGRAPH
 Project Page: http://www.springsource.org/spring-data/neo4j
 Forum: forum.springsource.org/forumdisplay.php?f=80

 Github: http://github.com/springsource/spring-data-graph
 Download: 
 http://www.springsource.com/download/community?project=Spring%20Data%20Neo4j






 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Which version of neo4j does spring data graph project use ?

2011-06-14 Thread Vipul Gupta
Michael,

I don't see anything released on maven repo yet?
Please update.

-VIpul

On Fri, Jun 10, 2011 at 3:40 PM, Michael Hunger
michael.hun...@neotechnology.com wrote:
 Wait for our spring data graph 1.1.0.M1 release on Monday :)

 it will be updated to Neo4j 1.4.M04

 Cheers

 Michael

 Am 10.06.2011 um 11:55 schrieb Vipul Gupta:

 Please let me know..
 I want to use the latest version of neo4j say  Neo4j 1.4 M03 “Kiruna
  with spring data graph. WHat do I do ?
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Which version of neo4j does spring data graph project use ?

2011-06-10 Thread Vipul Gupta
Please let me know..
I want to use the latest version of neo4j say  Neo4j 1.4 M03 “Kiruna
 with spring data graph. WHat do I do ?
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Which version of neo4j does spring data graph project use ?

2011-06-10 Thread Vipul Gupta
Cool. thanks Michael.


On Fri, Jun 10, 2011 at 3:40 PM, Michael Hunger
michael.hun...@neotechnology.com wrote:
 Wait for our spring data graph 1.1.0.M1 release on Monday :)

 it will be updated to Neo4j 1.4.M04

 Cheers

 Michael

 Am 10.06.2011 um 11:55 schrieb Vipul Gupta:

 Please let me know..
 I want to use the latest version of neo4j say  Neo4j 1.4 M03 “Kiruna
  with spring data graph. WHat do I do ?
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Question from Webinar - traversing a path with nodes of different types

2011-04-21 Thread Vipul Gupta
Hi David,

Inputs are 1 and 6 + Graph is acyclic.

domain.Client@1 - domain.Router@2 - domain.Router@3 - domain.Router@5 -
domain.Server@6
  - domain.Router@7 - domain.Router@8 -

I want a way to start from 1,

process the 2 path till it reaches 5 (say in a thread)
process the 7 path till it reaches 5 (in another thread)

then process 5 and eventually 6.
the above step of processing intermediate path and waiting on the blocking
point can happen over and over again in a more complex graph (that is there
could be a number of loops in between even) and the traversal stops only we
reach 6

I hope this makes it a bit clear. I was working out something for this, but
it is turning out to be too complex a solution for this sort of traversal of
a graph, so I am hoping if you can suggest something.

Best Regards,
Vipul


On Thu, Apr 21, 2011 at 11:36 AM, David Montag 
david.mon...@neotechnology.com wrote:

 Hi Vipul,

 Zooming out a little bit, what are the inputs to your algorithm, and what
 do you want it to do?

 For example, given 1 and 6, do you want to find any points in the chain
 between them that are join points of two (or more) subchains (5 in this
 case)?

 David


 On Wed, Apr 20, 2011 at 10:56 PM, Vipul Gupta vipulgupta...@gmail.comwrote:

 my mistake - I meant 5 depends on both 3 and 8 and acts as a blocking
 point till 3 and 8 finishes


 On Thu, Apr 21, 2011 at 11:19 AM, Vipul Gupta vipulgupta...@gmail.comwrote:

 David/Michael,

 Let me modify the example a bit.
 What if my graph structure is like this

 domain.Client@1 - domain.Router@2 - domain.Router@3 - domain.Router@5- 
 domain.Server@6
   - domain.Router@7 - domain.Router@8 -


 Imagine a manufacturing line.
 6 depends on both 3 and 8 and acts as a blocking point till 3 and 8
 finishes.

 Is there a way to get a cleaner traversal for such kind of relationship. I
 want to get a complete intermediate traversal from Client to Server.

 Thank a lot for helping out on this.

 Best Regards,
 Vipul




 On Thu, Apr 21, 2011 at 12:09 AM, David Montag 
 david.mon...@neotechnology.com wrote:

 Hi Vipul,

 Thanks for listening!

 It's a very good question, and the short answer is: yes! I'm cc'ing our
 mailing list so that everyone can take part in the answer.

 Here's the long answer, illustrated by an example:

 Let's assume you're modeling a network. You'll have some domain classes
 that are all networked entities with peers:

 @NodeEntity
 public class NetworkEntity {
 @RelatedTo(type = PEER, direction = Direction.BOTH, elementClass =
 NetworkEntity.class)
 private SetNetworkEntity peers;

 public void addPeer(NetworkEntity peer) {
 peers.add(peer);
 }
 }

 public class Server extends NetworkEntity {}
 public class Router extends NetworkEntity {}
 public class Client extends NetworkEntity {}

 Then we can build a small network:

 Client c = new Client().persist();
 Router r1 = new Router().persist();
 Router r21 = new Router().persist();
 Router r22 = new Router().persist();
 Router r3 = new Router().persist();
 Server s = new Server().persist();

 c.addPeer(r1);
 r1.addPeer(r21);
 r1.addPeer(r22);
 r21.addPeer(r3);
 r22.addPeer(r3);
 r3.addPeer(s);

 c.persist();

 Note that after linking the entities, I only call persist() on the
 client. You can read more about this in the reference documentation, but
 essentially it will cascade in the direction of the relationships created,
 and will in this case cascade all the way to the server entity.

 You can now query this:

 IterableEntityPathClient, Server paths =
 c.findAllPathsByTraversal(Traversal.description());

 The above code will get you an EntityPath per node visited during the
 traversal from c. The example does however not use a very interesting
 traversal description, but you can still print the results:

 for (EntityPathClient, Server path : paths) {
 StringBuilder sb = new StringBuilder();
 IteratorNetworkEntity iter =
 path.NetworkEntitynodeEntities().iterator();
 while (iter.hasNext()) {
 sb.append(iter.next());
 if (iter.hasNext()) sb.append( - );
 }
 System.out.println(sb);
 }

 This will print each path, with all entities in the path. This is what
 it looks like:

 domain.Client@1
 domain.Client@1 - domain.Router@2
 domain.Client@1 - domain.Router@2 - domain.Router@3
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Server@6
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Router@4

 Let us know if this is what you looked for. If you want to only find
 paths that end with a server, you'd use this query instead:

 IterableEntityPathClient, Server paths =
 c.findAllPathsByTraversal(Traversal.description().evaluator(new Evaluator()
 {
 @Override
 public Evaluation evaluate(Path path) {
 if (new

Re: [Neo4j] Question from Webinar - traversing a path with nodes of different types

2011-04-20 Thread Vipul Gupta
David/Michael,

Let me modify the example a bit.
What if my graph structure is like this

domain.Client@1 - domain.Router@2 - domain.Router@3 - domain.Router@5 -
domain.Server@6
  - domain.Router@7 - domain.Router@8 -


Imagine a manufacturing line.
6 depends on both 3 and 8 and acts as a blocking point till 3 and 8
finishes.

Is there a way to get a cleaner traversal for such kind of relationship. I
want to get a complete intermediate traversal from Client to Server.

Thank a lot for helping out on this.

Best Regards,
Vipul




On Thu, Apr 21, 2011 at 12:09 AM, David Montag 
david.mon...@neotechnology.com wrote:

 Hi Vipul,

 Thanks for listening!

 It's a very good question, and the short answer is: yes! I'm cc'ing our
 mailing list so that everyone can take part in the answer.

 Here's the long answer, illustrated by an example:

 Let's assume you're modeling a network. You'll have some domain classes
 that are all networked entities with peers:

 @NodeEntity
 public class NetworkEntity {
 @RelatedTo(type = PEER, direction = Direction.BOTH, elementClass =
 NetworkEntity.class)
 private SetNetworkEntity peers;

 public void addPeer(NetworkEntity peer) {
 peers.add(peer);
 }
 }

 public class Server extends NetworkEntity {}
 public class Router extends NetworkEntity {}
 public class Client extends NetworkEntity {}

 Then we can build a small network:

 Client c = new Client().persist();
 Router r1 = new Router().persist();
 Router r21 = new Router().persist();
 Router r22 = new Router().persist();
 Router r3 = new Router().persist();
 Server s = new Server().persist();

 c.addPeer(r1);
 r1.addPeer(r21);
 r1.addPeer(r22);
 r21.addPeer(r3);
 r22.addPeer(r3);
 r3.addPeer(s);

 c.persist();

 Note that after linking the entities, I only call persist() on the client.
 You can read more about this in the reference documentation, but essentially
 it will cascade in the direction of the relationships created, and will in
 this case cascade all the way to the server entity.

 You can now query this:

 IterableEntityPathClient, Server paths =
 c.findAllPathsByTraversal(Traversal.description());

 The above code will get you an EntityPath per node visited during the
 traversal from c. The example does however not use a very interesting
 traversal description, but you can still print the results:

 for (EntityPathClient, Server path : paths) {
 StringBuilder sb = new StringBuilder();
 IteratorNetworkEntity iter =
 path.NetworkEntitynodeEntities().iterator();
 while (iter.hasNext()) {
 sb.append(iter.next());
 if (iter.hasNext()) sb.append( - );
 }
 System.out.println(sb);
 }

 This will print each path, with all entities in the path. This is what it
 looks like:

 domain.Client@1
 domain.Client@1 - domain.Router@2
 domain.Client@1 - domain.Router@2 - domain.Router@3
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Server@6
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Router@4

 Let us know if this is what you looked for. If you want to only find paths
 that end with a server, you'd use this query instead:

 IterableEntityPathClient, Server paths =
 c.findAllPathsByTraversal(Traversal.description().evaluator(new Evaluator()
 {
 @Override
 public Evaluation evaluate(Path path) {
 if (new ConvertingEntityPath(graphDatabaseContext,
 path).endEntity() instanceof Server) {
 return Evaluation.INCLUDE_AND_PRUNE;
 }
 return Evaluation.EXCLUDE_AND_CONTINUE;
 }
 }));

 In the above code example, graphDatabaseContext is a bean of type
 GraphDatabaseContext created by Spring Data Graph. This syntax will
 dramatically improve in future releases. It will print:

 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Server@6

 Regarding your second question about types: If you want to convert a node
 into an entity, you would use the TypeRepresentationStrategy configured
 internally in Spring Data Graph. See the reference documentation for more
 information on this. If you want to convert Neo4j paths to entity paths, you
 can use the ConvertingEntityPath class as seen above. As an implementation
 detail, the class name is stored on the node as a property.

 Hope this helped!

 David

 On Wed, Apr 20, 2011 at 9:20 AM, Emil Eifrem e...@neotechnology.comwrote:

 David / Michael, do you guys want to dig in and help out Vipul below?

 -EE

 On Wed, Apr 20, 2011 at 09:17, Vipul Gupta vipulgupta...@gmail.com
 wrote:
  Hi Emil,
  I would like to start by thanking you for the webinar. It was very
 useful .
  This is the question I asked on the webinar as well.
  How can we traverse a graph which consists of nodes of different types
 using
  SDG?
  Say first Node in relationship is of type A, next 3 nodes in path

Re: [Neo4j] Question from Webinar - traversing a path with nodes of different types

2011-04-20 Thread Vipul Gupta
my mistake - I meant 5 depends on both 3 and 8 and acts as a blocking
point till 3 and 8 finishes

On Thu, Apr 21, 2011 at 11:19 AM, Vipul Gupta vipulgupta...@gmail.comwrote:

 David/Michael,

 Let me modify the example a bit.
 What if my graph structure is like this

 domain.Client@1 - domain.Router@2 - domain.Router@3 - domain.Router@5- 
 domain.Server@6
   - domain.Router@7 - domain.Router@8 -


 Imagine a manufacturing line.
 6 depends on both 3 and 8 and acts as a blocking point till 3 and 8
 finishes.

 Is there a way to get a cleaner traversal for such kind of relationship. I
 want to get a complete intermediate traversal from Client to Server.

 Thank a lot for helping out on this.

 Best Regards,
 Vipul




 On Thu, Apr 21, 2011 at 12:09 AM, David Montag 
 david.mon...@neotechnology.com wrote:

 Hi Vipul,

 Thanks for listening!

 It's a very good question, and the short answer is: yes! I'm cc'ing our
 mailing list so that everyone can take part in the answer.

 Here's the long answer, illustrated by an example:

 Let's assume you're modeling a network. You'll have some domain classes
 that are all networked entities with peers:

 @NodeEntity
 public class NetworkEntity {
 @RelatedTo(type = PEER, direction = Direction.BOTH, elementClass =
 NetworkEntity.class)
 private SetNetworkEntity peers;

 public void addPeer(NetworkEntity peer) {
 peers.add(peer);
 }
 }

 public class Server extends NetworkEntity {}
 public class Router extends NetworkEntity {}
 public class Client extends NetworkEntity {}

 Then we can build a small network:

 Client c = new Client().persist();
 Router r1 = new Router().persist();
 Router r21 = new Router().persist();
 Router r22 = new Router().persist();
 Router r3 = new Router().persist();
 Server s = new Server().persist();

 c.addPeer(r1);
 r1.addPeer(r21);
 r1.addPeer(r22);
 r21.addPeer(r3);
 r22.addPeer(r3);
 r3.addPeer(s);

 c.persist();

 Note that after linking the entities, I only call persist() on the client.
 You can read more about this in the reference documentation, but essentially
 it will cascade in the direction of the relationships created, and will in
 this case cascade all the way to the server entity.

 You can now query this:

 IterableEntityPathClient, Server paths =
 c.findAllPathsByTraversal(Traversal.description());

 The above code will get you an EntityPath per node visited during the
 traversal from c. The example does however not use a very interesting
 traversal description, but you can still print the results:

 for (EntityPathClient, Server path : paths) {
 StringBuilder sb = new StringBuilder();
 IteratorNetworkEntity iter =
 path.NetworkEntitynodeEntities().iterator();
 while (iter.hasNext()) {
 sb.append(iter.next());
 if (iter.hasNext()) sb.append( - );
 }
 System.out.println(sb);
 }

 This will print each path, with all entities in the path. This is what it
 looks like:

 domain.Client@1
 domain.Client@1 - domain.Router@2
 domain.Client@1 - domain.Router@2 - domain.Router@3
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Server@6
 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Router@4

 Let us know if this is what you looked for. If you want to only find paths
 that end with a server, you'd use this query instead:

 IterableEntityPathClient, Server paths =
 c.findAllPathsByTraversal(Traversal.description().evaluator(new Evaluator()
 {
 @Override
 public Evaluation evaluate(Path path) {
 if (new ConvertingEntityPath(graphDatabaseContext,
 path).endEntity() instanceof Server) {
 return Evaluation.INCLUDE_AND_PRUNE;
 }
 return Evaluation.EXCLUDE_AND_CONTINUE;
 }
 }));

 In the above code example, graphDatabaseContext is a bean of type
 GraphDatabaseContext created by Spring Data Graph. This syntax will
 dramatically improve in future releases. It will print:

 domain.Client@1 - domain.Router@2 - domain.Router@3 -
 domain.Router@5 - domain.Server@6

 Regarding your second question about types: If you want to convert a node
 into an entity, you would use the TypeRepresentationStrategy configured
 internally in Spring Data Graph. See the reference documentation for more
 information on this. If you want to convert Neo4j paths to entity paths, you
 can use the ConvertingEntityPath class as seen above. As an implementation
 detail, the class name is stored on the node as a property.

 Hope this helped!

 David

 On Wed, Apr 20, 2011 at 9:20 AM, Emil Eifrem e...@neotechnology.comwrote:

 David / Michael, do you guys want to dig in and help out Vipul below?

 -EE

 On Wed, Apr 20, 2011 at 09:17, Vipul Gupta vipulgupta...@gmail.com
 wrote:
  Hi Emil,
  I would like to start by thanking you for the webinar. It was very
 useful .
  This is the question I