package com.master.thesis;

import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert;
import com.tinkerpop.blueprints.oupls.sail.*;
import com.tinkerpop.blueprints.KeyIndexableGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;

import org.junit.Test;
import org.openrdf.rio.RDFFormat;
import org.openrdf.sail.Sail;
import org.openrdf.sail.SailConnection;
import org.openrdf.sail.memory.MemoryStore;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.assertEquals;

public class LoadData {
	
	static Sail sail;
	
    public void testAll(File f) throws Exception {
    	
        OrientGraph og = new OrientGraph("remote:diufpc307/test2", "admin", "admin");

        //for 
        og.setUseVertexFieldsForEdgeLabels(false);
        og.setUseClassForEdgeLabel(false);
        
        GraphSail sail = new GraphSail(og);
        
        sail.initialize();
        
        try {
            SailLoader loader = new SailLoader(sail);
           // File f = resourceToFile("scale1000.nt"); // not used anymore as file path sent from commandline
            SailConnection sc = sail.getConnection();

            try {
                sc.begin();
               // assertEquals(0, sc.size());
                loader.load(f);
                sc.rollback();
               // assertEquals(377241, sc.size());
            } finally {
                sc.close();
            }
        } finally {
            sail.shutDown();
        }
    }

 }