Folks,
that might be a good utility class IMHO, Peter.

/peter

On Mon, May 5, 2008 at 11:20 AM, Peter Haensgen <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  the "enum" approach has the disadvantage that the available relationship 
> types are static, e.g. they must be known at compile time. In some cases, 
> this may not be sufficient.
>  Therefore I have built a "DynamicRelationType", which simply looks like this:
>
>  public class DynamicRelationshipType implements RelationshipType
>  {
>     private static Map<String, RelationshipType> types = new HashMap<String, 
> RelationshipType>();
>
>     private String name;
>
>     private DynamicRelationshipType(String name)
>     {
>         this.name = name;
>     }
>
>     public String name()
>     {
>         return name;
>     }
>
>     public static synchronized RelationshipType getRelationshipType(String 
> name)
>     {
>         RelationshipType type = types.get(name);
>         if (type == null)
>         {
>             type = new DynamicRelationshipType(name);
>             types.put(name, type);
>         }
>
>         return type;
>     }
>  }
>
>
>  In the application code, you would use like this:
>
>  Node rn = neo.getReferenceNode();
>  Node n = neo.createNode();
>
>  RelationshipType t1 = DynamicRelationshipType.getRelationshipType("MyType");
>  rn.createRelationshipTo(n, t1);
>
>
>  Works fine for me!
>
>  FYI,
>  Peter
>
>
>
>
>  > -----Original Message-----
>  > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>  > On Behalf Of Philip Jägenstedt
>  > Sent: Sonntag, 4. Mai 2008 00:08
>  > To: Neo user discussions
>  > Subject: [Neo] Does RelationshipType enum need to be unique?
>  >
>  > This question may reveal some ignorance on my side, but I'm going ahead
>  > anyway.
>  >
>  > Is there anything which makes it a bad idea to have several different
>  > enums implementing RelationshipType and using these for different
>  > relationships in neo? The reason in my case is that some relationship
>  > types are native to the model (the MusicBrainz model) and ought to
>  > reside in org.musicbrainz.RelationTypes or similar, while other
>  > relationships are specific to my application and not really related to
>  > the model.
>  >
>  > The reason I ask is that I don't really understand what an enum is in
>  > Java. If I have
>  >
>  >  enum MyRelationshipTypes implements RelationshipType
>  >  {
>  >      CONTAINED_IN, KNOWS
>  >  }
>  >
>  > and then rename it to
>  >
>  >  enum MomsRelationshipTypes implements RelationshipType
>  >  {
>  >      CONTAINED_IN, KNOWS
>  >  }
>  >
>  > will neo treat these as the same or new relationships?
>  >
>  > Philip
>  > _______________________________________________
>  > Neo mailing list
>  > User@lists.neo4j.org
>  > https://lists.neo4j.org/mailman/listinfo/user
>  _______________________________________________
>  Neo mailing list
>  User@lists.neo4j.org
>  https://lists.neo4j.org/mailman/listinfo/user
>
>



-- 
GTalk: neubauer.peter
Skype peter.neubauer
ICQ 18762544
GTalk neubauer.peter
Phone +46704 106975
LinkedIn http://www.linkedin.com/in/neubauer

http://www.neo4j.org - New Energy for Data - the Graph Database.
http://www.ops4j.org - New Energy for OSS Communities - Open
Participation Software.
http://www.qi4j.org - New Energy for Java - Domain Driven Development.
_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to