A straightforward:

  Node target = db.createNode();
  copyProperties( source, target );
  for ( Relationship sourceRel : source.getRelationships() ) {
      Relationship targetRel = source.equals( sourceRel.getStartNode() ) ?
              target.createRelationshipTo( sourceRel.getEndNode(),
sourceRel.getType() ) :
              sourceRel.getEndNode().createRelationshipTo( target,
sourceRel.getType() );
      copyProperties( sourceRel, targetRel );
      sourceRel.delete();
  }
  source.delete();
...
  private static void copyProperties( PropertyContainer source,
PropertyContainer target ) {
      for ( String key : source.getPropertyKeys() )
          target.setProperty( key, source.getProperty( key ) );
  }

would suffice, I'd guess.

2012/1/12 Emil Dombagolla <em...@hsenidoutsourcing.com>

> Hi All,
>
> I am using Java API with neo4j 1.4.2.
>
> I want to copy all the relationships(Income/Outgoing) of a node to another
> node and delete the original node. Can anyone suggest what will be the
> easiest way.
>
> Emil Dombagolla,
> Thank you so much.
> _______________________________________________
> NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please
> register and consider posting at
> https://groups.google.com/forum/#!forum/neo4j
>
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
and consider posting at https://groups.google.com/forum/#!forum/neo4j

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

Reply via email to