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

📄 workflowmanager.java

📁 dspace 用j2ee架构的一个数字图书馆.开源程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            throws SQLException, IOException, AuthorizeException    {        Item myitem = wfi.getItem();        Collection mycollection = wfi.getCollection();        // FIXME: How should this interact with the workflow system?        // FIXME: Remove license        // FIXME: Provenance statement?        // Create the new workspace item row        TableRow row = DatabaseManager.create(c, "workspaceitem");        row.setColumn("item_id", myitem.getID());        row.setColumn("collection_id", mycollection.getID());        DatabaseManager.update(c, row);        int wsi_id = row.getIntColumn("workspace_item_id");        WorkspaceItem wi = WorkspaceItem.find(c, wsi_id);        wi.setMultipleFiles(wfi.hasMultipleFiles());        wi.setMultipleTitles(wfi.hasMultipleTitles());        wi.setPublishedBefore(wfi.isPublishedBefore());        wi.update();        // remove any licenses that the item may have been given        myitem.removeLicenses();        //myitem.update();        log.info(LogManager.getHeader(c, "return_to_workspace",                "workflow_item_id=" + wfi.getID() + "workspace_item_id="                        + wi.getID()));        // Now remove the workflow object manually from the database        DatabaseManager.updateQuery(c,                "DELETE FROM WorkflowItem WHERE workflow_id=" + wfi.getID());        return wi;    }    /**     * rejects an item - rejection means undoing a submit - WorkspaceItem is     * created, and the WorkflowItem is removed, user is emailed     * rejection_message.     *      * @param c     *            Context     * @param wi     *            WorkflowItem to operate on     * @param e     *            EPerson doing the operation     * @param rejection_message     *            message to email to user     */    public static WorkspaceItem reject(Context c, WorkflowItem wi, EPerson e,            String rejection_message) throws SQLException, AuthorizeException,            IOException    {        // authorize a DSpaceActions.REJECT        // stop workflow        deleteTasks(c, wi);        // rejection provenance        Item myitem = wi.getItem();        // Get current date        String now = DCDate.getCurrent().toString();        // Get user's name + email address        String usersName = getEPersonName(e);        // Here's what happened        String provDescription = "Rejected by " + usersName + ", reason: "                + rejection_message + " on " + now + " (GMT) ";        // Add to item as a DC field        myitem.addDC("description", "provenance", "en", provDescription);        myitem.update();        // convert into personal workspace        WorkspaceItem wsi = returnToWorkspace(c, wi);        // notify that it's been rejected        notifyOfReject(c, wi, e, rejection_message);        log.info(LogManager.getHeader(c, "reject_workflow", "workflow_item_id="                + wi.getID() + "item_id=" + wi.getItem().getID()                + "collection_id=" + wi.getCollection().getID() + "eperson_id="                + e.getID()));        return wsi;    }    // creates workflow tasklist entries for a workflow    // for all the given EPeople    private static void createTasks(Context c, WorkflowItem wi, EPerson[] epa)            throws SQLException    {        // create a tasklist entry for each eperson        for (int i = 0; i < epa.length; i++)        {            // can we get away without creating a tasklistitem class?            // do we want to?            TableRow tr = DatabaseManager.create(c, "tasklistitem");            tr.setColumn("eperson_id", epa[i].getID());            tr.setColumn("workflow_id", wi.getID());            DatabaseManager.update(c, tr);        }    }    // deletes all tasks associated with a workflowitem    static void deleteTasks(Context c, WorkflowItem wi) throws SQLException    {        String myrequest = "DELETE FROM TaskListItem WHERE workflow_id="                + wi.getID();        DatabaseManager.updateQuery(c, myrequest);    }    private static void notifyGroupOfTask(Context c, WorkflowItem wi,            Group mygroup, EPerson[] epa) throws SQLException, IOException    {        // check to see if notification is turned off        // and only do it once - delete key after notification has        // been suppressed for the first time        Integer myID = new Integer(wi.getItem().getID());        if (noEMail.containsKey(myID))        {            // suppress email, and delete key            noEMail.remove(myID);        }        else        {            try            {                // Get the item title                String title = getItemTitle(wi);                // Get the submitter's name                String submitter = getSubmitterName(wi);                // Get the collection                Collection coll = wi.getCollection();                String message = "";                switch (wi.getState())                {                case WFSTATE_STEP1POOL:                    message = "It requires reviewing.";                    break;                case WFSTATE_STEP2POOL:                    message = "The submission must be checked before inclusion in the archive.";                    break;                case WFSTATE_STEP3POOL:                    message = "The metadata needs to be checked to ensure compliance with the "                            + "collection's standards, and edited if necessary.";                    break;                }                Email email = ConfigurationManager.getEmail("submit_task");                email.addArgument(title);                email.addArgument(coll.getMetadata("name"));                email.addArgument(submitter);                email.addArgument(message);                email.addArgument(getMyDSpaceLink());                emailRecipients(c, epa, email);            }            catch (MessagingException e)            {                log.warn(LogManager.getHeader(c, "notifyGroupofTask",                        "cannot email user" + " group_id" + mygroup.getID()                                + " workflow_item_id" + wi.getID()));            }        }    }    /**     * Add all the specified people to the list of email recipients,     * and send it     *      * @param c     *            Context     * @param epeople     *            Eperson[] of recipients     * @param email     *            Email object containing the message     */    private static void emailRecipients(Context c, EPerson[] epa, Email email)            throws SQLException, MessagingException    {        for (int i = 0; i < epa.length; i++)        {            email.addRecipient(epa[i].getEmail());        }        email.send();    }    private static String getMyDSpaceLink()    {        return ConfigurationManager.getProperty("dspace.url") + "/mydspace";    }    private static void notifyOfReject(Context c, WorkflowItem wi, EPerson e,            String reason)    {        try        {            // Get the item title            String title = getItemTitle(wi);            // Get the collection            Collection coll = wi.getCollection();            // Get rejector's name            String rejector = getEPersonName(e);            Email email = ConfigurationManager.getEmail("submit_reject");            email.addRecipient(getSubmitterEPerson(wi).getEmail());            email.addArgument(title);            email.addArgument(coll.getMetadata("name"));            email.addArgument(rejector);            email.addArgument(reason);            email.addArgument(getMyDSpaceLink());            email.send();        }        catch (Exception ex)        {            // log this email error            log.warn(LogManager.getHeader(c, "notify_of_reject",                    "cannot email user" + " eperson_id" + e.getID()                            + " eperson_email" + e.getEmail()                            + " workflow_item_id" + wi.getID()));        }    }    // FIXME - are the following methods still needed?    private static EPerson getSubmitterEPerson(WorkflowItem wi)            throws SQLException    {        EPerson e = wi.getSubmitter();        return e;    }    /**     * get the title of the item in this workflow     *      * @param wi  the workflow item object     */    public static String getItemTitle(WorkflowItem wi) throws SQLException    {        Item myitem = wi.getItem();        DCValue[] titles = myitem.getDC("title", null, Item.ANY);        // only return the first element, or "Untitled"        if (titles.length > 0)        {            return titles[0].value;        }        else        {            return "Untitled";        }    }    /**     * get the name of the eperson who started this workflow     *      * @param wi  the workflow item     */    public static String getSubmitterName(WorkflowItem wi) throws SQLException    {        EPerson e = wi.getSubmitter();        return getEPersonName(e);    }    private static String getEPersonName(EPerson e) throws SQLException    {        String submitter = e.getFullName();        submitter = submitter + "(" + e.getEmail() + ")";        return submitter;    }    // Record approval provenance statement    private static void recordApproval(Context c, WorkflowItem wi, EPerson e)            throws SQLException, IOException, AuthorizeException    {        Item item = wi.getItem();        // Get user's name + email address        String usersName = getEPersonName(e);        // Get current date        String now = DCDate.getCurrent().toString();        // Here's what happened        String provDescription = "Approved for entry into archive by "                + usersName + " on " + now + " (GMT) ";        // add bitstream descriptions (name, size, checksums)        provDescription += InstallItem.getBitstreamProvenanceMessage(item);        // Add to item as a DC field        item.addDC("description", "provenance", "en", provDescription);        item.update();    }    // Create workflow start provenance message    private static void recordStart(Context c, Item myitem)            throws SQLException, IOException, AuthorizeException    {        // Get non-internal format bitstreams        Bitstream[] bitstreams = myitem.getNonInternalBitstreams();        // get date        DCDate now = DCDate.getCurrent();        // Create provenance description        String provmessage = "";        if (myitem.getSubmitter() != null)        {            provmessage = "Submitted by " + myitem.getSubmitter().getFullName()                    + " (" + myitem.getSubmitter().getEmail() + ") on "                    + now.toString() + "\n";        }        else        // null submitter        {            provmessage = "Submitted by unknown (probably automated) on"                    + now.toString() + "\n";        }        // add sizes and checksums of bitstreams        provmessage += InstallItem.getBitstreamProvenanceMessage(myitem);        // Add message to the DC        myitem.addDC("description", "provenance", "en", provmessage);        myitem.update();    }}

⌨️ 快捷键说明

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