@echo on
echo  =========================
echo  REPORTING DATABASE CREATE
echo  =========================

IF "%DEPLOY_TOOL_HOME%"=="" (
	echo > DEPLOY_TOOL_HOME must be defined
	exit/B
)

IF "%JBOSS_HOME%"=="" (
	echo > JBOSS_HOME must be defined
	exit/B
)

echo copy sql creation files
copy %DEPLOY_TOOL_HOME%\DBcreate\. %DEPLOY_TOOL_HOME%\sql
echo  - Run database create
java -jar %DEPLOY_TOOL_HOME%\bin\install-reports.jar
if %ERRORLEVEL% EQU 1 (
	echo  - Error detected, check install.log file
) else (
	echo  - Database create run successfully
)

echo clearing sql folder contents
del %DEPLOY_TOOL_HOME%\sql\* /Q

echo  ==========================
echo  END OF DATABASE CREATE
echo  ==========================

pause

exit/B