/**
  * Genearte the providers
  * 
  * @param String $serviceOutDir Path of output-files for current service
  * @param String $serviceXslDir Path of xsl-files for generating providers
  * @param string $configFile    path of service.config file
  * @param int    $stage         Identifier to judge ehether we need to take 
  *                              connection perameters from the .xml file or we 
  *                              need to pick values from the command line 
  *                              arguments
  *
  * @return void
  */
 public function generateProviders($serviceOutDir, $serviceXslDir, $configFile, $stage)
 {
     try {
         $serviceInfo = ServiceConfig::validateAndGetsServiceInfo();
         $edmxPath = $serviceOutDir . "/" . $this->options['serviceName'] . "EDMX.xml";
         $xdoc = new DomDocument();
         if (file_exists($edmxPath)) {
             if (!$xdoc->load($edmxPath)) {
                 die("Error while loading service EDMX xml file.");
             }
         } else {
             die("Erroe: XML file for metadata generation is not found.");
         }
         $xmlschema = "ODataConnectorForMySQL/EDMXmodel/EDMXModel.xsd";
         /*if (!$xdoc->schemaValidate($xmlschema)) {
               die("$edmxPath is invalid.\n");
           }*/
         $this->generateMetadataProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $edmxPath);
         $this->generateQueryProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $edmxPath, $stage);
         $this->generateServiceProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $configFile);
         $this->generateExpressionProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $configFile);
         $this->generateServiceConfig($serviceOutDir, $this->options['serviceName']);
         $connectionParamFile = $serviceOutDir . "/" . $this->options['serviceName'] . "ConnectionParams.xml";
         unlink($connectionParamFile);
     } catch (\Exception $e) {
         die("\n\nError: {$e->getMessage}()..!!!\n");
     }
 }
 /**
  * Construct a new instance of EDMXGenerator.
  *
  * @param array &$connectionParams Connection parameters for database.
  */
 public function __construct(&$connectionParams)
 {
     //set error handler
     set_error_handler(array($this, "customError"), E_ALL & ~E_DEPRECATED & ~E_NOTICE);
     try {
         $this->connectionParams = $connectionParams;
         $this->myNamespace = $this->connectionParams['serviceName'];
         $this->connection = DriverManager::getConnection($this->connectionParams);
         $this->schemaManager = $this->connection->getSchemaManager();
         $this->serviceInfo = ServiceConfig::validateAndGetsServiceInfo();
         $this->xmlWriter = new \XMLWriter();
         $this->xmlWriter->openMemory();
         $this->xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
         $this->xmlWriter->setIndent(4);
         $this->addTypes();
         $this->schema = $this->getSchema();
         $this->schema = $this->modifySchema($this->schema);
     } catch (Exception $e) {
         die("\n\nError: {$e->getMessage}...!!!()\n");
     }
 }
 /**
  * Genearte the providers
  * @param1 String $serviceOutDir Path of output-files for current service
  * @param2 String $serviceXslDir Path of xsl-files for generating providers
  * @param3 int $stage Identifier to judge ehether we need to take connection perameters from the .xml file or we need to pick values from the command line arguments
  *
  * @return void
  */
 public function generateProviders($serviceOutDir, $serviceXslDir, $configFile, $stage)
 {
     try {
         $serviceInfo = ServiceConfig::validateAndGetsServiceInfo();
         $edmxPath = $serviceOutDir . "/" . $this->_options['serviceName'] . "EDMX.xml";
         $this->generateMetadataProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $edmxPath);
         $this->generateQueryProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $edmxPath, $stage);
         $this->generateServiceProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $configFile);
         $this->generateExpressionProvider(&$serviceInfo, $serviceOutDir, $serviceXslDir, $configFile);
         $this->generateServiceConfig($serviceOutDir, $this->_options['serviceName']);
         $connectionParamFile = $serviceOutDir . "/" . $this->_options['serviceName'] . "ConnectionParams.xml";
         unlink($connectionParamFile);
     } catch (Exception $e) {
         //Handle excerption over here
     }
 }