MetaModelClasses are cached in a map, so while the property may be renamed and reindexed, the map still holds the original name value. After a restart of the application the new value should be applied. To make renaming possible a method needs to be added to MetaModelNamespace. Niels
> Date: Mon, 5 Jul 2010 08:57:09 +0200 > From: [email protected] > To: [email protected] > Subject: Re: [Neo4j] Meta-model component: problem with renaming classes > > 2010/7/5, Jörg Richter <[email protected]>: > > > > How can a MetaModelClass be renamed? > > There seems to be no obvious way. > > > > I tried to change the "meta_model_name" property of the wrapped node and > > re-index the node. This basically works, but namespace.getMetaClass() still > > returns a MetaModelClass object when called with the old name. IMO it would > > be correct if null is returned in this case, like for any unknown class. > > Otherwise the application could get confused. > > > > Example code: > > > > // creating a class and getting the wrapped node > > MetaModelClass class1 = namespace.getMetaClass("My Class", true); > > Node classNode1 = class1.node(); > > > > // change the node's name property and re-index > > classNode1.setProperty(MetaModelProperty.KEY_NAME, "New Class Name"); > > index.removeIndex(classNode1, MetaModelProperty.KEY_NAME); > > index.index(classNode1, MetaModelProperty.KEY_NAME, "New Class Name"); > > > > Maybe there's some bug in the removeIndex(Node,String) method. Instead > try to do a: > > index.removeIndex(classNode1,MetaModelProperty.KEY_NAME,classNode1.getName()); > > before you set the new name > > > // both calls return a class, the second one shouldn't > > namespace.getMetaClass("New Class Name", false); > > namespace.getMetaClass("My Class", false); > > > > Tested with latest snapshots of neo4j kernel, index, and meta-model > > components and Lucene 2.9.2 > > > > > > API proposal: > > > > Class MetaModelObject should have a setName(String) method for easy and > > consistent renaming of classes and properties. > > Furthermore, namespace.getMetaClass() should return null when called with a > > stale name. > > > > What is your use case for renaming a meta model class? Is that really > functionality that should be used at runtime? My gut feeling says that > this is a develpment time thing and once a class is created with a > name it sticks with that name. Or are you doing some kind of migration > of your data? > > > BTW: one big up to the great Neo4j team and community! > > Cheers! > > > Cheers, > > Jörg > > > > > > _______________________________________________ > > Neo4j mailing list > > [email protected] > > https://lists.neo4j.org/mailman/listinfo/user > > > > > -- > Mattias Persson, [[email protected]] > Hacker, Neo Technology > www.neotechnology.com > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

