Search in sources :

Example 41 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class OCommandExecutorSQLDeleteEdgeTest method init.

@BeforeClass
public static void init() throws Exception {
    db = new ODatabaseDocumentTx("memory:" + OCommandExecutorSQLDeleteEdgeTest.class.getSimpleName());
    if (db.exists()) {
        db.open("admin", "admin");
        db.drop();
    }
    db.create();
    final OSchema schema = db.getMetadata().getSchema();
    schema.createClass("User", schema.getClass("V"));
    schema.createClass("Folder", schema.getClass("V"));
    schema.createClass("CanAccess", schema.getClass("E"));
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Example 42 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class LuceneBackupRestoreTest method setUp.

@Before
public void setUp() throws Exception {
    String url = "plocal:./target/" + getClass().getName();
    databaseDocumentTx = new ODatabaseDocumentTx(url);
    dropIfExists();
    databaseDocumentTx.create();
    databaseDocumentTx.command(new OCommandSQL("create class City ")).execute();
    databaseDocumentTx.command(new OCommandSQL("create property City.name string")).execute();
    databaseDocumentTx.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
    ODocument doc = new ODocument("City");
    doc.field("name", "Rome");
    databaseDocumentTx.save(doc);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 43 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class LuceneDropTest method setUp.

@Before
public void setUp() throws Exception {
    dbName = "plocal:./target/databases/" + this.getClass().getSimpleName();
    // @maggiolo00 set cont to 0 and the test will not fail anymore
    insertcount = 100;
    ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbName);
    db.create();
    OClass test = db.getMetadata().getSchema().createClass("test");
    test.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index test.name on test (name) FULLTEXT ENGINE LUCENE")).execute();
    db.close();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Before(org.junit.Before)

Example 44 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class LuceneFreezeReleaseTest method freezeReleaseMisUsageTest.

// With double calling freeze/release
@Test
public void freezeReleaseMisUsageTest() {
    ODatabaseDocument db = new ODatabaseDocumentTx("plocal:target/freezeRelease");
    db.create();
    OSchema schema = db.getMetadata().getSchema();
    OClass person = schema.createClass("Person");
    person.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index Person.name on Person (name) FULLTEXT ENGINE LUCENE")).execute();
    db.save(new ODocument("Person").field("name", "John"));
    try {
        Collection results = db.command(new OCommandSQL("select from Person where name lucene 'John'")).execute();
        Assert.assertEquals(1, results.size());
        db.freeze();
        db.freeze();
        results = db.command(new OCommandSQL("select from Person where name lucene 'John'")).execute();
        Assert.assertEquals(1, results.size());
        db.release();
        db.release();
        db.save(new ODocument("Person").field("name", "John"));
        results = db.command(new OCommandSQL("select from Person where name lucene 'John'")).execute();
        Assert.assertEquals(2, results.size());
    } finally {
        db.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Collection(java.util.Collection) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 45 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class LuceneMiscTest method testSubLucene.

// TODO Re-enable when removed check syntax on ODB
@Test
public void testSubLucene() {
    OrientGraphNoTx graph = new OrientGraphNoTx("memory:doubleLucene");
    try {
        ODatabaseDocumentTx db = graph.getRawGraph();
        db.command(new OCommandSQL("create class Person extends V")).execute();
        db.command(new OCommandSQL("create property Person.name string")).execute();
        db.command(new OCommandSQL("create index Person.name on Person (name) fulltext engine lucene")).execute();
        db.command(new OCommandSQL("insert into Person set name='Enrico', age=18")).execute();
        OSQLSynchQuery query = new OSQLSynchQuery("select  from (select from Person where age = 18) where name lucene 'Enrico'");
        List results = db.command(query).execute();
        Assert.assertEquals(results.size(), 1);
        // WITH PROJECTION does not work as the class is missing
        query = new OSQLSynchQuery("select  from (select name  from Person where age = 18) where name lucene 'Enrico'");
        results = db.command(query).execute();
        Assert.assertEquals(results.size(), 0);
    } finally {
        graph.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) List(java.util.List) Test(org.junit.Test)

Aggregations

ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)590 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)257 Test (org.testng.annotations.Test)182 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)120 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)81 Test (org.junit.Test)79 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)61 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)47 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)46 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)41 ORID (com.orientechnologies.orient.core.id.ORID)39 ORecordId (com.orientechnologies.orient.core.id.ORecordId)34 Before (org.junit.Before)34 File (java.io.File)33 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)25 ArrayList (java.util.ArrayList)25 BeforeClass (org.testng.annotations.BeforeClass)23 BeforeMethod (org.testng.annotations.BeforeMethod)23 OStorage (com.orientechnologies.orient.core.storage.OStorage)21 List (java.util.List)20