⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workspaceitem.java

📁 dspace 用j2ee架构的一个数字图书馆.开源程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * @param context     *            the context object     * @param ep     *            the eperson     *      * @return the corresponding workspace items     */    public static WorkspaceItem[] findByEPerson(Context context, EPerson ep)            throws SQLException    {        List wsItems = new ArrayList();        TableRowIterator tri = DatabaseManager.query(context, "workspaceitem",                "SELECT workspaceitem.* FROM workspaceitem, item WHERE "                        + "workspaceitem.item_id=item.item_id AND "                        + "item.submitter_id=" + ep.getID()                        + " ORDER BY workspaceitem.workspace_item_id");        while (tri.hasNext())        {            TableRow row = tri.next();            // Check the cache            WorkspaceItem wi = (WorkspaceItem) context.fromCache(                    WorkspaceItem.class, row.getIntColumn("workspace_item_id"));            if (wi == null)            {                wi = new WorkspaceItem(context, row);            }            wsItems.add(wi);        }        // close the TableRowIterator to free up resources        tri.close();        WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];        wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);        return wsArray;    }    /**     * Get all workspace items for a particular collection.     *      * @param context     *            the context object     * @param c     *            the collection     *      * @return the corresponding workspace items     */    public static WorkspaceItem[] findByCollection(Context context, Collection c)            throws SQLException    {        List wsItems = new ArrayList();        TableRowIterator tri = DatabaseManager.query(context, "workspaceitem",                "SELECT workspaceitem.* FROM workspaceitem WHERE "                        + "workspaceitem.collection_id=" + c.getID());        while (tri.hasNext())        {            TableRow row = tri.next();            // Check the cache            WorkspaceItem wi = (WorkspaceItem) context.fromCache(                    WorkspaceItem.class, row.getIntColumn("workspace_item_id"));            // not in cache? turn row into workspaceitem            if (wi == null)            {                wi = new WorkspaceItem(context, row);            }            wsItems.add(wi);        }        // close the TableRowIterator to free up resources        tri.close();        WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];        wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);        return wsArray;    }    /**     * Get all workspace items in the whole system     *     * @param   context     the context object     *     * @return      all workspace items     */    public static WorkspaceItem[] findAll(Context context)        throws SQLException    {        List wsItems = new ArrayList();        String query = "SELECT * FROM workspaceitem ORDER BY item_id";        TableRowIterator tri = DatabaseManager.query(context,                                    "workspaceitem",                                    query);        while (tri.hasNext())        {            TableRow row = tri.next();                        // Check the cache            WorkspaceItem wi = (WorkspaceItem) context.fromCache(                    WorkspaceItem.class, row.getIntColumn("workspace_item_id"));            // not in cache? turn row into workspaceitem            if (wi == null)            {                wi = new WorkspaceItem(context, row);            }                        wsItems.add(wi);        }                WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];        wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);        return wsArray;    }        /**     * Get the internal ID of this workspace item     *      * @return the internal identifier     */    public int getID()    {        return wiRow.getIntColumn("workspace_item_id");    }    /**     * Get the value of the stage reached column     *      * @return the value of the stage reached column     */    public int getStageReached()    {        return wiRow.getIntColumn("stage_reached");    }    /**     * Set the value of the stage reached column     *      * @param v     *            the value of the stage reached column     */    public void setStageReached(int v)    {        wiRow.setColumn("stage_reached", v);    }    /**     * Update the workspace item, including the unarchived item.     */    public void update() throws SQLException, AuthorizeException, IOException    {        // Authorisation is checked by the item.update() method below        HistoryManager.saveHistory(ourContext, this, HistoryManager.MODIFY,                ourContext.getCurrentUser(), ourContext.getExtraLogInfo());        log.info(LogManager.getHeader(ourContext, "update_workspace_item",                "workspace_item_id=" + getID()));        // Update the item        item.update();        // Update ourselves        DatabaseManager.update(ourContext, wiRow);    }    /**     * Delete the workspace item. The entry in workspaceitem, the unarchived     * item and its contents are all removed (multiple inclusion     * notwithstanding.)     */    public void deleteAll() throws SQLException, AuthorizeException,            IOException    {        /*         * Authorisation is a special case. The submitter won't have REMOVE         * permission on the collection, so our policy is this: Only the         * original submitter or an administrator can delete a workspace item.         */        if (!AuthorizeManager.isAdmin(ourContext)                && ((ourContext.getCurrentUser() == null) || (ourContext                        .getCurrentUser().getID() != item.getSubmitter()                        .getID())))        {            // Not an admit, not the submitter            throw new AuthorizeException("Must be an administrator or the "                    + "original submitter to delete a workspace item");        }        HistoryManager.saveHistory(ourContext, this, HistoryManager.REMOVE,                ourContext.getCurrentUser(), ourContext.getExtraLogInfo());        log.info(LogManager.getHeader(ourContext, "delete_workspace_item",                "workspace_item_id=" + getID() + "item_id=" + item.getID()                        + "collection_id=" + collection.getID()));        //deleteSubmitPermissions();        // Remove from cache        ourContext.removeCached(this, getID());        // Need to delete the epersongroup2workspaceitem row first since it refers        // to workspaceitem ID        deleteEpersonGroup2WorkspaceItem();        // Need to delete the workspaceitem row first since it refers        // to item ID        DatabaseManager.delete(ourContext, wiRow);        // Delete item        item.delete();    }    private void deleteEpersonGroup2WorkspaceItem() throws SQLException    {                String removeSQL="DELETE FROM epersongroup2workspaceitem WHERE workspace_item_id = " + getID();        DatabaseManager.updateQuery(ourContext, removeSQL);            }    public void deleteWrapper() throws SQLException, AuthorizeException,            IOException    {        // Check authorisation. We check permissions on the enclosed item.        AuthorizeManager.authorizeAction(ourContext, item, Constants.WRITE);        HistoryManager.saveHistory(ourContext, this, HistoryManager.REMOVE,                ourContext.getCurrentUser(), ourContext.getExtraLogInfo());        log.info(LogManager.getHeader(ourContext, "delete_workspace_item",                "workspace_item_id=" + getID() + "item_id=" + item.getID()                        + "collection_id=" + collection.getID()));        //        deleteSubmitPermissions();        // Remove from cache        ourContext.removeCached(this, getID());        // Need to delete the workspaceitem row first since it refers        // to item ID        DatabaseManager.delete(ourContext, wiRow);    }    // InProgressSubmission methods    public Item getItem()    {        return item;    }    public Collection getCollection()    {        return collection;    }    public EPerson getSubmitter() throws SQLException    {        return item.getSubmitter();    }    public boolean hasMultipleFiles()    {        return wiRow.getBooleanColumn("multiple_files");    }    public void setMultipleFiles(boolean b)    {        wiRow.setColumn("multiple_files", b);    }    public boolean hasMultipleTitles()    {        return wiRow.getBooleanColumn("multiple_titles");    }    public void setMultipleTitles(boolean b)    {        wiRow.setColumn("multiple_titles", b);    }    public boolean isPublishedBefore()    {        return wiRow.getBooleanColumn("published_before");    }    public void setPublishedBefore(boolean b)    {        wiRow.setColumn("published_before", b);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -