<?xml version="1.0" encoding="UTF-8"?>

	<project name="CCTNSApplication" default="CCTNS" basedir=".">
<property name="directory" value="C:\CCTNSApplication"/>
<property name="ant_log_directory" value="C:\cctns_offline_installation_log"/>	
	    <record name="${ant_log_directory}\simple.log"/>




<echo message="CCTNS Application Installaing " /> 
	
<target name="CCTNS" depends="OfflineVersionCompliance,versionCheckComplianceStatusCheck,MySqlUserDetails,DBScript,ApplicationDBUserDetails" >

	<echo message="CCTNS Installed " /> 
</target>

<target name="OfflineVersionCompliance" description="OfflineVersionCompliance" >
<echo message="Ant java version: ${ant.java.version}" />
	<echo message="Offline Version Compliance check"> </echo>
  	  <java jar="C:\CCTNSApplication\OfflineVersionCompliance\OfflineVersionComplianceUtility.jar" fork="true" />
  <property file="C:/CCTNSApplication/version_compliance_result.txt"/>
  <property name="compliance_status" value="${status}"/>
	
  <echo message="value of compliance_status=${compliance_status}" />
  </target>

  <target name="versionCheckComplianceStatusCheck" depends="OfflineVersionCompliance" unless="${compliance_status}">
	<echo message="Offline Version Compliance Failed, Installation will exit." />
	<fail message="Offline Version Compliance Failed, Installation will exit."/>
  </target>  

<target name="MySqlUserDetails" description="MySqlUserDetails" >
	<echo message="MySql User Details to Access the DB"> </echo>
  	  <java jar="C:\CCTNSApplication\MySQlAccess\MySQLAccessConfig.jar" fork="true"/>
  <property file="C:/CCTNSApplication/database.properties"/>
  <property name="db.username" value="${db.user}"/>
  <property name="db.password" value="${db.pass}"/>
  <property name="db.name" value="${db.mySqlDBname}"/>
<!--
  <property name="mysql" value="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql"/>
  <property name="mysqladmin" value="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqladmin"/>
 -->
  <property name="mysql" value="${mysqlbin}\mysql"/>
  <property name="mysqladmin" value="${mysqladminbin}\mysqladmin"/> 
  <property name="restore.dir" value="C:\CCTNSApplication\DbScript\script"/>
  <property name="db.url" value="${db.urlMysql}"/> 	
  <echo message="value of Path=${mysqlbin}" />
  </target>

<target name="ApplicationDBUserDetails" description="ApplicationDBUserDetails" depends="DBScript"  >
<property name="return_value_app_configure" value=""/>
	<echo message="MySql User Details to Access the Application"> </echo>
	<java jar="C:\CCTNSApplication\ConfigureCASOffline.jar" fork="true"    />
	

   </target>
<target name="DBScript" description="Running DB Script" >
    <echo message="Executing DB script " />
    <exec executable="${mysql}" input="${restore.dir}.sql">
      <arg value="--user=${db.username}"/>
      <arg value="--password=${db.password}"/>
      <arg value="--force"/>
      <arg value="${db.name}"/>
    </exec>
</target>
<property name="browser" location="C:/CCTNSApplication"/>

   <target name="DeleteDB" description="Deleting DB" depends="MySqlUserDetails">
<echo message="Deleteing current DB" />
    <exec executable="${mysqladmin}">
      <arg value="--user=${db.username}"/>
      <arg value="--password=${db.password}"/>
      <arg value="--force"/>
      <arg value="drop"/>
      <arg value="${db.name}"/>
    </exec>
</target>
<target name="CreateDB" description="Creating DB" depends="DeleteDB" >
    <echo message="Creating DB " /> 
    <exec executable="${mysqladmin}">
      <arg value="--user=${db.username}"/>
      <arg value="--password=${db.password}"/>
      <arg value="--force"/>
      <arg value="create"/>
      <arg value="${db.name}"/>
    </exec>
</target>


<!--target name="ApplicationDBUserDetails" description="ApplicationDBUserDetails" depends="DBScript"  >
	<echo message="MySql User Details to Access the Application"> </echo>
  	  <java jar="C:\CCTNSApplication\ConfigureCASOffline.jar" fork="true"/>
   </target -->
<!--target name="SyncPSConfiguration" description="Sync PS Configuration" depends="ApplicationDBUserDetails"  >
	<echo message="MySql User Details to Access the Application"> </echo>
  	  <java jar="C:\CCTNSApplication\SyncPoliceStationConfiguration.jar" fork="true"/>
   </target -->
<target name="CrateShortCut" depends="ApplicationDBUserDetails" description="Created Short Cut">
    <echo message="CCTNS Short CUT Created" /> 	
    <exec executable="cscript">
        <arg value="C:\CCTNSApplication\ShotCCTNS.vbs"/>
     </exec>
</target>
<target name="pauseAfterDone" description="Pause After done" depends="CrateShortCut" >
    <echo message="Done, please look at the output above, if any error please follow the procedure again." /> 	
    <input>Press return(enter) key to continue...</input>
        
    </target>

</project>