Search in sources :

Example 61 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class LuceneNullTest method testNotNullChangeToNullWithLists.

@Test
public void testNotNullChangeToNullWithLists() {
    OrientGraphNoTx graph = new OrientGraphNoTx("memory:testNotNullChangeToNullWithLists");
    try {
        ODatabaseDocumentTx db = graph.getRawGraph();
        db.command(new OCommandSQL("create class Test extends V")).execute();
        db.command(new OCommandSQL("create property Test.names EMBEDDEDLIST STRING")).execute();
        db.command(new OCommandSQL("create index Test.names on Test (names) fulltext engine lucene")).execute();
        ODocument doc = new ODocument("Test");
        db.begin();
        doc.field("names", new String[] { "foo" });
        db.save(doc);
        db.commit();
        db.begin();
        doc.removeField("names");
        db.save(doc);
        db.commit();
        OIndex<?> index = db.getMetadata().getIndexManager().getIndex("Test.names");
        Assert.assertEquals(index.getSize(), 0);
    } finally {
        graph.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 62 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class OrientDbCreationHelper method loadDB.

public static void loadDB(ODatabaseDocumentTx db, int documents) throws IOException {
    db.declareIntent(new OIntentMassiveInsert());
    for (int i = 1; i <= documents; i++) {
        ODocument doc = new ODocument();
        doc.setClassName("Item");
        doc = createItem(i, doc);
        db.save(doc, "Item");
    }
    db.declareIntent(null);
    createAuthorAndArticles(db, 50, 50);
    createArticleWithAttachmentSplitted(db);
    createWriterAndPosts(new OrientGraphNoTx(db), 10, 10);
}
Also used : OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 63 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class TestNotTxVertexDropWithRidBagTree method before.

@Before
public void before() {
    graph = new OrientGraphNoTx("memory:" + TestNotTxVertexDropWithRidBagTree.class.getSimpleName());
    graph.createVertexType("Test");
    graph.createEdgeType("Ref");
}
Also used : OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) Before(org.junit.Before)

Example 64 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class OGremlinConsoleTest method testGraphMLImportIgnoreVAttribute.

@Test
public void testGraphMLImportIgnoreVAttribute() throws IOException {
    final String INPUT_FILE = "src/test/resources/graph-example-fromexport.xml";
    String dbUrl = "memory:testGraphMLImportIgnoreVAttribute";
    final OGraphMLReader graphml = new OGraphMLReader(new OrientGraphNoTx(dbUrl)).defineVertexAttributeStrategy("__type__", new OIgnoreGraphMLImportStrategy()).inputGraph(INPUT_FILE);
    ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl);
    db.open("admin", "admin");
    try {
        List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from V"));
        Assert.assertFalse(result.isEmpty());
        for (ODocument d : result) {
            Assert.assertFalse(d.containsField("__type__"));
        }
    } finally {
        db.close();
    }
}
Also used : OIgnoreGraphMLImportStrategy(com.orientechnologies.orient.graph.graphml.OIgnoreGraphMLImportStrategy) OGraphMLReader(com.orientechnologies.orient.graph.graphml.OGraphMLReader) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 65 with OrientGraphNoTx

use of com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx in project orientdb by orientechnologies.

the class GraphValidationTest method ok.

@Test
public void ok() {
    setupSchema();
    final OrientGraphNoTx graphNoTx = new OrientGraphNoTx(URL, "admin", "admin");
    try {
        graphNoTx.addVertex("class:M", "name", "n0");
        try {
            graphNoTx.addVertex("class:M");
            throw new RuntimeException("Schema problem was not detected!");
        } catch (Throwable e) {
            // This is what happens => OK
            System.out.println("This is the Message I want to see: \n" + e);
        }
        graphNoTx.commit();
    } finally {
        graphNoTx.shutdown();
    }
}
Also used : OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) Test(org.junit.Test)

Aggregations

OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)72 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)28 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)23 Test (org.junit.Test)22 OrientGraphFactory (com.tinkerpop.blueprints.impls.orient.OrientGraphFactory)20 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)17 OrientVertexType (com.tinkerpop.blueprints.impls.orient.OrientVertexType)17 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)16 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)15 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)7 Vertex (com.tinkerpop.blueprints.Vertex)6 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)6 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)5 OGraphMLReader (com.orientechnologies.orient.graph.graphml.OGraphMLReader)5 OGraphRepair (com.tinkerpop.blueprints.impls.orient.OGraphRepair)5 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 Edge (com.tinkerpop.blueprints.Edge)4 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)3 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)3 File (java.io.File)3