[ 
http://jira.dspace.org/jira/browse/DS-335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mark Diggory resolved DS-335.
-----------------------------

       Resolution: Fixed
    Fix Version/s: 1.6.0
         Assignee: Mark Diggory

> Minho Statistics Database Manager additions.
> --------------------------------------------
>
>                 Key: DS-335
>                 URL: http://jira.dspace.org/jira/browse/DS-335
>             Project: DSpace 1.x
>          Issue Type: Sub-task
>            Reporter: Mark Diggory
>            Assignee: Mark Diggory
>            Priority: Minor
>             Fix For: 1.6.0
>
>
> 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.
>      *

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.dspace.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Dspace-devel mailing list
Dspace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to