#!/bin/bash
let TotalLines=0
let TotalFiles=0
let DbFiles=0
let DbLines=0
let JavaFiles=0
let JavaLines=0
for afile in `find . -name '*.bash' -o -name '*.bat' -o -name '*.xml' -o -name '*.xsd' | grep -v .git | grep -v .svn | grep -v 'glassfish.*eclipsedefaultdomain' | grep -v installer | grep -v EarContent | grep -v '\\.settings' | grep -v '\\.metadata' | grep -v RemoteSystemsTempFiles | grep -v 'bin/' | grep -v Server`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
done
for afile in `find java/bin/initdata -name '*.xml' | grep -v .git | grep -v .svn`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
done
for afile in `find dbcreate -name '*.pgsql' | grep -v .git | grep -v .svn`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
	let DbLines=DbLines+SubLines
	let DbFiles=DbFiles+1
done
for afile in `find dbcreate -name '*.plsql' | grep -v .git | grep -v .svn`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
	let DbLines=DbLines+SubLines
	let DbFiles=DbFiles+1
done
for afile in `find dbcreate -name '*.sql' | grep -v .git | grep -v .svn`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
	let DbLines=DbLines+SubLines
	let DbFiles=DbFiles+1
done
for afile in `find dbcreate -name '*.isql' | grep -v .git | grep -v .svn`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
	let DbLines=DbLines+SubLines
	let DbFiles=DbFiles+1
done
for afile in `find dbcreate -name '*.tsql' | grep -v .git | grep -v .svn`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
	let DbLines=DbLines+SubLines
	let DbFiles=DbFiles+1
done
for afile in `find dbcreate -name '*.mysql' | grep -v .git | grep -v .svn`
do
	SubLines=`wc -l $afile | cut -d " " -f 1`
	let TotalLines=TotalLines+SubLines
	let TotalFiles=TotalFiles+1
	let DbLines=DbLines+SubLines
	let DbFiles=DbFiles+1
done
for adir in java/*
do
	if [ -d ${adir} ]; then
		for afile in `find ${adir} -name '*.java' | grep -v .git | grep -v .svn | grep -v 'glassfish.*eclipsedefaultdomain' | grep -v installer | grep -v EarContent | grep -v '\\.settings' | grep -v '\\.metadata' | grep -v RemoteSystemsTempFiles | grep -v 'bin/' | grep -v 'build/'`
		do
			SubLines=`wc -l $afile | cut -d " " -f 1`
			let TotalLines=TotalLines+SubLines
			let TotalFiles=TotalFiles+1
			let JavaLines=JavaLines+SubLines
			let JavaFiles=JavaFiles+1
		done
	fi
done
echo "Db files: $DbFiles"
echo "Db lines: $DbLines"
echo "Java files: $JavaFiles"
echo "Java lines: $JavaLines"
echo "Total files: $TotalFiles"
echo "Total lines: $TotalLines"
