Re: [Neo] Does RelationshipType enum need to be unique?
Thanks! On 5/8/08, Mattias Persson <[EMAIL PROTECTED]> wrote: > I fixed that bug... there will be a new SNAPSHOT of neo in an hour or two! > > 2008/5/8 Philip Jägenstedt <[EMAIL PROTECTED]>: > > > I've used this DynamicRelationType in my project, but there is > > something strange going on. Look at what I see in the neo shell: > > > > $ ls > > (me) --[INDEX_SERVICE]--> (1) > > (me) --[MUSICBRAINZ]--> (4) > > neo-sh (0)$ cd 4 > > neo-sh (4)$ ls > > (me) --[ARTISTS]--> (5) > > (me) <--[MUSICBRAINZ]-- (0) > > neo-sh (4)$ cd 5 > > neo-sh (5)$ ls > > (me) --[ARTIST]--> (6) > > (me) --[ARTIST]--> (16) > > (me) <--[ARTISTS]-- (4) > > neo-sh (5)$ cd 6 > > neo-sh (6)$ ls > > *mbid =[e83144dd-bb95-49fe-b1dd-00bab25cca9e] > > *name =[Robert Miles] > > *sortName =[Miles, Robert] > > (me) --[Myspace]--> (15) > > (me) --[OfficialHomepage]--> (13) > > (me) --[Biography]--> (14) > > (me) --[Discogs]--> (11) > > (me) --[Wikipedia]--> (12) > > (me) <--[ARTIST]-- (5) > > neo-sh (6)$ cd 15 > > neo-sh (15)$ ls > > *url =[http://www.myspace.com/robertmilesofficial] > > (me) <[EMAIL PROTECTED] (6) > > > > Look at that last line! The Myspace relationship is shown as > > "[EMAIL PROTECTED]" in the reverse > > direction. It looks like the name has been retrieved with toString() > > or similar instead of name() as per the interface. Has anyone else > > seen this? > > > > Philip > > > > On 5/5/08, 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 types = new > HashMap(); > >> > >> 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 > >> > > ___ > > 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 > > __
Re: [Neo] Does RelationshipType enum need to be unique?
I fixed that bug... there will be a new SNAPSHOT of neo in an hour or two! 2008/5/8 Philip Jägenstedt <[EMAIL PROTECTED]>: > I've used this DynamicRelationType in my project, but there is > something strange going on. Look at what I see in the neo shell: > > $ ls > (me) --[INDEX_SERVICE]--> (1) > (me) --[MUSICBRAINZ]--> (4) > neo-sh (0)$ cd 4 > neo-sh (4)$ ls > (me) --[ARTISTS]--> (5) > (me) <--[MUSICBRAINZ]-- (0) > neo-sh (4)$ cd 5 > neo-sh (5)$ ls > (me) --[ARTIST]--> (6) > (me) --[ARTIST]--> (16) > (me) <--[ARTISTS]-- (4) > neo-sh (5)$ cd 6 > neo-sh (6)$ ls > *mbid =[e83144dd-bb95-49fe-b1dd-00bab25cca9e] > *name =[Robert Miles] > *sortName =[Miles, Robert] > (me) --[Myspace]--> (15) > (me) --[OfficialHomepage]--> (13) > (me) --[Biography]--> (14) > (me) --[Discogs]--> (11) > (me) --[Wikipedia]--> (12) > (me) <--[ARTIST]-- (5) > neo-sh (6)$ cd 15 > neo-sh (15)$ ls > *url =[http://www.myspace.com/robertmilesofficial] > (me) <[EMAIL PROTECTED] (6) > > Look at that last line! The Myspace relationship is shown as > "[EMAIL PROTECTED]" in the reverse > direction. It looks like the name has been retrieved with toString() > or similar instead of name() as per the interface. Has anyone else > seen this? > > Philip > > On 5/5/08, 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 types = new HashMap> 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 >> > ___ > 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
Re: [Neo] Does RelationshipType enum need to be unique?
I've used this DynamicRelationType in my project, but there is something strange going on. Look at what I see in the neo shell: $ ls (me) --[INDEX_SERVICE]--> (1) (me) --[MUSICBRAINZ]--> (4) neo-sh (0)$ cd 4 neo-sh (4)$ ls (me) --[ARTISTS]--> (5) (me) <--[MUSICBRAINZ]-- (0) neo-sh (4)$ cd 5 neo-sh (5)$ ls (me) --[ARTIST]--> (6) (me) --[ARTIST]--> (16) (me) <--[ARTISTS]-- (4) neo-sh (5)$ cd 6 neo-sh (6)$ ls *mbid =[e83144dd-bb95-49fe-b1dd-00bab25cca9e] *name =[Robert Miles] *sortName =[Miles, Robert] (me) --[Myspace]--> (15) (me) --[OfficialHomepage]--> (13) (me) --[Biography]--> (14) (me) --[Discogs]--> (11) (me) --[Wikipedia]--> (12) (me) <--[ARTIST]-- (5) neo-sh (6)$ cd 15 neo-sh (15)$ ls *url =[http://www.myspace.com/robertmilesofficial] (me) <[EMAIL PROTECTED] (6) Look at that last line! The Myspace relationship is shown as "[EMAIL PROTECTED]" in the reverse direction. It looks like the name has been retrieved with toString() or similar instead of name() as per the interface. Has anyone else seen this? Philip On 5/5/08, 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 types = new HashMap 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 > ___ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user