Search in sources :

Example 1 with ORenameGraphMLImportStrategy

use of com.orientechnologies.orient.graph.graphml.ORenameGraphMLImportStrategy 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();
    }
}
Also used : ORenameGraphMLImportStrategy(com.orientechnologies.orient.graph.graphml.ORenameGraphMLImportStrategy) OGraphMLReader(com.orientechnologies.orient.graph.graphml.OGraphMLReader) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 OGraphMLReader (com.orientechnologies.orient.graph.graphml.OGraphMLReader)1 ORenameGraphMLImportStrategy (com.orientechnologies.orient.graph.graphml.ORenameGraphMLImportStrategy)1 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)1 Test (org.junit.Test)1