/** * Find the maximum page (within the maximum step) that 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 getMaximumPageReached(Context context, String id) throws SQLException, AuthorizeException, IOException { InProgressSubmission submission = findSubmission(context, id); if (submission instanceof WorkspaceItem) { WorkspaceItem workspaceItem = (WorkspaceItem) submission; int page = workspaceItem.getPageReached(); if (page < 0) { page = 0; } return page; } // This is a workflow, return infinity. return Integer.MAX_VALUE; }
/** * Find out which page a user has reached in this particular step. * * @param subInfo * Submission information * * @return page reached */ public static final int getPageReached(SubmissionInfo subInfo) { if (subInfo.isInWorkflow() || subInfo.getSubmissionItem() == null) { return -1; } else { WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem(); int i = wi.getPageReached(); return i; } }
/** * 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); }
/** * Sets the number of the page reached for the specified step * * @param session * HTTP session (where page reached is stored) * @param step * the current Submission Process Step (which we want to * increment the page reached) * @param pageNumber * new page reached */ private void updatePageReached(SubmissionInfo subInfo, int page) throws SQLException, AuthorizeException, IOException { if (!subInfo.isInWorkflow() && subInfo.getSubmissionItem() != null) { WorkspaceItem wi = (WorkspaceItem) subInfo.getSubmissionItem(); if (page > wi.getPageReached()) { wi.setPageReached(page); wi.update(); } } }
(page > workspaceItem.getPageReached()))