Search in sources :

Example 56 with OCommandSQL

use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.

the class LuceneInsertUpdateSingleDocumentNoTxTest method init.

@Before
public void init() {
    OSchema schema = db.getMetadata().getSchema();
    OClass oClass = schema.createClass("City");
    oClass.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Before(org.junit.Before)

Example 57 with OCommandSQL

use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.

the class LuceneInsertUpdateTest method init.

@Before
public void init() {
    OSchema schema = db.getMetadata().getSchema();
    OClass oClass = schema.createClass("City");
    oClass.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Before(org.junit.Before)

Example 58 with OCommandSQL

use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.

the class LuceneInsertUpdateTransactionTest method init.

@Before
public void init() {
    OSchema schema = db.getMetadata().getSchema();
    OClass oClass = schema.createClass("City");
    oClass.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Before(org.junit.Before)

Example 59 with OCommandSQL

use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.

the class CRUDDocumentValidationTest method validationDisabledAdDatabaseLevel.

@Test(dependsOnMethods = "validationMandatoryNullableNoCloseDb")
public void validationDisabledAdDatabaseLevel() throws ParseException {
    database.getMetadata().reload();
    try {
        ODocument doc = new ODocument("MyTestClass");
        doc.save();
        Assert.fail();
    } catch (OValidationException e) {
    }
    database.command(new OCommandSQL("ALTER DATABASE " + ODatabase.ATTRIBUTES.VALIDATION.name() + " FALSE")).execute();
    database.setValidationEnabled(false);
    try {
        ODocument doc = new ODocument("MyTestClass");
        doc.save();
        doc.delete();
    } finally {
        database.setValidationEnabled(true);
        database.command(new OCommandSQL("ALTER DATABASE " + ODatabase.ATTRIBUTES.VALIDATION.name() + " TRUE")).execute();
    }
}
Also used : OValidationException(com.orientechnologies.orient.core.exception.OValidationException) OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 60 with OCommandSQL

use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.

the class CRUDDocumentValidationTest method createSchemaForMandatoryNullableTest.

@Test(dependsOnMethods = "closeDb")
public void createSchemaForMandatoryNullableTest() throws ParseException {
    if (database.getMetadata().getSchema().existsClass("MyTestClass")) {
        database.getMetadata().getSchema().dropClass("MyTestClass");
        database.getMetadata().getSchema().reload();
    }
    database.command(new OCommandSQL("CREATE CLASS MyTestClass")).execute();
    database.command(new OCommandSQL("CREATE PROPERTY MyTestClass.keyField STRING")).execute();
    database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.keyField MANDATORY true")).execute();
    database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.keyField NOTNULL true")).execute();
    database.command(new OCommandSQL("CREATE PROPERTY MyTestClass.dateTimeField DATETIME")).execute();
    database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.dateTimeField MANDATORY true")).execute();
    database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.dateTimeField NOTNULL false")).execute();
    database.command(new OCommandSQL("CREATE PROPERTY MyTestClass.stringField STRING")).execute();
    database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.stringField MANDATORY true")).execute();
    database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.stringField NOTNULL false")).execute();
    database.command(new OCommandSQL("INSERT INTO MyTestClass (keyField,dateTimeField,stringField) VALUES (\"K1\",null,null)")).execute();
    database.reload();
    database.getMetadata().reload();
    database.close();
    database.open("admin", "admin");
    OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("SELECT FROM MyTestClass WHERE keyField = ?");
    List<ODocument> result = database.query(query, "K1");
    Assert.assertEquals(1, result.size());
    ODocument doc = result.get(0);
    Assert.assertTrue(doc.containsField("keyField"));
    Assert.assertTrue(doc.containsField("dateTimeField"));
    Assert.assertTrue(doc.containsField("stringField"));
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)621 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)422 Test (org.junit.Test)97 Test (org.testng.annotations.Test)93 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)83 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)79 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)78 ORID (com.orientechnologies.orient.core.id.ORID)64 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)61 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)54 Set (java.util.Set)53 HashMap (java.util.HashMap)45 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)42 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)41 List (java.util.List)25 Before (org.junit.Before)24 OStorage (com.orientechnologies.orient.core.storage.OStorage)23 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)23 ORecordId (com.orientechnologies.orient.core.id.ORecordId)21 Vertex (com.tinkerpop.blueprints.Vertex)19