#! /bin/bash
cyflexlogevent -t generic -m 1 -m "script" -m "$0" 

#
# Script name: cyflex_reporting
#
# Purpose: Generate a report file, for example plain text or HTML, based
#    on a template file and CyFlex label values.
#
# Invoking arguments:
#    -connection CONNECTION  Optional - CyFlex connection.
#                            Default - "local". Mainly for testing.
#    -object_name NAME       Optional - Name of references in template
#                            file. Default "facade"
#    -input OUTPUT           Input template file
#
# Output:
#    Output sent to standard out.
#
# Notes:
#    Based on the Velocity open-source report generation package.
#
# History:
#   05/02/11 - Rob Janes - Initial release.
#

if (( $# == 0 )); then
cat <<eod

Usage: cyflex_reporting -input template.html -output report.html -object_name cyflex
eod
exit 1
fi

# Shell variables must begin with a letter.  So this can not be called
# 3RDPARTY.  D is for Directory.
D3RDPARTY=/cyflex/specfilegui.3rdparty
SPECFILEGUI=/cyflex/specfilegui
PROPERTIES="-DPropertiesFile=/cell/cui_properties.txt"

# Find the protocol buffer jar file to reference.
. /cyflex/cmds/find_protobuf.sh

# Jar files are listing in approximate order of their use.
CLASSPATH=\
$SPECFILEGUI/applications.jar\
:$SPECFILEGUI/specfilegui.jar\
:$SPECFILEGUI/facade.jar\
:$D3RDPARTY/velocity-1.6.1-dep.jar\
:$D3RDPARTY/iText-5.0.2.jar\
:$PROTO\
:$D3RDPARTY/jcmdline.jar
export CLASSPATH

export JAVA_HOME=/cyflex/java_jdk
PATH=$JAVA_HOME/bin:$PATH
chrt -o 0 java -Xms128m -Xmx256m $PROPERTIES \
   com.cybermetrix.cyflex.applications.VelocityCyFlexInterface $*
