2010/7/5, Jörg Richter <j...@deepamehta.de>: > > 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 > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user