Daniel Quathamer
1 year ago
16 changed files with 1414 additions and 715 deletions
@ -0,0 +1,12 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<classpath> |
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
||||||
|
<classpathentry kind="src" path="src"/> |
||||||
|
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/freemarker-2.3.25.jar"/> |
||||||
|
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/postgresql-42.2.19.jar"/> |
||||||
|
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/superx5.0.jar"/> |
||||||
|
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/saxon-he-10.5.jar"/> |
||||||
|
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib_ext/servlet-api.jar"/> |
||||||
|
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/jersey-core-1.11.jar"/> |
||||||
|
<classpathentry kind="output" path="superx/WEB-INF/classes"/> |
||||||
|
</classpath> |
@ -0,0 +1,17 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<projectDescription> |
||||||
|
<name>etl</name> |
||||||
|
<comment></comment> |
||||||
|
<projects> |
||||||
|
</projects> |
||||||
|
<buildSpec> |
||||||
|
<buildCommand> |
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name> |
||||||
|
<arguments> |
||||||
|
</arguments> |
||||||
|
</buildCommand> |
||||||
|
</buildSpec> |
||||||
|
<natures> |
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature> |
||||||
|
</natures> |
||||||
|
</projectDescription> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,298 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||||
|
|
||||||
|
<xsl:stylesheet version="2.0" |
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||||
|
<xsl:import href="etl_step_fuellen.xsl" /> |
||||||
|
|
||||||
|
<xsl:param name="sx_client"/> |
||||||
|
<xsl:param name="dbsystem"/> |
||||||
|
<xsl:param name="jobtype"/> |
||||||
|
|
||||||
|
<xsl:output method="text" name="text"/> |
||||||
|
<xsl:variable name="unknown_id" select="999999" /> |
||||||
|
<xsl:variable name="unknown" select="Unbekannt" /> |
||||||
|
<xsl:variable name="singleQuote">'</xsl:variable> |
||||||
|
|
||||||
|
<xsl:template match="/"> |
||||||
|
|
||||||
|
<xsl:text><![CDATA[ |
||||||
|
--Freemarker Template |
||||||
|
--Erzeugt von $ETL_PFAD/conf/etl_step_unload_fuellen.xsl |
||||||
|
<#include "ETL_MAKROS"/> |
||||||
|
<sqlvars> |
||||||
|
<sqlvar name="etl_step_exists"> |
||||||
|
select sp_table_exists('etl_step') from xdummy; |
||||||
|
</sqlvar> |
||||||
|
<sqlvar name="sourcesystem"> |
||||||
|
select param_val from unload_params where param_id='SOURCESYSTEM' and systeminfo_id=]]></xsl:text><xsl:value-of select="/superx-unload/module/@systeminfo_id"/><xsl:text><![CDATA[; |
||||||
|
</sqlvar> |
||||||
|
<sqlvar name="database"> |
||||||
|
select param_val from unload_params where param_id='DATABASE' and systeminfo_id=]]></xsl:text><xsl:value-of select="/superx-unload/module/@systeminfo_id"/><xsl:text><![CDATA[; |
||||||
|
</sqlvar> |
||||||
|
]]></xsl:text> |
||||||
|
<xsl:for-each select="/superx-unload/parameters/param"> |
||||||
|
<xsl:text><![CDATA[<sqlvar name="]]></xsl:text><xsl:value-of select="@name"/><xsl:text><![CDATA["> |
||||||
|
select replace(param_val,'''','''''') from unload_params where systeminfo_id=]]></xsl:text><xsl:value-of select="/superx-unload/module/@systeminfo_id"/><xsl:text><![CDATA[ |
||||||
|
and param_id=']]></xsl:text><xsl:value-of select="@name"/><xsl:text><![CDATA['; |
||||||
|
</sqlvar> |
||||||
|
]]></xsl:text> |
||||||
|
</xsl:for-each> |
||||||
|
<xsl:text><![CDATA[ |
||||||
|
</sqlvars> |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
|
||||||
|
<xsl:variable name="job_uniquename" select="concat(/superx-unload/module/@id,'_unload')" /> |
||||||
|
<xsl:variable name="module_name" select="/superx-unload/module/@id" /> |
||||||
|
|
||||||
|
<xsl:call-template name="initJob"> |
||||||
|
<xsl:with-param name="modulkuerzel" select="/superx-unload/module/@id"/> |
||||||
|
<xsl:with-param name="uniquename" select="$job_uniquename" /> |
||||||
|
<xsl:with-param name="caption" select="concat(/superx-unload/module,' Unload')" /> |
||||||
|
<xsl:with-param name="systeminfo_id" select="/superx-unload/module/@systeminfo_id"/> |
||||||
|
<xsl:with-param name="logfile" select="concat('L_',/superx-unload/module/@id,'_Unload.log')" /> |
||||||
|
</xsl:call-template> |
||||||
|
|
||||||
|
<xsl:for-each select="/superx-unload/sourcesystems/sourcesystem"> |
||||||
|
<xsl:variable name="sourcesystem" select="@name" /> |
||||||
|
|
||||||
|
<xsl:text>--Unload für sourcesystem=</xsl:text><xsl:value-of select="$sourcesystem"/><xsl:text><![CDATA[ |
||||||
|
|
||||||
|
<#if sourcesystem=="]]></xsl:text><xsl:value-of select="$sourcesystem"/><xsl:text><![CDATA["> |
||||||
|
|
||||||
|
--First the steps: |
||||||
|
]]></xsl:text> |
||||||
|
<xsl:text><![CDATA[ |
||||||
|
<#assign etl_steps = [ |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
<xsl:for-each select="/superx-unload/unload-job"> |
||||||
|
<xsl:variable name="nr" select="position()" /> |
||||||
|
|
||||||
|
<xsl:if test="extraction-sql/@sourcesystem=$sourcesystem"> |
||||||
|
|
||||||
|
|
||||||
|
<xsl:variable name="step_type"> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="@transfer-unload-file=''"> |
||||||
|
<xsl:text>DOQUERY</xsl:text> |
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<xsl:text>UNLOAD</xsl:text> |
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:variable> |
||||||
|
|
||||||
|
<xsl:variable name="logfile"> |
||||||
|
<xsl:value-of select="concat('L_',$module_name,'_unload.log')"/> |
||||||
|
</xsl:variable> |
||||||
|
|
||||||
|
<xsl:call-template name="insertStep"> |
||||||
|
<xsl:with-param name="uniquename" select="concat($module_name,'_unload_',@id)"/> |
||||||
|
<xsl:with-param name="parent_uniquename" select="''"/> |
||||||
|
<xsl:with-param name="job_uniquename" select="$job_uniquename"/> |
||||||
|
<xsl:with-param name="caption" select="concat('Unload ',$module_name,' Ladeschritt ',@id)"/> |
||||||
|
<xsl:with-param name="nr" select="$nr"/> |
||||||
|
<xsl:with-param name="step_type" select="$step_type"/> |
||||||
|
<xsl:with-param name="force_continue" select="'0'"/> |
||||||
|
<xsl:with-param name="logfile" select="$logfile"/> |
||||||
|
<xsl:with-param name="systeminfo_id" select="/superx-unload/module/@systeminfo_id"/> |
||||||
|
<xsl:with-param name="isFinal" select="'0'"/> |
||||||
|
</xsl:call-template> |
||||||
|
|
||||||
|
</xsl:if> |
||||||
|
</xsl:for-each> |
||||||
|
|
||||||
|
<xsl:call-template name="insertStep"> |
||||||
|
<xsl:with-param name="uniquename" select="concat($module_name,'_unload_finish')"/> |
||||||
|
<xsl:with-param name="caption" select="concat('Ende Unload ',$module_name)"/> |
||||||
|
<xsl:with-param name="parent_uniquename" select="''"/> |
||||||
|
<xsl:with-param name="job_uniquename" select="$job_uniquename"/> |
||||||
|
<xsl:with-param name="nr" select="1000"/> |
||||||
|
<xsl:with-param name="step_type" select="'MSG'"/> |
||||||
|
<xsl:with-param name="force_continue" select="'0'"/> |
||||||
|
<xsl:with-param name="logfile" select="''"/> |
||||||
|
<xsl:with-param name="systeminfo_id" select="/superx-unload/module/@systeminfo_id"/> |
||||||
|
<xsl:with-param name="isFinal" select="'1'"/> |
||||||
|
</xsl:call-template> |
||||||
|
|
||||||
|
<xsl:text><![CDATA[ |
||||||
|
] /> |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
<xsl:text><![CDATA[ |
||||||
|
</#if> |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
|
||||||
|
</xsl:for-each> |
||||||
|
|
||||||
|
<!--Ende etl_step Schleife--> |
||||||
|
|
||||||
|
|
||||||
|
<xsl:for-each select="/superx-unload/sourcesystems/sourcesystem"> |
||||||
|
|
||||||
|
<xsl:call-template name="insertStepProperties"> |
||||||
|
<xsl:with-param name="sourcesystem" select="@name" /> |
||||||
|
<xsl:with-param name="database" select="'POSTGRES'" /> |
||||||
|
<xsl:with-param name="module_name" select="$module_name"/> |
||||||
|
</xsl:call-template> |
||||||
|
|
||||||
|
<xsl:call-template name="insertStepProperty"> |
||||||
|
<xsl:with-param name="uniquename" select="concat($module_name,'_unload_finish')"/> |
||||||
|
<xsl:with-param name="caption" select="concat('Ende Unload ',/superx-unload/module/@name)"/> |
||||||
|
<xsl:with-param name="nr" select="1"/> |
||||||
|
<xsl:with-param name="step_type" select="'MSG'"/> |
||||||
|
<xsl:with-param name="isFinal" select="'1'"/> |
||||||
|
</xsl:call-template> |
||||||
|
<xsl:text><![CDATA[ |
||||||
|
] /> |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
<xsl:text><![CDATA[ |
||||||
|
</#if> |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
</xsl:for-each> |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<xsl:text><![CDATA[ |
||||||
|
|
||||||
|
<#if etl_step_exists==1> |
||||||
|
|
||||||
|
<@ETL_STEPS_FUELLEN /> |
||||||
|
|
||||||
|
</#if> |
||||||
|
|
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
</xsl:template> |
||||||
|
<xsl:template name="insertStepProperties"> |
||||||
|
<xsl:param name="sourcesystem" /> |
||||||
|
<xsl:param name="database" /> |
||||||
|
<xsl:param name="module_name" /> |
||||||
|
<xsl:variable name="unloadDefaultVersion"><xsl:value-of select="/superx-unload/parameters/param[@name='VERSION']/@defaultValue"/></xsl:variable> |
||||||
|
|
||||||
|
|
||||||
|
<xsl:text>--Unload properties für sourcesystem=</xsl:text><xsl:value-of select="$sourcesystem"/> |
||||||
|
<xsl:text>,database=</xsl:text><xsl:value-of select="$database"/> |
||||||
|
<xsl:text>,unloadDefaultVersion=</xsl:text><xsl:value-of select="$unloadDefaultVersion"/> |
||||||
|
|
||||||
|
<xsl:text><![CDATA[ |
||||||
|
|
||||||
|
<#if sourcesystem=="]]></xsl:text><xsl:value-of select="$sourcesystem"/> |
||||||
|
<xsl:text>" && database=="</xsl:text><xsl:value-of select="$database"/> |
||||||
|
<xsl:text><![CDATA["> |
||||||
|
|
||||||
|
--then the properties: |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
<xsl:text><![CDATA[ |
||||||
|
<#assign etl_step_properties = [ |
||||||
|
]]></xsl:text> |
||||||
|
|
||||||
|
<xsl:for-each select="/superx-unload/unload-job"> |
||||||
|
<xsl:variable name="step_uniquename" select="concat($module_name,'_unload_',@id)" /> |
||||||
|
<xsl:variable name="nr" select="position()" /> |
||||||
|
<!-- first the params--> |
||||||
|
<xsl:for-each select="/superx-unload/parameters/param"> |
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="@name='JDBC_PARAM' and $sourcesystem='hisinone'"> |
||||||
|
<xsl:text><![CDATA[ |
||||||
|
{"etl_step":"]]></xsl:text><xsl:value-of select="$step_uniquename"/> |
||||||
|
<xsl:text>", "prop_name":"</xsl:text><xsl:value-of select="@name"/> |
||||||
|
<xsl:text>", "prop_value":"set search_path to hisinone"</xsl:text> |
||||||
|
<xsl:text><![CDATA[}, |
||||||
|
]]> |
||||||
|
</xsl:text> |
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<xsl:text><![CDATA[ |
||||||
|
{"etl_step":"]]></xsl:text><xsl:value-of select="$step_uniquename"/> |
||||||
|
<xsl:text>", "prop_name":"</xsl:text><xsl:value-of select="@name"/> |
||||||
|
<xsl:text>", "prop_value":</xsl:text><xsl:value-of select="@name" /> |
||||||
|
<xsl:text><![CDATA[}, |
||||||
|
]]> |
||||||
|
</xsl:text> |
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:for-each> |
||||||
|
|
||||||
|
<!--now the extraction-sqls--> |
||||||
|
<xsl:for-each select="extraction-sql"> |
||||||
|
<xsl:if test="@sourcesystem=$sourcesystem and (@database=$database or @database='') and (contains(@version,$unloadDefaultVersion) or @version='')"> |
||||||
|
|
||||||
|
|
||||||
|
<xsl:choose> |
||||||
|
<xsl:when test="../@transfer-unload-file=''"> |
||||||
|
<xsl:call-template name="insertStepProperty"> |
||||||
|
<xsl:with-param name="uniquename" select="$step_uniquename"/> |
||||||
|
<xsl:with-param name="caption" select="'SQL Script'"/> |
||||||
|
<xsl:with-param name="nr" select="$nr + 10"/> |
||||||
|
<xsl:with-param name="step_type" select="'DOQUERY'"/> |
||||||
|
<xsl:with-param name="isFinal" select="'0'"/> |
||||||
|
<xsl:with-param name="sql" select="."> |
||||||
|
<!--klappt nicht: <xsl:call-template name="parseSqlForUnloadParams"> |
||||||
|
<xsl:with-param name="sql" select="." /> |
||||||
|
</xsl:call-template>--> |
||||||
|
</xsl:with-param> |
||||||
|
<xsl:with-param name="dbconnection" select="$sourcesystem"/> |
||||||
|
<xsl:with-param name="sqlVarDbconnection" select="'eduetl'"/> |
||||||
|
|
||||||
|
</xsl:call-template> |
||||||
|
|
||||||
|
</xsl:when> |
||||||
|
<xsl:otherwise> |
||||||
|
<xsl:variable name="outPath"><xsl:text>$</xsl:text><xsl:call-template name="ucase"> |
||||||
|
<xsl:with-param name="s1" select="$module_name" /></xsl:call-template><xsl:text>_LOAD_PFAD/</xsl:text> |
||||||
|
<xsl:value-of select="../@transfer-unload-file"/></xsl:variable> |
||||||
|
<xsl:call-template name="insertStepProperty"> |
||||||
|
<xsl:with-param name="uniquename" select="$step_uniquename"/> |
||||||
|
<xsl:with-param name="caption" select="'SQL Unload'"/> |
||||||
|
<xsl:with-param name="nr" select="$nr + 10"/> |
||||||
|
<xsl:with-param name="step_type" select="'UNLOAD'"/> |
||||||
|
<xsl:with-param name="isFinal" select="'0'"/> |
||||||
|
<xsl:with-param name="sql" select="."> |
||||||
|
<!--klappt nicht: <xsl:call-template name="parseSqlForUnloadParams"> |
||||||
|
<xsl:with-param name="sql" select="." /> |
||||||
|
</xsl:call-template>--> |
||||||
|
</xsl:with-param> |
||||||
|
<xsl:with-param name="outfile" select="$outPath"/> |
||||||
|
<xsl:with-param name="format" select="'csv'"/> |
||||||
|
<xsl:with-param name="dbconnection" select="$sourcesystem"/> |
||||||
|
<xsl:with-param name="sqlVarDbconnection" select="'eduetl'"/> |
||||||
|
</xsl:call-template> |
||||||
|
|
||||||
|
</xsl:otherwise> |
||||||
|
</xsl:choose> |
||||||
|
</xsl:if> |
||||||
|
</xsl:for-each> |
||||||
|
|
||||||
|
</xsl:for-each> |
||||||
|
|
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
<xsl:template name="parseSqlForUnloadParams"> |
||||||
|
<xsl:param name="sql" /> |
||||||
|
<xsl:for-each select="/superx-unload/parameters/param"> |
||||||
|
<xsl:variable name="param_id" select="@name" /> |
||||||
|
<xsl:call-template name="search_replace"> |
||||||
|
<xsl:with-param name="string" select="$sql"/> |
||||||
|
<xsl:with-param name="search" select="'a'"/> |
||||||
|
<xsl:with-param name="replace" select="'A'"/> |
||||||
|
</xsl:call-template> |
||||||
|
</xsl:for-each> |
||||||
|
<!--<xsl:value-of select="$sql"/> |
||||||
|
<xsl:with-param name="search" select="concat('$',@name)"/> |
||||||
|
<xsl:with-param name="replace" select="concat('"+',@name,'+"')"/> |
||||||
|
|
||||||
|
--> |
||||||
|
</xsl:template> |
||||||
|
<xsl:template name="ucase"> |
||||||
|
<xsl:param name="s1"/> |
||||||
|
<xsl:value-of select="translate($s1,'abcdefghijklmnopqrstuvwxyz ','ABCDEFGHIJKLMNOPQRSTUVWXYZ_')" /> |
||||||
|
</xsl:template> |
||||||
|
|
||||||
|
</xsl:stylesheet> |
@ -1,4 +1,4 @@ |
|||||||
doku/etl_modul/etl.html |
doku/etl_modul/etl.html |
||||||
WEB-INF/conf/edustore/db/bin/SQL_ENV_etl.sam |
WEB-INF/conf/edustore/db/bin/SQL_ENV_etl.sam |
||||||
WEB-INF/lib/superx-etl0.2.jar |
WEB-INF/lib/superx-etl.jar |
||||||
|
|
||||||
|
@ -0,0 +1,220 @@ |
|||||||
|
package de.superx.etl.util; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class to analyze arguments passed to Java class
|
||||||
|
* Makes ETL compatible to BI 2021.06 and higher |
||||||
|
*/ |
||||||
|
public class GetOptsBackport{ |
||||||
|
|
||||||
|
public enum Options{ |
||||||
|
opt_logger("-logger"), |
||||||
|
opt_dbprops("-dbproperties"), |
||||||
|
opt_table("-table"), |
||||||
|
opt_outFormat("-outFormat"), |
||||||
|
opt_outFile("-outfile"), |
||||||
|
opt_outfileAttribute("-outfileattribute"), |
||||||
|
opt_cancel("-cancel"), |
||||||
|
opt_sql("-sqlfile"), |
||||||
|
opt_sqlAttribute("-sqlattribute"), |
||||||
|
opt_delim("-delim"), |
||||||
|
opt_header("-header"), |
||||||
|
opt_params("-params"), |
||||||
|
opt_param("-param"), |
||||||
|
opt_in("-in"), |
||||||
|
opt_inFormat("-informat"), |
||||||
|
opt_out("-out"), |
||||||
|
opt_xsl("-xsl"), |
||||||
|
opt_xslPfad("-xslpfad"), |
||||||
|
opt_fopxconf("-fopxconf"), |
||||||
|
opt_user("-user"), |
||||||
|
opt_tid("-tid"), |
||||||
|
opt_mandID("-mandantenid"), |
||||||
|
opt_locale("-locale"), |
||||||
|
opt_simpPars("-simpleParser"), |
||||||
|
opt_webinf("-web_inf_pfad"), |
||||||
|
opt_module("-module_pfad"), |
||||||
|
opt_jobUniqueName("-job_uniquename"), |
||||||
|
opt_uploadpath("-path_to_uploadfile"), |
||||||
|
opt_method("-method"), |
||||||
|
opt_xml("-xml"), |
||||||
|
opt_xmlconfig("-xmlconfig"), |
||||||
|
opt_db("-database"), |
||||||
|
opt_version("-version"), |
||||||
|
opt_unl("-unl"), |
||||||
|
opt_unlParams("-unload_params"), |
||||||
|
opt_jrxml("-jrxml"), |
||||||
|
opt_jasper("-jasper"), |
||||||
|
opt_jrPrint("-jrprint"), |
||||||
|
opt_ignorePagination("-ignore_pagination"), |
||||||
|
opt_idescr("-i_descr"), |
||||||
|
opt_odescr("-o_descr"), |
||||||
|
opt_element("-element"), |
||||||
|
opt_function("-function"), |
||||||
|
opt_mode("-mode"), |
||||||
|
opt_inserts("-inserts"), |
||||||
|
opt_encoding("-encoding"), |
||||||
|
opt_hsnr("-hsnr"), |
||||||
|
opt_noDelete("-nodelete"), |
||||||
|
opt_pause("-pause"), |
||||||
|
opt_jahr("-jahr"), |
||||||
|
opt_datentyp("-datentyp"), |
||||||
|
opt_runs("-runs"), |
||||||
|
opt_checkval("-checkval"), |
||||||
|
opt_url("-url"), |
||||||
|
opt_setname("-setname"), |
||||||
|
|
||||||
|
opt_kernTabellenFreischalten("-kern_tabellen_freischalten"), |
||||||
|
opt_noguiVar0("-nogui"), opt_noguiVar1("-no-gui"), opt_noguiVar2("--no-gui"), |
||||||
|
opt_job("-job"); |
||||||
|
|
||||||
|
private String value; |
||||||
|
private Options(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String stringValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static String[] arguments = null; |
||||||
|
private GetOptsBackport(){} //Do not instatiate
|
||||||
|
|
||||||
|
/** |
||||||
|
* If you pass the arguments you want to analyse to this static helper class
|
||||||
|
* using setOpts, you can later use the short form of the methods e.g. |
||||||
|
* isPresent(String option) without having to pass the arguments again. |
||||||
|
* |
||||||
|
* @param args |
||||||
|
*/ |
||||||
|
public static void setOpts(String args[]) { |
||||||
|
arguments = args; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* checks if the arguments passed before by setOpts contain the given option |
||||||
|
* |
||||||
|
* @param Options |
||||||
|
* option |
||||||
|
* @return true if arguments contain the option, i.e. one String which |
||||||
|
* starts with the option-String |
||||||
|
*/ |
||||||
|
public static boolean isPresent(Options option){ |
||||||
|
if(arguments == null){ |
||||||
|
throw new IllegalStateException("must either call setOpts() before or call the long version of this method"); |
||||||
|
} |
||||||
|
return isPresent(arguments, option); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* checks if the arguments contain the given option |
||||||
|
* |
||||||
|
* @param args |
||||||
|
* @param Options |
||||||
|
* option |
||||||
|
* @return true if arguments contain the option, i.e. one String which |
||||||
|
* starts with the option-String |
||||||
|
*/ |
||||||
|
public static boolean isPresent(String args[], Options option){ |
||||||
|
boolean result = false; |
||||||
|
|
||||||
|
for(int i = 0; i < args.length; i++){ |
||||||
|
if (args[i] != null && args[i].toLowerCase().startsWith(option.stringValue())){ |
||||||
|
result = true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets a named option from the arguments passed before with setOps. E.g. |
||||||
|
* getOpt("--log") would return the "--log:true" in the arguments |
||||||
|
* |
||||||
|
* @param Options |
||||||
|
* option |
||||||
|
* @return String option and value |
||||||
|
*/ |
||||||
|
public static String getOpt(Options option){ |
||||||
|
if (arguments == null){ |
||||||
|
throw new IllegalStateException("must either call setOpts() before or call the long version of this method"); |
||||||
|
} |
||||||
|
return getOpt(arguments, option); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets a named option from the arguments. E.g. getOpt("--log") would return |
||||||
|
* the "--log:true" in the arguments |
||||||
|
* |
||||||
|
* @param Options |
||||||
|
* option |
||||||
|
* @return String option and value |
||||||
|
*/ |
||||||
|
public static String getOpt(String args[], Options option){ |
||||||
|
String result = null; |
||||||
|
for(int i=0; i < args.length; i++){ |
||||||
|
if(args[i].toLowerCase().startsWith(option.stringValue())){ |
||||||
|
result = args[i]; |
||||||
|
} |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets the value of an option from the arguments passed before with setOpts |
||||||
|
* if for example, you ask getValue("--log:") and the arguments passed |
||||||
|
* before with setOpts contain a String "--log:true") "true" is returned |
||||||
|
* |
||||||
|
* @param Options |
||||||
|
* option |
||||||
|
* @return String value of the option |
||||||
|
*/ |
||||||
|
public static String getValue(Options option){ |
||||||
|
if (arguments == null){ |
||||||
|
throw new IllegalStateException("must either call setOpts() before or call the long version of this method"); |
||||||
|
} |
||||||
|
return getValue(arguments, option); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets the value of an option, if for example, you ask getValue("--log:") |
||||||
|
* and the arguments passed before with setOpts contain a String |
||||||
|
* "--log:true") "true" is returned |
||||||
|
* |
||||||
|
* @param Options |
||||||
|
* option |
||||||
|
* @return String value of the option |
||||||
|
*/ |
||||||
|
public static String getValue(String args[], Options option) { |
||||||
|
String value = null, temp = getOpt(args, option); |
||||||
|
int pos = option.stringValue().length(); |
||||||
|
if(temp.charAt(pos) == ':') { |
||||||
|
pos++; |
||||||
|
} |
||||||
|
value = temp.substring(pos); |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Prüft, ob alle notwendigen Optionen angegeben sind. |
||||||
|
* |
||||||
|
* @param Options[] |
||||||
|
* opts, ein Array mit Optionen die überprüft werden sollen |
||||||
|
* @return null - alles OK, ansonsten String mit den fehlenden Optionen |
||||||
|
*/ |
||||||
|
public static String isAllRequiredOptionsPresent(Options[] opts){ |
||||||
|
String missingOpts = null; |
||||||
|
for (Options o : opts){ |
||||||
|
if(!isPresent(o)){ |
||||||
|
if(missingOpts == null){ |
||||||
|
missingOpts = o.stringValue()+", "; |
||||||
|
}else{ |
||||||
|
missingOpts += o.stringValue()+", "; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return missingOpts; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
#Beispielumgebung für das ETL-Modul: |
||||||
|
|
||||||
|
#SUPERX_MODULE=$SUPERX_DIR/db/module |
||||||
|
#SUPERX_ROHDATEN=rohdaten |
||||||
|
|
||||||
|
ETL_PFAD=$SUPERX_MODULE/etl; export ETL_PFAD |
||||||
|
ETL_ERRORDAT=$ETL_PFAD/etl_update.err; export ETL_ERRORDAT |
||||||
|
#Hier stehen die Rohdaten (im Unterverzeichnis unl) |
||||||
|
ETL_LOAD_PFAD=$ETL_PFAD/$SUPERX_ROHDATEN; export ETL_LOAD_PFAD |
||||||
|
ETL_ERRORMAIL=$ERRORMAIL; export ETL_ERRORMAIL |
||||||
|
ETL_LOGMAIL=$LOGMAIL; export ETL_LOGMAIL |
||||||
|
|
||||||
|
PATH=$ETL_PFAD/bin:$PATH |
||||||
|
export PATH |
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in new issue