package cc.topicexplorer.plugin.wordtype.preprocessing.tables.documenttermtopic;

import java.sql.SQLException;

import cc.topicexplorer.chain.commands.TableCreateCommand;

/**
 * @author user
 * 
 */
public class DocumentTermTopicCreate extends TableCreateCommand {

	@Override
	public void createTable() throws SQLException {
		database.executeUpdateQuery("ALTER IGNORE TABLE `" + this.tableName
				+ "` ADD COLUMN WORDTYPE$WORDTYPE varchar(255) COLLATE utf8_bin NOT NULL;");
	}

	@Override
	public void dropTable() throws SQLException {
		// database.dropTable(this.tableName);
		try {
			this.database.executeUpdateQuery("ALTER TABLE " + this.tableName
					+ " DROP COLUMN WORDTYPE$WORDTYPE");
		} catch (Exception e) {
			logger.warn("Document.dropColumns: Cannot drop column, perhaps it doesn't exists. Doesn't matter ;)");

		}
	}

	@Override
	public void setTableName() {
		tableName = "DOCUMENT_TERM_TOPIC";
	}
	
	@Override
	public void addDependencies() {
		beforeDependencies.add("DocumentTermTopicCreate");
		afterDependencies.add("InFilePreparation");
	}	
}
@@ -299,38 +299,27 @@
 Table() 
-throws SQLException
+%7B%0A%09%09try
  %7B%0A
+%09
 %09%09databa
@@ -376,24 +376,25 @@
 s.tableName%0A
+%09
 %09%09%09%09+ %22%60 ADD
@@ -467,54 +467,18 @@
 );%0A%09
-%7D%0A%0A%09@Override%0A%09public void dropTable() throws 
+%09%7D catch (
 SQLE
@@ -489,51 +489,184 @@
 tion
+ e)
  %7B%0A%09%09
-// database.dropTable(this.tableName);
+%09logger.error(%22Column WORDTYPE$WORDTYPE could not be added to table %22 + this.tableName);%0A%09%09%09throw new RuntimeException(e);%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void dropTable() %7B
 %0A%09%09t
@@ -737,22 +737,17 @@
 ableName
-%0A%09%09%09%09%09
+ 
 + %22 DROP
@@ -786,16 +786,19 @@
  catch (
+SQL
 Exceptio
@@ -796,32 +796,171 @@
 LException e) %7B%0A
+%09%09%09if (e.getErrorCode() != 1091) %7B // MySQL Error code for: 'Can't //%0A%09%09%09%09%09%09%09%09%09%09%09// DROP..; check that column/key //%0A%09%09%09%09%09%09%09%09%09%09%09// exists%0A%09
 %09%09%09logger.warn(%22
@@ -957,12 +957,13 @@
 ger.
-warn
+error
 (%22Do
@@ -1004,57 +1004,52 @@
 lumn
-, perhaps it doesn't exists. Doesn't matter ;)%22);
+.%22);%0A%09%09%09%09throw new RuntimeException(e);%0A%09%09%09%7D
 %0A%0A%09%09
@@ -1135,17 +1135,16 @@
 IC%22;%0A%09%7D%0A
-%09
 %0A%09@Overr
@@ -1281,11 +1281,10 @@
 on%22);%0A%09%7D
-%09
 %0A%7D

FEHLERB. (wordtype-preprocessing): - Kommandos entscheiden selbständig, ob sie erfolgreich abgearbeitet wurden - Checked Exceptions aus Methodensignatur entfernen - kleinere Überarbeitungen