Schnittstelle CampusOnline (TU Graz) zu SuperX-Modul COSTAGE http://www.superx-projekt.de/doku/costage_modul/
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.

76 lines
2.5 KiB

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xml:output method="text" indent="yes"/>
<xsl:template match="/">
<xsl:text><![CDATA[#!/bin/bash
# XML-generiertes SQL-Script
# von costage_prepare_unlfiles.xsl
if [ "$1" == "" ]
then
echo "Usage: costage_prepare_unlfiles.x <Delimiter> HEADER<optional>"
echo "Beispiel: costage_prepare_unlfiles.x , HEADER"
echo "Folgende Dateien können geladen werden:"
]]>
</xsl:text>
<xsl:for-each select="/superx-unload/unload-job [ @transfer-unload-file != '' ] ">
<xsl:text><![CDATA[
echo "$COSTAGE_LOAD_PFAD/unl/]]></xsl:text><xsl:value-of select="concat(@id,'.csv')" /><xsl:text><![CDATA["
]]>
</xsl:text>
</xsl:for-each>
<xsl:text><![CDATA[
fi
if [ ! -f $COSTAGE_LOAD_PFAD/superx.datum ]
then
echo "superx.datum wird nicht übergeben"
date +'%d.%m.%Y' > $COSTAGE_LOAD_PFAD/superx.datum
fi
if [ ! -f $COSTAGE_LOAD_PFAD/costage_unload.err ]
then
echo "costage_unload.err wird nicht übergeben"
cat /dev/null > $COSTAGE_LOAD_PFAD/costage_unload.err
fi
#zuerst alle Dateien nach UTF-8 konvertieren, wenn nötig:
sx_list_isofiles.x $COSTAGE_LOAD_PFAD/unl >iso.txt
sx_recode_isofiles.x iso.txt
]]>
</xsl:text>
<xsl:for-each select="/superx-unload/unload-job [ @transfer-unload-file != '' ] ">
<xsl:text><![CDATA[
if [ -f "$COSTAGE_LOAD_PFAD/unl/]]></xsl:text><xsl:value-of select="concat(@id,'.csv')" /><xsl:text>" ]
then
echo "$COSTAGE_LOAD_PFAD/unl/</xsl:text><xsl:value-of select="concat(@id,'.csv')" /><xsl:text><![CDATA[ wird übergeben:"
DOQUERY "truncate table ]]></xsl:text><xsl:value-of select="@target-table" /><xsl:text><![CDATA[;"
DOQUERY "vacuum full ]]></xsl:text><xsl:value-of select="@target-table" /><xsl:text><![CDATA[;"
psql --dbname=$DBNAME -c "\copy ]]></xsl:text><xsl:value-of select="@target-table" /><xsl:text><![CDATA[ from unl/]]></xsl:text><xsl:value-of select="concat(@id,'.csv')" /><xsl:text><![CDATA[ using delimiters '"$1"' with null as '' CSV $2"
sx_unload_table.x ]]></xsl:text><xsl:value-of select="@target-table" /><xsl:text> </xsl:text><xsl:value-of select="@transfer-unload-file" /><xsl:text><![CDATA[
fi
if [ ! -f "$COSTAGE_LOAD_PFAD/]]></xsl:text><xsl:value-of select="@transfer-unload-file" /><xsl:text>" ]
then
echo "$COSTAGE_LOAD_PFAD/</xsl:text><xsl:value-of select="@transfer-unload-file" /><xsl:text><![CDATA[ wird nicht übergeben"
cat /dev/null > "$COSTAGE_LOAD_PFAD/]]></xsl:text><xsl:value-of select="@transfer-unload-file" /><xsl:text>"
fi
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>