Browse Source

Export von Datenbalken #3

rpta_0.2_Release
Daniel Quathamer 10 months ago
parent
commit
d25a955e75
  1. 18
      .classpath
  2. 17
      .project
  3. 73
      build.xml
  4. 1
      src-modules/module/rpta/conf/includes.txt
  5. 64
      src/de/superx/rpta/SvgProducer.java
  6. 1
      superx/WEB-INF/.gitignore
  7. BIN
      superx/WEB-INF/lib/superx-rpta.jar
  8. 82
      superx/xml/rpta_templates.xsl

18
.classpath

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
<?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="lib" path="/kern/superx/WEB-INF/lib/fop-2.2.jar"/>
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/spring-jdbc-3.0.3.RELEASE.jar"/>
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/kettle-core-6.0.0.0-353.jar"/>
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/log4j-core-2.16.0.jar"/>
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/log4j-1.2-api-2.16.0.jar"/>
<classpathentry kind="lib" path="/kern/superx/WEB-INF/lib/log4j-api-2.16.0.jar"/>
<classpathentry kind="output" path="superx/WEB-INF/classes"/>
</classpath>

17
.project

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>rpta</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>

73
build.xml

@ -2,11 +2,27 @@ @@ -2,11 +2,27 @@
<project name="ModuleCreation" default="help" basedir=".">
<!--Aufruf mit
VIZ-JAR erzeugen:
ant -DWEBAPP=$WEBAPP distRpta
ant -DWEBAPP=$WEBAPP cleanBuildPath
-->
<dirname file="${ant.file}" property="moduleCreateBaseDir" />
<property name="BASE_DIR" value="${moduleCreateBaseDir}/../.." />
<dirname file="${ant.file.superx}" property="superxBuildBaseDir" />
<property name="distDir" location="${superxBuildBaseDir}/superx/WEB-INF/lib" />
<property name="BASE_DIR" value="." />
<property name="WEBAPP" value="${MODULE_PATH}/../../../webserver/tomcat/webapps/superx" />
<property name="BUILD_PATH" value="${WEBAPP}/WEB-INF/classes"/>
<property name="SRC_DIR" value="${BASE_DIR}/src" />
<property name="SRC_DIR_TEST" value="${BASE_DIR}/test-src"/>
<property name="LIB_SUPERX_DIR" value="${WEBAPP}/WEB-INF/lib"/>
<property name="LIB_WEBAPP_DIR" value="${WEBAPP}"/>
<property name="LIB_EXT_SUPERX_DIR" value="${WEBAPP}/WEB-INF/lib_ext"/>
<property name="superx-classes" value="${WEBAPP}/WEB-INF/classes" />
<property name="src-java" value="${SRC_DIR}"/>
<property name="rpta_version" value="0.2" />
<path id="classpath">
<!--WEB-INF/lib-->
<fileset dir="${WEBAPP}/WEB-INF">
@ -39,6 +55,14 @@ @@ -39,6 +55,14 @@
<antcall target="call_module_scripts_create_ant" />
<antcall target="module_copy_webapp_files" />
</target>
<target name="initTimestamp">
<tstamp>
<format property="SX_TIMESTAMP" pattern="dd.MM.yyyy HH:mm" />
</tstamp>
</target>
<target name="module_copy_source" description="Kopiere Modul Sourcen in den WEB-INF-Verzeichnisbaum">
<echo message="Start module_copy_sources für Modul ${MODULE} in Pfad ${MODULE_PATH}" />
<copy todir="${MODULE_PATH}" overwrite="true">
@ -77,6 +101,53 @@ @@ -77,6 +101,53 @@
<fileset dir="${MODULE_PATH}/../../conf" includes="build.xml" />
</subant>
</target>
<target name="distRpta" depends="compileSuperx" description="Erzeugt die superx-etl.jar. ">
<delete>
<fileset dir="${distDir}" includes="superx-rpta*.jar" />
</delete>
<jar destfile="${distDir}/superx-rpta.jar" basedir="${BUILD_PATH}" includes="de/superx/rpta/** de/superx/sxrest/**" excludes="freemarker/**/* com/**/* javax/**/* **/*.java">
<manifest>
<!-- Who is building this jar? -->
<attribute name="Built-By" value="superx"/>
<!-- Information about the program itself -->
<attribute name="Implementation-Date" value="${SX_TIMESTAMP}"/>
<attribute name="Implementation-Title" value="SuperX"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
</jar>
</target>
<target name="compileSuperx" depends="cleanBuildPath" description="Compile all classes for superx.">
<filter token="sxtimestamp" value="${SX_TIMESTAMP}" />
<filter token="version" value="${rpta_version}" />
<!-- MB 13.8.2009 auch mitkompilieren <echo message="de/memtext/db/Servlet* weggelassen"/>-->
<copy todir="${BUILD_PATH}" filtering="true">
<fileset dir="${SRC_DIR}">
<include name="**/*.java" />
<include name="**/*.properties" />
<include name="**/*.gif" />
<include name="**/*.xml" />
<include name="edustore/*" />
<include name="saiku-datasources/*" />
<include name="saiku-repository/*" />
<exclude name="de/superx/docmanagement/*"/>
</fileset>
</copy>
<!--<echo message="cp:${FULL_CLASSPATH}"/>-->
<javac source="1.8" target="1.8"
srcdir="${BUILD_PATH}" excludes="**/*Test*.java,test/**/*"
destdir="${BUILD_PATH}"
listfiles="false" encoding="UTF-8" debug="yes">
<classpath refid="classpath" />
</javac>
</target>
<target name="cleanBuildPath" depends="initTimestamp" description="Löscht alle *.class-Dateien in WEB-INF/classes">
<delete failonerror="false" includeemptydirs="true">
<fileset dir="${BUILD_PATH}" includes="**/*.class,**/*.java" excludes="*.properties" />
</delete>
</target>
<target name="xml2jrxml_tabelle_a4_quer" description="Target: aus einer XML-Datei (SuperX-Bericht XML-Export) eine JRXML-Datei"
depends="init">
<!-- Aufruf:

1
src-modules/module/rpta/conf/includes.txt

@ -3,6 +3,7 @@ WEB-INF/conf/edustore/db/bin/SQL_ENV_rpta.sam @@ -3,6 +3,7 @@ WEB-INF/conf/edustore/db/bin/SQL_ENV_rpta.sam
images/icons/file-excel_rpta.svg
images/icons/magic.svg
WEB-INF/conf/edustore/db/module/rpta/schluesseltabellen/sx_stylesheets_einfuegen.sql
WEB-INF/lib/superx-rpta.jar
WEB-INF/reports/simple_table.jrtx
xml/tabelle_jrxml_a4_quer.xsl
xml/tabelle_jrxml_book_without_cover.xsl

64
src/de/superx/rpta/SvgProducer.java

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
package de.superx.rpta;
public class SvgProducer {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(SimpleBarChart("40|110",100,120,50,"#cccccc","steelblue",true));
}
/* erzeugt Datenbalken aus "_graph"-Columns, mit Maxvalue Def.
* Beispielaufruf aus JR:
* <imageExpression>net.sf.jasperreports.renderers.SimpleDataRenderer.getInstance(de.superx.rpta.SvgProducer.SimpleBarChart($F{männlich},100,149,30,"#cccccc","steelblue",false).getBytes("UTF-8"))</imageExpression>
*
*/
public static String SimpleBarChart(String barValueStr, double totalValue, double totalWidth, double height,String bgColor, String fgColor,boolean alignLeft)
{
double barValue=0;
int delim=barValueStr.indexOf("|");
if(delim!=0)
{
barValue=Double.valueOf(barValueStr.substring(0, delim));
totalValue=Double.valueOf(barValueStr.substring(delim+1));
}
else
barValue=Double.valueOf(barValueStr);
if(Double.valueOf(totalValue)==null)
totalValue=100; //percent is default
String ret = generateSvg(totalValue, totalWidth, height, bgColor, fgColor, alignLeft, barValue);
return ret;
}
/* erzeugt Datenbalken aus "_graph"-Columns, zum maxValue 100
* Beispielaufruf aus JR:
* <imageExpression>net.sf.jasperreports.renderers.SimpleDataRenderer.getInstance(de.superx.rpta.SvgProducer.SimpleBarChart($F{ Anteil Benutzer an Gesamtzahl (in %) },100,199,30,"#cccccc","steelblue",true).getBytes("UTF-8"))</imageExpression> *
*/
public static String SimpleBarChart(double barValue, double totalValue, double totalWidth, double height,String bgColor, String fgColor,boolean alignLeft)
{
if(Double.valueOf(totalValue)==null)
totalValue=100; //percent is default
String ret = generateSvg(totalValue, totalWidth, height, bgColor, fgColor, alignLeft, barValue);
return ret;
}
/* erzeugt svg-Code für Datenbalken aus "_graph"-Columns
*
*/
private static String generateSvg(double totalValue, double totalWidth, double height, String bgColor,
String fgColor, boolean alignLeft, double barValue) {
//Compute width:
double barWidth=totalWidth*(barValue/totalValue);
double x=0;
if(!alignLeft)
x=totalWidth-barWidth; //rechtsbündig
String ret="<svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+totalWidth+"px\" height=\""+height+"px\">";
//background:
ret+="<g><rect x=\"0\" y=\"0\" width=\""+totalWidth+"px\" height=\""+height+"px\" fill=\""+bgColor+"\"><title>"+totalValue+"</title></rect>";
//foreground:
ret+="<rect class=\"chartBar\" width=\""+barWidth+"\" height=\""+(height-1) +"\" x=\""+x+"\" y=\"0\" rx=\"5\" ry=\"5\" fill=\""+fgColor+"\"><title>"+barValue+"</title></rect>";
ret+="</g></svg>";
return ret;
}
}

1
superx/WEB-INF/.gitignore vendored

@ -0,0 +1 @@ @@ -0,0 +1 @@
/classes/

BIN
superx/WEB-INF/lib/superx-rpta.jar

Binary file not shown.

82
superx/xml/rpta_templates.xsl

@ -4,6 +4,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" @@ -4,6 +4,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://jasperreports.sourceforge.net/jasperreports">
<xsl:param name="font" select="'Liberation Sans'" /><!--TODO {$font} als style-->
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template name="generateJasperReport">
<xsl:param name="isMainReport" select="'true'" />
<xsl:param name="ergebniselementOrdnr" select="0" />
@ -22,7 +23,7 @@ xmlns="http://jasperreports.sourceforge.net/jasperreports"> @@ -22,7 +23,7 @@ xmlns="http://jasperreports.sourceforge.net/jasperreports">
<xsl:param name="std_spaltenbreite" select="'12'" />
<xsl:param name="std_zeilenhoehe_header" select="30" />
<xsl:param name="std_zeilenhoehe_tablerow" select="25" />
<xsl:param name="isMacroReport" select="'false'" />
<xsl:variable name="isMacroReport" select="/ergebnisse/@isMakro" />
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="{/ergebnisse/ergebnis[@ordnr=$ergebniselementOrdnr]/maskenname}"
@ -58,7 +59,9 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -58,7 +59,9 @@ isIgnorePagination="{$isIgnorePagination}" >
</xsl:if>
<xsl:call-template name="jr_fields" >
<xsl:with-param name="ergebniselementOrdnr" select="$ergebniselementOrdnr"/>
<xsl:with-param name="isMacroReport" select="/ergebnisse/@isMakro" />
<xsl:with-param name="isMacroReport" select="$isMacroReport" />
<xsl:with-param name="isMainReport" select="$isMainReport" />
</xsl:call-template>
@ -118,6 +121,7 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -118,6 +121,7 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:call-template name="jr_textField">
<xsl:with-param name="ergebnisElementOrdnr" select="$ergebniselementOrdnr" />
<xsl:with-param name="fieldName" select="wert" />
<xsl:with-param name="colName" select="f_name" />
<xsl:with-param name="colId" select="@id" />
<xsl:with-param name="x" select="$columnX" />
<xsl:with-param name="width" select="$columnWidth" />
@ -132,6 +136,7 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -132,6 +136,7 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:call-template name="jr_textfield_levelx">
<xsl:with-param name="ergebnisElementOrdnr" select="$ergebniselementOrdnr" />
<xsl:with-param name="fieldName" select="wert" />
<xsl:with-param name="colName" select="f_name" />
<xsl:with-param name="colId" select="@id" />
<xsl:with-param name="x" select="$columnX" />
<xsl:with-param name="width" select="$columnWidth" />
@ -239,11 +244,12 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -239,11 +244,12 @@ isIgnorePagination="{$isIgnorePagination}" >
</xsl:template>
<xsl:template name="jr_fields">
<xsl:param name="ergebniselementOrdnr" select="0"/>
<xsl:param name="isMainReport" />
<xsl:param name="isMacroReport" />
<field name="Berichtsname" class="java.lang.String">
<fieldDescription>
<xsl:choose>
<xsl:when test="$isMacroReport = 'true'">
<xsl:when test="$isMacroReport = 'true' and $isMainReport= 'true'">
<xsl:text><![CDATA[/ergebnisse/makro/name]]></xsl:text></xsl:when>
<xsl:otherwise><xsl:text><![CDATA[/ergebnisse/ergebnis[ @ordnr=']]></xsl:text>
<xsl:value-of select="$ergebniselementOrdnr"/>
@ -265,7 +271,7 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -265,7 +271,7 @@ isIgnorePagination="{$isIgnorePagination}" >
</field>
<xsl:comment> dann die Tabellenspalten </xsl:comment>
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement">
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]">
<xsl:variable name="ordnr"><xsl:value-of select="@ordnr"/></xsl:variable>
<xsl:for-each select="sqlerg/complete_headers/header">
<xsl:variable name="jasperFieldname">
@ -294,9 +300,33 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -294,9 +300,33 @@ isIgnorePagination="{$isIgnorePagination}" >
</field>
</xsl:if>
</xsl:for-each>
<!-- dann die Legende pro Unterbericht-->
<xsl:if test="$isMainReport='false'">
<xsl:for-each select="distinct-values(../completefields/feld/@varname)">
<xsl:variable name="jasperFieldname">
<xsl:call-template name="createJasperFieldname">
<xsl:with-param name="fieldName_orig" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="varname">
<xsl:value-of select="." />
</xsl:variable>
<!-- zuerst Label -->
<field name="{concat('legende_',$jasperFieldname,'_label')}" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis[@ordnr=]]></xsl:text><xsl:value-of select="$ordnr"/><xsl:text><![CDATA[]/completefields/feld [@varname="]]></xsl:text><xsl:value-of select="$varname"/><xsl:text><![CDATA["]/@varname]]></xsl:text></fieldDescription>
</field>
<!--dann Wert-->
<field name="{concat('legende_',$jasperFieldname,'_value')}" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis[@ordnr=]]></xsl:text><xsl:value-of select="$ordnr"/><xsl:text><![CDATA[]/felder/feld [@varname="]]></xsl:text><xsl:value-of select="$varname"/><xsl:text><![CDATA["]/value_caption]]></xsl:text></fieldDescription>
</field>
</xsl:for-each>
<!-- dann die Legende-->
<xsl:for-each select="distinct-values(//ergebnisse/ergebnis/completefields/feld/@varname)">
</xsl:if>
</xsl:for-each><!-- Ende Ergebniselemente -->
<!-- dann die Legende Hauptbericht-->
<xsl:if test="$isMainReport='true'">
<xsl:for-each select="distinct-values(/ergebnisse/ergebnis/completefields/feld/@varname)">
<xsl:variable name="jasperFieldname">
<xsl:call-template name="createJasperFieldname">
<xsl:with-param name="fieldName_orig" select="."/>
@ -313,8 +343,8 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -313,8 +343,8 @@ isIgnorePagination="{$isIgnorePagination}" >
<field name="{concat('legende_',$jasperFieldname,'_value')}" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis/felder/feld [@varname="]]></xsl:text><xsl:value-of select="$varname"/><xsl:text><![CDATA["]/value_caption]]></xsl:text></fieldDescription>
</field>
</xsl:for-each>
</xsl:if>
<!--Standatum und User:-->
<field name="standdatum" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis[ @ordnr='0']/stand]]></xsl:text></fieldDescription>
@ -479,6 +509,7 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -479,6 +509,7 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:template name="jr_textField">
<xsl:param name="ergebnisElementOrdnr" />
<xsl:param name="fieldName" />
<xsl:param name="colName" />
<xsl:param name="colId" />
<xsl:param name="x" select="'0'" />
<xsl:param name="width" select="'0'" />
@ -503,7 +534,34 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -503,7 +534,34 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:with-param name="colId" select="$colId" />
</xsl:call-template>
</xsl:variable>
<xsl:if test="normalize-space($jasperFieldname)!=''"> <!-- keine leeren Feldnamen-->
<!--start Feldausgabe, zuerst prüfen ob besonderer Feldname-->
<xsl:choose>
<xsl:when test="normalize-space($jasperFieldname)=''"> <!-- keine leeren Feldnamen-->
</xsl:when>
<xsl:when test="starts-with($colName,'_graph')">
<xsl:variable name="alignLeft">
<xsl:choose>
<xsl:when test="starts-with($colName,'_graphbarright')">
<xsl:text>false</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>true</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<image scaleImage="RealSize" evaluationTime="Band">
<reportElement x="{$x}" y="0" width="{$width}" height="{$height}" />
<imageExpression><xsl:text><![CDATA[net.sf.jasperreports.renderers.SimpleDataRenderer.getInstance(de.superx.rpta.SvgProducer.SimpleBarChart($F{]]></xsl:text><xsl:value-of select="$jasperFieldname" />
<xsl:text>},100,</xsl:text>
<xsl:value-of select="$width"/><xsl:text>,</xsl:text>
<xsl:value-of select="$height"/><xsl:text>,"#cccccc","steelblue",</xsl:text>
<xsl:value-of select="$alignLeft"/><xsl:text>).getBytes("UTF-8"))</xsl:text></imageExpression>
</image>
</xsl:when>
<xsl:otherwise>
<!-- normales Textfeld: -->
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="ContainerHeight" x="{$x}" y="0" width="{$width}" height="{$height}" >
<xsl:attribute name="style">
@ -533,7 +591,10 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -533,7 +591,10 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:with-param name="fieldName" select="$fieldName" />
</xsl:call-template>
</textField>
</xsl:if>
</xsl:otherwise><!-- ende normales Textfeld-->
</xsl:choose>
</xsl:template>
<xsl:template name="getFieldType">
<xsl:param name="ergebnisElementOrdnr" />
@ -812,6 +873,7 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -812,6 +873,7 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:template name="jr_textfield_levelx">
<xsl:param name="ergebnisElementOrdnr" />
<xsl:param name="fieldName" />
<xsl:param name="colName" />
<xsl:param name="colId" />
<xsl:param name="x" />
<xsl:param name="width" />
@ -825,6 +887,7 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -825,6 +887,7 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:with-param name="tableRowLevel" select="$tableRowLevel" />
<xsl:with-param name="ergebnisElementOrdnr" select="$ergebnisElementOrdnr" />
<xsl:with-param name="fieldName" select="$fieldName" />
<xsl:with-param name="colName" select="$colName" />
<xsl:with-param name="colId" select="$colId" />
<xsl:with-param name="x" select="$x" />
<xsl:with-param name="width" select="$width" />
@ -835,6 +898,7 @@ isIgnorePagination="{$isIgnorePagination}" > @@ -835,6 +898,7 @@ isIgnorePagination="{$isIgnorePagination}" >
<xsl:with-param name="maxLevel" select="$maxLevel"/>
<xsl:with-param name="ergebnisElementOrdnr" select="$ergebnisElementOrdnr" />
<xsl:with-param name="fieldName" select="$fieldName" />
<xsl:with-param name="colName" select="$colName" />
<xsl:with-param name="colId" select="$colId" />
<xsl:with-param name="x" select="$x" />
<xsl:with-param name="width" select="$width" />

Loading…
Cancel
Save