Esempio n. 1
0
 /**
  * Constructor creates and initializes the meta data object create DS object per table
  *
  * @param tableNames - String array of database table names ,It can be zero element array
  * @param singleService - select the service generation mode true one service for whole database
  *     when it false services per table wise
  * @param dataSourceId - carbon datasource id it can be null
  *     <p>When create the connection there are 3 away to do it , First way is provide the relevant
  *     information(url, driver, username, password) which need to create connection that time
  *     other fields(connection, datasourceId) should be null
  *     <p>Second way directly you can provide connection instance
  *     <p>final way is you can provide carbon datasource id(name)
  *     <p>if you wish to use all the tables of database you can provide zero element array
  */
 public DSGenerator(
     String dataSourceId,
     String dbName,
     String[] schemas,
     String[] tableNames,
     boolean singleService,
     String nameSpace,
     String serviceName) {
   this.DSErrorList = new ArrayList<String>();
   try {
     Connection connection;
     String[] tableNameList = tableNames;
     if (dataSourceId != null) {
       connection = createConnection(dataSourceId);
       DatabaseMetaData metaObject = connection.getMetaData();
       if (tableNameList.length == 0) {
         tableNameList = DSGenerator.getTableList(connection, dbName, schemas);
       }
       if (singleService) {
         this.generatedService =
             generateService(
                 dataSourceId, dbName, schemas, tableNameList, metaObject, nameSpace, serviceName);
       } else {
         this.generatedServiceList =
             generateServices(dataSourceId, dbName, schemas, tableNameList, metaObject, nameSpace);
       }
       connection.close();
     }
   } catch (Exception e) {
     log.error("Meta Object initialization failed due to ", e);
   }
 }
Esempio n. 2
0
 public static String[] getSchemas(String datasourceId) throws Exception {
   if (datasourceId != null) {
     Connection connection = createConnection(datasourceId);
     String schemas[] = DSGenerator.getSchemas(connection);
     connection.close();
     return schemas;
   } else {
     return null;
   }
 }
Esempio n. 3
0
 public static String[] getTableList(
     String url, String driver, String userName, String password, String dbName, String[] schemas)
     throws ClassNotFoundException, SQLException {
   if ((url != null) && (driver != null) && (userName != null) && (password != null)) {
     Class.forName(driver);
     Connection connection = DriverManager.getConnection(url, userName, password);
     return DSGenerator.getTableList(connection, dbName, schemas);
   } else {
     return null;
   }
 }
Esempio n. 4
0
 public static String[] getTableList(String datasourceId, String dbName, String[] schemas)
     throws SQLException, DataServiceFault {
   if (datasourceId != null) {
     Connection connection = createConnection(datasourceId);
     String tableList[] = DSGenerator.getTableList(connection, dbName, schemas);
     connection.close();
     return tableList;
   } else {
     return null;
   }
 }