示例#1
0
  private void loadDatabaseMetadata() {
    if (!databaseMetadataLoaded) {
      String componentName = "UNKNOWN";
      Connection con = null;
      try {
        componentName = getMetaComponent().getName();

        con = DataSourceConnectionProvider.getByComponent(componentName).getConnection();
        DatabaseMetaData metaData = con.getMetaData();
        supportsSchemasInDataManipulation = metaData.supportsSchemasInDataManipulation();
        Collection timeDateFunctions =
            Strings.toCollection(metaData.getTimeDateFunctions().toUpperCase());

        //
        // another solution instead of the use of 'if' would be to use a xml with
        //	the information of the functions from each BBDD
        if ("DB2 UDB for AS/400".equals(metaData.getDatabaseProductName())
            || "Oracle".equals(metaData.getDatabaseProductName())
            || "PostgresSQL".equals(metaData.getDatabaseProductName())) {
          supportsTranslateFunction = true;
        }
        if ("Oracle".equals(metaData.getDatabaseProductName())
            || "PostgreSQL".equals(metaData.getDatabaseProductName())) {
          supportsYearFunction = supportsMonthFunction = false;
        } else {
          supportsYearFunction = timeDateFunctions.contains("YEAR");
          supportsMonthFunction = timeDateFunctions.contains("MONTH");
        }
        databaseMetadataLoaded = true;
      } catch (Exception ex) {
        log.warn(XavaResources.getString("load_database_metadata_warning"));
      } finally {
        try {
          if (con != null) {
            con.close();
          }
        } catch (SQLException e) {
          log.warn(XavaResources.getString("close_connection_warning"));
        }
      }
    }
  }
示例#2
0
 public MetaTab cloneMetaTab() {
   try {
     MetaTab r = (MetaTab) clone();
     if (r.metaPropertiesHiddenCalculated != null) {
       r.metaPropertiesHiddenCalculated = new ArrayList(metaPropertiesHiddenCalculated);
     }
     if (r.metaPropertiesHidden != null) {
       r.metaPropertiesHidden = new ArrayList(metaPropertiesHidden);
     }
     if (r.propertiesNames != null) {
       r.propertiesNames = new ArrayList(propertiesNames);
     }
     if (r.metaProperties != null) {
       r.metaProperties = new ArrayList(metaProperties);
     }
     if (r.metaPropertiesCalculated != null) {
       r.metaPropertiesCalculated = new ArrayList(metaPropertiesCalculated);
     }
     if (r.tableColumns != null) {
       r.tableColumns = new ArrayList(tableColumns);
     }
     if (r.hiddenPropertiesNames != null) {
       r.hiddenPropertiesNames = new ArrayList(hiddenPropertiesNames);
     }
     if (r.propertiesNamesWithKeyAndHidden != null) {
       r.propertiesNamesWithKeyAndHidden = new ArrayList(propertiesNamesWithKeyAndHidden);
     }
     if (r.hiddenTableColumns != null) {
       r.hiddenTableColumns = new ArrayList(hiddenTableColumns);
     }
     if (r.metaPropertiesTab != null) {
       r.metaPropertiesTab = new HashMap(metaPropertiesTab);
     }
     return r;
   } catch (CloneNotSupportedException ex) {
     throw new RuntimeException(XavaResources.getString("clone_error", getClass()));
   }
 }