Examples of TableRowIterator


Examples of org.dspace.storage.rdbms.TableRowIterator

     * @return
     * @throws SQLException
     */
    private Integer getParentCommunityID(int commId) throws SQLException
    {
        TableRowIterator tri = null;

        try
        {
            tri = DatabaseManager.queryTable(context, "Community2Community",
                        "SELECT * FROM Community2Community WHERE child_comm_id=?", commId);

            if (tri.hasNext())
            {
                return tri.next().getIntColumn("parent_comm_id");
            }
        }
        finally
        {
            if (tri != null)
                tri.close();
        }

        return null;
    }
View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

    public static MetadataField[] findAll(Context context) throws SQLException
    {
        List fields = new ArrayList();

        // Get all the metadatafieldregistry rows
        TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataFieldRegistry",
                               "SELECT mfr.* FROM MetadataFieldRegistry mfr, MetadataSchemaRegistry msr where mfr.metadata_schema_id= msr.metadata_schema_id ORDER BY msr.short_id,  mfr.element, mfr.qualifier");

        try
        {
            // Make into DC Type objects
            while (tri.hasNext())
            {
                fields.add(new MetadataField(tri.next()));
            }
        }
        finally
        {
            // close the TableRowIterator to free up resources
            if (tri != null)
                tri.close();
        }

        // Convert list into an array
        MetadataField[] typeArray = new MetadataField[fields.size()];
        return (MetadataField[]) fields.toArray(typeArray);
View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

            throws SQLException
    {
        List fields = new ArrayList();

        // Get all the metadatafieldregistry rows
        TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
                "SELECT * FROM MetadataFieldRegistry WHERE metadata_schema_id= ? " +
                " ORDER BY element, qualifier", schemaID);

        try
        {
            // Make into DC Type objects
            while (tri.hasNext())
            {
                fields.add(new MetadataField(tri.next()));
            }
        }
        finally
        {
            // close the TableRowIterator to free up resources
            if (tri != null)
                tri.close();
        }

        // Convert list into an array
        MetadataField[] typeArray = new MetadataField[fields.size()];
        return (MetadataField[]) fields.toArray(typeArray);
View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

            {
                HashMap new_id2field = new HashMap();
                log.info("Loading MetadataField elements into cache.");

                // Grab rows from DB
                TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
                        "SELECT * from MetadataFieldRegistry");

                try
                {
                    while (tri.hasNext())
                    {
                        TableRow row = tri.next();
                        int fieldID = row.getIntColumn("metadata_field_id");
                        new_id2field.put(new Integer(fieldID), new MetadataField(row));
                    }
                }
                finally
                {
                    // close the TableRowIterator to free up resources
                    if (tri != null)
                        tri.close();
                }

                id2field = new_id2field;
            }
        }
View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

        {
            return null;
        }

        // See if the extension is in the fileextension table
        TableRowIterator tri = DatabaseManager.query(context,
                "SELECT bitstreamformatregistry.* FROM bitstreamformatregistry, " +
                "fileextension WHERE fileextension.extension LIKE ? " +
                "AND bitstreamformatregistry.bitstream_format_id=" +
                "fileextension.bitstream_format_id",
                extension);

        BitstreamFormat retFormat = null;
        try
        {
            if (tri.hasNext())
            {
                // Return first match
                retFormat = new BitstreamFormat(context, tri.next());
            }
            else
            {
                retFormat = null;
            }
        }
        finally
        {
            // close the TableRowIterator to free up resources
            if (tri != null)
                tri.close();
        }
        return retFormat;
    }
View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

        ourContext = context;
        bundleRow = row;
        bitstreams = new ArrayList<Bitstream>();

        // Get bitstreams
        TableRowIterator tri = DatabaseManager.queryTable(
                ourContext, "bitstream",
                "SELECT bitstream.* FROM bitstream, bundle2bitstream WHERE "
                        + "bundle2bitstream.bitstream_id=bitstream.bitstream_id AND "
                        + "bundle2bitstream.bundle_id= ? ",
                bundleRow.getIntColumn("bundle_id"));

        try
        {
            while (tri.hasNext())
            {
                TableRow r = (TableRow) tri.next();

                // First check the cache
                Bitstream fromCache = (Bitstream) context.fromCache(
                        Bitstream.class, r.getIntColumn("bitstream_id"));

                if (fromCache != null)
                {
                    bitstreams.add(fromCache);
                }
                else
                {
                    bitstreams.add(new Bitstream(ourContext, r));
                }
            }
        }
        finally
        {
            // close the TableRowIterator to free up resources
            if (tri != null)
                tri.close();
        }

        // Cache ourselves
        context.cache(this, row.getIntColumn("bundle_id"));

View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

    public Item[] getItems() throws SQLException
    {
        List<Item> items = new ArrayList<Item>();

        // Get items
        TableRowIterator tri = DatabaseManager.queryTable(
            ourContext, "item",
                "SELECT item.* FROM item, item2bundle WHERE " +
                "item2bundle.item_id=item.item_id AND " +
                "item2bundle.bundle_id= ? ",
                bundleRow.getIntColumn("bundle_id"));

        try
        {
            while (tri.hasNext())
            {
                TableRow r = (TableRow) tri.next();

                // Used cached copy if there is one
                Item fromCache = (Item) ourContext.fromCache(Item.class, r
                        .getIntColumn("item_id"));

                if (fromCache != null)
                {
                    items.add(fromCache);
                }
                else
                {
                    items.add(new Item(ourContext, r));
                }
            }
        }
        finally
        {
            // close the TableRowIterator to free up resources
            if (tri != null)
                tri.close();
        }

        Item[] itemArray = new Item[items.size()];
        itemArray = (Item[]) items.toArray(itemArray);

View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

                "DELETE FROM bundle2bitstream WHERE bundle_id= ? "+
                "AND bitstream_id= ? ",
                getID(), b.getID());

        // If the bitstream is orphaned, it's removed
        TableRowIterator tri = DatabaseManager.query(ourContext,
                "SELECT * FROM bundle2bitstream WHERE bitstream_id= ? ",
                b.getID());

        try
        {
            if (!tri.hasNext())
            {
                // The bitstream is an orphan, delete it
                b.delete();
            }
        }
        finally
        {
            // close the TableRowIterator to free up resources
            if (tri != null)
                tri.close();
        }
    }
View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

        {
            context = new Context();

            // Deal with withdrawn items first.
            // last_modified takes the value of the deletion date
            TableRowIterator tri = DatabaseManager.queryTable(context, "item",
                    "SELECT * FROM item WHERE withdrawal_date IS NOT NULL");

            while (tri.hasNext())
            {
                TableRow row = tri.next();
                DCDate d = new DCDate(row.getStringColumn("withdrawal_date"));
                row.setColumn("last_modified", d.toDate());
                DatabaseManager.update(context, row);
            }
            tri.close();

            // Next, update those items with a date.available
            tri = DatabaseManager.query(context,
                        "SELECT item.item_id, dcvalue.text_value FROM item, dctyperegistry, "+
                        "dcvalue WHERE item.item_id=dcvalue.item_id AND dcvalue.dc_type_id="+
                        "dctyperegistry.dc_type_id AND dctyperegistry.element LIKE 'date' "+
                        "AND dctyperegistry.qualifier LIKE 'available'");

            while (tri.hasNext())
            {
                TableRow resultRow = tri.next();
                DCDate d = new DCDate(resultRow.getStringColumn("text_value"));

                // Can't update the row, have to do a separate query
                TableRow itemRow = DatabaseManager.find(context, "item",
                        resultRow.getIntColumn("item_id"));
                itemRow.setColumn("last_modified", d.toDate());
                DatabaseManager.update(context, itemRow);
            }
            tri.close();

            // Finally, for all items that have no date.available or withdrawal
            // date, set the update time to now!
            DatabaseManager.updateQuery(context,
                        "UPDATE item SET last_modified=now() WHERE last_modified IS NULL");
View Full Code Here

Examples of org.dspace.storage.rdbms.TableRowIterator

     * @return WorkflowItem [] of all workflows in system
     */
    public static WorkflowItem[] findAll(Context c) throws SQLException
    {
        List wfItems = new ArrayList();
        TableRowIterator tri = DatabaseManager.queryTable(c, "workflowitem",
                "SELECT * FROM workflowitem");

        try
        {
            // make a list of workflow items
            while (tri.hasNext())
            {
                TableRow row = tri.next();
                WorkflowItem wi = new WorkflowItem(c, row);
                wfItems.add(wi);
            }
        }
        finally
        {
            if (tri != null)
                tri.close();
        }

        WorkflowItem[] wfArray = new WorkflowItem[wfItems.size()];
        wfArray = (WorkflowItem[]) wfItems.toArray(wfArray);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.