Details

    • Type: Sub-task
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6.0
    • Component/s: None
    • Labels:
      None
    • Attachments:
      0
    • Comments:
      0
    • Documentation Status:
      Needed

      Description

      Adding DatabaseMnager "namespace" support to create tables in other namespaces than the dspace default namespace

      Modified: dspace/trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java
      ==============================================================================
      — dspace/trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java (original)
      +++ dspace/trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java Sat Oct 3 02:30:56 2009
      @@ -110,7 +110,7 @@

      • type attacks because we are unable to determine where the input came from. Instead
      • we could pass in static integer constants which are then mapped to their sql name.
        */
      • private static final Pattern DB_SAFE_NAME = Pattern.compile("^[a-zA-Z_1-9]+$");
        + private static final Pattern DB_SAFE_NAME = Pattern.compile("^[a-zA-Z_1-9.]+$");

      /**

      • A map of database column information. The key is the table name, a
        @@ -1190,6 +1190,10 @@ { row.setColumn(name, results.getLong(i)); }

        + else if (jdbctype == Types.DOUBLE)
        +

        { + row.setColumn(name, results.getDouble(i)); + }

        else if (jdbctype == Types.CLOB && "oracle".equals(dbName))
        {
        // Support CLOBs in place of TEXT columns in Oracle
        @@ -1484,6 +1488,17 @@
        try
        {
        String schema = ConfigurationManager.getProperty("db.schema");
        + String catalog = null;
        +
        + int dotIndex = table.indexOf(".");
        + if (dotIndex > 0)
        +

        { + catalog = table.substring(0, dotIndex); + table = table.substring(dotIndex + 1, table.length()); + log.warn("catalog: " + catalog); + log.warn("table: " + table); + }

        +
        connection = getConnection();

      DatabaseMetaData metadata = connection.getMetaData();
      @@ -1492,14 +1507,15 @@
      int max = metadata.getMaxTableNameLength();
      String tname = (table.length() >= max) ? table
      .substring(0, max - 1) : table;
      -

      • pkcolumns = metadata.getPrimaryKeys(null, schema, tname);
        +
        + pkcolumns = metadata.getPrimaryKeys(catalog, schema, tname);
        +
        Set pks = new HashSet();

      while (pkcolumns.next())
      pks.add(pkcolumns.getString(4));

      • columns = metadata.getColumns(null, schema, tname, null);
        + columns = metadata.getColumns(catalog, schema, tname, null);

      while (columns.next())

      { Modified: dspace/trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/TableRow.java ============================================================================== --- dspace/trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/TableRow.java (original) +++ dspace/trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/TableRow.java Sat Oct 3 02:30:56 2009 @@ -230,6 +230,47 @@ }

      /**
      + * Return the double value of column.
      + *
      + * If the column's type is not an float, or the column does not exist, an
      + * IllegalArgumentException is thrown.
      + *
      + * @param column
      + * The column name (case-insensitive)
      + * @return The double value of the column, or -1 if the column is an SQL null.
      + */
      + public double getDoubleColumn(String column)
      + {
      + if (!hasColumn(column))
      +

      { + throw new IllegalArgumentException("No such column " + column); + }
      +
      + String name = canonicalize(column);
      +
      + if (isColumnNull(name))
      + { + return -1; + }
      +
      + Object value = data.get(name);
      +
      + if (value == null)
      + { + throw new IllegalArgumentException("Column " + column + + " not present"); + }
      +
      + if (!(value instanceof Double))
      + { + throw new IllegalArgumentException("Value for " + column + + " is not a double"); + }
      +
      + return ((Double) value).doubleValue();
      + }
      +
      + /**
      * Return the String value of column.
      *
      * If the column's type is not a String, or the column does not exist, an
      @@ -504,6 +545,32 @@
      }

      /**
      + * Set column to the double d.
      + *
      + * If the column does not exist, an IllegalArgumentException is thrown.
      + *
      + * @param column
      + * The column name (case-insensitive)
      + * @param l
      + * The double value
      + */
      + public void setColumn(String column, double d)
      + {
      + if (!hasColumn(column))
      + {+ throw new IllegalArgumentException("No such column " + column);+ }

      +
      + String canonName = canonicalize(column);
      + Double value = new Double(d);
      + if (!value.equals(data.get(canonName)))
      +

      { + data.put(canonName, value); + changed.put(canonName, Boolean.TRUE); + }

      + }
      +
      + /**

      • Set column to the date d. If the date is null, the column is set to NULL
      • as well.
        *

        Attachments

          Activity

            People

            Assignee:
            mdiggory Mark Diggory
            Reporter:
            mdiggory Mark Diggory
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: