use of org.neo4j.meta.model.MetaModelProperty in project graphdb by neo4j-attic.
the class MetastructureTest method shouldCreateMetaModel.
/**
* A simple test to exercise the meta-model api.
*/
@Test
public void shouldCreateMetaModel() {
IndexService index = new LuceneIndexService(neo4j);
MetaModel meta = new MetaModelImpl(neo4j, index);
Transaction tx = neo4j.beginTx();
try {
MetaModelNamespace namespace = meta.getGlobalNamespace();
// Create a class, use ", true" for "create it if it doesn't exist".
MetaModelClass personClass = namespace.getMetaClass("http://metaexample.org/meta#Person", true);
// Create a property in a similar way.
MetaModelProperty nameProperty = namespace.getMetaProperty("http://metaexample.org/meta#name", true);
// Tell the meta model that persons can have name properties.
personClass.getDirectProperties().add(nameProperty);
tx.success();
} catch (Exception e) {
tx.failure();
} finally {
tx.finish();
}
}
Aggregations