import java.sql.*;
import java.io.*;
import java.awt.Color;
import uk.ac.ic.doc.automed.*;
import uk.ac.ic.doc.automed.reps.*;
import uk.ac.ic.doc.automed.wrappers.*;

/*
 * An application to demonstrate how to setup models (i.e. modelling
 * languages such as ER, Relational, etc) using the
 * Automed API
 */

public class DefineRepository {
  // Generic reinitialise of a repository, to clear the main repositories,
  // call this twice, once with "MDR" and once with "STR"
  public static void initialiseRepository(String sourceName)
  throws DSRException, SQLException, IOException {
    String sa[]=new String[]{"",sourceName};

    DSR.doDropdbCommand(sa);
    DSR.doCreatedbCommand(sa);
    System.out.println("Repository "+sourceName+" initialised");
  }

  public static void main(String[] args) {
    try {
      System.out.println("AutoMed Repository Reinitialisation");

      STR.setDebugLevel(0);
      initialiseRepository(MDR.getDataSourceName());      
      initialiseRepository(STR.getDataSourceName());
      initialiseRepository(SchemaModelingRepository.getDataSourceName());
      initialiseRepository(TemplateExecutionRepository.getDataSourceName());
      initialiseRepository(TemplateTransformationRepository.getDataSourceName());
      initialiseRepository(TemplateTransformationSyntaxRepository.getDataSourceName());
      
      /*dmle 6/12/2005: create HDM models and its types */
      System.out.println("Intialising HDM model...");
      HDMWrapperFactory hdmf = new HDMWrapperFactory();
      hdmf.createModel();      
    }
    catch (SQLException se) { 
      se.printStackTrace();
    }
    catch (IOException ie) {
      ie.printStackTrace();
    } 
    catch (AutoMedException ame) {
      ame.printStackTrace();
    }      
  }
}

























