/** * Find the maximum step the user has reached in the submission processes. * If this submission is a workflow then return max-int. * * @param context The current DSpace content * @param id The unique ID of the current workflow/workspace */ public static int getMaximumStepReached(Context context, String id) throws SQLException, AuthorizeException, IOException { InProgressSubmission submission = findSubmission(context, id); if (submission instanceof WorkspaceItem) { WorkspaceItem workspaceItem = (WorkspaceItem) submission; int stage = workspaceItem.getStageReached(); if (stage < 0) { stage = 0; } return stage; } // This is a workflow, return infinity. return Integer.MAX_VALUE; }
/** * Find the maximum step and page that the user has * reached in the submission processes. * If this submission is a workflow then return max-int. */ public StepAndPage getMaxStepAndPageReached() throws SQLException { if (this.submission instanceof WorkspaceItem) { WorkspaceItem workspaceItem = (WorkspaceItem) submission; int step = workspaceItem.getStageReached(); if(step<0) { step = 0; } int page = workspaceItem.getPageReached(); if (page < 0) { page = 0; } return new StepAndPage(step, page); } // This is a workflow, return infinity. return new StepAndPage(Integer.MAX_VALUE, Integer.MAX_VALUE); }
/** * Find out which step a user has reached in the submission process. If the * submission is in the workflow process, this returns -1. * * @param subInfo * submission info object * * @return step reached */ public static int getStepReached(SubmissionInfo subInfo) { if (subInfo == null || subInfo.isInWorkflow() || subInfo.getSubmissionItem() == null) { return -1; } else { WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem(); int i = wi.getStageReached(); // Uninitialised workspace items give "-1" as the stage reached // this is a special value used by the progress bar, so we change // it to "FIRST_STEP" if (i == -1) { i = FIRST_STEP; } return i; } }
if (step > workspaceItem.getStageReached()) context.commit(); else if ((step == workspaceItem.getStageReached()) && (page > workspaceItem.getPageReached()))
/** * Indicate the user has advanced to the given stage. This will only * actually do anything when it's a user initially entering a submission. It * will only increase the "stage reached" column - it will not "set back" * where a user has reached. Whenever the "stage reached" column is * increased, the "page reached" column is reset to 1, since you've now * reached page #1 of the next stage. * * @param subInfo * the SubmissionInfo object pertaining to the current submission * @param step * the step the user has just reached */ private void userHasReached(SubmissionInfo subInfo, int step) throws SQLException, AuthorizeException, IOException { if (!subInfo.isInWorkflow() && subInfo.getSubmissionItem() != null) { WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem(); if (step > wi.getStageReached()) { wi.setStageReached(step); wi.setPageReached(1); // reset page reached back to 1 (since // it's page 1 of the new step) wi.update(); } } }