Пример #1
0
  private void makeServices(
      String dbName,
      String[] tableNames,
      DatabaseMetaData metaData,
      List<DataService> dataServiceList,
      String schema,
      String datasourceId,
      String serviceNamespace)
      throws SQLException, DataServiceFault {

    for (String tableName : tableNames) {
      String serviceName = tableName + DBConstants.DataServiceGenerator.SERVICE_NAME_SUFFIX;
      DataService dataService =
          new DataService(
              serviceName,
              DBConstants.DataServiceGenerator.MUTLIPLE_SERVICE_DESCRIPTION,
              null,
              null,
              DBConstants.DataServiceGenerator.ACTIVE,
              false,
              false,
              false,
              null);
      if (DBUtils.isEmptyString(serviceNamespace)) {
        dataService.setServiceNamespace(DBConstants.WSO2_DS_NAMESPACE);
      } else {
        dataService.setServiceNamespace(serviceNamespace);
      }
      this.setConfig(dataService, datasourceId);
      String tablePrimaryKey = this.getPrimaryKey(metaData, dbName, schema, tableName);
      this.addOperations(dataService, schema, metaData, dbName, tableName, tablePrimaryKey);
      dataServiceList.add(dataService);
    }
  }
Пример #2
0
 private DataService generateService(
     String datasourceId,
     String dbName,
     String[] schemas,
     String[] tableNames,
     DatabaseMetaData metaData,
     String serviceNamespace,
     String serviceName)
     throws DataServiceFault, SQLException {
   // String serviceName = dbName + DBConstants.DataServiceGenerator.SERVICE_NAME_SUFFIX;
   DataService dataService =
       new DataService(
           serviceName,
           DBConstants.DataServiceGenerator.SINGLE_SERVICE_DESCRIPTION,
           null,
           null,
           DBConstants.DataServiceGenerator.ACTIVE,
           false,
           false,
           false,
           null);
   this.setConfig(dataService, datasourceId);
   if (DBUtils.isEmptyString(serviceNamespace)) {
     dataService.setServiceNamespace(DBConstants.WSO2_DS_NAMESPACE);
   } else {
     dataService.setServiceNamespace(serviceNamespace);
   }
   if (schemas.length != 0) {
     for (String schema : schemas) {
       makeService(dbName, tableNames, metaData, dataService, schema);
     }
   } else {
     String schema = null;
     makeService(dbName, tableNames, metaData, dataService, schema);
   }
   return dataService;
 }