Search in sources :

Example 6 with OSchemaProxy

use of com.orientechnologies.orient.core.metadata.schema.OSchemaProxy in project orientdb by orientechnologies.

the class SQLSelectTest method testExpandSkip.

@Test
public void testExpandSkip() {
    OSchemaProxy schema = database.getMetadata().getSchema();
    OClass v = schema.getClass("V");
    final OClass cls = schema.createClass("TestExpandSkip", v);
    cls.createProperty("name", OType.STRING);
    cls.createIndex("TestExpandSkip.name", INDEX_TYPE.UNIQUE, "name");
    database.command(new OCommandSQL("CREATE VERTEX TestExpandSkip set name = '1'")).execute();
    database.command(new OCommandSQL("CREATE VERTEX TestExpandSkip set name = '2'")).execute();
    database.command(new OCommandSQL("CREATE VERTEX TestExpandSkip set name = '3'")).execute();
    database.command(new OCommandSQL("CREATE VERTEX TestExpandSkip set name = '4'")).execute();
    database.command(new OCommandSQL("CREATE EDGE E FROM (SELECT FROM TestExpandSkip WHERE name = '1') to (SELECT FROM TestExpandSkip WHERE name <> '1')")).execute();
    List<OIdentifiable> result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out()) from TestExpandSkip where name = '1'"));
    Assert.assertEquals(result.size(), 3);
    Map<Object, Object> params = new HashMap<Object, Object>();
    params.put("values", Arrays.asList(new String[] { "2", "3", "antani" }));
    result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out()[name in :values]) from TestExpandSkip where name = '1'"), params);
    Assert.assertEquals(result.size(), 2);
    result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out()) from TestExpandSkip where name = '1' skip 1"));
    Assert.assertEquals(result.size(), 2);
    result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out()) from TestExpandSkip where name = '1' skip 2"));
    Assert.assertEquals(result.size(), 1);
    result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out()) from TestExpandSkip where name = '1' skip 3"));
    Assert.assertEquals(result.size(), 0);
    result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out()) from TestExpandSkip where name = '1' skip 1 limit 1"));
    Assert.assertEquals(result.size(), 1);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test)

Example 7 with OSchemaProxy

use of com.orientechnologies.orient.core.metadata.schema.OSchemaProxy in project orientdb by orientechnologies.

the class SQLSelectTest method testPolymorphicEdges.

@Test
public void testPolymorphicEdges() {
    OSchemaProxy schema = database.getMetadata().getSchema();
    OClass v = schema.getClass("V");
    OClass e = schema.getClass("E");
    final OClass v1 = schema.createClass("TestPolymorphicEdges_V", v);
    final OClass e1 = schema.createClass("TestPolymorphicEdges_E1", e);
    final OClass e2 = schema.createClass("TestPolymorphicEdges_E2", e1);
    database.command(new OCommandSQL("CREATE VERTEX TestPolymorphicEdges_V set name = '1'")).execute();
    database.command(new OCommandSQL("CREATE VERTEX TestPolymorphicEdges_V set name = '2'")).execute();
    database.command(new OCommandSQL("CREATE VERTEX TestPolymorphicEdges_V set name = '3'")).execute();
    database.command(new OCommandSQL("CREATE EDGE TestPolymorphicEdges_E1 FROM (SELECT FROM TestPolymorphicEdges_V WHERE name = '1') to (SELECT FROM TestPolymorphicEdges_V WHERE name = '2')")).execute();
    database.command(new OCommandSQL("CREATE EDGE TestPolymorphicEdges_E2 FROM (SELECT FROM TestPolymorphicEdges_V WHERE name = '1') to (SELECT FROM TestPolymorphicEdges_V WHERE name = '3')")).execute();
    List<OIdentifiable> result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out('TestPolymorphicEdges_E1')) from TestPolymorphicEdges_V where name = '1'"));
    Assert.assertEquals(result.size(), 2);
    result = database.query(new OSQLSynchQuery<OIdentifiable>("select expand(out('TestPolymorphicEdges_E2')) from TestPolymorphicEdges_V where name = '1' "));
    Assert.assertEquals(result.size(), 1);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test)

Example 8 with OSchemaProxy

use of com.orientechnologies.orient.core.metadata.schema.OSchemaProxy in project orientdb by orientechnologies.

the class SQLSelectTest method testSizeOfLink.

@Test
public void testSizeOfLink() {
    OSchemaProxy schema = database.getMetadata().getSchema();
    OClass v = schema.getClass("V");
    final OClass cls = schema.createClass("TestSizeOfLink", v);
    database.command(new OCommandSQL("CREATE VERTEX TestSizeOfLink set name = '1'")).execute();
    database.command(new OCommandSQL("CREATE VERTEX TestSizeOfLink set name = '2'")).execute();
    database.command(new OCommandSQL("CREATE VERTEX TestSizeOfLink set name = '3'")).execute();
    database.command(new OCommandSQL("CREATE EDGE E FROM (SELECT FROM TestSizeOfLink WHERE name = '1') to (SELECT FROM TestSizeOfLink WHERE name <> '1')")).execute();
    List<OIdentifiable> result = database.query(new OSQLSynchQuery<OIdentifiable>(" select from (select from TestSizeOfLink where name = '1') where out()[name=2].size() > 0"));
    Assert.assertEquals(result.size(), 1);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test)

Example 9 with OSchemaProxy

use of com.orientechnologies.orient.core.metadata.schema.OSchemaProxy in project orientdb by orientechnologies.

the class ODatabaseDocumentTx method dropCluster.

@Override
public boolean dropCluster(final int iClusterId, final boolean iTruncate) {
    checkIfActive();
    checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_DELETE);
    OSchemaProxy schema = metadata.getSchema();
    final OClass clazz = schema.getClassByClusterId(iClusterId);
    if (clazz != null)
        clazz.removeClusterId(iClusterId);
    getLocalCache().freeCluster(iClusterId);
    if (schema.getBlobClusters().contains(iClusterId))
        schema.removeBlobCluster(getClusterNameById(iClusterId));
    storage.checkForClusterPermissions(getClusterNameById(iClusterId));
    return storage.dropCluster(iClusterId, iTruncate);
}
Also used : OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OClass(com.orientechnologies.orient.core.metadata.schema.OClass)

Example 10 with OSchemaProxy

use of com.orientechnologies.orient.core.metadata.schema.OSchemaProxy in project orientdb by orientechnologies.

the class ODatabaseDocumentTx method dropCluster.

@Override
public boolean dropCluster(final String iClusterName, final boolean iTruncate) {
    checkIfActive();
    checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_DELETE);
    final int clusterId = getClusterIdByName(iClusterName);
    OSchemaProxy schema = metadata.getSchema();
    OClass clazz = schema.getClassByClusterId(clusterId);
    if (clazz != null)
        clazz.removeClusterId(clusterId);
    if (schema.getBlobClusters().contains(clusterId))
        schema.removeBlobCluster(iClusterName);
    getLocalCache().freeCluster(clusterId);
    storage.checkForClusterPermissions(iClusterName);
    return storage.dropCluster(iClusterName, iTruncate);
}
Also used : OSchemaProxy(com.orientechnologies.orient.core.metadata.schema.OSchemaProxy) OClass(com.orientechnologies.orient.core.metadata.schema.OClass)

Aggregations

OSchemaProxy (com.orientechnologies.orient.core.metadata.schema.OSchemaProxy)17 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)14 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)10 Test (org.testng.annotations.Test)10 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)7 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)6 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)3 Test (org.junit.Test)3 Date (java.util.Date)2 OException (com.orientechnologies.common.exception.OException)1 OCommandCacheSoftRefs (com.orientechnologies.orient.core.cache.OCommandCacheSoftRefs)1 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 OSecurityException (com.orientechnologies.orient.core.exception.OSecurityException)1 OIndexManager (com.orientechnologies.orient.core.index.OIndexManager)1 OIndexManagerProxy (com.orientechnologies.orient.core.index.OIndexManagerProxy)1 OIndexManagerRemote (com.orientechnologies.orient.core.index.OIndexManagerRemote)1 OIndexManagerShared (com.orientechnologies.orient.core.index.OIndexManagerShared)1 OFunctionLibrary (com.orientechnologies.orient.core.metadata.function.OFunctionLibrary)1 OFunctionLibraryImpl (com.orientechnologies.orient.core.metadata.function.OFunctionLibraryImpl)1 OFunctionLibraryProxy (com.orientechnologies.orient.core.metadata.function.OFunctionLibraryProxy)1