You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
3.7 KiB
137 lines
3.7 KiB
package de.superx.elt; |
|
import static de.superx.servlet.SxSQL_Server.DEFAULT_MANDANTEN_ID; |
|
import java.io.File; |
|
import java.io.FileNotFoundException; |
|
import java.io.IOException; |
|
import java.sql.Connection; |
|
import java.sql.ResultSet; |
|
import java.sql.SQLException; |
|
import java.sql.Statement; |
|
import java.sql.DatabaseMetaData; |
|
import java.util.HashMap; |
|
import java.util.Hashtable; |
|
import java.util.Iterator; |
|
import java.util.Properties; |
|
import java.util.StringTokenizer; |
|
import java.util.logging.Level; |
|
import java.util.logging.Logger; |
|
|
|
import de.memtext.db.ConnectionCreator; |
|
import de.memtext.util.DateUtils; |
|
import de.memtext.util.GetOpts; |
|
import de.memtext.util.StringUtils; |
|
import de.superx.common.DBServletException; |
|
import de.superx.common.FieldContainer; |
|
import de.superx.common.Sichten; |
|
import de.superx.common.StandaloneSicht; |
|
import de.superx.common.SuperX_el; |
|
import de.superx.common.SxResultRow; |
|
import de.superx.common.SxResultSet; |
|
import de.superx.common.SxSqlHelper; |
|
import de.superx.common.SxUser; |
|
import de.superx.common.TableFieldExists; |
|
import de.superx.common.TemplateProcessor; |
|
import de.superx.servlet.SuperXManager; |
|
import de.superx.servlet.SxPools; |
|
import de.superx.servlet.SxSQL_Server; |
|
import de.superx.util.PropsReader; |
|
import de.superx.util.SqlStringUtils; |
|
|
|
public class EtlFmParser extends TemplateProcessor { |
|
private String dbprop, infile, outfile; |
|
private Properties props; |
|
|
|
private Statement stm; |
|
private String isSimpleParser; |
|
private static String sqlDialect; |
|
|
|
EtlFmParser(String mandantenID, Connection con) { |
|
super(mandantenID,con); |
|
|
|
} |
|
|
|
|
|
|
|
private void initConAndParser() throws IOException, SQLException, |
|
ClassNotFoundException { |
|
|
|
stm = con.createStatement(); |
|
if(SqlStringUtils.tableExists(con,"fm_templates",DEFAULT_MANDANTEN_ID)) |
|
{ |
|
setTemplates(readFromDb("select trim(both from id),content from fm_templates")); |
|
repositoryToMap(readFromDb(REPOSITORY_SELECT), repositoryMap); |
|
} |
|
if(SqlStringUtils.tableExists(con,"konstanten",DEFAULT_MANDANTEN_ID)) |
|
{ |
|
SxResultSet rs = readFromDb("select trim(both from beschreibung),apnr from konstanten"); |
|
for (Iterator it = rs.iterator(); it.hasNext();) { |
|
SxResultRow row = (SxResultRow) it.next(); |
|
String beschreibung = (String) row.get(0); |
|
|
|
repositoryMap.put("K_" + beschreibung.trim(), row.get(1)); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
protected SxResultSet readFromDb(String sql) throws SQLException { |
|
SuperX_el el = new SuperX_el(); |
|
|
|
SxSqlHelper sh=new SxSqlHelper(); |
|
sh.execute(sql, this.con, el); |
|
|
|
|
|
if (el.getError_String() != null |
|
&& !el.getError_String().trim().equals("")) |
|
throw new SQLException("\nProblem bei:" + "\n\n Meldung:" |
|
+ el.getError_String() + "\n sql:" + sql); |
|
|
|
return el.getResultSet(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
* Einfacher Parser für Fremddatenbanken, nur sqlDialect wird übergeben wird |
|
* von DOSQL direkt aufgerufen |
|
*/ |
|
public String simpleParser( String input) |
|
throws FileNotFoundException, IOException, Exception { |
|
String output = ""; |
|
sqlDialect = "Postgres";// de.superx.util.SqlStringUtils.getSqlDialect(props .getProperty("driverName")); |
|
initConAndParser(); |
|
HashMap map = new HashMap(); |
|
try { |
|
output = "--automatically created by SuperX/Freemarker for " |
|
+ sqlDialect |
|
+ " (" |
|
+ DateUtils.getTodayString() |
|
+ " " |
|
+ DateUtils.getNowString() |
|
+ ")\n" |
|
+ process("FM-Parsing ", input, map, |
|
sqlDialect); |
|
|
|
} catch (Exception e) { |
|
System.err.println("Fehler beim FM-Parsen "); |
|
e.printStackTrace(); |
|
System.exit(1); |
|
} |
|
return output; |
|
|
|
} |
|
|
|
} |
|
|
|
// Created on 08.12.2006 at 18:03:46 |
|
|
|
|
|
|
|
|