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");
// 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.
BTW: one big up to the great Neo4j team and community!!
Cheers,
Jörg
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user