package semistructured.xml.biomap;

import uk.ac.bbk.dcs.automed.xml.relational.XMLDSSFromRDB;
import uk.ac.bbk.dcs.automed.xml.wrappers.DOMWrapperFactory;
import uk.ac.ic.doc.automed.reps.Schema;

/**
 * Class Task Description
 * 
 * @author <a href="mailto:lucas@dcs.bbk.ac.uk">Lucas Zamboulis </a>
 */
public class GlobalWrapping {

    public static void main(String[] args) {
        System.out.println("Starting wrapping Global data source: " + System.currentTimeMillis());
        String globalUsername = "global";
        String password = "sqlex";
        String driver = "oracle.jdbc.driver.OracleDriver";
        String globalSchemaName = globalUsername.toUpperCase();
        String urlbase = "jdbc:oracle:thin:";
        String url = urlbase + '@' + "193.61.29.5:1521:teach";

        try {
            if (Schema.exists(globalSchemaName)) {
                System.out.print("Deleting old schema " + globalSchemaName + "...");
                Schema.retract(globalSchemaName);
                System.out.println("done.");
            }
            DOMWrapperFactory xwf = new DOMWrapperFactory();
            xwf.setFeatures(DOMWrapperFactory.WHITESPACE_COLLAPSE);

            XMLDSSFromRDB globalTool = new XMLDSSFromRDB(XMLDSSFromRDB.oracle, globalUsername, password, driver, url, globalSchemaName);

            System.out.println("Before list schema: " + System.currentTimeMillis());
            System.out.println("\nFinal Schema " + globalSchemaName + "\n");
            globalTool.getXMLDSSSchema().listSchema();
            System.out.println("After list schema: " + System.currentTimeMillis());
            System.out.println("Finished wrapping Global data source: " + System.currentTimeMillis());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
