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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations