@echo off

if "%1"=="" goto :usage
if "%2"=="" goto :usage
if "%3"=="" goto :usage
if "%4"=="" goto :usage
if "%5"=="" goto :usage

@echo Install Schema
sqlplus /nolog @Schema\InstallMIP %1 %2 %3 %4 %5

@echo Install Seed
cd Data\Seed
call InstallSeed %3/%4@%5
cd ..\..
@echo Seed Complete


@echo Install Modules
sqlplus %3/%4@%5 @Modules\Modules.sql
@echo Modules Complete


sqlplus %3/%4@%5 @Data\Seed\create_passwords.sql


if "%6"=="" goto :done
if "%6"=="demo" goto :demo
if "%6"=="test" goto :test
if "%6"=="fat" goto :fat


:demo
@echo Demo
cd Data\Demo
call InstallData %3/%4@%5
cd ..\..
@echo Demo Complete

goto :done

:test
@echo Install Test data
cd Data\test
call InstallData %3/%4@%5
@echo Installed Test data
@echo Installing Test application in APEX...
ruby apex_auto_install.rb
cd ..\..

@echo Test Complete

goto :done

:fat
@echo Install FAT data
cd Data\fat
call InstallData %3/%4@%5
@echo Installed fat data
@echo Installing fat application in APEX...
ruby apex_auto_install.rb
cd ..\..

@echo fat install Complete

goto :done

:usage

echo "usage 		InstallMIP sys_name sys_password app_name app_password db_connect_string [demo|test|fat]"

:done
sqlplus %3/%4@%5 @Data\BulkLoad\bulk_load.sql "%6"