/**
* This package contrains the controller classes, which control the application.
*/
package org.uploadDB.controller;
import org.uploadDB.Connect.CreateTable;
import org.uploadDB.Connect.InsertTable;
import org.uploadDB.core.ParseFile;
import org.uploadDB.ui.ConnectionScreen;
public class CreateController {
private CreateTable ct;
private InsertTable it;
public void CreateTable (ConnectionScreen cs, ConnectController cc, CSVParserController csvc) {
//Create a parsefile object.
ParseFile pf = new ParseFile(false);
//Let the parse file methods analyse the file to get the field values and the field length.
pf.ReadFirstLine(cs.getFileOpen().getSelectedFile());
pf.AnalyseFile(cs.getFileOpen().getSelectedFile());
//Set the db connection for the createtable object
ct = new CreateTable();
ct.setDbCon(cc.getDbCon());
ct.setTableName(cs.getFTableName().getText());
ct.createtable(cc.getDbCon(), pf.getTableLayout(), pf.getFieldLength());
//Create an inserttable object and sets it name.
it = new InsertTable(false);
it.setDbCon(cc.getDbCon());
it.setTableName(cs.getFTableName().getText());
it.ReadFile(cc.getDbCon(), cs.getFileOpen().getSelectedFile(), pf.getTableLayout(),pf.getCsvStrat());
//Disconnect from DB
try {
cc.getDbCon().disConnect();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @param ct the ct to set
*/
public void setCt(CreateTable ct) {
this.ct = ct;
}
/**
* @return the ct
*/
public CreateTable getCt() {
return ct;
}
/**
* @param it the it to set
*/
public void setIt(InsertTable it) {
this.it = it;
}
/**
* @return the it
*/
public InsertTable getIt() {
return it;
}
}