14 changed files with 392 additions and 10 deletions
			
			
		@ -0,0 +1,68 @@
				@@ -0,0 +1,68 @@
					 | 
				
			||||
--Freemarker Template | 
				
			||||
 | 
				
			||||
--used in etl-job qa_project_upload | 
				
			||||
<#if SQLdialect='Postgres'> | 
				
			||||
drop table if exists tmp_rpta_resultset; | 
				
			||||
drop table if exists tmp_etl_rpta_column_layout; | 
				
			||||
drop table if exists tmp_rpta_column; | 
				
			||||
drop table if exists tmp_rpta_column2layout; | 
				
			||||
</#if> | 
				
			||||
 | 
				
			||||
 | 
				
			||||
CREATE TABLE tmp_rpta_resultset ( | 
				
			||||
    tid integer, | 
				
			||||
    caption character varying(255), | 
				
			||||
    uniquename character varying(255), | 
				
			||||
    fieldclause text, | 
				
			||||
    joinclause text, | 
				
			||||
    whereclause text, | 
				
			||||
    systeminfo_id integer, | 
				
			||||
    is_virtual smallint | 
				
			||||
); | 
				
			||||
 | 
				
			||||
 | 
				
			||||
CREATE TABLE tmp_etl_rpta_column_layout ( | 
				
			||||
    tid integer, | 
				
			||||
    uniquename character varying(255), | 
				
			||||
    caption character varying(255), | 
				
			||||
    resultset_id integer, | 
				
			||||
    whereclause text, | 
				
			||||
    description text, | 
				
			||||
    userinfo_id integer, | 
				
			||||
    sortnr integer, | 
				
			||||
    sortclause text, | 
				
			||||
    is_virtual smallint, | 
				
			||||
    resultset_uniquename character varying(255) | 
				
			||||
); | 
				
			||||
 | 
				
			||||
CREATE TABLE tmp_rpta_column ( | 
				
			||||
    tid integer, | 
				
			||||
    uniquename character varying(255), | 
				
			||||
    caption character varying(255), | 
				
			||||
    srcfieldname character varying(255), | 
				
			||||
    column_type integer, | 
				
			||||
    col_function text, | 
				
			||||
    is_aggregate smallint, | 
				
			||||
    resultset_id integer, | 
				
			||||
    custom integer, | 
				
			||||
    description text, | 
				
			||||
    targetfieldname character varying(255) | 
				
			||||
); | 
				
			||||
 | 
				
			||||
 | 
				
			||||
CREATE TABLE tmp_rpta_column2layout ( | 
				
			||||
    tid integer, | 
				
			||||
    column_id integer, | 
				
			||||
    layout_id integer, | 
				
			||||
    sortnr smallint, | 
				
			||||
    is_visible smallint, | 
				
			||||
    visible_size smallint, | 
				
			||||
    targetfieldname character varying(255), | 
				
			||||
    caption character varying(255), | 
				
			||||
    description text, | 
				
			||||
    format_code character varying(255), | 
				
			||||
    format_code_id integer | 
				
			||||
); | 
				
			||||
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
@ -1,3 +1,4 @@
				@@ -1,3 +1,4 @@
					 | 
				
			||||
1^MASK^Masken^0^sx_select_mask^sx_insert_mask^TID^42000^42006^1^ | 
				
			||||
2^SICHT^Sichten^0^sichten_unload^sichten_upload^SYSTEMINFO_ID^42000^42004^1^ | 
				
			||||
3^QA_PROJECT^Testfälle^0^qa_project_unload^qa_project_upload^QA_PROJECT_ID^42000^42007^1^ | 
				
			||||
4^RPTA_COLUMN_LAYOUT^Spaltenlayouts^0^rpta_column_layout_unload^rpta_column_layout_upload^RPTA_COLUMN_LAYOUT_TID^42000^42008^1^ | 
				
			||||
				 
					 | 
				
			||||
@ -0,0 +1,40 @@
				@@ -0,0 +1,40 @@
					 | 
				
			||||
--freemarker template | 
				
			||||
<#include "SQL_lingua_franca"/> | 
				
			||||
<#include "SuperX_general"/> | 
				
			||||
<#include "RPTA-Makros"/> | 
				
			||||
 | 
				
			||||
<sqlvars> | 
				
			||||
<sqlvar name="rpta_column_layout" type="hash"> | 
				
			||||
select uniquename, | 
				
			||||
caption, | 
				
			||||
resultset_uniquename as rpta_resultset, | 
				
			||||
whereclause, | 
				
			||||
description, | 
				
			||||
sortclause, | 
				
			||||
is_virtual | 
				
			||||
from tmp_etl_rpta_column_layout; | 
				
			||||
</sqlvar> | 
				
			||||
<sqlvar name="rpta_columns" type="hashsequence"> | 
				
			||||
select C.uniquename, | 
				
			||||
null::varchar(255) as caption, | 
				
			||||
C.caption as caption_der_spalte, | 
				
			||||
L.caption as caption_in_ergebnistabelle, | 
				
			||||
C.srcfieldname, | 
				
			||||
C.targetfieldname, | 
				
			||||
T.uniquename as column_type, | 
				
			||||
C.col_function, | 
				
			||||
L.is_visible, | 
				
			||||
L.visible_size, | 
				
			||||
C.is_aggregate, | 
				
			||||
null::varchar(255) as description, | 
				
			||||
L.format_code, | 
				
			||||
C.description as description_der_spalte, | 
				
			||||
L.description as description_in_ergebnistabelle | 
				
			||||
from tmp_rpta_column C, tmp_rpta_column2layout L, rpta_column_type T | 
				
			||||
where L.column_id=C.tid | 
				
			||||
and T.tid=C.column_type | 
				
			||||
</sqlvar> | 
				
			||||
</sqlvars> | 
				
			||||
 | 
				
			||||
 | 
				
			||||
<@rpta_column_layout_fuellen /> | 
				
			||||
@ -0,0 +1,137 @@
				@@ -0,0 +1,137 @@
					 | 
				
			||||
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
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
									
										Binary file not shown.
									
								
							
						
					Loading…
					
					
				
		Reference in new issue