Rem : creating batch for windows platform

@echo off

Rem : ********* Optional step javaExe : specifies the location of your JRE. Note that if java is installed in your machine, you can access to jre simply with JAVA
Rem Example : javaExe=C:\Program Files\Java\jre6\bin\java.exe
Rem supported JRE is starting with 5.0
set javaExe=java

Rem : ********* Optional step buildPath : specifies the location of the CASTDBExtractor and CASTDBDeliveryTool. 
Rem - With this example, location of extractor and delivery is the actual batch's path => this variable becomes useless
Rem Example : buildPath=C:\MetadataExtractor\
set buildPath=.

Rem : ********* Step 1 url : specifies the target Oracle server for connection purposes
Rem url form : jdbc:oracle:thin:@SERVERNAME:PORT:SERVICENAME
Rem SERVERNAME: replace with the name or IP address of the server hosting your Oracle server
Rem PORT: specify the port number on which your Oracle instance is running. By default this is 1521 but this may have been changed in your environment
Rem SERVICENAME: replace with the name of your Oracle instance

set url=jdbc:oracle:thin:@teamsgbd03:1521:O102

Rem : ********* Step 2 dbuser and dbpassword : 
Rem dbuser	: tells the Extraction tool what username to use to access the Oracle server
Rem dbpassword 	: tells the Extraction tool what password to use to access the Oracle server (corresponds to the username specified above)
Rem Example : dbuser=system
Rem Example : dbpassword=manager

set dbuser=%1
set dbpassword=%2

Rem : ********* Step 3 platform : specifies the version of the Oracle server you want to deliver ( Oracle11g - Oracle10g - Oracle9i - Oracle8 )
Rem Example : platform=Oracle10g

set platform=%3

if /I %platform% NEQ Oracle11g ( 
if /I %platform% NEQ Oracle10g (
if /I %platform% NEQ Oracle9i (
if /I %platform% NEQ Oracle8i (
		echo Bad platform name. It MUST BE ONE OF THE FOLLOWING : Oracle11g - Oracle10g - Oracle9i - Oracle8
		pause
	)
	)
	)
 )

Rem : ********* Step 4 out_dir : specifies the file you would like the Extractor to output the results to (the resulting file will be a .zip file)
Rem - For example, to put results in your desktop , you have to put in this batch : set out_dir=C:\Documents and Settings\All Users\Desktop\Output
Rem - In this example, out_dir is a folder in the same dir of actual batch. 
set out_dir=.\Results

if NOT EXIST %out_dir% (
	MD %out_dir%
)

Rem : ********* Step 5 container : specifies the schema you would like to extract
Rem - If you intend to extract an entire instance and all schemas, remove this entire parameter from the batch file.
Rem - If you intend to extract multiple schemas you can list them separated with a comma (",")
Rem - extFile : This will be a .zip file,  containing results of extraction
Rem - logFile : an output file for logging purposes. You can name the file anything you like.
Rem Example : container=SQUIRREL_PMT
set container=%4
set extFile=%out_dir%\%container%
set logFile=%out_dir%\output_%container%.log

Rem Run extractor : generate zip files
 %javaExe% -jar "%buildPath%\CASTDBExtractor.jar" -url %url% -user %dbuser% -password %dbpassword% -platform %platform% -parameters schema=%container%  -target %extFile% -l %logFile%

Rem Run injector : generate uax files
 %javaExe% -Xmx512M -jar "%buildPath%\CASTDBDeliveryTool.jar" -source %extFile%  -target "%extFile%" -relativepaths

pause
