Commits

tbrugz committed 1a79945

datadump: small refactoring

Comments (0)

Files changed (2)

src/tbrugz/sqldump/datadump/DataDump.java

 
 		List<String> tables4dump = getTables4dump(prop);
 		
-		List<DumpSyntax> syntaxList = getSyntaxList(prop);
+		List<DumpSyntax> syntaxList = getSyntaxList(prop, PROP_DATADUMP_SYNTAXES);
 		if(syntaxList==null) {
 			log.error("no datadump syntax(es) defined [prop '"+PROP_DATADUMP_SYNTAXES+"']");
 			if(failonerror) {
 			) throws SQLException, IOException {
 		String charset = prop.getProperty(PROP_DATADUMP_CHARSET, CHARSET_DEFAULT);
 		long rowlimit = getTableRowLimit(prop, tableOrQueryName);
-		List<DumpSyntax> syntaxList = getSyntaxList(prop);
+		List<DumpSyntax> syntaxList = getSyntaxList(prop, PROP_DATADUMP_SYNTAXES);
 		if(syntaxList==null) {
 			log.error("no datadump syntax defined");
 			if(failonerror) {
 					initTime);
 	}
 
-	void dumpResultSet(ResultSet rs, Properties prop, 
+	public void dumpResultSet(ResultSet rs, Properties prop, 
 			String tableOrQueryId, String tableOrQueryName, String charset, 
 			long rowlimit,
 			List<DumpSyntax> syntaxList,
 			
 			long count = 0;
 			
+			if(charset==null) { charset = CHARSET_DEFAULT; }
+			
 			try {
 
 			//headers
 		}
 		return null;
 	}
-	
-	static List<DumpSyntax> getSyntaxList(Properties prop) {
-		String syntaxes = prop.getProperty(PROP_DATADUMP_SYNTAXES);
+		
+	static List<DumpSyntax> getSyntaxList(Properties prop, String dumpSyntaxesProperty) {
+		String syntaxes = prop.getProperty(dumpSyntaxesProperty);
 		if(syntaxes==null) {
 			return null;
 		}
 		
+		String[] syntaxArr = syntaxes.split(",");
+		return getSyntaxList(prop, syntaxArr);
+	}
+	
+	public static List<DumpSyntax> getSyntaxList(Properties prop, String[] dumpSyntaxes) {
 		List<DumpSyntax> syntaxList = new ArrayList<DumpSyntax>();
-		String[] syntaxArr = syntaxes.split(",");
-		for(String syntax: syntaxArr) {
+		for(String syntax: dumpSyntaxes) {
 			boolean syntaxAdded = false;
 			for(Class<? extends DumpSyntax> dsc: DumpSyntaxRegistry.getSyntaxes()) {
 				DumpSyntax ds = (DumpSyntax) Utils.getClassInstance(dsc);

src/tbrugz/sqldump/datadump/SQLQueries.java

 	
 	@Override
 	public void process() {
-		DataDump dd = new DataDump();
 		boolean runQueries = true;
 		boolean addQueriesToModel = false;
 		
 			if(runQueries) {
 				try {
 					log.debug("running query [id="+qid+"; name="+queryName+"]: "+sql);
+					DataDump dd = new DataDump();
 					dd.runQuery(conn, stmt, params, prop, qid, queryName, charset, rowlimit, syntaxList, 
 							partitionsBy!=null ? partitionsBy.toArray(new String[]{}) : null, 
 							keyCols, null, null, rsdf);