use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class TestGraphTransactionOnBatch method testReferToInTxCreatedAndDeletedVertex.
@Test
public void testReferToInTxCreatedAndDeletedVertex() {
try {
db.command(new OCommandScript("sql", "begin \n LET t0 = create vertex V set Mid = '1' \n" + "LET t1 = delete vertex V where Mid = '1' \n LET t2 = create vertex V set Mid = '2' \n" + "LET t4 = create edge E from $t2 to $t0 \n commit \n return [$t4] ")).execute();
Assert.fail("it should go in exception because referring to a in transaction delete vertex");
} catch (Exception ex) {
}
List<ODocument> res = db.query(new OSQLSynchQuery("select from E"));
Assert.assertEquals(res.size(), 0);
}
use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class TestGraphTransactionOnBatch method testDuplicateRollback.
@Test
public void testDuplicateRollback() {
OClass clazz = db.getMetadata().getSchema().createClass("Test");
clazz.setSuperClass(V);
clazz.createProperty("id", OType.STRING).createIndex(INDEX_TYPE.UNIQUE);
try {
db.command(new OCommandScript("sql", "BEGIN \n LET a = create vertex Test SET id = \"12345678\" \n LET b = create vertex Test SET id = \"4kkrPhGe\" \n LET c =create vertex Test SET id = \"4kkrPhGe\" \n COMMIT \n RETURN $b ")).execute();
Assert.fail("expected record duplicate exception");
} catch (ORecordDuplicatedException ex) {
}
try {
db.command(new OCommandScript("sql", "BEGIN \n LET a = create vertex Test content {\"id\": \"12345678\"} \n LET b = create vertex Test content {\"id\": \"4kkrPhGe\"} \n LET c =create vertex Test content { \"id\": \"4kkrPhGe\"} \n COMMIT \n RETURN $b ")).execute();
Assert.fail("expected record duplicate exception");
} catch (ORecordDuplicatedException ex) {
}
List<ODocument> res = db.query(new OSQLSynchQuery("select from Test"));
Assert.assertEquals(0, res.size());
}
use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class TestBatchRemoteResultSet method runBatchQuery.
@Test
public void runBatchQuery() {
String batchQuery = "begin; LET t0 = CREATE VERTEX V set mame=\"a\" ;\n LET t1 = CREATE VERTEX V set name=\"b\" ;\n" + "LET t2 = CREATE EDGE E FROM $t0 TO $t1 ;\n commit retry 100\n" + "return [$t0,$t1,$t2]";
OrientGraph graph = new OrientGraph("remote:localhost:3064/" + OrientGraphRemoteTest.class.getSimpleName(), "root", "root");
Iterable<OIdentifiable> res = graph.getRawGraph().command(new OCommandScript("sql", batchQuery)).execute();
Iterator iter = res.iterator();
assertTrue(iter.next() instanceof OIdentifiable);
assertTrue(iter.next() instanceof OIdentifiable);
Object edges = iter.next();
assertTrue(edges instanceof Collection);
assertTrue(((Collection) edges).iterator().next() instanceof OIdentifiable);
}
use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class LuceneVsLuceneTest method init.
@Before
public void init() {
InputStream stream = ClassLoader.getSystemResourceAsStream("testLuceneIndex.sql");
db.command(new OCommandScript("sql", getScriptFromStream(stream))).execute();
OSchema schema = db.getMetadata().getSchema();
OFileUtils.deleteRecursively(getPath().getAbsoluteFile());
try {
Directory dir = getDirectory();
analyzer = new OLucenePerFieldAnalyzerWrapper(new StandardAnalyzer());
analyzer.add("title", new StandardAnalyzer()).add("Song.title", new StandardAnalyzer());
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
indexWriter = new IndexWriter(dir, iwc);
} catch (IOException e) {
e.printStackTrace();
}
db.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class LuceneCreateIndexTest method loadAndTest.
@Test
public void loadAndTest() {
InputStream stream = ClassLoader.getSystemResourceAsStream("testLuceneIndex.sql");
db.command(new OCommandScript("sql", getScriptFromStream(stream))).execute();
db.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE METADATA {\"analyzer\":\"" + StandardAnalyzer.class.getName() + "\"}")).execute();
db.command(new OCommandSQL("create index Song.author on Song (author) FULLTEXT ENGINE LUCENE METADATA {\"analyzer\":\"" + StandardAnalyzer.class.getName() + "\"}")).execute();
ODocument doc = new ODocument("Song");
doc.field("title", "Local");
doc.field("author", "Local");
db.save(doc);
testMetadata();
assertQuery();
assertNewQuery();
db.close();
db.open("admin", "admin");
assertQuery();
assertNewQuery();
}
Aggregations