Search in sources :

Example 1 with LuceneIndexService

use of org.neo4j.index.lucene.LuceneIndexService 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();
    }
}
Also used : MetaModelNamespace(org.neo4j.meta.model.MetaModelNamespace) MetaModel(org.neo4j.meta.model.MetaModel) Transaction(org.neo4j.graphdb.Transaction) LuceneIndexService(org.neo4j.index.lucene.LuceneIndexService) IndexService(org.neo4j.index.IndexService) MetaModelProperty(org.neo4j.meta.model.MetaModelProperty) LuceneIndexService(org.neo4j.index.lucene.LuceneIndexService) MetaModelImpl(org.neo4j.meta.model.MetaModelImpl) MetaModelClass(org.neo4j.meta.model.MetaModelClass) Test(org.junit.Test)

Example 2 with LuceneIndexService

use of org.neo4j.index.lucene.LuceneIndexService in project qi4j-sdk by Qi4j.

the class NeoEntityStoreMixin method activateService.

@Override
public void activateService() throws Exception {
    String path = config.get().path().get();
    if (path == null) {
        if (fileConfiguration != null)
            path = new File(fileConfiguration.dataDirectory(), config.get().identity().get()).getAbsolutePath();
        else
            path = "build/neodb";
    }
    neo = new EmbeddedGraphDatabase(path);
    indexService = new LuceneIndexService(neo);
    uuid = UUID.randomUUID().toString() + "-";
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) LuceneIndexService(org.neo4j.index.lucene.LuceneIndexService) File(java.io.File)

Aggregations

LuceneIndexService (org.neo4j.index.lucene.LuceneIndexService)2 File (java.io.File)1 Test (org.junit.Test)1 Transaction (org.neo4j.graphdb.Transaction)1 IndexService (org.neo4j.index.IndexService)1 EmbeddedGraphDatabase (org.neo4j.kernel.EmbeddedGraphDatabase)1 MetaModel (org.neo4j.meta.model.MetaModel)1 MetaModelClass (org.neo4j.meta.model.MetaModelClass)1 MetaModelImpl (org.neo4j.meta.model.MetaModelImpl)1 MetaModelNamespace (org.neo4j.meta.model.MetaModelNamespace)1 MetaModelProperty (org.neo4j.meta.model.MetaModelProperty)1