📄 workflowmanager.java
字号:
// authorize DSpaceActions.SUBMIT_STEP2 // Record provenance recordApproval(c, wi, e); doState(c, wi, WFSTATE_STEP3POOL, e); break; case WFSTATE_STEP3: // authorize DSpaceActions.SUBMIT_STEP3 // We don't record approval for editors, since they can't reject, // and thus didn't actually make a decision doState(c, wi, WFSTATE_ARCHIVE, e); break; // error handling? shouldn't get here } log.info(LogManager.getHeader(c, "advance_workflow", "workflow_item_id=" + wi.getID() + ",item_id=" + wi.getItem().getID() + ",collection_id=" + wi.getCollection().getID() + ",old_state=" + taskstate + ",new_state=" + wi.getState())); } /** * unclaim() returns an owned task/item to the pool * * @param c * Context * @param wi * WorkflowItem to operate on * @param e * EPerson doing the operation */ public static void unclaim(Context c, WorkflowItem wi, EPerson e) throws SQLException, IOException, AuthorizeException { int taskstate = wi.getState(); switch (taskstate) { case WFSTATE_STEP1: // authorize DSpaceActions.STEP1 doState(c, wi, WFSTATE_STEP1POOL, e); break; case WFSTATE_STEP2: // authorize DSpaceActions.APPROVE doState(c, wi, WFSTATE_STEP2POOL, e); break; case WFSTATE_STEP3: // authorize DSpaceActions.STEP3 doState(c, wi, WFSTATE_STEP3POOL, e); break; // error handling? shouldn't get here // FIXME - what to do with error - log it? } log.info(LogManager.getHeader(c, "unclaim_workflow", "workflow_item_id=" + wi.getID() + ",item_id=" + wi.getItem().getID() + ",collection_id=" + wi.getCollection().getID() + ",old_state=" + taskstate + ",new_state=" + wi.getState())); } /** * abort() aborts a workflow, completely deleting it (administrator do this) * (it will basically do a reject from any state - the item ends up back in * the user's PersonalWorkspace * * @param c * Context * @param wi * WorkflowItem to operate on * @param e * EPerson doing the operation */ public static void abort(Context c, WorkflowItem wi, EPerson e) throws SQLException, AuthorizeException, IOException { // authorize a DSpaceActions.ABORT if (!AuthorizeManager.isAdmin(c)) { throw new AuthorizeException( "You must be an admin to abort a workflow"); } // stop workflow regardless of its state deleteTasks(c, wi); log.info(LogManager.getHeader(c, "abort_workflow", "workflow_item_id=" + wi.getID() + "item_id=" + wi.getItem().getID() + "collection_id=" + wi.getCollection().getID() + "eperson_id=" + e.getID())); // convert into personal workspace WorkspaceItem wsi = returnToWorkspace(c, wi); } // returns true if archived private static boolean doState(Context c, WorkflowItem wi, int newstate, EPerson newowner) throws SQLException, IOException, AuthorizeException { Collection mycollection = wi.getCollection(); Group mygroup = null; boolean archived = false; wi.setState(newstate); switch (newstate) { case WFSTATE_STEP1POOL: // any reviewers? // if so, add them to the tasklist wi.setOwner(null); // get reviewers (group 1 ) mygroup = mycollection.getWorkflowGroup(1); if ((mygroup != null) && !(mygroup.isEmpty())) { // get a list of all epeople in group (or any subgroups) EPerson[] epa = Group.allMembers(c, mygroup); // there were reviewers, change the state // and add them to the list createTasks(c, wi, epa); wi.update(); // email notification notifyGroupOfTask(c, wi, mygroup, epa); } else { // no reviewers, skip ahead archived = doState(c, wi, WFSTATE_STEP2POOL, null); } break; case WFSTATE_STEP1: // remove reviewers from tasklist // assign owner deleteTasks(c, wi); wi.setOwner(newowner); break; case WFSTATE_STEP2POOL: // clear owner // any approvers? // if so, add them to tasklist // if not, skip to next state wi.setOwner(null); // get approvers (group 2) mygroup = mycollection.getWorkflowGroup(2); if ((mygroup != null) && !(mygroup.isEmpty())) { //get a list of all epeople in group (or any subgroups) EPerson[] epa = Group.allMembers(c, mygroup); // there were approvers, change the state // timestamp, and add them to the list createTasks(c, wi, epa); // email notification notifyGroupOfTask(c, wi, mygroup, epa); } else { // no reviewers, skip ahead archived = doState(c, wi, WFSTATE_STEP3POOL, null); } break; case WFSTATE_STEP2: // remove admins from tasklist // assign owner deleteTasks(c, wi); wi.setOwner(newowner); break; case WFSTATE_STEP3POOL: // any editors? // if so, add them to tasklist wi.setOwner(null); mygroup = mycollection.getWorkflowGroup(3); if ((mygroup != null) && !(mygroup.isEmpty())) { // get a list of all epeople in group (or any subgroups) EPerson[] epa = Group.allMembers(c, mygroup); // there were editors, change the state // timestamp, and add them to the list createTasks(c, wi, epa); // email notification notifyGroupOfTask(c, wi, mygroup, epa); } else { // no editors, skip ahead archived = doState(c, wi, WFSTATE_ARCHIVE, newowner); } break; case WFSTATE_STEP3: // remove editors from tasklist // assign owner deleteTasks(c, wi); wi.setOwner(newowner); break; case WFSTATE_ARCHIVE: // put in archive in one transaction try { // remove workflow tasks deleteTasks(c, wi); mycollection = wi.getCollection(); Item myitem = archive(c, wi); // now email notification notifyOfArchive(c, myitem, mycollection); archived = true; } catch (IOException e) { // indexer causes this throw e; } catch (SQLException e) { // problem starting workflow throw e; } break; } if ((wi != null) && !archived) { wi.update(); } return archived; } /** * Commit the contained item to the main archive. The item is associated * with the relevant collection, added to the search index, and any other * tasks such as assigning dates are performed. * * @return the fully archived item. */ private static Item archive(Context c, WorkflowItem wfi) throws SQLException, IOException, AuthorizeException { // FIXME: Check auth Item item = wfi.getItem(); Collection collection = wfi.getCollection(); log.info(LogManager.getHeader(c, "archive_item", "workflow_item_id=" + wfi.getID() + "item_id=" + item.getID() + "collection_id=" + collection.getID())); InstallItem.installItem(c, wfi); // Log the event log.info(LogManager.getHeader(c, "install_item", "workflow_id=" + wfi.getID() + ", item_id=" + item.getID() + "handle=FIXME")); return item; } /** * notify the submitter that the item is archived */ private static void notifyOfArchive(Context c, Item i, Collection coll) throws SQLException, IOException { try { // Get the item handle to email to user String handle = HandleManager.findHandle(c, i); // Get title DCValue[] titles = i.getDC("title", null, Item.ANY); String title = "Untitled"; if (titles.length > 0) { title = titles[0].value; } // Get submitter EPerson ep = i.getSubmitter(); Email email = ConfigurationManager.getEmail("submit_archive"); email.addRecipient(ep.getEmail()); email.addArgument(title); email.addArgument(coll.getMetadata("name")); email.addArgument(HandleManager.getCanonicalForm(handle)); email.send(); } catch (MessagingException e) { log.warn(LogManager.getHeader(c, "notifyOfArchive", "cannot email user" + " item_id=" + i.getID())); } } /** * Return the workflow item to the workspace of the submitter. The workflow * item is removed, and a workspace item created. * * @param c * Context * @param wfi * WorkflowItem to be 'dismantled' * @return the workspace item */ private static WorkspaceItem returnToWorkspace(Context c, WorkflowItem wfi)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -