コード例 #1
0
 private int countTableRows(String tableName) {
   int tableRows = 0;
   if (isValidTable(tableName)) {
     ResultSet rs = null;
     try {
       rs = executeTableQuery(tableName);
       int rsRowCount = ResultSetTranslator.getRowCount(rs);
       if (rsRowCount > 0) {
         tableRows += rsRowCount;
       }
       rs.close();
     } catch (SQLException e) {
       final String msg =
           "Error doing rowCount on table "
               + this.modelAndSchemaName
               + DELIM
               + tableName; //$NON-NLS-1$
       MetamodelBuilderUtil.addStatus(status, IStatus.WARNING, msg, e);
       return tableRows;
     }
     return tableRows;
   }
   final String msg =
       "Table not found when counting rows: "
           + this.modelAndSchemaName
           + DELIM
           + tableName; //$NON-NLS-1$
   MetamodelBuilderUtil.addStatus(status, IStatus.WARNING, msg);
   return tableRows;
 }
コード例 #2
0
  /* (non-Javadoc)
   * @see com.metamatrix.metamodels.builder.processor.Processor#getRecordCount(org.eclipse.core.runtime.IStatus)
   */
  public int getRecordCount() {
    int totalRows = 0;

    // ----------------------------------------------
    // Get the available Tables for this schema
    // ----------------------------------------------
    List tableNames = null;
    try {
      tableNames = getSchemaTables();
    } catch (SQLException e) {
      // Log the exception
      final String msg =
          "Error retrieving the tables for " + this.modelAndSchemaName; // $NON-NLS-1$
      MetamodelBuilderUtil.addStatus(status, IStatus.ERROR, msg, e);
      return totalRows;
    }

    // ----------------------------------------------
    // Count the table rows
    // ----------------------------------------------
    if (tableNames != null) {
      for (int i = 0; i < processingOrder.length; i++) {
        if (tableNames.contains(processingOrder[i])) {
          int tableRows = countTableRows(processingOrder[i]);
          if (tableRows > 0) {
            totalRows += tableRows;
          }
          if (status.getSeverity() == IStatus.ERROR) {
            return totalRows;
          }
        }
      }
    }
    return totalRows;
  }
コード例 #3
0
  /* (non-Javadoc)
   * @see com.metamatrix.metamodels.builder.processor.Processor#process(org.eclipse.core.runtime.IProgressMonitor)
   */
  public IStatus process(IProgressMonitor monitor) {
    if (monitor != null) {
      monitor.subTask("Processing Entities for " + this.modelAndSchemaName); // $NON-NLS-1$
    }

    // ----------------------------------------------
    // Get the available Tables for this schema
    // ----------------------------------------------
    List tableNames = null;
    try {
      tableNames = getSchemaTables();
    } catch (SQLException e) {
      // Log the exception
      final String msg =
          "Error retrieving the tables for " + this.modelAndSchemaName; // $NON-NLS-1$
      MetamodelBuilderUtil.addStatus(status, IStatus.ERROR, msg, e);
      return status;
    }

    // ----------------------------------------------
    // Process Tables in the specified order
    // ----------------------------------------------
    if (tableNames != null) {
      for (int i = 0; i < processingOrder.length; i++) {
        if (tableNames.contains(processingOrder[i])) {
          processTable(processingOrder[i], monitor);
          if (status.getSeverity() == IStatus.ERROR) {
            return status;
          }
        }
      }
    }

    if (monitor != null && monitor.isCanceled()) {
      final String msg = "Entity Processing Cancelled"; // $NON-NLS-1$
      MetamodelBuilderUtil.addStatus(status, IStatus.CANCEL, msg);
      return status;
    }
    return status;
  }
コード例 #4
0
 private void processTable(String tableName, IProgressMonitor monitor) {
   if (isValidTable(tableName)) {
     ResultSet rs = null;
     try {
       rs = executeTableQuery(tableName);
       List entityRecords = RecordGenerator.generateEntityRecords(rs, this.status, monitor);
       // Iterate for progress monitor
       Iterator iter = entityRecords.iterator();
       while (iter.hasNext()) {
         this.entityBuilder.create((MetamodelEntityRecord) iter.next(), monitor);
       }
       rs.close();
     } catch (SQLException e) {
       final String msg =
           "Error Processing Table " + this.modelAndSchemaName + DELIM + tableName; // $NON-NLS-1$
       MetamodelBuilderUtil.addStatus(status, IStatus.ERROR, msg, e);
       return;
     }
     return;
   }
   final String msg =
       "Table not found: " + this.modelAndSchemaName + DELIM + tableName; // $NON-NLS-1$
   MetamodelBuilderUtil.addStatus(status, IStatus.WARNING, msg);
 }