use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OGremlinConsoleTest method testMoveVertexCommand.
@Test
public void testMoveVertexCommand() {
final String INPUT_FILE = "src/test/resources/graph-example-2.xml";
String dbUrl = "memory:testMoveVertexCommand";
StringBuilder builder = new StringBuilder();
builder.append("create database " + dbUrl + ";\n");
builder.append("import database " + INPUT_FILE + " batchSize=10;\n");
builder.append("create class newposition extends V;\n");
builder.append("move vertex (select from V) to class:newposition;\n");
OConsoleDatabaseApp console = new TestOGremlinConsole(new String[] { builder.toString() });
try {
console.run();
ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl);
db.open("admin", "admin");
try {
List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from newposition"));
Assert.assertFalse(result.isEmpty());
} finally {
db.close();
}
} finally {
console.close();
}
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OGremlinConsoleTest method testGraphMLImportDirect.
@Test
public void testGraphMLImportDirect() throws IOException {
final String INPUT_FILE = "src/test/resources/graph-example-fromexport.xml";
String dbUrl = "memory:testGraphMLImportDirect";
new OGraphMLReader(new OrientGraphNoTx(dbUrl)).inputGraph(INPUT_FILE);
ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl);
db.open("admin", "admin");
try {
boolean foundTypeVAttr = false;
boolean foundFriendEAttr = false;
List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from V"));
Assert.assertFalse(result.isEmpty());
for (ODocument d : result) {
if (d.containsField("__type__"))
foundTypeVAttr = true;
}
Assert.assertTrue(foundTypeVAttr);
result = db.query(new OSQLSynchQuery<ODocument>("select from E"));
Assert.assertFalse(result.isEmpty());
for (ODocument d : result) {
if (d.containsField("friend"))
foundFriendEAttr = true;
}
Assert.assertTrue(foundFriendEAttr);
} finally {
db.close();
}
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OGremlinConsoleTest method testGraphMLImportIgnoreEAttribute.
@Test
public void testGraphMLImportIgnoreEAttribute() throws IOException {
final String INPUT_FILE = "src/test/resources/graph-example-fromexport.xml";
String dbUrl = "memory:testGraphMLImportIgnoreEAttribute";
new OGraphMLReader(new OrientGraphNoTx(dbUrl)).defineEdgeAttributeStrategy("friend", new OIgnoreGraphMLImportStrategy()).inputGraph(INPUT_FILE);
ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl);
db.open("admin", "admin");
try {
List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from E"));
Assert.assertFalse(result.isEmpty());
for (ODocument d : result) {
Assert.assertFalse(d.containsField("friend"));
}
} finally {
db.close();
}
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OGremlinConsoleTest method testGraphSONImport.
@Test
public void testGraphSONImport() throws IOException {
final String INPUT_FILE = "src/test/resources/graph-example-fromexport.xml";
String dbUrl1 = "memory:testGraphSONImport1";
String dbUrl2 = "memory:testGraphSONImport2";
final OrientGraphNoTx g1 = new OrientGraphNoTx(dbUrl1);
new OGraphMLReader(g1).inputGraph(INPUT_FILE);
// EXPORT IN GRAPHSON FORMAT
final ByteArrayOutputStream output = new ByteArrayOutputStream();
new GraphSONWriter(g1).outputGraph(output, null, null, GraphSONMode.NORMAL);
final OrientGraphNoTx g2 = new OrientGraphNoTx(dbUrl2);
ByteArrayInputStream is = new ByteArrayInputStream(output.toByteArray());
new OGraphSONReader(g2).inputGraph(is);
ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl2);
db.open("admin", "admin");
try {
boolean foundTypeVAttr = false;
boolean foundFriendEAttr = false;
List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from V"));
Assert.assertFalse(result.isEmpty());
for (ODocument d : result) {
if (d.containsField("__type__"))
foundTypeVAttr = true;
}
Assert.assertTrue(foundTypeVAttr);
result = db.query(new OSQLSynchQuery<ODocument>("select from E"));
Assert.assertFalse(result.isEmpty());
for (ODocument d : result) {
if (d.containsField("friend"))
foundFriendEAttr = true;
}
Assert.assertTrue(foundFriendEAttr);
} finally {
db.close();
}
}
use of com.orientechnologies.orient.core.record.impl.ODocument in project orientdb by orientechnologies.
the class OGremlinConsoleTest method testGraphMLImportRenameVAttribute.
@Test
public void testGraphMLImportRenameVAttribute() throws IOException {
final String INPUT_FILE = "src/test/resources/graph-example-fromexport.xml";
String dbUrl = "memory:testGraphMLImportRenameVAttribute";
final OrientGraphNoTx graph = new OrientGraphNoTx(dbUrl);
try {
new OGraphMLReader(graph).defineVertexAttributeStrategy("__type__", new ORenameGraphMLImportStrategy("t")).inputGraph(INPUT_FILE);
ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl);
db.open("admin", "admin");
try {
List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from Person"));
Assert.assertFalse(result.isEmpty());
for (ODocument d : result) {
Assert.assertTrue(d.containsField("t"));
Assert.assertFalse(d.containsField("__type__"));
}
} finally {
db.close();
}
} finally {
graph.shutdown();
}
}
Aggregations