Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java,v diff -u -r1.82 -r1.83 --- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java 11 Mar 2009 01:10:33 -0000 1.82 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java 2 Jul 2009 13:02:40 -0000 1.83 @@ -35,8 +35,8 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.dao.IBaseDAO; -import org.lamsfoundation.lams.learningdesign.ActivityEvaluation; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.ActivityEvaluation; import org.lamsfoundation.lams.learningdesign.ActivityOrderComparator; import org.lamsfoundation.lams.learningdesign.BranchActivityEntry; import org.lamsfoundation.lams.learningdesign.BranchCondition; @@ -46,6 +46,7 @@ import org.lamsfoundation.lams.learningdesign.CompetenceMapping; import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.ConditionGateActivity; +import org.lamsfoundation.lams.learningdesign.DataTransition; import org.lamsfoundation.lams.learningdesign.FloatingActivity; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.learningdesign.Group; @@ -106,14 +107,8 @@ */ public class ObjectExtractor implements IObjectExtractor { - private static final Integer DEFAULT_COORD = new Integer(10); // default - // coordinate - // used if - // the entry - // from - // Flash is - // 0 or - // less. + private static final Integer DEFAULT_COORD = new Integer(10); // default coordinate used if the entry from Flash + // is 0 or less. protected IBaseDAO baseDAO = null; protected ILearningDesignDAO learningDesignDAO = null; @@ -862,13 +857,12 @@ /** * This method extracts and saves the evaluation object for each activity. * - * Here we would normally go through the tool activity evaluation list and - * check if there have been any added/removed. But since our current - * implementation only allows 1 tool output per activity to go to Gradebook, - * we only need to fetch the first. + * Here we would normally go through the tool activity evaluation list and check if there have been any + * added/removed. But since our current implementation only allows 1 tool output per activity to go to Gradebook, we + * only need to fetch the first. * - * This implementation will need to be changed if we ever choose to allow - * more than one output per activity to go to Gradebook + * This implementation will need to be changed if we ever choose to allow more than one output per activity to go to + * Gradebook * * @param activityDetails * @param toolActivity @@ -881,13 +875,13 @@ // Get the first (only) ActivityEvaluation if it exists if (activityEvaluations != null && activityEvaluations.size() >= 1) { - activityEvaluation = (ActivityEvaluation) activityEvaluations.iterator().next(); + activityEvaluation = activityEvaluations.iterator().next(); } else { activityEvaluation = new ActivityEvaluation(); } if (keyExists(activityDetails, WDDXTAGS.TOOL_OUTPUT_DEFINITION) - && WDDXProcessor.convertToString(activityDetails, WDDXTAGS.TOOL_OUTPUT_DEFINITION) != null + && WDDXProcessor.convertToString(activityDetails, WDDXTAGS.TOOL_OUTPUT_DEFINITION) != null && !WDDXProcessor.convertToString(activityDetails, WDDXTAGS.TOOL_OUTPUT_DEFINITION).equals("")) { activityEvaluations = new HashSet(); activityEvaluation.setActivity(toolActivity); @@ -910,9 +904,8 @@ } /** - * Parses the list of activities sent from the WDDX packet for competence - * mappings. Each activity's new set of competenceMapping is compared - * against the old set and the db is updated accordingly + * Parses the list of activities sent from the WDDX packet for competence mappings. Each activity's new set of + * competenceMapping is compared against the old set and the db is updated accordingly * * @param activitiesList * The list of activities from the WDDX packet. @@ -1558,11 +1551,18 @@ throw new WDDXProcessorConversionException("Transition is missing its fromUUID " + transitionDetails); } + Integer transitionType = WDDXProcessor.convertToInteger(transitionDetails, WDDXTAGS.TRANSITION_TYPE); + Transition transition = null; - Transition existingTransition = findTransition(transitionUUID, toUIID, fromUIID); + Transition existingTransition = findTransition(transitionUUID, toUIID, fromUIID, transitionType); if (existingTransition == null) { - transition = new Transition(); + if (false/* It will soon be implemented in Flash. Now we need to check what kind of transition are we dealing with + transitionType.equals(Transition.DATA_TRANSITION_TYPE) */) { + transition = new DataTransition(); + } else { + transition = new Transition(); + } } else { transition = existingTransition; } @@ -1574,7 +1574,9 @@ transition.setToActivity(toActivity); transition.setToUIID(toUIID); // update the transitionTo property for the activity - toActivity.setTransitionTo(transition); + if (transition.isProgressTransition()) { + toActivity.setTransitionTo(transition); + } } else { transition.setToActivity(null); transition.setToUIID(null); @@ -1585,7 +1587,9 @@ transition.setFromActivity(fromActivity); transition.setFromUIID(fromUIID); // update the transitionFrom property for the activity - fromActivity.setTransitionFrom(transition); + if (transition.isProgressTransition()) { + fromActivity.setTransitionFrom(transition); + } } else { transition.setFromActivity(null); transition.setFromUIID(null); @@ -1632,17 +1636,19 @@ * it between the same activities, then inserting a new one in the db will trigger a duplicate key exception. So we * need to reuse any that have the same to/from. */ - private Transition findTransition(Integer transitionUUID, Integer toUIID, Integer fromUIID) { + private Transition findTransition(Integer transitionUUID, Integer toUIID, Integer fromUIID, Integer transitionType) { Transition existingTransition = null; Set transitions = learningDesign.getTransitions(); Iterator iter = transitions.iterator(); while (existingTransition == null && iter.hasNext()) { Transition element = (Transition) iter.next(); - if (transitionUUID != null && transitionUUID.equals(element.getTransitionUIID())) { - existingTransition = element; - } else if (toUIID != null && toUIID.equals(element.getToUIID()) && fromUIID != null - && fromUIID.equals(element.getFromUIID())) { - existingTransition = element; + if (element.getTransitionType().equals(transitionType)) { + if (transitionUUID != null && transitionUUID.equals(element.getTransitionUIID())) { + existingTransition = element; + } else if (toUIID != null && toUIID.equals(element.getToUIID()) && fromUIID != null + && fromUIID.equals(element.getFromUIID())) { + existingTransition = element; + } } } return existingTransition; Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java,v diff -u -r1.85 -r1.86 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java 1 Jul 2009 02:46:38 -0000 1.85 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java 2 Jul 2009 13:02:40 -0000 1.86 @@ -43,8 +43,8 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.authoring.IObjectExtractor; import org.lamsfoundation.lams.dao.hibernate.BaseDAO; -import org.lamsfoundation.lams.learningdesign.ActivityEvaluation; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.ActivityEvaluation; import org.lamsfoundation.lams.learningdesign.BranchActivityEntry; import org.lamsfoundation.lams.learningdesign.BranchingActivity; import org.lamsfoundation.lams.learningdesign.Competence; @@ -169,9 +169,9 @@ this.pedagogicalPlannerDAO = pedagogicalPlannerDAO; } - /*************************************************************************** + /******************************************************************************************************************* * Setter Methods - **************************************************************************/ + ******************************************************************************************************************/ /** * Set i18n MessageService */ @@ -371,13 +371,12 @@ this.beanFactory = beanFactory; } - /*************************************************************************** + /******************************************************************************************************************* * Utility/Service Methods - **************************************************************************/ + ******************************************************************************************************************/ /** - * Helper method to retrieve the user data. Gets the id from the user - * details in the shared session + * Helper method to retrieve the user data. Gets the id from the user details in the shared session * * @return the user id */ @@ -390,9 +389,10 @@ /** * @see org.lamsfoundation.lams.authoring.service.IAuthoringService#getToolOutputDefinitions(java.lang.Long) */ - public String getToolOutputDefinitions(Long toolContentID) throws IOException { + public String getToolOutputDefinitions(Long toolContentID, int definitionType) throws IOException { - SortedMap defns = lamsCoreToolService.getOutputDefinitionsFromTool(toolContentID); + SortedMap defns = lamsCoreToolService.getOutputDefinitionsFromTool(toolContentID, + definitionType); ArrayList defnDTOList = new ArrayList(defns != null ? defns .size() : 0); @@ -536,8 +536,8 @@ } if (design != null) { /* - * only the user who is editing the design may unlock it - */ + * only the user who is editing the design may unlock it + */ if (design.getEditOverrideUser().equals(user)) { design.setEditOverrideLock(false); design.setEditOverrideUser(null); @@ -599,12 +599,10 @@ } /** - * Remove a temp. System Gate from the design. Requires removing the gate - * from any learner progress entries - should only be a current activity but - * remove it from previous and next, just in case. + * Remove a temp. System Gate from the design. Requires removing the gate from any learner progress entries - should + * only be a current activity but remove it from previous and next, just in case. * - * This will leave a "hole" in the learner progress, but the progress engine - * can take care of that. + * This will leave a "hole" in the learner progress, but the progress engine can take care of that. * * @param gate * @param design @@ -619,6 +617,7 @@ if (toTransition != null && fromTransition != null) { toTransition.setToActivity(fromTransition.getToActivity()); + fromTransition.getToActivity().setTransitionTo(toTransition); toTransition.setToUIID(toTransition.getToActivity().getActivityUIID()); design.getTransitions().remove(fromTransition); @@ -695,8 +694,8 @@ toActivity = fromTransition.getToActivity(); fromTransition.setToActivity(gate); - fromTransition.setToUIID(gate.getActivityUIID()); + fromTransition.setToUIID(gate.getActivityUIID()); newTransition.setTransitionUIID(++maxId); newTransition.setFromActivity(gate); newTransition.setFromUIID(gate.getActivityUIID()); @@ -705,8 +704,8 @@ newTransition.setLearningDesign(design); gate.setTransitionFrom(newTransition); - toActivity.setTransitionTo(newTransition); + gate.setTransitionTo(fromTransition); // set x / y position for Gate Integer x1 = activity.getXcoord() != null ? activity.getXcoord() : 0; @@ -919,8 +918,7 @@ /** * @see org.lamsfoundation.lams.authoring.service.IAuthoringService#copyLearningDesign(org.lamsfoundation.lams.learningdesign.LearningDesign, * java.lang.Integer, org.lamsfoundation.lams.usermanagement.User, - * org.lamsfoundation.lams.usermanagement.WorkspaceFolder, - * java.lang.Boolean, java.lang.String) + * org.lamsfoundation.lams.usermanagement.WorkspaceFolder, java.lang.Boolean, java.lang.String) */ public LearningDesign copyLearningDesign(LearningDesign originalLearningDesign, Integer copyType, User user, WorkspaceFolder workspaceFolder, boolean setOriginalDesign, String newDesignName, String customCSV) @@ -964,8 +962,7 @@ * @throws WorkspaceFolderException * @throws IOException * @see org.lamsfoundation.lams.authoring.service.IAuthoringService#insertLearningDesign(java.lang.Long, - * java.lang.Long, java.lang.Integer, java.lang.Boolean, - * java.lang.String, java.lang.Integer) + * java.lang.Long, java.lang.Integer, java.lang.Boolean, java.lang.String, java.lang.Integer) */ public LearningDesign insertLearningDesign(Long originalDesignID, Long designToImportID, Integer userID, boolean createNewLearningDesign, String newDesignName, Integer workspaceFolderID, String customCSV) @@ -1034,26 +1031,25 @@ insertCompetenceMappings(mainDesign.getCompetences(), designToImport.getCompetences(), newActivities); - // For some reason, the evaluations will not save on insert when the + // For some reason, the evaluations will not save on insert when the // learning design is saved, so doing it manually here - + this.updateEvaluations(newActivities); - -// for (Integer activityKey : newActivities.keySet()) { -// Activity activity = newActivities.get(activityKey); -// if (activity.isToolActivity()) { -// ToolActivity toolAct = (ToolActivity) activity; -// baseDAO.insertOrUpdateAll(toolAct.getActivityEvaluations()); -// } -// } + // for (Integer activityKey : newActivities.keySet()) { + // Activity activity = newActivities.get(activityKey); + // if (activity.isToolActivity()) { + // ToolActivity toolAct = (ToolActivity) activity; + // baseDAO.insertOrUpdateAll(toolAct.getActivityEvaluations()); + // } + // } + return mainDesign; } /** * @see org.lamsfoundation.lams.authoring.service.IAuthoringService#copyLearningDesignToolContent(org.lamsfoundation.lams.learningdesign.LearningDesign, - * org.lamsfoundation.lams.learningdesign.LearningDesign, - * java.lang.Integer) + * org.lamsfoundation.lams.learningdesign.LearningDesign, java.lang.Integer) */ private LearningDesign copyLearningDesignToolContent(LearningDesign design, LearningDesign originalLearningDesign, Integer copyType, String customCSV) throws LearningDesignException { @@ -1105,21 +1101,20 @@ } /** - * Updates the Activity information in the newLearningDesign based on the - * originalLearningDesign. This any grouping details. + * Updates the Activity information in the newLearningDesign based on the originalLearningDesign. This any grouping + * details. * - * As new activities are created, the UIID is incremented by the uiidOffset. - * If we are just copying a sequence this will be set to 0. But if we are - * importing a sequence into another sequence, this will be an offset value - * so we new ids guaranteed to be outside of the range of the main sequence - * (this may mean gaps in the uiids but that doesn't matter). + * As new activities are created, the UIID is incremented by the uiidOffset. If we are just copying a sequence this + * will be set to 0. But if we are importing a sequence into another sequence, this will be an offset value so we + * new ids guaranteed to be outside of the range of the main sequence (this may mean gaps in the uiids but that + * doesn't matter). * * @param originalLearningDesign * The LearningDesign to be copied * @param newLearningDesign * The copy of the originalLearningDesign - * @return Map of all the new activities, where the key is the UIID value. - * This is used as an input to updateDesignTransitions + * @return Map of all the new activities, where the key is the UIID value. This is used as an input to + * updateDesignTransitions */ private HashMap updateDesignActivities(LearningDesign originalLearningDesign, LearningDesign newLearningDesign, int uiidOffset, String customCSV) { @@ -1255,25 +1250,21 @@ } /** - * As part of updateDesignActivities(), process an activity and, via - * recursive calls, the activity's child activities. Need to keep track of - * any new groupings created so we can go back and update the grouped - * activities with their new groupings at the end. Also copies the tool - * content. + * As part of updateDesignActivities(), process an activity and, via recursive calls, the activity's child + * activities. Need to keep track of any new groupings created so we can go back and update the grouped activities + * with their new groupings at the end. Also copies the tool content. * * @param activity * Activity to process. May not be null. * @param newLearningDesign * The new learning design. May not be null. * @param newActivities - * Temporary set of new activities - as activities are - * processed they are added to the set. May not be null. + * Temporary set of new activities - as activities are processed they are added to the set. May not + * be null. * @param newGroupings - * Temporary set of new groupings. Key is the grouping UUID. - * May not be null. + * Temporary set of new groupings. Key is the grouping UUID. May not be null. * @param parentActivity - * This activity's parent activity (if one exists). May be - * null. + * This activity's parent activity (if one exists). May be null. */ private void processActivity(Activity activity, LearningDesign newLearningDesign, Map newActivities, Map newGroupings, Activity parentActivity, @@ -1327,8 +1318,7 @@ } /** - * Updates the Transition information in the newLearningDesign based on the - * originalLearningDesign + * Updates the Transition information in the newLearningDesign based on the originalLearningDesign * * @param originalLearningDesign * The LearningDesign to be copied @@ -1347,11 +1337,16 @@ Activity fromActivity = null; if (newTransition.getToUIID() != null) { toActivity = newActivities.get(newTransition.getToUIID()); - toActivity.setTransitionTo(newTransition); + if (transition.isProgressTransition()) { + toActivity.setTransitionTo(newTransition); + } } if (newTransition.getFromUIID() != null) { fromActivity = newActivities.get(newTransition.getFromUIID()); - fromActivity.setTransitionFrom(newTransition); + //check if we are dealing with a "real" transition, not data flow + if (transition.isProgressTransition()) { + fromActivity.setTransitionFrom(newTransition); + } } newTransition.setToActivity(toActivity); newTransition.setFromActivity(fromActivity); @@ -1378,8 +1373,7 @@ } /** - * Updates the competence information in the newLearningDesign based on the - * originalLearningDesign + * Updates the competence information in the newLearningDesign based on the originalLearningDesign * * @param originalLearningDesign * The LearningDesign to be copied @@ -1482,8 +1476,7 @@ } /** - * Updates the competence information in the newLearningDesign based on the - * originalLearningDesign + * Updates the competence information in the newLearningDesign based on the originalLearningDesign * * @param originalLearningDesign * The LearningDesign to be copied @@ -1519,12 +1512,11 @@ private void updateEvaluations(HashMap newActivities) { - for (Integer key : newActivities.keySet()) - { + for (Integer key : newActivities.keySet()) { Activity activity = newActivities.get(key); if (activity.isToolActivity()) { - Set newActivityEvaluations = ((ToolActivity)activity).getActivityEvaluations(); - + Set newActivityEvaluations = ((ToolActivity) activity).getActivityEvaluations(); + if (newActivityEvaluations != null) { baseDAO.insertOrUpdateAll(newActivityEvaluations); } @@ -1538,8 +1530,7 @@ * @param activity * The object to be deep-copied * @param newGroupings - * Temporary set of new groupings. Key is the grouping UUID. - * May not be null. + * Temporary set of new groupings. Key is the grouping UUID. May not be null. * @return Activity The new deep-copied Activity object */ private Activity getActivityCopy(final Activity activity, Map newGroupings, int uiidOffset) { @@ -1577,13 +1568,11 @@ } /** - * This method saves a new Learning Design to the database. It received a - * WDDX packet from flash, deserializes it and then finally persists it to - * the database. + * This method saves a new Learning Design to the database. It received a WDDX packet from flash, deserializes it + * and then finally persists it to the database. * - * A user may update an existing learning design if they have user/owner - * rights to the folder or they are doing live edit. A user may create a new - * learning design only if they have user/owner rights to the folder. + * A user may update an existing learning design if they have user/owner rights to the folder or they are doing live + * edit. A user may create a new learning design only if they have user/owner rights to the folder. * * Note: it does not validate the design - that must be done separately. * @@ -1650,9 +1639,8 @@ /** * Validate the learning design, updating the valid flag appropriately. * - * This needs to be run in a separate transaction to - * storeLearningDesignDetails to ensure the database is fully updated before - * the validation occurs (due to some quirks we are finding using Hibernate) + * This needs to be run in a separate transaction to storeLearningDesignDetails to ensure the database is fully + * updated before the validation occurs (due to some quirks we are finding using Hibernate) * * @param learningDesignId * @throws Exception @@ -1708,8 +1696,7 @@ } /** - * This is a utility method used by the method - * getAllLearningDesignDetails to pack the required + * This is a utility method used by the method getAllLearningDesignDetails to pack the required * information in a data transfer object. * * @param iterator @@ -1803,8 +1790,8 @@ } /** - * Delete a learning design from the database. Does not remove any content - * stored in tools - that is done by the LamsCoreToolService + * Delete a learning design from the database. Does not remove any content stored in tools - that is done by the + * LamsCoreToolService */ public void deleteLearningDesign(LearningDesign design) { if (design == null) { @@ -1859,12 +1846,10 @@ } /** - * Get a unique name for a learning design, based on the names of the - * learning designs in the folder. If the learning design has duplicated - * name in same folder, then the new name will have a timestamp. The new - * name format will be oldname_ddMMYYYY_idx. The idx will be auto - * incremental index number, start from 1. Warning - this may be quite - * intensive as it gets all the learning designs in a folder. + * Get a unique name for a learning design, based on the names of the learning designs in the folder. If the + * learning design has duplicated name in same folder, then the new name will have a timestamp. The new name format + * will be oldname_ddMMYYYY_idx. The idx will be auto incremental index number, start from 1. Warning - this may be + * quite intensive as it gets all the learning designs in a folder. * * @param originalLearningDesign * @param workspaceFolder Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java,v diff -u -r1.32 -r1.33 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java 19 Feb 2009 14:01:31 -0000 1.32 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java 2 Jul 2009 13:02:40 -0000 1.33 @@ -199,7 +199,7 @@ * @return String The required definitions in WDDX format * @throws IOException */ - public String getToolOutputDefinitions(Long toolContentID) throws IOException; + public String getToolOutputDefinitions(Long toolContentID, int definitionType) throws IOException; /** * This method returns a list of all available Learning Designs in WDDX format. Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java,v diff -u -r1.29 -r1.30 --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java 12 Nov 2008 05:35:26 -0000 1.29 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java 2 Jul 2009 13:02:40 -0000 1.30 @@ -37,6 +37,7 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.authoring.service.IAuthoringService; +import org.lamsfoundation.lams.tool.ToolOutputDefinition; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.FileUtilException; import org.lamsfoundation.lams.util.WebUtil; @@ -51,8 +52,7 @@ /** * @author Manpreet Minhas * - * @struts.action path = "/authoring/author" parameter = "method" validate = - * "false" + * @struts.action path = "/authoring/author" parameter = "method" validate = "false" * */ public class AuthoringAction extends LamsDispatchAction { @@ -80,21 +80,20 @@ } /** - * Output the supplied WDDX packet. If the request parameter USE_JSP_OUTPUT - * is set, then it sets the session attribute "parameterName" to the wddx - * packet string. If USE_JSP_OUTPUT is not set, then the packet is written - * out to the request's PrintWriter. + * Output the supplied WDDX packet. If the request parameter USE_JSP_OUTPUT is set, then it sets the session + * attribute "parameterName" to the wddx packet string. If USE_JSP_OUTPUT is not set, then the packet is written out + * to the request's PrintWriter. * * @param mapping - * action mapping (for the forward to the success jsp) + * action mapping (for the forward to the success jsp) * @param request - * needed to check the USE_JSP_OUTPUT parameter + * needed to check the USE_JSP_OUTPUT parameter * @param response - * to write out the wddx packet if not using the jsp + * to write out the wddx packet if not using the jsp * @param wddxPacket - * wddxPacket or message to be sent/displayed + * wddxPacket or message to be sent/displayed * @param parameterName - * session attribute to set if USE_JSP_OUTPUT is set + * session attribute to set if USE_JSP_OUTPUT is set * @throws IOException */ private ActionForward outputPacket(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response, @@ -110,9 +109,10 @@ IAuthoringService authoringService = getAuthoringService(); try { Long toolContentID = WebUtil.readLongParam(request, "toolContentID", false); + Integer definitionType = ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION; // WebUtil.readIntParam(request, + // "toolOutputDefinitionType"); + wddxPacket = authoringService.getToolOutputDefinitions(toolContentID, definitionType); - wddxPacket = authoringService.getToolOutputDefinitions(toolContentID); - } catch (Exception e) { wddxPacket = handleException(e, "getToolOutputDefinitions", authoringService, true).serializeMessage(); } @@ -126,7 +126,7 @@ try { Long learningDesignID = WebUtil.readLongParam(request, "learningDesignID", false); wddxPacket = authoringService.getLearningDesignDetails(learningDesignID, getUserLanguage()); - log.debug("LD wddx packet: " + wddxPacket); + AuthoringAction.log.debug("LD wddx packet: " + wddxPacket); } catch (Exception e) { wddxPacket = handleException(e, "getLearningDesignDetails", authoringService, true).serializeMessage(); } @@ -176,7 +176,7 @@ } catch (Exception e) { wddxPacket = handleException(e, "getAllLearningDesignDetails", authoringService, true).serializeMessage(); } - log.debug("getAllLearningDesignDetails: returning " + wddxPacket); + AuthoringAction.log.debug("getAllLearningDesignDetails: returning " + wddxPacket); return outputPacket(mapping, request, response, wddxPacket, "details"); } @@ -189,7 +189,7 @@ } catch (Exception e) { wddxPacket = handleException(e, "getAllLearningLibraryDetails", authoringService, true).serializeMessage(); } - log.debug("getAllLearningLibraryDetails: returning " + wddxPacket); + AuthoringAction.log.debug("getAllLearningLibraryDetails: returning " + wddxPacket); return outputPacket(mapping, request, response, wddxPacket, "details"); } @@ -209,9 +209,8 @@ } /** - * Copy some existing content. Used when the user copies an activity in - * authoring. Expects one parameters - toolContentId (the content to be - * copied) + * Copy some existing content. Used when the user copies an activity in authoring. Expects one parameters - + * toolContentId (the content to be copied) */ public ActionForward copyToolContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { @@ -232,11 +231,9 @@ /** * This method returns a list of all available license in WDDX format. * - * This will include our supported Creative Common licenses and an "OTHER" - * license which may be used for user entered license details. The picture - * url supplied should be a full URL i.e. if it was a relative URL in the - * database, it should have been converted to a complete server URL - * (starting http://) before sending to the client. + * This will include our supported Creative Common licenses and an "OTHER" license which may be used for user + * entered license details. The picture url supplied should be a full URL i.e. if it was a relative URL in the + * database, it should have been converted to a complete server URL (starting http://) before sending to the client. * * @return String The required information in WDDX format * @throws IOException @@ -250,7 +247,7 @@ Vector licenses = authoringService.getAvailableLicenses(); flashMessage = new FlashMessage("getAvailableLicenses", licenses); } catch (Exception e) { - log.error("getAvailableLicenses: License details unavailable due to system error.", e); + AuthoringAction.log.error("getAvailableLicenses: License details unavailable due to system error.", e); flashMessage = new FlashMessage("getAvailableLicenses", "License details unavailable due to system error :" + e.getMessage(), FlashMessage.ERROR); @@ -310,7 +307,7 @@ */ private FlashMessage handleException(Exception e, String methodKey, IAuthoringService authoringService, boolean useCriticalError) { - log.error("Exception thrown " + methodKey, e); + AuthoringAction.log.error("Exception thrown " + methodKey, e); getAuditService().log(AuthoringAction.class.getName() + ":" + methodKey, e.toString()); String[] msg = new String[1]; @@ -325,12 +322,12 @@ * @return */ private IAuditService getAuditService() { - if (auditService == null) { + if (AuthoringAction.auditService == null) { WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() .getServletContext()); - auditService = (IAuditService) ctx.getBean("auditService"); + AuthoringAction.auditService = (IAuditService) ctx.getBean("auditService"); } - return auditService; + return AuthoringAction.auditService; } } Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java,v diff -u -r1.25 -r1.26 --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java 2 Jul 2009 08:19:14 -0000 1.25 +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LessonManagerServlet.java 2 Jul 2009 13:02:40 -0000 1.26 @@ -90,6 +90,7 @@ /** * Destruction of the servlet.
*/ + @Override public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here @@ -109,6 +110,7 @@ * @throws IOException * if an error occurred */ + @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); @@ -149,8 +151,9 @@ Element element = null; - if (hashValue == null || hashValue.equals("")) + if (hashValue == null || hashValue.equals("")) { throw new NullPointerException("Hash value missing in parameters"); + } if (method.equals(CentralConstants.METHOD_START)) { ldId = new Long(ldIdStr); @@ -225,7 +228,7 @@ true, outputsUser); } else { String msg = "Method :" + method + " is not recognised"; - log.error(msg); + LessonManagerServlet.log.error(msg); response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); } @@ -242,22 +245,22 @@ out.write(writer.toString()); } catch (NumberFormatException nfe) { - log.error("lsId or ldId is not an integer" + lsIdStr + ldIdStr, nfe); + LessonManagerServlet.log.error("lsId or ldId is not an integer" + lsIdStr + ldIdStr, nfe); response.sendError(HttpServletResponse.SC_BAD_REQUEST, "lsId or ldId is not an integer"); } catch (TransformerConfigurationException e) { - log.error("Can not convert XML document to string", e); + LessonManagerServlet.log.error("Can not convert XML document to string", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (TransformerException e) { - log.error("Can not convert XML document to string", e); + LessonManagerServlet.log.error("Can not convert XML document to string", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (ParserConfigurationException e) { - log.error("Can not build XML document", e); + LessonManagerServlet.log.error("Can not build XML document", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (NullPointerException e) { - log.error("Missing parameters", e); + LessonManagerServlet.log.error("Missing parameters", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (Exception e) { - log.error("Problem loading learning manager servlet request", e); + LessonManagerServlet.log.error("Problem loading learning manager servlet request", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } @@ -268,8 +271,7 @@ /** * The doPost method of the servlet.
* - * This method is called when a form has its tag value method equals to - * post. + * This method is called when a form has its tag value method equals to post. * * @param request * the request send by the client to the server @@ -280,6 +282,7 @@ * @throws IOException * if an error occurred */ + @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } @@ -288,19 +291,19 @@ String courseId, String title, String desc, String countryIsoCode, String langIsoCode, String customCSV) throws RemoteException { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId, - countryIsoCode, langIsoCode, null); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + ExtCourseClassMap orgMap = LessonManagerServlet.integrationService.getExtCourseClassMap(serverMap, userMap, + courseId, countryIsoCode, langIsoCode, null); // 1. init lesson - Lesson lesson = monitoringService.initializeLesson(title, desc, Boolean.TRUE, ldId, orgMap - .getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, Boolean.FALSE, - Boolean.FALSE, Boolean.FALSE); + Lesson lesson = LessonManagerServlet.monitoringService.initializeLesson(title, desc, Boolean.TRUE, ldId, + orgMap.getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, + Boolean.FALSE, Boolean.FALSE, Boolean.FALSE); // 2. create lessonClass for lesson createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); // 3. start lesson - monitoringService.startLesson(lesson.getLessonId(), userMap.getUser().getUserId()); + LessonManagerServlet.monitoringService.startLesson(lesson.getLessonId(), userMap.getUser().getUserId()); return lesson.getLessonId(); } catch (Exception e) { @@ -312,20 +315,21 @@ String courseId, String title, String desc, String startDate, String countryIsoCode, String langIsoCode, String customCSV) throws RemoteException { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId, - countryIsoCode, langIsoCode, null); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + ExtCourseClassMap orgMap = LessonManagerServlet.integrationService.getExtCourseClassMap(serverMap, userMap, + courseId, countryIsoCode, langIsoCode, null); // 1. init lesson - Lesson lesson = monitoringService.initializeLesson(title, desc, Boolean.TRUE, ldId, orgMap - .getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, false, - false); + Lesson lesson = LessonManagerServlet.monitoringService.initializeLesson(title, desc, Boolean.TRUE, ldId, + orgMap.getOrganisation().getOrganisationId(), userMap.getUser().getUserId(), customCSV, false, + false, false); // 2. create lessonClass for lesson createLessonClass(lesson, orgMap.getOrganisation(), userMap.getUser()); // 3. schedule lesson Date date = DateUtil.convertFromLAMSFlashFormat(startDate); - monitoringService.startLessonOnSchedule(lesson.getLessonId(), date, userMap.getUser().getUserId(), null); + LessonManagerServlet.monitoringService.startLessonOnSchedule(lesson.getLessonId(), date, userMap.getUser() + .getUserId(), null); return lesson.getLessonId(); } catch (Exception e) { throw new RemoteException(e.getMessage(), e); @@ -335,10 +339,10 @@ public Element getAllStudentProgress(Document document, String serverId, String datetime, String hashValue, String username, long lsId, String courseID) throws RemoteException { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - Lesson lesson = lessonService.getLesson(lsId); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + Lesson lesson = LessonManagerServlet.lessonService.getLesson(lsId); Element element = document.createElement(CentralConstants.ELEM_LESSON_PROGRESS); element.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lsId); @@ -354,7 +358,8 @@ // get the username with the integration prefix removed String userNoPrefixName = learnerProgress.getUserName().substring(prefix.length() + 1); - ExtUserUseridMap learnerMap = integrationService.getExtUserUseridMap(serverMap, userNoPrefixName); + ExtUserUseridMap learnerMap = LessonManagerServlet.integrationService.getExtUserUseridMap( + serverMap, userNoPrefixName); Element learnerProgElem = document.createElement(CentralConstants.ELEM_LEARNER_PROGRESS); @@ -369,7 +374,7 @@ + completedActivities); learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITIES_ATTEMPTED, "" + attemptedActivities); - //learnerProgElem.setAttribute(CentralConstants.ATTR_CURRENT_ACTIVITY , currActivity); + // learnerProgElem.setAttribute(CentralConstants.ATTR_CURRENT_ACTIVITY , currActivity); learnerProgElem.setAttribute(CentralConstants.ATTR_STUDENT_ID, "" + learnerMap.getSid()); learnerProgElem.setAttribute(CentralConstants.ATTR_COURSE_ID, courseID); learnerProgElem.setAttribute(CentralConstants.ATTR_USERNAME, userNoPrefixName); @@ -393,10 +398,10 @@ public Element getSingleStudentProgress(Document document, String serverId, String datetime, String hashValue, String username, long lsId, String courseID, String progressUser) throws RemoteException { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - Lesson lesson = lessonService.getLesson(lsId); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + Lesson lesson = LessonManagerServlet.lessonService.getLesson(lsId); Element element = document.createElement(CentralConstants.ELEM_LESSON_PROGRESS); element.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lsId); @@ -406,10 +411,11 @@ if (lesson != null) { int activitiesTotal = lesson.getLearningDesign().getActivities().size(); - ExtUserUseridMap progressUserMap = integrationService.getExistingExtUserUseridMap(serverMap, - progressUser); + ExtUserUseridMap progressUserMap = LessonManagerServlet.integrationService.getExistingExtUserUseridMap( + serverMap, progressUser); - LearnerProgress learnProg = lessonService.getUserProgressForLesson(userMap.getUser().getUserId(), lsId); + LearnerProgress learnProg = LessonManagerServlet.lessonService.getUserProgressForLesson(userMap + .getUser().getUserId(), lsId); Element learnerProgElem = document.createElement(CentralConstants.ELEM_LEARNER_PROGRESS); @@ -428,7 +434,7 @@ + completedActivities); learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITIES_ATTEMPTED, "" + attemptedActivities); - //learnerProgElem.setAttribute(CentralConstants.ATTR_CURRENT_ACTIVITY , currActivity); + // learnerProgElem.setAttribute(CentralConstants.ATTR_CURRENT_ACTIVITY , currActivity); learnerProgElem.setAttribute(CentralConstants.ATTR_STUDENT_ID, "" + progressUserMap.getSid()); learnerProgElem.setAttribute(CentralConstants.ATTR_COURSE_ID, courseID); learnerProgElem.setAttribute(CentralConstants.ATTR_USERNAME, progressUser); @@ -440,7 +446,7 @@ learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITY_COUNT, "" + activitiesTotal); learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITIES_COMPLETED, "0"); learnerProgElem.setAttribute(CentralConstants.ATTR_ACTIVITIES_ATTEMPTED, "0"); - //learnerProgElem.setAttribute(CentralConstants.ATTR_CURRENT_ACTIVITY , currActivity); + // learnerProgElem.setAttribute(CentralConstants.ATTR_CURRENT_ACTIVITY , currActivity); learnerProgElem.setAttribute(CentralConstants.ATTR_STUDENT_ID, "" + progressUserMap.getSid()); learnerProgElem.setAttribute(CentralConstants.ATTR_COURSE_ID, courseID); learnerProgElem.setAttribute(CentralConstants.ATTR_USERNAME, progressUser); @@ -464,10 +470,10 @@ public boolean deleteLesson(String serverId, String datetime, String hashValue, String username, long lsId) throws RemoteException { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - monitoringService.removeLesson(lsId, userMap.getUser().getUserId()); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + LessonManagerServlet.monitoringService.removeLesson(lsId, userMap.getUser().getUserId()); return true; } catch (Exception e) { throw new RemoteException(e.getMessage(), e); @@ -479,19 +485,20 @@ throws RemoteException { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); - ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId, - countryIsoCode, langIsoCode, null); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); + ExtCourseClassMap orgMap = LessonManagerServlet.integrationService.getExtCourseClassMap(serverMap, userMap, + courseId, countryIsoCode, langIsoCode, null); // 1. init lesson - Lesson lesson = monitoringService.initializeLessonForPreview(title, desc, ldId, userMap.getUser() - .getUserId(), customCSV, false, false, false); + Lesson lesson = LessonManagerServlet.monitoringService.initializeLessonForPreview(title, desc, ldId, + userMap.getUser().getUserId(), customCSV, false, false, false); // 2. create lessonClass for lesson - monitoringService.createPreviewClassForLesson(userMap.getUser().getUserId(), lesson.getLessonId()); + LessonManagerServlet.monitoringService.createPreviewClassForLesson(userMap.getUser().getUserId(), lesson + .getLessonId()); // 3. start lesson - monitoringService.startLesson(lesson.getLessonId(), userMap.getUser().getUserId()); + LessonManagerServlet.monitoringService.startLesson(lesson.getLessonId(), userMap.getUser().getUserId()); return lesson.getLessonId(); } catch (Exception e) { @@ -509,11 +516,11 @@ Integer workspaceFolderUid = null; ExtUserUseridMap userMap; User user = null; - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); try { - userMap = integrationService.getExtUserUseridMap(serverMap, username); + userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); user = userMap.getUser(); @@ -528,8 +535,8 @@ } File designFile = new File(filePath); - Object[] ldResults = exportService.importLearningDesign(designFile, user, workspaceFolderUid, - toolsErrorMsgs, customCSV); + Object[] ldResults = LessonManagerServlet.exportService.importLearningDesign(designFile, user, + workspaceFolderUid, toolsErrorMsgs, customCSV); ldId = (Long) ldResults[0]; ldErrorMsgs = (List) ldResults[1]; toolsErrorMsgs = (List) ldResults[2]; @@ -549,8 +556,9 @@ List staffList = new LinkedList(); staffList.add(creator); List learnerList = new LinkedList(); - monitoringService.createLessonClassForLesson(lesson.getLessonId(), organisation, organisation.getName() - + "Learners", learnerList, organisation.getName() + "Staff", staffList, creator.getUserId()); + LessonManagerServlet.monitoringService.createLessonClassForLesson(lesson.getLessonId(), organisation, + organisation.getName() + "Learners", learnerList, organisation.getName() + "Staff", staffList, creator + .getUserId()); } @@ -560,24 +568,25 @@ * @throws ServletException * if an error occured */ + @Override public void init() throws ServletException { - service = (IWorkspaceManagementService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("workspaceManagementService"); + LessonManagerServlet.service = (IWorkspaceManagementService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("workspaceManagementService"); - integrationService = (IntegrationService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("integrationService"); + LessonManagerServlet.integrationService = (IntegrationService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("integrationService"); - monitoringService = (IMonitoringService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("monitoringService"); + LessonManagerServlet.monitoringService = (IMonitoringService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("monitoringService"); - lessonService = (ILessonService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("lessonService"); + LessonManagerServlet.lessonService = (ILessonService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("lessonService"); - exportService = (IExportToolContentService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("exportToolContentService"); + LessonManagerServlet.exportService = (IExportToolContentService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("exportToolContentService"); - toolService = (ILamsCoreToolService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("lamsCoreToolService"); + LessonManagerServlet.toolService = (ILamsCoreToolService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("lamsCoreToolService"); } @@ -617,9 +626,8 @@ } /** - * Adds each user in learnerIds and monitorIds as learner and staff to - * the given lesson id; authenticates using the 3rd party server - * requestor's username. + * Adds each user in learnerIds and monitorIds as learner and staff to the given lesson id; authenticates using + * the 3rd party server requestor's username. * * @param serverId * @param datetime @@ -656,10 +664,10 @@ } return true; } catch (UserInfoFetchException e) { - log.error(e, e); + LessonManagerServlet.log.error(e, e); return false; } catch (AuthenticationException e) { - log.error(e, e); + LessonManagerServlet.log.error(e, e); return false; } } @@ -669,42 +677,43 @@ String courseId, String countryIsoCode, String langIsoCode) throws AuthenticationException, UserInfoFetchException { - if (log.isDebugEnabled()) { - log.debug("Adding user '" + username + "' as " + method + " to lesson with id '" + lsIdStr + "'."); + if (LessonManagerServlet.log.isDebugEnabled()) { + LessonManagerServlet.log.debug("Adding user '" + username + "' as " + method + " to lesson with id '" + + lsIdStr + "'."); } - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); Authenticator.authenticate(serverMap, datetime, requestorUsername, hashValue); - ExtUserUseridMap userMap = integrationService.getExtUserUseridMap(serverMap, username); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExtUserUseridMap(serverMap, username); // adds user to group - ExtCourseClassMap orgMap = integrationService.getExtCourseClassMap(serverMap, userMap, courseId, - countryIsoCode, langIsoCode, null); + ExtCourseClassMap orgMap = LessonManagerServlet.integrationService.getExtCourseClassMap(serverMap, userMap, + courseId, countryIsoCode, langIsoCode, null); - if (lessonService == null) { - lessonService = (ILessonService) WebApplicationContextUtils.getRequiredWebApplicationContext( - request.getSession().getServletContext()).getBean("lessonService"); + if (LessonManagerServlet.lessonService == null) { + LessonManagerServlet.lessonService = (ILessonService) WebApplicationContextUtils + .getRequiredWebApplicationContext(request.getSession().getServletContext()).getBean( + "lessonService"); } User user = userMap.getUser(); if (user == null) { String error = "Unable to add user to lesson class as user is missing from the user map"; - log.error(error); + LessonManagerServlet.log.error(error); throw new UserInfoFetchException(error); } if (LoginRequestDispatcher.METHOD_LEARNER.equals(method)) { - lessonService.addLearner(Long.parseLong(lsIdStr), user.getUserId()); + LessonManagerServlet.lessonService.addLearner(Long.parseLong(lsIdStr), user.getUserId()); } else if (LoginRequestDispatcher.METHOD_MONITOR.equals(method)) { - lessonService.addStaffMember(Long.parseLong(lsIdStr), user.getUserId()); + LessonManagerServlet.lessonService.addStaffMember(Long.parseLong(lsIdStr), user.getUserId()); } } } /** * - * This method gets the tool outputs for an entire lesson and returns them - * in an XML format. + * This method gets the tool outputs for an entire lesson and returns them in an XML format. * * @param document * @param serverId @@ -720,20 +729,20 @@ public Element getToolOutputs(Document document, String serverId, String datetime, String hashValue, String username, Long lsId, String courseID, boolean isAuthoredToolOutputs) throws Exception { try { - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); // TODO: Un-comment once finished testing as well as the prefix stuff - //Authenticator.authenticate(serverMap, datetime, username, hashValue); + // Authenticator.authenticate(serverMap, datetime, username, hashValue); // Get the lesson and activitied given an lsId - Lesson lesson = lessonService.getLesson(lsId); - Set activities = (Set) lesson.getLearningDesign().getActivities(); + Lesson lesson = LessonManagerServlet.lessonService.getLesson(lsId); + Set activities = lesson.getLearningDesign().getActivities(); // Create the root node of the xml document Element toolOutputsElement = document.createElement("ToolOutputs"); if (lesson != null) { - log.debug("Getting tool ouputs report for: " + lsId + ". With learning design: " + LessonManagerServlet.log.debug("Getting tool ouputs report for: " + lsId + ". With learning design: " + lesson.getLearningDesign().getLearningDesignId()); toolOutputsElement.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lsId); @@ -747,23 +756,22 @@ } } else { // TODO: handle this error instead of throwing an exception - log.debug("No lesson exists for: " + lsId + ". Cannot get tool outputs report."); + LessonManagerServlet.log.debug("No lesson exists for: " + lsId + ". Cannot get tool outputs report."); throw new Exception("Lesson with lessonID: " + lsId + " could not be found for learner progresses"); } return toolOutputsElement; } catch (Exception e) { - log.error("Problem creating tool output report for lesson: " + lsId.toString(), e); + LessonManagerServlet.log.error("Problem creating tool output report for lesson: " + lsId.toString(), e); throw new Exception(e); } } /** * - * This method gets the tool outputs for a specific user in a lesson and - * returns them in XML format. + * This method gets the tool outputs for a specific user in a lesson and returns them in XML format. * * @param document * @param serverId @@ -784,22 +792,23 @@ // Create the root node of the xml document Element toolOutputsElement = document.createElement("ToolOutputs"); - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LessonManagerServlet.integrationService.getExtServerOrgMap(serverId); // TODO: Un-comment once finished testing as well as the prefix stuff - //Authenticator.authenticate(serverMap, datetime, username, hashValue); + // Authenticator.authenticate(serverMap, datetime, username, hashValue); - ExtUserUseridMap userMap = integrationService.getExistingExtUserUseridMap(serverMap, userStr); + ExtUserUseridMap userMap = LessonManagerServlet.integrationService.getExistingExtUserUseridMap(serverMap, + userStr); if (userMap != null) { - User learner = (User) userMap.getUser(); + User learner = userMap.getUser(); // Get the lesson and activitied given an lsId - Lesson lesson = lessonService.getLesson(lsId); - Set activities = (Set) lesson.getLearningDesign().getActivities(); + Lesson lesson = LessonManagerServlet.lessonService.getLesson(lsId); + Set activities = lesson.getLearningDesign().getActivities(); if (lesson != null) { - log.debug("Getting tool ouputs report for: " + lsId + ". With learning design: " - + lesson.getLearningDesign().getLearningDesignId()); + LessonManagerServlet.log.debug("Getting tool ouputs report for: " + lsId + + ". With learning design: " + lesson.getLearningDesign().getLearningDesignId()); toolOutputsElement.setAttribute(CentralConstants.ATTR_LESSON_ID, "" + lsId); toolOutputsElement.setAttribute("name", lesson.getLessonName()); @@ -809,22 +818,21 @@ } } else { // TODO: handle this error instead of throwing an exception - log.debug("No user exists for: " + userStr + ". Cannot get tool outputs report."); + LessonManagerServlet.log.debug("No user exists for: " + userStr + ". Cannot get tool outputs report."); throw new Exception("No user exists for: " + userStr + ". Cannot get tool outputs report."); } return toolOutputsElement; } catch (Exception e) { - log.error("Problem creating tool output report for lesson: " + lsId.toString(), e); + LessonManagerServlet.log.error("Problem creating tool output report for lesson: " + lsId.toString(), e); throw new Exception(e); } } /** - * Gets the outputs for an activity for a specific learner and returns them - * in XML format + * Gets the outputs for an activity for a specific learner and returns them in XML format * * @param document * @param learner @@ -836,33 +844,30 @@ private Element getLearnerOutputsElement(Document document, User learner, Lesson lesson, Set activities, boolean isAuthoredToolOutputs) { Element learnerElement = document.createElement("LearnerOutput"); - //String userNoPrefixName = learner.getLogin().substring(serverMap.getPrefix().length() + 1); + // String userNoPrefixName = learner.getLogin().substring(serverMap.getPrefix().length() + 1); learnerElement.setAttribute("userName", learner.getLogin()); learnerElement.setAttribute("lamsUserName", learner.getLogin()); learnerElement.setAttribute("lamsUserId", learner.getUserId().toString()); learnerElement.setAttribute("firstName", learner.getFirstName()); learnerElement.setAttribute("lastName", learner.getLastName()); - LearnerProgress learnerProgress = monitoringService.getLearnerProgress(learner.getUserId(), lesson - .getLessonId()); + LearnerProgress learnerProgress = LessonManagerServlet.monitoringService.getLearnerProgress( + learner.getUserId(), lesson.getLessonId()); if (learnerProgress != null) { learnerElement.setAttribute("completedLesson", "" + learnerProgress.isComplete()); } /* - * Hibernate CGLIB is failing to load the first activity in - * the sequence as a ToolActivity for some mysterious reason - * Causes a ClassCastException when you try to cast it, even - * if it is a ToolActivity. + * Hibernate CGLIB is failing to load the first activity in the sequence as a ToolActivity for some mysterious + * reason Causes a ClassCastException when you try to cast it, even if it is a ToolActivity. * - * THIS IS A HACK to retrieve the first tool activity - * manually so it can be cast as a ToolActivity + * THIS IS A HACK to retrieve the first tool activity manually so it can be cast as a ToolActivity */ - Activity firstActivity = monitoringService.getActivityById(lesson.getLearningDesign().getFirstActivity() - .getActivityId()); - log.debug("Getting tool ouputs for first activity: " + firstActivity.getActivityId() + ". For user: " - + learner.getUserId()); + Activity firstActivity = LessonManagerServlet.monitoringService.getActivityById(lesson.getLearningDesign() + .getFirstActivity().getActivityId()); + LessonManagerServlet.log.debug("Getting tool ouputs for first activity: " + firstActivity.getActivityId() + + ". For user: " + learner.getUserId()); if (firstActivity.isToolActivity() && firstActivity instanceof ToolActivity) { learnerElement.appendChild(getActivityOutputsElement(document, (ToolActivity) firstActivity, learner, learnerProgress, isAuthoredToolOutputs)); @@ -872,8 +877,8 @@ if (activity.getActivityId().longValue() != firstActivity.getActivityId().longValue()) { - log.debug("Getting tool ouputs for activity: " + activity.getActivityId() + ". For user: " - + learner.getUserId()); + LessonManagerServlet.log.debug("Getting tool ouputs for activity: " + activity.getActivityId() + + ". For user: " + learner.getUserId()); if (activity.isToolActivity() && activity instanceof ToolActivity) { @@ -886,8 +891,7 @@ } /** - * Gets the tool output for a specified activity and learner and returns an - * XML representation of the data + * Gets the tool output for a specified activity and learner and returns an XML representation of the data * * @param document * @param toolAct @@ -907,10 +911,10 @@ boolean activityAttempted = false; if (progress != null) { - boolean completed = (progress.getProgressState(toolAct) == LearnerProgress.ACTIVITY_COMPLETED); + boolean completed = progress.getProgressState(toolAct) == LearnerProgress.ACTIVITY_COMPLETED; activityElement.setAttribute("completed", "" + completed); - activityAttempted = completed || (progress.getProgressState(toolAct) == LearnerProgress.ACTIVITY_ATTEMPTED); + activityAttempted = completed || progress.getProgressState(toolAct) == LearnerProgress.ACTIVITY_ATTEMPTED; activityElement.setAttribute("attempted", "" + activityAttempted); } else { @@ -919,31 +923,32 @@ } if (activityAttempted) { - ToolSession toolSession = toolService.getToolSessionByLearner(learner, toolAct); - SortedMap map = toolService.getOutputDefinitionsFromTool(toolAct - .getToolContentId()); + ToolSession toolSession = LessonManagerServlet.toolService.getToolSessionByLearner(learner, toolAct); + SortedMap map = LessonManagerServlet.toolService + .getOutputDefinitionsFromTool(toolAct.getToolContentId(), + ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION); if (toolSession != null) { for (String outputName : map.keySet()) { try { ToolOutputDefinition definition = map.get(outputName); - + if (isAuthoredToolOutputs) { Set activityEvaluations = toolAct.getActivityEvaluations(); if (activityEvaluations != null) { for (ActivityEvaluation evaluation : activityEvaluations) { if (outputName.equals(evaluation.getToolOutputDefinition())) { - ToolOutput toolOutput = toolService.getOutputFromTool(outputName, toolSession, - learner.getUserId()); + ToolOutput toolOutput = LessonManagerServlet.toolService.getOutputFromTool( + outputName, toolSession, learner.getUserId()); activityElement.appendChild(getOutputElement(document, toolOutput, definition)); } } } } else { - ToolOutput toolOutput = toolService.getOutputFromTool(outputName, toolSession, learner - .getUserId()); + ToolOutput toolOutput = LessonManagerServlet.toolService.getOutputFromTool(outputName, + toolSession, learner.getUserId()); if (toolOutput != null) { activityElement.appendChild(getOutputElement(document, toolOutput, definition)); @@ -953,7 +958,7 @@ } } catch (RuntimeException e) { - log.debug("Runtime exception when attempted to get outputs for activity: " + LessonManagerServlet.log.debug("Runtime exception when attempted to get outputs for activity: " + toolAct.getActivityId() + ", continuing for other activities", e); } } @@ -975,11 +980,11 @@ toolOutputElement.setAttribute("name", toolOutput.getName()); toolOutputElement.setAttribute("description", toolOutput.getDescription()); toolOutputElement.setAttribute("output", toolOutput.getValue().getString()); - + Long marksPossible = getTotalMarksAvailable(definition); - - toolOutputElement.setAttribute("marksPossible", (marksPossible != null) ? marksPossible.toString() : ""); + toolOutputElement.setAttribute("marksPossible", marksPossible != null ? marksPossible.toString() : ""); + String type; OutputType outputType = toolOutput.getValue().getType(); Index: lams_common/build.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/build.xml,v diff -u -r1.69 -r1.70 --- lams_common/build.xml 9 Apr 2009 05:05:51 -0000 1.69 +++ lams_common/build.xml 2 Jul 2009 13:06:10 -0000 1.70 @@ -435,6 +435,8 @@ + + Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml,v diff -u -r1.51 -r1.52 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml 9 Apr 2009 05:05:40 -0000 1.51 +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Activity.hbm.xml 2 Jul 2009 13:06:09 -0000 1.52 @@ -90,10 +90,17 @@ - - - - + + @hibernate.column name="transition_to_id" + + + + + @hibernate.column name="transition_from_id" + + + + @hibernate.column name="learning_library_id" Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/DataFlowObject.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Attic/DataFlowObject.hbm.xml,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/DataFlowObject.hbm.xml 2 Jul 2009 13:06:09 -0000 1.1 @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Transition.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Transition.hbm.xml,v diff -u -r1.8 -r1.9 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Transition.hbm.xml 23 Oct 2006 23:58:55 -0000 1.8 +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/Transition.hbm.xml 2 Jul 2009 13:06:09 -0000 1.9 @@ -14,13 +14,14 @@ @hibernate.class table="lams_learning_transition" true - + - + + + + @hibernate.property column="transition_ui_id" length="11" @@ -89,16 +93,16 @@ - - @hibernate.many-to-one unique="true" + + @hibernate.many-to-one @hibernate.column name="to_activity_id" - - @hibernate.many-to-one unique="true" + + @hibernate.many-to-one @hibernate.column name="from_activity_id" @@ -108,15 +112,25 @@ @hibernate.many-to-one - not-null="true" @hibernate.column name="learning_design_id" - + + + + @hibernate.set lazy="true" cascade="all" sort="org.lamsfoundation.lams.learningdesign.DataFlowObjectComparator" + @hibernate.collection-key column="transition_id" + @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.DataFlowObject" + + + + + + Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/create_lams_11_tables.sql,v diff -u -r1.142 -r1.143 --- lams_common/db/sql/create_lams_11_tables.sql 2 Jul 2009 08:19:27 -0000 1.142 +++ lams_common/db/sql/create_lams_11_tables.sql 2 Jul 2009 13:06:08 -0000 1.143 @@ -544,6 +544,8 @@ , end_xcoord INT(11) , end_ycoord INT(11) , stop_after_activity TINYINT NOT NULL DEFAULT 0 + , transition_to_id BIGINT(20) + , transition_from_id BIGINT(20) , PRIMARY KEY (activity_id) , INDEX (learning_library_id) , CONSTRAINT FK_lams_learning_activity_7 FOREIGN KEY (learning_library_id) @@ -940,11 +942,11 @@ , title VARCHAR(255) , to_activity_id BIGINT(20) NOT NULL , from_activity_id BIGINT(20) NOT NULL - , learning_design_id BIGINT(20) NOT NULL DEFAULT 0 + , learning_design_id BIGINT(20) , create_date_time DATETIME NOT NULL , to_ui_id INT(11) , from_ui_id INT(11) - , UNIQUE UQ_transition_activities (from_activity_id, to_activity_id) + , transition_type TINYINT NOT NULL DEFAULT 0 , PRIMARY KEY (transition_id) , INDEX (from_activity_id) , CONSTRAINT FK_learning_transition_3 FOREIGN KEY (from_activity_id) @@ -956,6 +958,11 @@ , CONSTRAINT lddefn_transition_ibfk_1 FOREIGN KEY (learning_design_id) REFERENCES lams_learning_design (learning_design_id) ON DELETE NO ACTION ON UPDATE NO ACTION )TYPE=InnoDB; +ALTER TABLE lams_learning_activity + ADD CONSTRAINT FK_lams_learning_activity_15 FOREIGN KEY (transition_to_id) + REFERENCES lams_learning_transition (transition_id) + , ADD CONSTRAINT FK_lams_learning_activity_16 FOREIGN KEY (transition_from_id) + REFERENCES lams_learning_transition (transition_id); CREATE TABLE lams_role_privilege ( rp_id BIGINT(20) NOT NULL AUTO_INCREMENT @@ -1136,6 +1143,18 @@ , PRIMARY KEY (uid) )TYPE=InnoDB; +CREATE TABLE lams_data_flow ( + data_flow_object_id BIGINT(20) NOT NULL auto_increment + , transition_id BIGINT(20) NOT NULL + , order_id INT(11) + , name VARCHAR(255) NOT NULL + , display_name VARCHAR(255) + , tool_assigment_id INT(11) + , CONSTRAINT FK_lams_learning_transition_1 FOREIGN KEY (transition_id) + REFERENCES lams_learning_transition (transition_id) ON DELETE CASCADE ON UPDATE CASCADE + , PRIMARY KEY (data_flow_object_id) +)TYPE=InnoDB; + CREATE TABLE lams_user_disabled_tutorials ( user_id BIGINT(20) NOT NULL , page_str CHAR(5) NOT NULL Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/commonContext.xml,v diff -u -r1.82 -r1.83 --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml 2 Jul 2009 08:19:28 -0000 1.82 +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml 2 Jul 2009 13:06:10 -0000 1.83 @@ -42,7 +42,7 @@ classpath:org/lamsfoundation/lams/learningdesign/Activity.hbm.xml classpath:org/lamsfoundation/lams/learningdesign/BranchActivityEntry.hbm.xml classpath:org/lamsfoundation/lams/learningdesign/BranchCondition.hbm.xml - classpath:org/lamsfoundation/lams/learningdesign/Group.hbm.xml + classpath:org/lamsfoundation/lams/learningdesign/Group.hbm.xml classpath:org/lamsfoundation/lams/learningdesign/GroupUser.hbm.xml classpath:org/lamsfoundation/lams/learningdesign/Grouping.hbm.xml classpath:org/lamsfoundation/lams/learningdesign/LearningDesign.hbm.xml @@ -52,6 +52,7 @@ classpath:org/lamsfoundation/lams/learningdesign/Transition.hbm.xml classpath:org/lamsfoundation/lams/learningdesign/License.hbm.xml classpath:org/lamsfoundation/lams/learningdesign/ActivityEvaluation.hbm.xml + classpath:org/lamsfoundation/lams/learningdesign/DataFlowObject.hbm.xml @@ -592,6 +593,11 @@ + + + + + { + + /** + * {@inheritDoc} + */ + public int compare(DataFlowObject o1, DataFlowObject o2) { + if (o1 != null && o2 != null) { + return o1.getOrderId() - o2.getOrderId(); + } else if (o1 != null) { + return 1; + } else { + return -1; + } + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/DataTransition.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/DataTransition.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/DataTransition.java 2 Jul 2009 13:06:08 -0000 1.1 @@ -0,0 +1,74 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: DataTransition.java,v 1.1 2009/07/02 13:06:08 marcin Exp $ */ +package org.lamsfoundation.lams.learningdesign; + +import java.util.Date; +import java.util.Set; +import java.util.TreeSet; + +/** + * Different type of transition - does not indicate lesson progress, but rather data flow between tools. + * + * @author Marcin Cieslak + * + */ +public class DataTransition extends Transition { + /** + * Tool output definitions which can be later used in the target tool. + */ + private Set dataFlowObjects = new TreeSet(new DataFlowObjectComparator()); + + public DataTransition() { + super(); + transitionType = Transition.DATA_TRANSITION_TYPE; + } + + public DataTransition(Long transitionId, Date createDateTime, Activity toActivity, Activity fromActivity, + LearningDesign learningDesign) { + super(transitionId, createDateTime, toActivity, fromActivity, learningDesign); + transitionType = Transition.DATA_TRANSITION_TYPE; + } + + public DataTransition(Long transitionId, Integer id, String description, String title, Date createDateTime, + Activity toActivity, Activity fromActivity, LearningDesign learningDesign, Integer toUIID, Integer fromUIID) { + super(transitionId, id, description, title, createDateTime, toActivity, fromActivity, learningDesign, toUIID, + fromUIID); + transitionType = Transition.DATA_TRANSITION_TYPE; + } + + /** + * @hibernate.set lazy="true" cascade="all" inverse="true" + * sort="org.lamsfoundation.lams.learningdesign.DataFlowObjectComparator" + * @hibernate.collection-key column="transition_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.DataFlowObject" + * + */ + public Set getDataFlowObjects() { + return dataFlowObjects; + } + + public void setDataFlowObjects(Set dataFlowObjects) { + this.dataFlowObjects = dataFlowObjects; + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Transition.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/Transition.java,v diff -u -r1.15 -r1.16 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Transition.java 9 Dec 2007 09:55:22 -0000 1.15 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Transition.java 2 Jul 2009 13:06:08 -0000 1.16 @@ -34,243 +34,267 @@ /** * @author Manpreet Minhas * @hibernate.class table="lams_learning_transition" - * + * */ public class Transition implements Serializable { + // LAMS 2.4 introduced different transition types; "classical" one is progress type; now we also have data flow; see + // DataTransition - /** identifier field */ - private Long transitionId; + public static final int PROGRESS_TRANSITION_TYPE = 0; - /** nullable persistent field */ - private Integer transitionUIID; + public static final int DATA_TRANSITION_TYPE = 1; - /** nullable persistent field */ - private Integer toUIID; + /** identifier field */ + private Long transitionId; - /** nullable persistent field */ - private Integer fromUIID; + /** nullable persistent field */ + private Integer transitionUIID; - /** nullable persistent field */ - private String description; + /** nullable persistent field */ + private Integer toUIID; - /** nullable persistent field */ - private String title; + /** nullable persistent field */ + private Integer fromUIID; - /** persistent field */ - private Date createDateTime; + /** nullable persistent field */ + private String description; - /** persistent field */ - Activity toActivity; + /** nullable persistent field */ + private String title; - /** persistent field */ - Activity fromActivity; + /** persistent field */ + private Date createDateTime; - /** persistent field */ - LearningDesign learningDesign; + /** persistent field */ + Activity toActivity; - /* - * If the value for createDateTime is null then it will - * be assigned the default value equal to the current datetime - */ - /** full constructor */ - public Transition( - Long transitionId, - Integer id, - String description, - String title, - Date createDateTime, - Activity toActivity, - Activity fromActivity, - LearningDesign learningDesign, - Integer toUIID, - Integer fromUIID) { - this.transitionId = transitionId; - this.transitionUIID = id; - this.description = description; - this.title = title; - this.createDateTime = createDateTime != null ? createDateTime : new Date(); - this.toActivity = toActivity; - this.fromActivity = fromActivity; - this.learningDesign = learningDesign; - this.toUIID = toUIID; - this.fromUIID = fromUIID; - } + /** persistent field */ + Activity fromActivity; - /** default constructor */ - public Transition() { - this.createDateTime = new Date(); //default value is set to when the Transition object is created - } + /** persistent field */ + LearningDesign learningDesign; - /** minimal constructor */ - public Transition( - Long transitionId, - Date createDateTime, - Activity toActivity, - Activity fromActivity, - LearningDesign learningDesign) { - this.transitionId = transitionId; - this.createDateTime = createDateTime != null ? createDateTime : new Date(); - this.toActivity = toActivity; - this.fromActivity = fromActivity; - this.learningDesign = learningDesign; - } + /** persistent field */ + protected Integer transitionType = Transition.PROGRESS_TRANSITION_TYPE; - /** - * Makes a copy of the Transition for authoring, preview and monitoring environment - * - * @param originalTransition The transition to be deep-copied - * @return Transition Returns a deep-copy o fthe originalTransition - */ - public static Transition createCopy(Transition originalTransition, int uiidOffset){ - Transition newTransition = new Transition(); - - newTransition.setTransitionUIID(LearningDesign.addOffset(originalTransition.getTransitionUIID(),uiidOffset)); - newTransition.setDescription(originalTransition.getDescription()); - newTransition.setTitle(originalTransition.getTitle()); - newTransition.setCreateDateTime(new Date()); - newTransition.setToUIID(LearningDesign.addOffset(originalTransition.getToUIID(),uiidOffset)); - newTransition.setFromUIID(LearningDesign.addOffset(originalTransition.getFromUIID(),uiidOffset)); - return newTransition; - } + /* + * If the value for createDateTime is null then it will be assigned the default value equal to the current datetime + */ + /** full constructor */ + public Transition(Long transitionId, Integer id, String description, String title, Date createDateTime, + Activity toActivity, Activity fromActivity, LearningDesign learningDesign, Integer toUIID, Integer fromUIID) { + this.transitionId = transitionId; + transitionUIID = id; + this.description = description; + this.title = title; + this.createDateTime = createDateTime != null ? createDateTime : new Date(); + this.toActivity = toActivity; + this.fromActivity = fromActivity; + this.learningDesign = learningDesign; + this.toUIID = toUIID; + this.fromUIID = fromUIID; + } - /** - * @hibernate.transitionUIID generator-class="native" - * type="java.lang.Long" column="transition_id" - * - */ - public Long getTransitionId() { - return this.transitionId; - } + /** default constructor */ + public Transition() { + createDateTime = new Date(); // default value is set to when the Transition object is created + } - public void setTransitionId(Long transitionId) { - this.transitionId = transitionId; - } + /** minimal constructor */ + public Transition(Long transitionId, Date createDateTime, Activity toActivity, Activity fromActivity, + LearningDesign learningDesign) { + this.transitionId = transitionId; + this.createDateTime = createDateTime != null ? createDateTime : new Date(); + this.toActivity = toActivity; + this.fromActivity = fromActivity; + this.learningDesign = learningDesign; + } - /** - * @hibernate.property column="transitionUIID" length="11" - * - */ - public Integer getTransitionUIID() { - return this.transitionUIID; - } + /** + * Makes a copy of the Transition for authoring, preview and monitoring environment + * + * @param originalTransition + * The transition to be deep-copied + * @return Transition Returns a deep-copy o fthe originalTransition + */ + public static Transition createCopy(Transition originalTransition, int uiidOffset) { - public void setTransitionUIID(Integer id) { - this.transitionUIID = id; + Transition newTransition = null; + if (originalTransition.isDataTransition()) { + newTransition = new DataTransition(); + for (DataFlowObject dataFlowObject : ((DataTransition) originalTransition).getDataFlowObjects()) { + DataFlowObject newDataFlowObject = DataFlowObject.createCopy(dataFlowObject, + ((DataTransition) newTransition)); + ((DataTransition) newTransition).getDataFlowObjects().add(newDataFlowObject); + } + } else { + newTransition = new Transition(); } - /** - * @hibernate.property column="description" length="65535" - * - */ - public String getDescription() { - return this.description; - } + newTransition.setTransitionUIID(LearningDesign.addOffset(originalTransition.getTransitionUIID(), uiidOffset)); + newTransition.setDescription(originalTransition.getDescription()); + newTransition.setTitle(originalTransition.getTitle()); + newTransition.setCreateDateTime(new Date()); + newTransition.setToUIID(LearningDesign.addOffset(originalTransition.getToUIID(), uiidOffset)); + newTransition.setFromUIID(LearningDesign.addOffset(originalTransition.getFromUIID(), uiidOffset)); + return newTransition; + } - public void setDescription(String description) { - this.description = description; - } + /** + * @hibernate.transitionUIID generator-class="native" type="java.lang.Long" column="transition_id" + * + */ + public Long getTransitionId() { + return transitionId; + } - /** - * @hibernate.property column="title" length="255" - * - */ - public String getTitle() { - return this.title; - } + public void setTransitionId(Long transitionId) { + this.transitionId = transitionId; + } - public void setTitle(String title) { - this.title = title; - } + /** + * @hibernate.property column="transitionUIID" length="11" + * + */ + public Integer getTransitionUIID() { + return transitionUIID; + } - /** - * @hibernate.property column="create_date_time" length="19" not-null="true" - * - */ - public Date getCreateDateTime() { - return this.createDateTime; - } + public void setTransitionUIID(Integer id) { + transitionUIID = id; + } - public void setCreateDateTime(Date createDateTime) { - this.createDateTime = createDateTime != null ? createDateTime : new Date(); - } + /** + * @hibernate.property column="description" length="65535" + * + */ + public String getDescription() { + return description; + } - /** - * @hibernate.many-to-one not-null="true" - * @hibernate.column name="to_activity_id" - * - */ - public org.lamsfoundation.lams.learningdesign.Activity getToActivity() { - return this.toActivity; - } + public void setDescription(String description) { + this.description = description; + } - public void setToActivity( - org.lamsfoundation.lams.learningdesign.Activity toActivity) { - this.toActivity = toActivity; - } + /** + * @hibernate.property column="title" length="255" + * + */ + public String getTitle() { + return title; + } - /** - * @hibernate.many-to-one not-null="true" - * @hibernate.column name="from_activity_id" - * - */ - public org.lamsfoundation.lams.learningdesign.Activity getFromActivity() { - return this.fromActivity; - } + public void setTitle(String title) { + this.title = title; + } - public void setFromActivity( - org.lamsfoundation.lams.learningdesign.Activity fromActivity) { - this.fromActivity = fromActivity; - } + /** + * @hibernate.property column="create_date_time" length="19" not-null="true" + * + */ + public Date getCreateDateTime() { + return createDateTime; + } - /** - * @hibernate.many-to-one not-null="true" - * @hibernate.column name="learning_design_id" - * - */ - public org.lamsfoundation.lams.learningdesign.LearningDesign getLearningDesign() { - return this.learningDesign; - } + public void setCreateDateTime(Date createDateTime) { + this.createDateTime = createDateTime != null ? createDateTime : new Date(); + } - public void setLearningDesign( - org.lamsfoundation.lams.learningdesign.LearningDesign learningDesign) { - this.learningDesign = learningDesign; - } + /** + * @hibernate.many-to-one not-null="true" + * @hibernate.column name="to_activity_id" + * + */ + public org.lamsfoundation.lams.learningdesign.Activity getToActivity() { + return toActivity; + } - public String toString() { - return new ToStringBuilder(this).append("transitionId", - getTransitionId()).toString(); - } + public void setToActivity(org.lamsfoundation.lams.learningdesign.Activity toActivity) { + this.toActivity = toActivity; + } - public boolean equals(Object other) { - if ((this == other)) - return true; - if (!(other instanceof Transition)) - return false; - Transition castOther = (Transition) other; - return new EqualsBuilder().append(this.getTransitionId(), - castOther.getTransitionId()).isEquals(); - } + /** + * @hibernate.many-to-one not-null="true" + * @hibernate.column name="from_activity_id" + * + */ + public org.lamsfoundation.lams.learningdesign.Activity getFromActivity() { + return fromActivity; + } - public int hashCode() { - return new HashCodeBuilder().append(getTransitionId()).toHashCode(); - } + public void setFromActivity(org.lamsfoundation.lams.learningdesign.Activity fromActivity) { + this.fromActivity = fromActivity; + } - public Integer getFromUIID() { - return fromUIID; - } + /** + * @hibernate.many-to-one not-null="true" + * @hibernate.column name="learning_design_id" + * + */ + public org.lamsfoundation.lams.learningdesign.LearningDesign getLearningDesign() { + return learningDesign; + } - public void setFromUIID(Integer fromUIID) { - this.fromUIID = fromUIID; - } + public void setLearningDesign(org.lamsfoundation.lams.learningdesign.LearningDesign learningDesign) { + this.learningDesign = learningDesign; + } - public Integer getToUIID() { - return toUIID; - } + @Override + public String toString() { + return new ToStringBuilder(this).append("transitionId", getTransitionId()).toString(); + } - public void setToUIID(Integer toUIID) { - this.toUIID = toUIID; + @Override + public boolean equals(Object other) { + if (this == other) { + return true; } - public TransitionDTO getTransitionDTO(){ - return new TransitionDTO(this); + if (!(other instanceof Transition)) { + return false; } + Transition castOther = (Transition) other; + return new EqualsBuilder().append(this.getTransitionId(), castOther.getTransitionId()).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(getTransitionId()).toHashCode(); + } + + public Integer getFromUIID() { + return fromUIID; + } + + public void setFromUIID(Integer fromUIID) { + this.fromUIID = fromUIID; + } + + public Integer getToUIID() { + return toUIID; + } + + public void setToUIID(Integer toUIID) { + this.toUIID = toUIID; + } + + public TransitionDTO getTransitionDTO() { + return new TransitionDTO(this); + } + + public boolean isDataTransition() { + return transitionType.equals(Transition.DATA_TRANSITION_TYPE); + } + + public boolean isProgressTransition() { + return transitionType.equals(Transition.PROGRESS_TRANSITION_TYPE); + } + + /** + * @hibernate.many-to-one not-null="true" + * @hibernate.column name="transition_type" + * + */ + public Integer getTransitionType() { + return transitionType; + } } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/IDataFlowDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/IDataFlowDAO.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/IDataFlowDAO.java 2 Jul 2009 13:06:08 -0000 1.1 @@ -0,0 +1,55 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id: IDataFlowDAO.java,v 1.1 2009/07/02 13:06:08 marcin Exp $$ */ +package org.lamsfoundation.lams.learningdesign.dao; + +import java.util.List; + +import org.lamsfoundation.lams.dao.IBaseDAO; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; + +/** + * + * + * @author Marcin Cieslak + * + */ +public interface IDataFlowDAO extends IBaseDAO { + /** + * Finds data flow objects (definitions of tool inputs) based on the tool's ID. + * + * @param toolContentId + * @return + */ + public List getDataFlowObjectsByToolContentId(Long toolContentId); + + /** + * Finds the data flow object assigned somewhere within the tool. It's up to tool to manage assigment ID, for core + * it's meaningless. + * + * @param toolContentId + * @param assigmentId + * @return + */ + public DataFlowObject getAssignedDataFlowObject(Long toolContentId, Integer assigmentId); +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/hibernate/DataFlowDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/hibernate/DataFlowDAO.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/hibernate/DataFlowDAO.java 2 Jul 2009 13:06:08 -0000 1.1 @@ -0,0 +1,73 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id: DataFlowDAO.java,v 1.1 2009/07/02 13:06:08 marcin Exp $$ */ +package org.lamsfoundation.lams.learningdesign.dao.hibernate; + +import java.util.List; + +import org.lamsfoundation.lams.dao.hibernate.BaseDAO; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; +import org.lamsfoundation.lams.learningdesign.DataTransition; +import org.lamsfoundation.lams.learningdesign.ToolActivity; +import org.lamsfoundation.lams.learningdesign.dao.IDataFlowDAO; + +/** + * @author Marcin Cieslak + */ +public class DataFlowDAO extends BaseDAO implements IDataFlowDAO { + + private static final String FIND_DATA_FLOW_OBJECTS_BY_TOOL_CONTENT_ID = "SELECT obj FROM " + + DataFlowObject.class.getName() + + " AS obj, " + + DataTransition.class.getName() + + " AS transition, " + + ToolActivity.class.getName() + + " AS activity WHERE activity.toolContentId=? AND activity=transition.toActivity AND transition=obj.dataTransition ORDER BY transition.transitionUIID ASC, obj.orderId ASC"; + private static final String FIND_ASSIGNED_DATA_FLOW_OBJECTS = "SELECT obj FROM " + + DataFlowObject.class.getName() + + " AS obj, " + + DataTransition.class.getName() + + " AS transition, " + + ToolActivity.class.getName() + + " AS activity WHERE activity.toolContentId=:toolContentId AND activity=transition.toActivity AND transition=obj.dataTransition AND obj.toolAssigmentId=:toolAssigmentId"; + + public List getDataFlowObjectsByToolContentId(Long toolContentId) { + List result = this.getHibernateTemplate().find( + DataFlowDAO.FIND_DATA_FLOW_OBJECTS_BY_TOOL_CONTENT_ID, toolContentId); + if (result == null || result.isEmpty()) { + return null; + } + return result; + } + + public DataFlowObject getAssignedDataFlowObject(Long toolContentId, Integer assigmentId) { + List result = this.getHibernateTemplate().findByNamedParam( + DataFlowDAO.FIND_ASSIGNED_DATA_FLOW_OBJECTS, new String[] { "toolContentId", "toolAssigmentId" }, + new Object[] { toolContentId, assigmentId }); + // There must be exactly one result + if (result == null || result.isEmpty() || result.size() > 1) { + return null; + } + return result.get(0); + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/DataFlowObjectDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/DataFlowObjectDTO.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/DataFlowObjectDTO.java 2 Jul 2009 13:06:10 -0000 1.1 @@ -0,0 +1,101 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: DataFlowObjectDTO.java,v 1.1 2009/07/02 13:06:10 marcin Exp $ */ +package org.lamsfoundation.lams.learningdesign.dto; + +import org.lamsfoundation.lams.learningdesign.DataFlowObject; + +public class DataFlowObjectDTO { + + private Long dataFlowObjectId; + + private String name; + + private String displayName; + + private Integer orderId; + + private String toolAssigmentId; + + public DataFlowObjectDTO() { + + } + + public DataFlowObjectDTO(Long dataFlowObjectId, String name, String displayName, Integer orderId, + Integer toolAssigmentId) { + this.dataFlowObjectId = dataFlowObjectId; + this.name = name; + this.displayName = displayName; + this.orderId = orderId; + this.toolAssigmentId = toolAssigmentId == null ? null : toolAssigmentId.toString(); + } + + public DataFlowObjectDTO(DataFlowObject dataFlowObject) { + dataFlowObjectId = dataFlowObject.getDataFlowObjectId(); + name = dataFlowObject.getName(); + displayName = dataFlowObject.getDisplayName(); + orderId = dataFlowObject.getOrderId(); + toolAssigmentId = dataFlowObject.getToolAssigmentId() == null ? null : dataFlowObject.getToolAssigmentId() + .toString(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer orderId) { + this.orderId = orderId; + } + + public Long getDataFlowObjectId() { + return dataFlowObjectId; + } + + public void setDataFlowObjectId(Long dataFlowObjectId) { + this.dataFlowObjectId = dataFlowObjectId; + } + + public String getToolAssigmentId() { + return toolAssigmentId; + } + + public void setToolAssigmentId(String toolAssigmentId) { + this.toolAssigmentId = toolAssigmentId; + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/TransitionDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/TransitionDTO.java,v diff -u -r1.9 -r1.10 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/TransitionDTO.java 17 Sep 2006 06:14:19 -0000 1.9 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/TransitionDTO.java 2 Jul 2009 13:06:10 -0000 1.10 @@ -23,187 +23,258 @@ /* $$Id$$ */ package org.lamsfoundation.lams.learningdesign.dto; +import java.util.ArrayList; import java.util.Date; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; +import org.lamsfoundation.lams.learningdesign.DataTransition; import org.lamsfoundation.lams.learningdesign.Transition; import org.lamsfoundation.lams.util.wddx.WDDXTAGS; - /** * @author Manpreet Minhas */ -public class TransitionDTO extends BaseDTO{ - - private Long transitionID; - private Integer transitionUIID; - private Integer toUIID; - private Integer fromUIID; - private String description; - private String title; - private Date createDateTime; - private Long toActivityID; - private Long fromActivityID; - private Long learningDesignID; - - public TransitionDTO(){ - +public class TransitionDTO extends BaseDTO { + + private Long transitionID; + private Integer transitionUIID; + private Integer toUIID; + private Integer fromUIID; + private String description; + private String title; + private Date createDateTime; + private Long toActivityID; + private Long fromActivityID; + private Long learningDesignID; + private Integer transitionType; + private ArrayList dataFlowObjects; + + public TransitionDTO() { + + } + + public TransitionDTO(Long transitionId, Integer transitionUIID, Integer toUIID, Integer fromUIID, + String description, String title, Date createDateTime, Long toActivityID, Long fromActivityID, + Long learningDesignID) { + super(); + transitionID = transitionId; + this.transitionUIID = transitionUIID; + this.toUIID = toUIID; + this.fromUIID = fromUIID; + this.description = description; + this.title = title; + this.createDateTime = createDateTime; + this.toActivityID = toActivityID; + this.fromActivityID = fromActivityID; + this.learningDesignID = learningDesignID; + dataFlowObjects = new ArrayList(); + } + + public TransitionDTO(Transition transition) { + transitionID = transition.getTransitionId(); + transitionUIID = transition.getTransitionUIID(); + toUIID = transition.getToUIID(); + fromUIID = transition.getFromUIID(); + description = transition.getDescription(); + title = transition.getTitle(); + createDateTime = transition.getCreateDateTime(); + toActivityID = transition.getToActivity().getActivityId(); + fromActivityID = transition.getFromActivity().getActivityId(); + learningDesignID = transition.getLearningDesign().getLearningDesignId(); + transitionType = transition.getTransitionType(); + dataFlowObjects = new ArrayList(); + if (transition.isDataTransition()) { + DataTransition dataTransition = (DataTransition) transition; + for (DataFlowObject dataFlowObject : dataTransition.getDataFlowObjects()) { + DataFlowObjectDTO dataFlowObjectDto = new DataFlowObjectDTO(dataFlowObject); + dataFlowObjects.add(dataFlowObjectDto); + } } - public TransitionDTO(Long transitionId, Integer transitionUIID, - Integer toUIID, Integer fromUIID, String description, String title, - Date createDateTime, Long toActivityID, Long fromActivityID, - Long learningDesignID) { - super(); - this.transitionID = transitionId; - this.transitionUIID = transitionUIID; - this.toUIID = toUIID; - this.fromUIID = fromUIID; - this.description = description; - this.title = title; - this.createDateTime = createDateTime; - this.toActivityID = toActivityID; - this.fromActivityID = fromActivityID; - this.learningDesignID = learningDesignID; + } + + /** + * @return Returns the createDateTime. + */ + public Date getCreateDateTime() { + return createDateTime; + } + + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + /** + * @return Returns the fromActivityID. + */ + public Long getFromActivityID() { + return fromActivityID; + } + + /** + * @return Returns the fromUIID. + */ + public Integer getFromUIID() { + return fromUIID; + } + + /** + * @return Returns the learningDesignID. + */ + public Long getLearningDesignID() { + return learningDesignID; + } + + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + } + + /** + * @return Returns the toActivityID. + */ + public Long getToActivityID() { + return toActivityID; + } + + /** + * @return Returns the toUIID. + */ + public Integer getToUIID() { + return toUIID; + } + + /** + * @return Returns the transitionID. + */ + public Long getTransitionID() { + return transitionID; + } + + /** + * @return Returns the transitionUIID. + */ + public Integer getTransitionUIID() { + return transitionUIID; + } + + /** + * @param createDateTime + * The createDateTime to set. + */ + public void setCreateDateTime(Date createDateTime) { + if (!createDateTime.equals(WDDXTAGS.DATE_NULL_VALUE)) { + this.createDateTime = createDateTime; } - public TransitionDTO(Transition transition){ - this.transitionID = transition.getTransitionId(); - this.transitionUIID = transition.getTransitionUIID(); - this.toUIID = transition.getToUIID(); - this.fromUIID = transition.getFromUIID(); - this.description = transition.getDescription(); - this.title = transition.getTitle(); - this.createDateTime = transition.getCreateDateTime(); - this.toActivityID = transition.getToActivity().getActivityId(); - this.fromActivityID = transition.getFromActivity().getActivityId(); - this.learningDesignID = transition.getLearningDesign().getLearningDesignId(); + } + + /** + * @param description + * The description to set. + */ + public void setDescription(String description) { + if (!description.equals(WDDXTAGS.STRING_NULL_VALUE)) { + this.description = description; } - /** - * @return Returns the createDateTime. - */ - public Date getCreateDateTime() { - return createDateTime; + } + + /** + * @param fromActivityID + * The fromActivityID to set. + */ + public void setFromActivityID(Long fromActivityID) { + if (!fromActivityID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) { + this.fromActivityID = fromActivityID; } - /** - * @return Returns the description. - */ - public String getDescription() { - return description; + } + + /** + * @param fromUIID + * The fromUIID to set. + */ + public void setFromUIID(Integer fromUIID) { + if (!fromUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER)) { + this.fromUIID = fromUIID; } - /** - * @return Returns the fromActivityID. - */ - public Long getFromActivityID() { - return fromActivityID; + } + + /** + * @param learningDesignID + * The learningDesignID to set. + */ + public void setLearningDesignID(Long learningDesignID) { + if (!learningDesignID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) { + this.learningDesignID = learningDesignID; } - /** - * @return Returns the fromUIID. - */ - public Integer getFromUIID() { - return fromUIID; + } + + /** + * @param title + * The title to set. + */ + public void setTitle(String title) { + if (!title.equals(WDDXTAGS.STRING_NULL_VALUE)) { + this.title = title; } - /** - * @return Returns the learningDesignID. - */ - public Long getLearningDesignID() { - return learningDesignID; + } + + /** + * @param toActivityID + * The toActivityID to set. + */ + public void setToActivityID(Long toActivityID) { + if (!toActivityID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) { + this.toActivityID = toActivityID; } - /** - * @return Returns the title. - */ - public String getTitle() { - return title; + } + + /** + * @param toUIID + * The toUIID to set. + */ + public void setToUIID(Integer toUIID) { + if (!toUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER)) { + this.toUIID = toUIID; } - /** - * @return Returns the toActivityID. - */ - public Long getToActivityID() { - return toActivityID; + } + + /** + * @param transitionID + * The transitionID to set. + */ + public void setTransitionID(Long transitionId) { + if (!transitionId.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) { + transitionID = transitionId; } - /** - * @return Returns the toUIID. - */ - public Integer getToUIID() { - return toUIID; + } + + /** + * @param transitionUIID + * The transitionUIID to set. + */ + public void setTransitionUIID(Integer transitionUIID) { + if (!transitionUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER)) { + this.transitionUIID = transitionUIID; } - /** - * @return Returns the transitionID. - */ - public Long getTransitionID() { - return transitionID; - } - /** - * @return Returns the transitionUIID. - */ - public Integer getTransitionUIID() { - return transitionUIID; - } - /** - * @param createDateTime The createDateTime to set. - */ - public void setCreateDateTime(Date createDateTime) { - if(!createDateTime.equals(WDDXTAGS.DATE_NULL_VALUE)) - this.createDateTime = createDateTime; - } - /** - * @param description The description to set. - */ - public void setDescription(String description) { - if(!description.equals(WDDXTAGS.STRING_NULL_VALUE)) - this.description = description; - } - /** - * @param fromActivityID The fromActivityID to set. - */ - public void setFromActivityID(Long fromActivityID) { - if(!fromActivityID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) - this.fromActivityID = fromActivityID; - } - /** - * @param fromUIID The fromUIID to set. - */ - public void setFromUIID(Integer fromUIID) { - if(!fromUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER)) - this.fromUIID = fromUIID; - } - /** - * @param learningDesignID The learningDesignID to set. - */ - public void setLearningDesignID(Long learningDesignID) { - if(!learningDesignID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) - this.learningDesignID = learningDesignID; - } - /** - * @param title The title to set. - */ - public void setTitle(String title) { - if(!title.equals(WDDXTAGS.STRING_NULL_VALUE)) - this.title = title; - } - /** - * @param toActivityID The toActivityID to set. - */ - public void setToActivityID(Long toActivityID) { - if(!toActivityID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) - this.toActivityID = toActivityID; - } - /** - * @param toUIID The toUIID to set. - */ - public void setToUIID(Integer toUIID) { - if(!toUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER)) - this.toUIID = toUIID; - } - /** - * @param transitionID The transitionID to set. - */ - public void setTransitionID(Long transitionId) { - if(!transitionId.equals(WDDXTAGS.NUMERIC_NULL_VALUE_LONG)) - this.transitionID = transitionId; - } - /** - * @param transitionUIID The transitionUIID to set. - */ - public void setTransitionUIID(Integer transitionUIID) { - if(!transitionUIID.equals(WDDXTAGS.NUMERIC_NULL_VALUE_INTEGER)) - this.transitionUIID = transitionUIID; - } + } + + public Integer getTransitionType() { + return transitionType; + } + + public void setTransitionType(Integer transitionType) { + this.transitionType = transitionType; + } + + public ArrayList getDataFlowObjects() { + return dataFlowObjects; + } + + public void setDataFlowObjects(ArrayList dataFlowObjects) { + this.dataFlowObjects = dataFlowObjects; + } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java,v diff -u -r1.102 -r1.103 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java 28 Apr 2009 05:19:59 -0000 1.102 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java 2 Jul 2009 13:06:09 -0000 1.103 @@ -87,6 +87,8 @@ import org.lamsfoundation.lams.learningdesign.CompetenceMapping; import org.lamsfoundation.lams.learningdesign.ComplexActivity; import org.lamsfoundation.lams.learningdesign.ConditionGateActivity; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; +import org.lamsfoundation.lams.learningdesign.DataTransition; import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.GroupingActivity; @@ -111,6 +113,7 @@ import org.lamsfoundation.lams.learningdesign.dto.BranchActivityEntryDTO; import org.lamsfoundation.lams.learningdesign.dto.BranchConditionDTO; import org.lamsfoundation.lams.learningdesign.dto.CompetenceDTO; +import org.lamsfoundation.lams.learningdesign.dto.DataFlowObjectDTO; import org.lamsfoundation.lams.learningdesign.dto.GroupDTO; import org.lamsfoundation.lams.learningdesign.dto.GroupingDTO; import org.lamsfoundation.lams.learningdesign.dto.LearningDesignDTO; @@ -1952,37 +1955,40 @@ } boolean transitionBreak = true; for (TransitionDTO transDto : transDtoList) { - // find out the transition of current first - // activity - if (nextActId.equals(transDto.getFromActivityID())) { - transitionBreak = false; - nextActId = transDto.getToActivityID(); - if (nextActId != null && !removedActMap.containsKey(nextActId)) { - existFirstAct = nextActId; - found = true; + // we deal with progress transitions only + if (transDto.getTransitionType().equals(Transition.PROGRESS_TRANSITION_TYPE)) { + // find out the transition of current first + // activity + if (nextActId.equals(transDto.getFromActivityID())) { + transitionBreak = false; + nextActId = transDto.getToActivityID(); + if (nextActId != null && !removedActMap.containsKey(nextActId)) { + existFirstAct = nextActId; + found = true; + break; + } else if (nextActId == null) { + // no more activity + found = true; + break; + } + // already found the desire transition break; - } else if (nextActId == null) { - // no more activity - found = true; - break; + // if found flag is false yet, then it + // means the 2nd node remove as well, + // continue try 3rd... } - // already found the desire transition + } + // This activity also removed!!! then retrieve + // again + // If found is false, then the nextAct is still + // not available, then continue find. + // tranisitionBreak mean the activity is removed + // but it can not find its transition to + // decide next available activity. + if (found || transitionBreak) { break; - // if found flag is false yet, then it - // means the 2nd node remove as well, - // continue try 3rd... } } - // This activity also removed!!! then retrieve - // again - // If found is false, then the nextAct is still - // not available, then continue find. - // tranisitionBreak mean the activity is removed - // but it can not find its transition to - // decide next available activity. - if (found || transitionBreak) { - break; - } } Activity next = activityMapper.get(existFirstAct); dto.setFirstActivityUIID(next == null ? null : next.getActivityUIID()); @@ -2010,10 +2016,7 @@ Transition trans = getTransition(transDto, activityMapper); transList.add(trans); - // persist trans.setTransitionId(null); - // leave it to learning design to save it. - // transitionDAO.insert(trans); } // Once the learning design is saved, we can import the competences @@ -2049,37 +2052,41 @@ } else { ld.setValidDesign(true); } + // Generation of title triggers Hibernate flush. After changes done to transition<->activity associations, there + // were errors if we tried to read LD data before saving the current one. So the workaround is to first save, + // then read and update the title, then save again. + learningDesignDAO.insert(ld); ld.setTitle(ImportExportUtil.generateUniqueLDTitle(folder, ld.getTitle(), learningDesignDAO)); + learningDesignDAO.update(ld); // persist - learningDesignDAO.insert(ld); // Once we have the competences saved, we can save the competence mappings - Set allCompetenceMappings = new HashSet(); + Set allCompetenceMappings = new HashSet(); for (AuthoringActivityDTO actDto : actDtoList) { - if (removedActMap.containsKey(actDto.getActivityID())){ - continue; - } - if (actDto.getActivityTypeID().intValue() == Activity.TOOL_ACTIVITY_TYPE){ - for (Activity act : actList){ - for(Competence competence : competenceList){ - for (String comptenceMappingStr : actDto.getCompetenceMappingTitles()){ - if (competence.getTitle() == comptenceMappingStr){ - if (activityMapper.get(actDto.getActivityID()).getActivityId() == act.getActivityId() ){ - CompetenceMapping competenceMapping = new CompetenceMapping(); - competenceMapping.setToolActivity((ToolActivity)act); - competenceMapping.setCompetence(competence); - allCompetenceMappings.add(competenceMapping); - break; - } - } - } - } - } - } - } - baseDAO.insertOrUpdateAll(allCompetenceMappings); + if (removedActMap.containsKey(actDto.getActivityID())) { + continue; + } + if (actDto.getActivityTypeID().intValue() == Activity.TOOL_ACTIVITY_TYPE) { + for (Activity act : actList) { + for (Competence competence : competenceList) { + for (String comptenceMappingStr : actDto.getCompetenceMappingTitles()) { + if (competence.getTitle() == comptenceMappingStr) { + if (activityMapper.get(actDto.getActivityID()).getActivityId() == act.getActivityId()) { + CompetenceMapping competenceMapping = new CompetenceMapping(); + competenceMapping.setToolActivity((ToolActivity) act); + competenceMapping.setCompetence(competence); + allCompetenceMappings.add(competenceMapping); + break; + } + } + } + } + } + } + } + baseDAO.insertOrUpdateAll(allCompetenceMappings); return ld.getLearningDesignId(); } @@ -2347,8 +2354,13 @@ } private Transition getTransition(TransitionDTO transDto, Map activityMapper) { - Transition trans = new Transition(); + Transition trans = null; + if (transDto.getTransitionType().equals(Transition.DATA_TRANSITION_TYPE)) { + trans = new DataTransition(); + } else { + trans = new Transition(); + } if (transDto == null) { return trans; } @@ -2360,7 +2372,9 @@ // also set transition to activity: It is nonsense for persisit data, // but it is help this learning design // validated - fromAct.setTransitionFrom(trans); + if (trans.isProgressTransition()) { + fromAct.setTransitionFrom(trans); + } // set to null // trans.setLearningDesign(); trans.setTitle(transDto.getTitle()); @@ -2371,13 +2385,32 @@ // also set transition to activity: It is nonsense for persisit data, // but it is help this learning design // validated - toAct.setTransitionTo(trans); + if (trans.isProgressTransition()) { + toAct.setTransitionTo(trans); + } trans.setTransitionId(transDto.getTransitionID()); trans.setTransitionUIID(transDto.getTransitionUIID()); // reset value trans.setCreateDateTime(new Date()); + + // copy data flow objects + if (trans.isDataTransition()) { + DataTransition dataTransition = (DataTransition) trans; + for (DataFlowObjectDTO dataFlowObjectDto : transDto.getDataFlowObjects()) { + DataFlowObject dataFlowObject = new DataFlowObject(); + dataFlowObject.setDataTransition(dataTransition); + dataFlowObject.setName(dataFlowObjectDto.getName()); + dataFlowObject.setDisplayName(dataFlowObjectDto.getDisplayName()); + dataFlowObject.setOrderId(dataFlowObjectDto.getOrderId()); + Integer toolAssigmentId = StringUtils.isBlank(dataFlowObjectDto.getToolAssigmentId()) ? null + : new Integer(dataFlowObjectDto.getToolAssigmentId()); + dataFlowObject.setToolAssigmentId(toolAssigmentId); + dataTransition.getDataFlowObjects().add(dataFlowObject); + } + } + return trans; } Index: lams_common/src/java/org/lamsfoundation/lams/tool/OutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/OutputFactory.java,v diff -u -r1.8 -r1.9 --- lams_common/src/java/org/lamsfoundation/lams/tool/OutputFactory.java 2 Jul 2009 08:19:27 -0000 1.8 +++ lams_common/src/java/org/lamsfoundation/lams/tool/OutputFactory.java 2 Jul 2009 13:06:10 -0000 1.9 @@ -29,60 +29,45 @@ import java.util.SortedMap; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.learningdesign.BranchCondition; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.util.ILoadedMessageSourceService; import org.lamsfoundation.lams.util.MessageService; - import org.springframework.context.MessageSource; import org.springframework.context.NoSuchMessageException; import org.springframework.context.i18n.LocaleContextHolder; -import org.lamsfoundation.lams.learningdesign.BranchCondition; /** - * This class forms the basic implementation of an output definition and output - * value factory, which is the class in a tool that creates the output - * definition and output values for a tool. Each tool that has outputs should - * create its own factory class that extends this class and uses the methods - * implemented in this class to create the actual ToolOutputDefinition and - * ToolOutput objects. + * This class forms the basic implementation of an output definition and output value factory, which is the class in a + * tool that creates the output definition and output values for a tool. Each tool that has outputs should create its + * own factory class that extends this class and uses the methods implemented in this class to create the actual + * ToolOutputDefinition and ToolOutput objects. * - * The implemented factory (in the tool) needs to supply either (a) its own - * messageService bean (a Spring bean normally defined in the tool's - * applicationContext file in the toolMessageService property or (b) the name of - * its I18N language package/filename AND the the loadedMessageSourceService - * (which is defined as a Spring bean in the core context). One of the two - * options (but not both) is required so that the getDescription() method can - * get the internationalised description of the output definition from the - * tool's internationalisation files. If neither the messageService or the I18N - * name is not supplied then the name if the output definition will appear in - * the description field. + * The implemented factory (in the tool) needs to supply either (a) its own messageService bean (a Spring bean normally + * defined in the tool's applicationContext file in the toolMessageService property or (b) the name of its I18N language + * package/filename AND the the loadedMessageSourceService (which is defined as a Spring bean in the core context). One + * of the two options (but not both) is required so that the getDescription() method can get the internationalised + * description of the output definition from the tool's internationalisation files. If neither the messageService or the + * I18N name is not supplied then the name if the output definition will appear in the description field. * - * The implemented factory should implement public SortedMap getToolOutputDefinitions(Object toolContentObject) and - * this method should call the buildBlahDefinition() calls to build the - * definitions. + * The implemented factory should implement public SortedMap + * getToolOutputDefinitions(Object toolContentObject) and this method should call the buildBlahDefinition() calls to + * build the definitions. * - * It should also implement two methods similar to SortedMap getToolOutput(List names, various tool objects) and - * ToolOutput getToolOutput(String name, various tool objects) to get the actual - * outputs. The "various tool objects" will vary from tool to tool - some tools - * may wish to pass in the raw session and user ids, others may pass in specific - * tool objects. As these inputs will vary greatly from tool to tool, no - * abstract method has been included in this parent class. Putting these calls - * in the factory allows all the "work" of the output generation to be grouped - * together and it also allows the getToolOutput() logic to get to - * getDescription() logic in the factory. + * It should also implement two methods similar to SortedMap getToolOutput(List names, + * various tool objects) and ToolOutput getToolOutput(String name, various tool objects) to get the actual outputs. The + * "various tool objects" will vary from tool to tool - some tools may wish to pass in the raw session and user ids, + * others may pass in specific tool objects. As these inputs will vary greatly from tool to tool, no abstract method has + * been included in this parent class. Putting these calls in the factory allows all the "work" of the output generation + * to be grouped together and it also allows the getToolOutput() logic to get to getDescription() logic in the factory. * * Example definitions for tool factories: - * org.lamsfoundation.lams.tool.mc.ApplicationResources + * class="org.lamsfoundation.lams.tool.mc.service.MCOutputFactory"> org.lamsfoundation.lams.tool.mc.ApplicationResources * * - * - * - * + * + * * */ public abstract class OutputFactory { @@ -92,32 +77,29 @@ private MessageService toolMessageService; private ILoadedMessageSourceService loadedMessageSourceService; private String languageFilename; - private MessageSource msgSource = null; // derived from toolMessageService, loadedMessageSourceService, languageFilename + private MessageSource msgSource = null; // derived from toolMessageService, loadedMessageSourceService, + // languageFilename protected final String KEY_PREFIX = "output.desc."; protected final String CONDITION_NAME_SEPARATOR = "#"; /** - * Create a map of the tool output definitions, suitable for returning from - * the method getToolOutputDefinitions() in the ToolContentManager - * interface. The class for the toolContentObject will be unique to each - * tool e.g. for Multiple Choice tool it will be the McContent object. + * Create a map of the tool output definitions, suitable for returning from the method getToolOutputDefinitions() in + * the ToolContentManager interface. The class for the toolContentObject will be unique to each tool e.g. for + * Multiple Choice tool it will be the McContent object. * - * If the toolContentObject should not be null - if the toolContentId - * supplied in the call to getToolOutputDefinitions(Long toolContentId) does - * not match to any existing content, the content should be the tool's - * default tool content. + * If the toolContentObject should not be null - if the toolContentId supplied in the call to + * getToolOutputDefinitions(Long toolContentId) does not match to any existing content, the content should be the + * tool's default tool content. * * @param toolContentObject - * @return SortedMap of ToolOutputDefinitions where the key is the name from - * each definition + * @return SortedMap of ToolOutputDefinitions where the key is the name from each definition * @throws ToolException */ - public abstract SortedMap getToolOutputDefinitions(Object toolContentObject) - throws ToolException; + public abstract SortedMap getToolOutputDefinitions(Object toolContentObject, + int definitionType) throws ToolException; /** - * Tool specific toolMessageService, such as the forumMessageService in the - * Forum tool + * Tool specific toolMessageService, such as the forumMessageService in the Forum tool */ private MessageService getToolMessageService() { return toolMessageService; @@ -128,9 +110,8 @@ } /** - * Set the common loadedMessageSourceService, based on the bean defined in - * the common Spring context. If toolMessageService is not set, then the - * languageFilename and loadedMessageSourceService should be set. + * Set the common loadedMessageSourceService, based on the bean defined in the common Spring context. If + * toolMessageService is not set, then the languageFilename and loadedMessageSourceService should be set. */ private ILoadedMessageSourceService getLoadedMessageSourceService() { return loadedMessageSourceService; @@ -141,9 +122,8 @@ } /** - * Set the filename/path for the tool's I18N files. If toolMessageService is - * not set, then the languageFilename and loadedMessageSourceService should - * be set. + * Set the filename/path for the tool's I18N files. If toolMessageService is not set, then the languageFilename and + * loadedMessageSourceService should be set. */ public String getLanguageFilename() { return languageFilename; @@ -155,29 +135,26 @@ } /** - * Get the I18N description for this key. If the tool has supplied a - * messageService, then this is used to look up the key and hence get the - * text. Otherwise if the tool has supplied a I18N languageFilename then it - * is accessed via the shared toolActMessageService. If neither are supplied - * or the key is not found, then any "." in the name are converted to space - * and this is used as the return value. + * Get the I18N description for this key. If the tool has supplied a messageService, then this is used to look up + * the key and hence get the text. Otherwise if the tool has supplied a I18N languageFilename then it is accessed + * via the shared toolActMessageService. If neither are supplied or the key is not found, then any "." in the name + * are converted to space and this is used as the return value. * - * This is normally used to get the description for a definition, in whic - * case the key should be in the format output.desc.[definition name], key = - * definition name and addPrefix = true. For example a definition name of + * This is normally used to get the description for a definition, in whic case the key should be in the format + * output.desc.[definition name], key = definition name and addPrefix = true. For example a definition name of * "learner.mark" becomes output.desc.learner.mark. * - * If you want to use this to get an arbitrary string from the I18N files, - * then set addPrefix = false and the output.desc will not be added to the - * beginning. + * If you want to use this to get an arbitrary string from the I18N files, then set addPrefix = false and the + * output.desc will not be added to the beginning. */ protected String getI18NText(String key, boolean addPrefix) { String translatedText = null; MessageSource tmpMsgSource = getMsgSource(); if (tmpMsgSource != null) { - if (addPrefix) + if (addPrefix) { key = KEY_PREFIX + key; + } Locale locale = LocaleContextHolder.getLocale(); try { translatedText = tmpMsgSource.getMessage(key, null, locale); @@ -200,9 +177,8 @@ } /** - * Get the MsgSource, combining getToolMessageService() and - * getLoadedMessageSourceService(). Caches the result so it only needs to be - * calculated once (most tools will require more than one call to this code! + * Get the MsgSource, combining getToolMessageService() and getLoadedMessageSourceService(). Caches the result so it + * only needs to be calculated once (most tools will require more than one call to this code! */ private MessageSource getMsgSource() { if (msgSource == null) { @@ -217,10 +193,8 @@ } /** - * Generic method for building a tool output definition. It will get the - * definition's description from the I18N file using the getDescription() - * method. Only use if the other buildBlahDefinitions do not suit your - * needs. + * Generic method for building a tool output definition. It will get the definition's description from the I18N file + * using the getDescription() method. Only use if the other buildBlahDefinitions do not suit your needs. */ protected ToolOutputDefinition buildDefinition(String definitionName, OutputType type, Object startValue, Object endValue, Object complexValue, Boolean showConditionNameOnly) { @@ -236,8 +210,7 @@ } /** - * Wrapper method for build definition to set the isDefaultGradebookMark - * flag + * Wrapper method for build definition to set the isDefaultGradebookMark flag */ protected ToolOutputDefinition buildDefinition(String definitionName, OutputType type, Object startValue, Object endValue, Object complexValue, Boolean showConditionNameOnly, Boolean isDefaultGradebookMark) { @@ -248,18 +221,16 @@ } /** - * Build a tool definition designed for a range of integer values. It will - * get the definition's description from the I18N file using the - * getDescription() method and set the type to OUTPUT_LONG. + * Build a tool definition designed for a range of integer values. It will get the definition's description from the + * I18N file using the getDescription() method and set the type to OUTPUT_LONG. */ protected ToolOutputDefinition buildRangeDefinition(String definitionName, Long startValue, Long endValue) { return buildDefinition(definitionName, OutputType.OUTPUT_LONG, startValue, endValue, null, Boolean.FALSE); } /** - * Build a tool definition designed for a range of string values. It will - * get the definition's description from the I18N file using the - * getDescription() method and set the type to OUTPUT_LONG. + * Build a tool definition designed for a range of string values. It will get the definition's description from the + * I18N file using the getDescription() method and set the type to OUTPUT_LONG. */ protected ToolOutputDefinition buildRangeDefinition(String definitionName, String startValue, String endValue) { return buildDefinition(definitionName, OutputType.OUTPUT_STRING, startValue, endValue, null, Boolean.FALSE); @@ -284,32 +255,28 @@ } /** - * Build a tool definition designed for a single double value, which is - * likely to be a statistic number of questions answered It will get the - * definition's description from the I18N file using the getDescription() - * method and set the type to OUTPUT_LONG. + * Build a tool definition designed for a single double value, which is likely to be a statistic number of questions + * answered It will get the definition's description from the I18N file using the getDescription() method and set + * the type to OUTPUT_LONG. */ protected ToolOutputDefinition buildLongOutputDefinition(String definitionName) { return buildDefinition(definitionName, OutputType.OUTPUT_LONG, null, null, null, Boolean.FALSE); } /** - * Build a tool definition designed for a single double value, which is - * likely to be a statistic such as average number of posts. It will get the - * definition's description from the I18N file using the getDescription() - * method and set the type to OUTPUT_DOUBLE. + * Build a tool definition designed for a single double value, which is likely to be a statistic such as average + * number of posts. It will get the definition's description from the I18N file using the getDescription() method + * and set the type to OUTPUT_DOUBLE. */ protected ToolOutputDefinition buildDoubleOutputDefinition(String definitionName) { return buildDefinition(definitionName, OutputType.OUTPUT_DOUBLE, null, null, null, Boolean.FALSE); } /** - * Build a tool definition designed for a single boolean value, which is - * likely to be a test such as user has answered all questions correctly. It - * will get the definition's description from the I18N file using the - * getDescription() method and set the type to OUTPUT_BOOLEAN. A Boolean - * tool definition should have default condition name for the true and false - * conditions. The code will automatically look for two strings in the I18N + * Build a tool definition designed for a single boolean value, which is likely to be a test such as user has + * answered all questions correctly. It will get the definition's description from the I18N file using the + * getDescription() method and set the type to OUTPUT_BOOLEAN. A Boolean tool definition should have default + * condition name for the true and false conditions. The code will automatically look for two strings in the I18N * file output.desc..true and output.desc..false */ protected ToolOutputDefinition buildBooleanOutputDefinition(String definitionName) { @@ -331,12 +298,10 @@ } /** - * Build a tool definition designed for a set of boolean conditions. It will - * get the definition's description from the I18N file using the - * getDescription() method and set the type to OUTPUT_SET_BOOLEAN. The - * tool's factory should then set up a series of conditions, each of type - * OUTPUT_BOOLEAN. Sets showConditionNameOnly to true so that the user in - * authoring doesn't see the internal definitions, just the condition name. + * Build a tool definition designed for a set of boolean conditions. It will get the definition's description from + * the I18N file using the getDescription() method and set the type to OUTPUT_SET_BOOLEAN. The tool's factory should + * then set up a series of conditions, each of type OUTPUT_BOOLEAN. Sets showConditionNameOnly to true so that the + * user in authoring doesn't see the internal definitions, just the condition name. */ protected ToolOutputDefinition buildBooleanSetOutputDefinition(String definitionName) { ToolOutputDefinition definition = buildDefinition(definitionName, OutputType.OUTPUT_SET_BOOLEAN, null, null, @@ -347,35 +312,30 @@ } /** - * Build a tool definition designed for a single String value. It will get - * the definition's description from the I18N file using the - * getDescription() method and set the type to OUTPUT_STRING. + * Build a tool definition designed for a single String value. It will get the definition's description from the + * I18N file using the getDescription() method and set the type to OUTPUT_STRING. */ protected ToolOutputDefinition buildStringOutputDefinition(String definitionName) { return buildDefinition(definitionName, OutputType.OUTPUT_STRING, null, null, null, Boolean.FALSE); } /** - * Build a tool definition for a complex value output. It will get the - * definition's description from the I18N file using the getDescription() - * method and set the type to OUTPUT_COMPLEX. + * Build a tool definition for a complex value output. It will get the definition's description from the I18N file + * using the getDescription() method and set the type to OUTPUT_COMPLEX. */ protected ToolOutputDefinition buildComplexOutputDefinition(String definitionName) { return buildDefinition(definitionName, OutputType.OUTPUT_COMPLEX, null, null, null, Boolean.FALSE); } /** - * Build a condition name based on a definition name. For user customised - * conditions, the conditions name MUST start with the definition name for - * Flash to be able to match conditions to definition in the authoring - * interface, but then each condition name needs to be unique, hence - * "uniquePart". + * Build a condition name based on a definition name. For user customised conditions, the conditions name MUST start + * with the definition name for Flash to be able to match conditions to definition in the authoring interface, but + * then each condition name needs to be unique, hence "uniquePart". * * @param definitionName: * Must not be null * @param uniquePart: - * May be null if the condition names are to be the same as - * the definition name. + * May be null if the condition names are to be the same as the definition name. * @return combined string */ protected String buildConditionName(String definitionName, String uniquePart) { @@ -384,8 +344,7 @@ } /** - * Given a condition name built with buildConditionName, split is back into - * its definition name and unique part. + * Given a condition name built with buildConditionName, split is back into its definition name and unique part. * * @param conditionName: * Must not be null @@ -394,10 +353,11 @@ protected String[] splitConditionName(String conditionName) { int index = conditionName.indexOf(CONDITION_NAME_SEPARATOR); if (index > -1) { - if (index + 1 < conditionName.length()) + if (index + 1 < conditionName.length()) { return new String[] { conditionName.substring(0, index), conditionName.substring(index + 1) }; - else + } else { return new String[] { conditionName.substring(0, index), "" }; + } } else { return new String[] { conditionName, "" }; } Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java,v diff -u -r1.18 -r1.19 --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java 22 Aug 2007 07:02:14 -0000 1.18 +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java 2 Jul 2009 13:06:10 -0000 1.19 @@ -24,108 +24,119 @@ package org.lamsfoundation.lams.tool; import java.util.SortedMap; -import java.util.SortedSet; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; - /** * Tool interface that defines the contract regarding tool content manipulation. * * @author Jacky Fang 2004-12-7 * @author Fiona Malikoff May 2005 * */ -public interface ToolContentManager -{ +public interface ToolContentManager { + /** - * Make a copy of requested tool content. It will be needed by LAMS to - * create a copy of learning design and start a new tool session. If - * no content exists with the given fromToolContentId or if fromToolContent is - * null, then use the default content id. + * Make a copy of requested tool content. It will be needed by LAMS to create a copy of learning design and start a + * new tool session. If no content exists with the given fromToolContentId or if fromToolContent is null, then use + * the default content id. * - * @param fromContentId the original tool content id. - * @param toContentId the destination tool content id. - * @throws ToolException if an error occurs e.g. defaultContent is missing + * @param fromContentId + * the original tool content id. + * @param toContentId + * the destination tool content id. + * @throws ToolException + * if an error occurs e.g. defaultContent is missing */ - public void copyToolContent(Long fromContentId, Long toContentId) - throws ToolException; - - /** This tool content should be define later, that is, the - * teacher will define the content at runtime. The toolContentId - * should already exist in the tool. This method will normally be - * called after copyToolContent. - * @param toolContentId the tool content id of the tool content to be changed. - * @param value whether to set or unset define later. - * @throws DataMissingException if no tool content matches the toolContentId - * @throws ToolException if any other error occurs - */ - public void setAsDefineLater(Long toolContentId, boolean value) - throws DataMissingException, ToolException; + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException; + /** + * This tool content should be define later, that is, the teacher will define the content at runtime. The + * toolContentId should already exist in the tool. This method will normally be called after copyToolContent. + * + * @param toolContentId + * the tool content id of the tool content to be changed. + * @param value + * whether to set or unset define later. + * @throws DataMissingException + * if no tool content matches the toolContentId + * @throws ToolException + * if any other error occurs + */ + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException; - /** This tool content should be setup to run offline, that is, the - * activity will be done offline. The toolContentId - * should already exist in the tool. This method will normally be - * called after copyToolContent. - * @param toolContentId the tool content id of the tool content to be changed. - * @param value whether to set or unset run offline. - * @throws DataMissingException if no tool content matches the toolContentId - * @throws ToolException if any other error occurs + /** + * This tool content should be setup to run offline, that is, the activity will be done offline. The toolContentId + * should already exist in the tool. This method will normally be called after copyToolContent. + * + * @param toolContentId + * the tool content id of the tool content to be changed. + * @param value + * whether to set or unset run offline. + * @throws DataMissingException + * if no tool content matches the toolContentId + * @throws ToolException + * if any other error occurs */ - public void setAsRunOffline(Long toolContentId, boolean value) - throws DataMissingException, ToolException; + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException; /** - * Remove tool's content according specified the content id. It will be - * needed by lams to modify the learning design. + * Remove tool's content according specified the content id. It will be needed by lams to modify the learning + * design. * - * If the tool content includes files in the content repository (e.g. - * online and offline instructions) then the files should be removed - * from the repository. + * If the tool content includes files in the content repository (e.g. online and offline instructions) then the + * files should be removed from the repository. * - * If session data for this toolContentId exists and removeSessionData = true, - * then the tool should delete the session data as well as the content data. + * If session data for this toolContentId exists and removeSessionData = true, then the tool should delete the + * session data as well as the content data. * - * If session data for this toolContentId exists and removeSessionData = false, - * then the tool should throw SessionDataExists. + * If session data for this toolContentId exists and removeSessionData = false, then the tool should throw + * SessionDataExists. * - * If no matching data exists, the tool should return without throwing - * an exception. + * If no matching data exists, the tool should return without throwing an exception. * - * @param toolContentId the requested tool content id. - * @param removeSessionData should it remove any related session data? - * @throws ToolException if any other error occurs + * @param toolContentId + * the requested tool content id. + * @param removeSessionData + * should it remove any related session data? + * @throws ToolException + * if any other error occurs */ - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException; - + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException; + /** - * Export the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws DataMissingException if no tool content matches the toolSessionId - * @throws ToolException if any other error occurs + * Export the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws DataMissingException + * if no tool content matches the toolSessionId + * @throws ToolException + * if any other error occurs */ - public void exportToolContent(Long toolContentId, String toPath) - throws DataMissingException, ToolException; + public void exportToolContent(Long toolContentId, String toPath) throws DataMissingException, ToolException; /** - * Import the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws ToolException if any other error occurs + * Import the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws ToolException + * if any other error occurs */ - public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, String toVersion) - throws ToolException; - - /** Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are always - * available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular activity - * such as the answer to the third question contains the word Koala and hence the need for the toolContentId + public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException; + + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition. * * Added in LAMS 2.1 */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException; - + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException; + } Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputDefinition.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputDefinition.java,v diff -u -r1.5 -r1.6 --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputDefinition.java 2 Jul 2009 08:19:27 -0000 1.5 +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolOutputDefinition.java 2 Jul 2009 13:06:10 -0000 1.6 @@ -32,26 +32,28 @@ import org.lamsfoundation.lams.learningdesign.BranchCondition; /** - * Each tool that has outputs will define a set of output definitions. Some - * definitions will be "predefined" for a tool, e.g. "Learner's Mark". Others - * may be created for a specific tool activity, via a Conditions/Output tab in - * monitoring, e.g. Second answer contains the word "Mercury". + * Each tool that has outputs will define a set of output definitions. Some definitions will be "predefined" for a tool, + * e.g. "Learner's Mark". Others may be created for a specific tool activity, via a Conditions/Output tab in monitoring, + * e.g. Second answer contains the word "Mercury". *

- * If the tool contains generated definitions, then they must be copied when the - * tool content is copied, as the conditions may be modified via Live Edit. This - * must not modify the original design. + * If the tool contains generated definitions, then they must be copied when the tool content is copied, as the + * conditions may be modified via Live Edit. This must not modify the original design. *

- * For 2.1, we will not deal with complex outputs, so for now we will not define - * how a complex definition is defined. The field is placed in the object so - * that we have the place for it when we do design the complex output - * definitions. + * For 2.1, we will not deal with complex outputs, so for now we will not define how a complex definition is defined. + * The field is placed in the object so that we have the place for it when we do design the complex output definitions. *

- * Sample ToolOutputDefinition: ToolOutputDefinition { name = "LEARNERS_MARK", - * description = "Mark for an individual learner"; type = "NUMERIC"; startValue = - * "0.0"; endValue = "10.0"; complexDefinition = null; } + * Sample ToolOutputDefinition: ToolOutputDefinition { name = "LEARNERS_MARK", description = "Mark for an individual + * learner"; type = "NUMERIC"; startValue = "0.0"; endValue = "10.0"; complexDefinition = null; } */ public class ToolOutputDefinition implements Comparable { + /* + * Definition Type indicates what kind of definitions should be provided. Some outputs are not valid for conditions, + * some are not valid for data flow between tools. + */ + public static final int DATA_OUTPUT_DEFINITION_TYPE_CONDITION = 1; + public static final int DATA_OUTPUT_DEFINITION_TYPE_DATA_FLOW = 2; + private String name; private String description; private OutputType type; @@ -63,13 +65,11 @@ private List defaultConditions; /** - * Name must be unique within the current tool content. This will be used to - * identify the output. If the definition is a predefined definition then - * the name will always be the same (e.g. LEARNER_MARK) but if it is defined - * in authoring then it will need to made unique for this tool content (e.g. - * ANSWER_2_CONTAINS_1). At lesson time, the tool will be given back the - * name and will need to be able to uniquely identify the required output - * based on name, the tool session id and possibly the learner's user id. + * Name must be unique within the current tool content. This will be used to identify the output. If the definition + * is a predefined definition then the name will always be the same (e.g. LEARNER_MARK) but if it is defined in + * authoring then it will need to made unique for this tool content (e.g. ANSWER_2_CONTAINS_1). At lesson time, the + * tool will be given back the name and will need to be able to uniquely identify the required output based on name, + * the tool session id and possibly the learner's user id. */ public String getName() { return name; @@ -80,10 +80,9 @@ } /** - * Description: Description is an internationalised text string which is - * displayed to the user as the output "name". It is the responsibility of - * the tool to internationalise the string. We suggest that the key for each - * predefined definition follow the convention OUTPUT_DESC_ + * Description: Description is an internationalised text string which is displayed to the user as the output "name". + * It is the responsibility of the tool to internationalise the string. We suggest that the key for each predefined + * definition follow the convention OUTPUT_DESC_ */ public String getDescription() { return description; @@ -105,10 +104,9 @@ } /** - * If the output value may be compared to a range, then startValue and - * endValue are the inclusive start values and end values for the range. - * This may be used to customise fixed definitions to ranges appropriate for - * the current data. + * If the output value may be compared to a range, then startValue and endValue are the inclusive start values and + * end values for the range. This may be used to customise fixed definitions to ranges appropriate for the current + * data. */ public Object getStartValue() { return startValue; @@ -135,33 +133,38 @@ this.complexDefinition = complexDefinition; } + @Override public String toString() { return new ToStringBuilder(this).append("name", name).append("description", description).append("type", type) .append("startValue", startValue).append("endValue", endValue).toString(); } + @Override public boolean equals(Object other) { - if ((this == other)) + if (this == other) { return true; - if (!(other instanceof ToolOutputDefinition)) + } + if (!(other instanceof ToolOutputDefinition)) { return false; + } ToolOutputDefinition castOther = (ToolOutputDefinition) other; - return new EqualsBuilder().append(this.name, castOther.name).append(this.type, castOther.type).isEquals(); + return new EqualsBuilder().append(name, castOther.name).append(type, castOther.type).isEquals(); } + @Override public int hashCode() { return new HashCodeBuilder().append(name).append(type).toHashCode(); } public int compareTo(Object o) { ToolOutputDefinition myClass = (ToolOutputDefinition) o; - return new CompareToBuilder().append(this.name, myClass.name).append(this.type, myClass.type).toComparison(); + return new CompareToBuilder().append(name, myClass.name).append(type, myClass.type).toComparison(); } /** - * Default Conditions are sample conditions that should be presented to the - * user as a starting point for using this OutputDefinition + * Default Conditions are sample conditions that should be presented to the user as a starting point for using this + * OutputDefinition * * @return */ @@ -174,10 +177,8 @@ } /** - * Should Flash show the definition of the branch conditions (e.g. Range - * from blah to blah) or just the name of the condition. Set to true if the - * definition relates to an internal parameter and will mean nothing to the - * user + * Should Flash show the definition of the branch conditions (e.g. Range from blah to blah) or just the name of the + * condition. Set to true if the definition relates to an internal parameter and will mean nothing to the user */ public Boolean isShowConditionNameOnly() { return showConditionNameOnly; @@ -188,18 +189,17 @@ } /** - * If set, this flag makes the current tool output definition the default - * output to go straight to gradebook marks when the user completes an - * activity. There should only be one of these per tool. + * If set, this flag makes the current tool output definition the default output to go straight to gradebook marks + * when the user completes an activity. There should only be one of these per tool. * * @return */ public Boolean isDefaultGradebookMark() { - return isDefaultGradebookMark; + return isDefaultGradebookMark; } public void setIsDefaultGradebookMark(Boolean isDefaultGradebookMark) { - this.isDefaultGradebookMark = isDefaultGradebookMark; + this.isDefaultGradebookMark = isDefaultGradebookMark; } } Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java,v diff -u -r1.22 -r1.23 --- lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java 21 Oct 2008 01:50:34 -0000 1.22 +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java 2 Jul 2009 13:06:09 -0000 1.23 @@ -209,7 +209,7 @@ * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition * @throws ToolException */ - public SortedMap getOutputDefinitionsFromTool(Long toolContentId) + public SortedMap getOutputDefinitionsFromTool(Long toolContentId, int definitionType) throws ToolException; /** Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java,v diff -u -r1.38 -r1.39 --- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java 1 Jul 2009 02:47:11 -0000 1.38 +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java 2 Jul 2009 13:06:09 -0000 1.39 @@ -358,7 +358,7 @@ * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition * @throws ToolException */ - public SortedMap getOutputDefinitionsFromTool(Long toolContentId) + public SortedMap getOutputDefinitionsFromTool(Long toolContentId, int definitionType) throws ToolException { ToolContent toolContent = (ToolContent) toolContentDAO.find(ToolContent.class, toolContentId); @@ -378,7 +378,7 @@ try { ToolContentManager contentManager = (ToolContentManager) findToolService(tool); - return contentManager.getToolOutputDefinitions(toolContentId); + return contentManager.getToolOutputDefinitions(toolContentId, definitionType); } catch (NoSuchBeanDefinitionException e) { String message = "A tool which is defined in the database appears to missing from the classpath. Unable to get the tool output definitions. ToolContentId " + toolContentId; Index: lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java,v diff -u -r1.36 -r1.37 --- lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java 11 Mar 2009 01:08:31 -0000 1.36 +++ lams_common/src/java/org/lamsfoundation/lams/util/wddx/WDDXTAGS.java 2 Jul 2009 13:06:09 -0000 1.37 @@ -160,6 +160,7 @@ public static final String TRANSITION_FROM = "from_activity_id"; public static final String TO_ACTIVITY_UIID = "toUIID"; public static final String FROM_ACTIVITY_UIID = "fromUIID"; + public static final String TRANSITION_TYPE = "transitionType"; /** Tool Specific tags */ public static final String TOOL_DISPLAY_NAME = "displayName"; @@ -238,7 +239,7 @@ /** Tool adapters specific tags */ public static final String CUSTOM_CSV = "customCSV"; - + /** Evaluation tool output tag */ public static final String TOOL_OUTPUT_DEFINITION = "gradebookToolOutputDefinitionName"; } Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java,v diff -u -r1.7 -r1.8 --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java 1 Jul 2009 02:46:52 -0000 1.7 +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java 2 Jul 2009 13:02:25 -0000 1.8 @@ -71,8 +71,8 @@ import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; -import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.web.util.AttributeNames; /** * @author lfoxton @@ -82,15 +82,15 @@ */ /** * @author lfoxton - * + * */ public class GradebookService implements IGradebookService { private static Logger logger = Logger.getLogger(GradebookService.class); private static final ExcelCell[] EMPTY_ROW = new ExcelCell[4]; - // Services + // Services private ILamsCoreToolService toolService; private IGradebookDAO gradebookDAO; private ILessonService lessonService; @@ -106,8 +106,8 @@ @SuppressWarnings("unchecked") public List getGBActivityRowsForLearner(Lesson lesson, User learner) { - logger.debug("Getting gradebook user data for lesson: " + lesson.getLessonId() + ". For user: " - + learner.getUserId()); + GradebookService.logger.debug("Getting gradebook user data for lesson: " + lesson.getLessonId() + + ". For user: " + learner.getUserId()); List gradebookActivityDTOs = new ArrayList(); @@ -116,16 +116,14 @@ properties.put("user", learner); LearnerProgress learnerProgress = getLearnerProgress(lesson, learner); - Set activities = (Set) lesson.getLearningDesign().getActivities(); + Set activities = lesson.getLearningDesign().getActivities(); /* - * Hibernate CGLIB is failing to load the first activity in - * the sequence as a ToolActivity for some mysterious reason - * Causes a ClassCastException when you try to cast it, even - * if it is a ToolActivity. + * Hibernate CGLIB is failing to load the first activity in the sequence as a ToolActivity for some mysterious + * reason Causes a ClassCastException when you try to cast it, even if it is a ToolActivity. * - * THIS IS A HACK to retrieve the first tool activity - * manually so it can be cast as a ToolActivity - if it is one + * THIS IS A HACK to retrieve the first tool activity manually so it can be cast as a ToolActivity - if it is + * one */ Activity firstActivity = activityDAO.getActivityByActivityId(lesson.getLearningDesign().getFirstActivity() @@ -158,28 +156,26 @@ @SuppressWarnings("unchecked") public List getGBActivityRowsForLesson(Lesson lesson) { - logger.debug("Getting gradebook data for lesson: " + lesson.getLessonId()); + GradebookService.logger.debug("Getting gradebook data for lesson: " + lesson.getLessonId()); List gradebookActivityDTOs = new ArrayList(); - Set activities = (Set) lesson.getLearningDesign().getActivities(); + Set activities = lesson.getLearningDesign().getActivities(); /* - * Hibernate CGLIB is failing to load the first activity in - * the sequence as a ToolActivity for some mysterious reason - * Causes a ClassCastException when you try to cast it, even - * if it is a ToolActivity. + * Hibernate CGLIB is failing to load the first activity in the sequence as a ToolActivity for some mysterious + * reason Causes a ClassCastException when you try to cast it, even if it is a ToolActivity. * - * THIS IS A HACK to retrieve the first tool activity - * manually so it can be cast as a ToolActivity - if it is one + * THIS IS A HACK to retrieve the first tool activity manually so it can be cast as a ToolActivity - if it is + * one */ Activity firstActivity = activityDAO.getActivityByActivityId(lesson.getLearningDesign().getFirstActivity() .getActivityId()); if (firstActivity.isToolActivity() && firstActivity instanceof ToolActivity) { Grouping grouping = firstActivity.getGrouping(); if (grouping != null) { - Set groups = (Set) grouping.getGroups(); + Set groups = grouping.getGroups(); if (groups != null) { for (Group group : groups) { @@ -202,7 +198,7 @@ Grouping grouping = activity.getGrouping(); if (grouping != null) { - Set groups = (Set) grouping.getGroups(); + Set groups = grouping.getGroups(); if (groups != null) { for (Group group : groups) { @@ -237,12 +233,12 @@ if (groupId != null) { Group group = (Group) baseDAO.find(Group.class, groupId); if (group != null) { - learners = (Set) group.getUsers(); + learners = group.getUsers(); } else { - learners = (Set) lesson.getAllLearners(); + learners = lesson.getAllLearners(); } } else { - learners = (Set) lesson.getAllLearners(); + learners = lesson.getAllLearners(); } if (learners != null) { @@ -299,7 +295,7 @@ ArrayList gradebookUserDTOs = new ArrayList(); if (lesson != null) { - Set learners = (Set) lesson.getAllLearners(); + Set learners = lesson.getAllLearners(); if (learners != null) { @@ -382,8 +378,8 @@ /** * @see org.lamsfoundation.lams.gradebook.service.IGradebookService#updateUserActivityGradebookMark(org.lamsfoundation.lams.lesson.Lesson, - * org.lamsfoundation.lams.usermanagement.User, - * org.lamsfoundation.lams.learningdesign.Activity, java.lang.Double) + * org.lamsfoundation.lams.usermanagement.User, org.lamsfoundation.lams.learningdesign.Activity, + * java.lang.Double) */ public void updateUserActivityGradebookMark(Lesson lesson, User learner, Activity activity, Double mark, Boolean markedInGradebook) { @@ -526,13 +522,12 @@ } } else { - logger.error("Request for gradebook grid with a null organisation"); + GradebookService.logger.error("Request for gradebook grid with a null organisation"); } return lessonRows; } - /** * @see org.lamsfoundation.lams.gradebook.service.IGradebookService#getActivityViewDataForExcel(org.lamsfoundation.lams.lesson.Lesson) */ @@ -541,7 +536,7 @@ ExcelCell[][] data = null; if (lesson != null) { - Set activities = (Set) lesson.getLearningDesign().getActivities(); + Set activities = lesson.getLearningDesign().getActivities(); Activity firstActivity = activityDAO.getActivityByActivityId(lesson.getLearningDesign().getFirstActivity() .getActivityId()); @@ -591,7 +586,7 @@ rowList.add(userDataRow); } - rowList.add(EMPTY_ROW); + rowList.add(GradebookService.EMPTY_ROW); } data = rowList.toArray(new ExcelCell[][] {}); @@ -608,7 +603,7 @@ ExcelCell[][] data = null; if (lesson != null) { - Set learners = (Set) lesson.getAllLearners(); + Set learners = lesson.getAllLearners(); List rowList = new LinkedList(); for (User learner : learners) { @@ -636,7 +631,7 @@ rowList.add(activityDataRow); } - rowList.add(EMPTY_ROW); + rowList.add(GradebookService.EMPTY_ROW); } data = rowList.toArray(new ExcelCell[][] {}); @@ -652,41 +647,41 @@ public ExcelCell[][] getSummaryDataForExcel(Lesson lesson) { ExcelCell[][] data = null; if (lesson != null) { - + // The entire data list List rowList = new LinkedList(); - + // Adding the lesson average data to the summary ------------------- ExcelCell[] lessonAverageMark = new ExcelCell[2]; lessonAverageMark[0] = new ExcelCell(getMessage("gradebook.export.average.lesson.mark"), true); lessonAverageMark[1] = new ExcelCell(getAverageMarkForLesson(lesson.getLessonId()), false); rowList.add(lessonAverageMark); - + ExcelCell[] lessonAverageTimeTaken = new ExcelCell[2]; lessonAverageTimeTaken[0] = new ExcelCell(getMessage("gradebook.export.average.lesson.time.taken"), true); - lessonAverageTimeTaken[1] = new ExcelCell(gradebookDAO.getAverageDurationLesson(lesson.getLessonId()), false); + lessonAverageTimeTaken[1] = new ExcelCell(gradebookDAO.getAverageDurationLesson(lesson.getLessonId()), + false); rowList.add(lessonAverageTimeTaken); - rowList.add(EMPTY_ROW); - //------------------------------------------------------------------ - - + rowList.add(GradebookService.EMPTY_ROW); + // ------------------------------------------------------------------ + // Adding the activity average data to the summary ----------------- List activityRows = getGBActivityRowsForLesson(lesson); ExcelCell[] activityAverageTitle = new ExcelCell[1]; activityAverageTitle[0] = new ExcelCell(getMessage("gradebook.export.activities"), true); rowList.add(activityAverageTitle); - + // Setting up the activity summary table ExcelCell[] activityAverageRow = new ExcelCell[4]; activityAverageRow[0] = new ExcelCell(getMessage("gradebook.export.activity"), true); activityAverageRow[1] = new ExcelCell(getMessage("gradebook.columntitle.competences"), true); activityAverageRow[2] = new ExcelCell(getMessage("gradebook.export.average.time.taken.seconds"), true); activityAverageRow[3] = new ExcelCell(getMessage("gradebook.columntitle.averageMark"), true); rowList.add(activityAverageRow); - + Iterator it = activityRows.iterator(); while (it.hasNext()) { - GBActivityGridRowDTO activityRow = (GBActivityGridRowDTO)it.next(); + GBActivityGridRowDTO activityRow = (GBActivityGridRowDTO) it.next(); // Add the activity average data ExcelCell[] activityDataRow = new ExcelCell[4]; activityDataRow[0] = new ExcelCell(activityRow.getRowName(), false); @@ -695,35 +690,34 @@ activityDataRow[3] = new ExcelCell(activityRow.getAverageMark(), false); rowList.add(activityDataRow); } - rowList.add(EMPTY_ROW); - //------------------------------------------------------------------ - - + rowList.add(GradebookService.EMPTY_ROW); + // ------------------------------------------------------------------ + // Adding the user lesson marks to the summary---------------------- ExcelCell[] userMarksTitle = new ExcelCell[1]; userMarksTitle[0] = new ExcelCell(getMessage("gradebook.export.total.marks.for.lesson"), true); rowList.add(userMarksTitle); - + // Fetching the user data ArrayList userRows = getGBUserRowsForLesson(lesson); - + // Setting up the user marks table ExcelCell[] userTitleRow = new ExcelCell[3]; userTitleRow[0] = new ExcelCell(getMessage("gradebook.export.user"), true); userTitleRow[1] = new ExcelCell(getMessage("gradebook.export.time.taken.seconds"), true); userTitleRow[2] = new ExcelCell(getMessage("gradebook.export.total.mark"), true); rowList.add(userTitleRow); - + for (GBUserGridRowDTO userRow : userRows) { - // Adding the user data for the lesson - ExcelCell[] userDataRow = new ExcelCell[3]; - userDataRow[0] = new ExcelCell(userRow.getRowName(), false); - userDataRow[1] = new ExcelCell(userRow.getTimeTakenSeconds(), false); - userDataRow[2] = new ExcelCell(userRow.getMark(), false); - rowList.add(userDataRow); + // Adding the user data for the lesson + ExcelCell[] userDataRow = new ExcelCell[3]; + userDataRow[0] = new ExcelCell(userRow.getRowName(), false); + userDataRow[1] = new ExcelCell(userRow.getTimeTakenSeconds(), false); + userDataRow[2] = new ExcelCell(userRow.getMark(), false); + rowList.add(userDataRow); } - //------------------------------------------------------------------ - + // ------------------------------------------------------------------ + data = rowList.toArray(new ExcelCell[][] {}); } @@ -858,8 +852,8 @@ private GBActivityGridRowDTO getGradebookActivityDTO(ToolActivity activity, User learner, LearnerProgress learnerProgress) { - logger.debug("Getting gradebook data for activity: " + activity.getActivityId() + ". For user: " - + learner.getUserId()); + GradebookService.logger.debug("Getting gradebook data for activity: " + activity.getActivityId() + + ". For user: " + learner.getUserId()); GBActivityGridRowDTO gactivityDTO = new GBActivityGridRowDTO(); gactivityDTO.setId(activity.getActivityId().toString()); @@ -888,7 +882,7 @@ gactivityDTO.setTimeTaken(getActivityDuration(learnerProgress, activity)); gactivityDTO.setStatus(getActivityStatusStr(learnerProgress, activity)); - // Setting averages + // Setting averages gactivityDTO.setAverageMark(gradebookDAO.getAverageMarkForActivity(activity.getActivityId())); gactivityDTO.setAverageTimeTaken(gradebookDAO.getAverageDurationForActivity(activity.getActivityId())); @@ -989,8 +983,7 @@ } /** - * Gets the outputs for a tool activity and returns the html for the ouputs - * cell in the grid + * Gets the outputs for a tool activity and returns the html for the ouputs cell in the grid * * @param toolAct * @param toolSession @@ -1004,7 +997,7 @@ if (toolAct != null && toolSession != null && learner != null) { SortedMap map = toolService.getOutputDefinitionsFromTool(toolAct - .getToolContentId()); + .getToolContentId(), ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION); Set toolOutputs = new HashSet(); @@ -1026,11 +1019,11 @@ } } catch (RuntimeException e) { - logger.debug("Runtime exception when attempted to get outputs for activity: " + GradebookService.logger.debug("Runtime exception when attempted to get outputs for activity: " + toolAct.getActivityId() + ", continuing for other activities", e); } } - //toolOutputsStr += ""; + // toolOutputsStr += ""; } } @@ -1050,7 +1043,7 @@ */ private Long getTotalMarksAvailable(ToolActivity activity) { SortedMap map = toolService.getOutputDefinitionsFromTool(activity - .getToolContentId()); + .getToolContentId(), ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION); Set actEvals = activity.getActivityEvaluations(); @@ -1059,7 +1052,7 @@ ToolOutputDefinition definition = map.get(key); if (actEvals != null && actEvals.size() > 0) { - // get first evaluation + // get first evaluation ActivityEvaluation actEval = actEvals.iterator().next(); if (actEval.getToolOutputDefinition().equals(key)) { @@ -1101,7 +1094,7 @@ return null; } } - + public String getMessage(String key) { return messageService.getMessage(key); } @@ -1157,12 +1150,12 @@ } public MessageService getMessageService() { - return messageService; + return messageService; } public void setMessageService(MessageService messageService) { - this.messageService = messageService; + this.messageService = messageService; } - + // ------------------------------------------------------------------------- } Index: lams_learning/conf/xdoclet/web-settings.xml =================================================================== RCS file: /usr/local/cvsroot/lams_learning/conf/xdoclet/web-settings.xml,v diff -u -r1.21 -r1.22 --- lams_learning/conf/xdoclet/web-settings.xml 26 Mar 2009 10:00:35 -0000 1.21 +++ lams_learning/conf/xdoclet/web-settings.xml 2 Jul 2009 13:03:15 -0000 1.22 @@ -14,7 +14,7 @@ locatorFactorySelector - classpath*:/org/lamsfoundation/lams/**/beanRefContext.xml + classpath:/org/lamsfoundation/lams/beanRefContext.xml parentContextKey Index: lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml,v diff -u -r1.25 -r1.26 --- lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml 2 Jul 2009 08:19:32 -0000 1.25 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml 2 Jul 2009 13:03:15 -0000 1.26 @@ -38,6 +38,7 @@ + Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java,v diff -u -r1.32 -r1.33 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java 17 Sep 2006 06:17:58 -0000 1.32 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/ILearnerService.java 2 Jul 2009 13:03:16 -0000 1.33 @@ -21,28 +21,31 @@ * **************************************************************** */ -/* $$Id$$ */ +/* $$Id$$ */ package org.lamsfoundation.lams.learning.service; +import org.lamsfoundation.lams.tool.ToolOutput; + /** - * Learner service methods available to tools. These methods should work fine as long as the web - * context contains the core Spring context files. + * Learner service methods available to tools. These methods should work fine as long as the web context contains the + * core Spring context files. */ -public interface ILearnerService -{ +public interface ILearnerService { /** - * Marks an tool session as complete and calculates the next activity against - * the learning design. This method is for tools to redirect the client on - * complete. + * Marks an tool session as complete and calculates the next activity against the learning design. This method is + * for tools to redirect the client on complete. * - * Do not change learnerId to Integer (to match the other calls) - * as all the tools expect this to be a Long. + * Do not change learnerId to Integer (to match the other calls) as all the tools expect this to be a Long. * - * @param toolSessionId, session ID for completed tool - * @param learnerId the learner who is completing the tool session. + * @param toolSessionId, + * session ID for completed tool + * @param learnerId + * the learner who is completing the tool session. * @return the URL for the next activity - * @throws LearnerServiceException in case of problems. + * @throws LearnerServiceException + * in case of problems. */ public String completeToolSession(Long toolSessionId, Long learnerId); + ToolOutput getToolInput(Long requestingToolContentId, Integer assigmentId, Integer learnerId); } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java,v diff -u -r1.97 -r1.98 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 2 Jul 2009 08:19:32 -0000 1.97 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 2 Jul 2009 13:03:15 -0000 1.98 @@ -48,6 +48,7 @@ import org.lamsfoundation.lams.learningdesign.BranchCondition; import org.lamsfoundation.lams.learningdesign.BranchingActivity; import org.lamsfoundation.lams.learningdesign.ConditionGateActivity; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; @@ -58,6 +59,7 @@ import org.lamsfoundation.lams.learningdesign.ToolActivity; import org.lamsfoundation.lams.learningdesign.ToolBranchingActivity; import org.lamsfoundation.lams.learningdesign.dao.IActivityDAO; +import org.lamsfoundation.lams.learningdesign.dao.IDataFlowDAO; import org.lamsfoundation.lams.learningdesign.dao.IGroupingDAO; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; @@ -77,7 +79,7 @@ import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.MessageService; -import org.springframework.dao.DeadlockLoserDataAccessException; +import org.springframework.dao.DataIntegrityViolationException; /** * This class is a facade over the Learning middle tier. @@ -96,6 +98,7 @@ private IGroupingDAO groupingDAO; private ProgressEngine progressEngine; private IToolSessionDAO toolSessionDAO; + private IDataFlowDAO dataFlowDAO; private ILamsCoreToolService lamsCoreToolService; private ActivityMapping activityMapping; private IUserManagementService userManagementService; @@ -114,9 +117,8 @@ } /** - * Creates a new instance of LearnerService. To be used by Spring, assuming - * the Spring will set up the progress engine via method injection. If you - * are creating the bean manually then use the other constructor. + * Creates a new instance of LearnerService. To be used by Spring, assuming the Spring will set up the progress + * engine via method injection. If you are creating the bean manually then use the other constructor. */ public LearnerService() { } @@ -225,8 +227,7 @@ } /** - * Get the lesson data for a particular lesson. In a DTO format suitable for - * sending to the client. + * Get the lesson data for a particular lesson. In a DTO format suitable for sending to the client. */ public LessonDTO getLessonData(Long lessonId) { Lesson lesson = getLesson(lessonId); @@ -235,21 +236,18 @@ /** *

- * Joins a User to a lesson as a learner. It could either be a new lesson or - * a lesson that has been started. + * Joins a User to a lesson as a learner. It could either be a new lesson or a lesson that has been started. *

* *

- * In terms of new lesson, a new learner progress would be initialized. Tool - * session for the next activity will be initialized if necessary. + * In terms of new lesson, a new learner progress would be initialized. Tool session for the next activity will be + * initialized if necessary. *

* *

- * In terms of an started lesson, the learner progress will be returned - * without calculation. Tool session will be initialized if necessary. Note - * that we won't initialize tool session for current activity because we - * assume tool session will always initialize before it becomes a current - * activity.

- * Create a lams tool session for learner against a tool activity. This will - * have concurrency issues interms of grouped tool session because it might - * be inserting some tool session that has already been inserted by other - * member in the group. If the unique_check is broken, we need to query the - * database to get the instance instead of inserting it. It should be done - * in the Spring rollback strategy. + * Create a lams tool session for learner against a tool activity. This will have concurrency issues interms of + * grouped tool session because it might be inserting some tool session that has already been inserted by other + * member in the group. If the unique_check is broken, we need to query the database to get the instance instead of + * inserting it. It should be done in the Spring rollback strategy. *

* - * Once lams tool session is inserted, we need to notify the tool to its own - * session. + * Once lams tool session is inserted, we need to notify the tool to its own session. * * @param toolActivity * @param learner @@ -978,7 +957,33 @@ private void createToolSessionFor(ToolActivity toolActivity, User learner, Lesson lesson) throws LamsToolServiceException, ToolException { // if the tool session already exists, createToolSession() will return null - ToolSession toolSession = lamsCoreToolService.createToolSession(learner, toolActivity, lesson); + ToolSession toolSession = null; + try { + toolSession = lamsCoreToolService.createToolSession(learner, toolActivity, lesson); + } catch (DataIntegrityViolationException e) { + LearnerService.log.warn("There was an attempt to create two tool sessions with the same name. Retrying...", + e); + /* + * LDEV-1533: Two users tried to create a tool session with the same name. One of them was successful, the + * other got an error. The second one will now retry. This might create a loop; on the other hand the second + * attempt should be successful, since either the existing session will be retrieved or a session with a new + * name will be created. + * + * This workaround can not be in LamsCoreToolService (initially it was). If the exception occurs, the + * transaction is unusable anymore and any further DB actions will throw an error. We need to restart the + * transaction on the higher level - here. + * + * This exception should never occur, as lamsCoreToolService.createToolSession is now synchronized. + * Nevertheless, it sometimes occurs, so additional security measures stay. + */ + try { + Thread.sleep(2000); + } catch (InterruptedException e1) { + // do nothing, it does not hurt us + } + + toolSession = lamsCoreToolService.createToolSession(learner, toolActivity, lesson); + } if (toolSession != null) { toolActivity.getToolSessions().add(toolSession); lamsCoreToolService.notifyToolsToCreateSession(toolSession, toolActivity); @@ -1004,8 +1009,7 @@ /** * @throws LearnerServiceException * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#determineBranch(org.lamsfoundation.lams.lesson.Lesson, - * org.lamsfoundation.lams.learningdesign.BranchingActivity, - * java.lang.Integer) + * org.lamsfoundation.lams.learningdesign.BranchingActivity, java.lang.Integer) */ public SequenceActivity determineBranch(Lesson lesson, BranchingActivity branchingActivity, Integer learnerId) throws LearnerServiceException { @@ -1034,10 +1038,9 @@ } /** - * Get all the conditions for this branching activity, ordered by order id. - * Go through each condition until we find one that passes and that is the - * required branch. If no conditions match, use the branch that is the - * "default" branch for this branching activity. + * Get all the conditions for this branching activity, ordered by order id. Go through each condition until we find + * one that passes and that is the required branch. If no conditions match, use the branch that is the "default" + * branch for this branching activity. */ private SequenceActivity determineToolBasedBranch(Lesson lesson, ToolBranchingActivity branchingActivity, User learner) { @@ -1169,8 +1172,7 @@ * gate to check * @param learner * learner who is knocking to the gate - * @return true if learner satisfied any of the conditions - * and is allowed to pass + * @return true if learner satisfied any of the conditions and is allowed to pass */ private boolean determineConditionGateStatus(GateActivity gate, User learner) { boolean shouldOpenGate = false; @@ -1230,13 +1232,11 @@ } /** - * Select a particular branch - we are in preview mode and the author has - * selected a particular activity. + * Select a particular branch - we are in preview mode and the author has selected a particular activity. * * @throws LearnerServiceException * @see org.lamsfoundation.lams.learning.service.ICoreLearnerService#determineBranch(org.lamsfoundation.lams.lesson.Lesson, - * org.lamsfoundation.lams.learningdesign.BranchingActivity, - * java.lang.Integer) + * org.lamsfoundation.lams.learningdesign.BranchingActivity, java.lang.Integer) */ public SequenceActivity selectBranch(Lesson lesson, BranchingActivity branchingActivity, Integer learnerId, Long branchId) throws LearnerServiceException { @@ -1371,4 +1371,28 @@ public void setGradebookService(IGradebookService gradebookService) { this.gradebookService = gradebookService; } + + public IDataFlowDAO getDataFlowDAO() { + return dataFlowDAO; + } + + public void setDataFlowDAO(IDataFlowDAO dataFlowDAO) { + this.dataFlowDAO = dataFlowDAO; + } + + /** + * Gets the concreted tool output (not the definition) from a tool. This method is called by target tool in order to + * get data from source tool. + */ + public ToolOutput getToolInput(Long requestingToolContentId, Integer assigmentId, Integer learnerId) { + DataFlowObject dataFlowObject = getDataFlowDAO() + .getAssignedDataFlowObject(requestingToolContentId, assigmentId); + User learner = (User) getUserManagementService().findById(User.class, learnerId); + Activity activity = dataFlowObject.getDataTransition().getFromActivity(); + String outputName = dataFlowObject.getName(); + ToolSession session = lamsCoreToolService.getToolSessionByLearner(learner, activity); + ToolOutput output = lamsCoreToolService.getOutputFromTool(outputName, session, learnerId); + + return output; + } } \ No newline at end of file Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentOutputFactory.java,v diff -u -r1.4 -r1.5 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentOutputFactory.java 8 May 2009 04:15:29 -0000 1.4 +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentOutputFactory.java 2 Jul 2009 13:01:30 -0000 1.5 @@ -46,7 +46,7 @@ /** * @see org.lamsfoundation.lams.tool.OutputDefinitionFactory#getToolOutputDefinitions(java.lang.Object) */ - public SortedMap getToolOutputDefinitions(Object toolContentObject) { + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) { TreeMap definitionMap = new TreeMap(); Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java,v diff -u -r1.16 -r1.17 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java 1 Jul 2009 02:39:10 -0000 1.16 +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java 2 Jul 2009 13:01:30 -0000 1.17 @@ -154,9 +154,8 @@ // Service method // ******************************************************************************* /** - * Try to get the file. If forceLogin = false and an access denied exception - * occurs, call this method again to get a new ticket and retry file lookup. - * If forceLogin = true and it then fails then throw exception. + * Try to get the file. If forceLogin = false and an access denied exception occurs, call this method again to get a + * new ticket and retry file lookup. If forceLogin = true and it then fails then throw exception. * * @param uuid * @param versionId @@ -185,12 +184,11 @@ } /** - * This method verifies the credentials of the Assessment Tool and gives it - * the Ticket to login and access the Content Repository. + * This method verifies the credentials of the Assessment Tool and gives it the Ticket to login and + * access the Content Repository. * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. * * @return ITicket The ticket for repostory access * @throws AssessmentApplicationException @@ -410,7 +408,7 @@ pattern = Pattern.compile(optionString, java.util.regex.Pattern.CASE_INSENSITIVE | java.util.regex.Pattern.UNICODE_CASE); } - boolean isAnswerCorrect = (question.getAnswerString() != null) ? pattern.matcher( + boolean isAnswerCorrect = question.getAnswerString() != null ? pattern.matcher( question.getAnswerString()).matches() : false; if (isAnswerCorrect) { @@ -426,8 +424,8 @@ boolean isAnswerCorrect = false; try { float answerFloat = Float.valueOf(question.getAnswerString()); - isAnswerCorrect = ((answerFloat >= (option.getOptionFloat() - option.getAcceptedError())) && (answerFloat <= (option - .getOptionFloat() + option.getAcceptedError()))); + isAnswerCorrect = answerFloat >= option.getOptionFloat() - option.getAcceptedError() + && answerFloat <= option.getOptionFloat() + option.getAcceptedError(); } catch (Exception e) { } @@ -442,9 +440,9 @@ try { float answerFloat = Float.valueOf(answerFloatStr); answerFloat = answerFloat / unit.getMultiplier(); - isAnswerCorrect = ((answerFloat >= (option.getOptionFloat() - option - .getAcceptedError())) && (answerFloat <= (option.getOptionFloat() + option - .getAcceptedError()))); + isAnswerCorrect = answerFloat >= option.getOptionFloat() + - option.getAcceptedError() + && answerFloat <= option.getOptionFloat() + option.getAcceptedError(); if (isAnswerCorrect) { break; } @@ -461,7 +459,7 @@ } } } else if (question.getType() == AssessmentConstants.QUESTION_TYPE_TRUE_FALSE) { - if ((question.getAnswerBoolean() == question.getCorrectAnswer()) && (question.getAnswerString() != null)) { + if (question.getAnswerBoolean() == question.getCorrectAnswer() && question.getAnswerString() != null) { mark = maxMark; } } else if (question.getType() == AssessmentConstants.QUESTION_TYPE_ORDERING) { @@ -587,8 +585,8 @@ AssessmentResult lastFinishedResult = assessmentResultDao.getLastFinishedAssessmentResultBySessionId(sessionId, userId); - long timeTaken = (lastFinishedResult == null) ? 0 - : (lastFinishedResult.getFinishDate().getTime() - lastFinishedResult.getStartDate().getTime()); + long timeTaken = lastFinishedResult == null ? 0 : lastFinishedResult.getFinishDate().getTime() + - lastFinishedResult.getStartDate().getTime(); userSummary.setTimeOfLastAttempt(new Date(timeTaken)); if (lastFinishedResult != null) { userSummary.setLastAttemptGrade(lastFinishedResult.getGrade()); @@ -669,7 +667,7 @@ } } } - float averageMark = (count == 0) ? 0 : total / count; + float averageMark = count == 0 ? 0 : total / count; questionSummary.setAverageMark(averageMark); escapeQuotes(questionSummary); @@ -808,9 +806,10 @@ } return node; } - + /** * Get a message from the language files with the given key + * * @param key * @return */ @@ -947,21 +946,20 @@ } /** - * Get the definitions for possible output for an activity, based on the - * toolContentId. These may be definitions that are always available for the - * tool (e.g. number of marks for Multiple Choice) or a custom definition - * created for a particular activity such as the answer to the third - * question contains the word Koala and hence the need for the toolContentId + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId * - * @return SortedMap of ToolOutputDefinitions with the key being the name of - * each definition + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { Assessment assessment = getAssessmentByContentId(toolContentId); if (assessment == null) { assessment = getDefaultAssessment(); } - return getAssessmentOutputFactory().getToolOutputDefinitions(assessment); + return getAssessmentOutputFactory().getToolOutputDefinitions(assessment, definitionType); } public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { @@ -1073,8 +1071,8 @@ /** * Get the tool output for the given tool output names. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) */ public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { return assessmentOutputFactory.getToolOutput(names, this, toolSessionId, learnerId); @@ -1083,8 +1081,8 @@ /** * Get the tool output for the given tool output name. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) */ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return assessmentOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); @@ -1099,8 +1097,7 @@ } /** - * Set the description, throws away the title value as this is not supported - * in 2.0 + * Set the description, throws away the title value as this is not supported in 2.0 */ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { @@ -1167,13 +1164,11 @@ } /** - * Finds out which lesson the given tool content belongs to and returns its - * monitoring users. + * Finds out which lesson the given tool content belongs to and returns its monitoring users. * * @param sessionId * tool session ID - * @return list of teachers that monitor the lesson which contains the tool - * with given session ID + * @return list of teachers that monitor the lesson which contains the tool with given session ID */ public List getMonitorsByToolSessionId(Long sessionId) { return getLessonService().getMonitorsByToolSessionId(sessionId); Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java,v diff -u -r1.3 -r1.4 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java 31 Oct 2008 05:57:27 -0000 1.3 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java 2 Jul 2009 13:01:20 -0000 1.4 @@ -51,7 +51,7 @@ * {@inheritDoc} */ @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); if (toolContentObject != null) { Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java,v diff -u -r1.51 -r1.52 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java 16 Mar 2009 05:55:59 -0000 1.51 +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java 2 Jul 2009 13:01:20 -0000 1.52 @@ -381,14 +381,15 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { Chat chat = getChatDAO().getByContentId(toolContentId); if (chat == null) { chat = getDefaultContent(); } - return getChatOutputFactory().getToolOutputDefinitions(chat); + return getChatOutputFactory().getToolOutputDefinitions(chat, definitionType); } /* IChatService Methods */ @@ -819,11 +820,11 @@ } public IRepositoryService getRepositoryService() { - return repositoryService; + return repositoryService; } public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; + this.repositoryService = repositoryService; } public IAuditService getAuditService() { @@ -848,11 +849,11 @@ .getFromUser().getLoginName(), chatMessage.toString()); } } - + public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } - + /* Private methods */ private Map messageFilters = new ConcurrentHashMap(); Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoOutputFactory.java,v diff -u -r1.1 -r1.2 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoOutputFactory.java 14 Nov 2008 04:05:26 -0000 1.1 +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoOutputFactory.java 2 Jul 2009 13:03:37 -0000 1.2 @@ -44,7 +44,7 @@ * @see org.lamsfoundation.lams.tool.OutputDefinitionFactory#getToolOutputDefinitions(java.lang.Object) */ @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java,v diff -u -r1.9 -r1.10 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java 14 Nov 2008 04:05:26 -0000 1.9 +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java 2 Jul 2009 13:03:37 -0000 1.10 @@ -559,7 +559,8 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { Daco daco = getDacoByContentId(toolContentId); if (daco == null) { try { @@ -568,7 +569,7 @@ DacoServiceImpl.log.error(e.getMessage()); } } - return getDacoOutputFactory().getToolOutputDefinitions(daco); + return getDacoOutputFactory().getToolOutputDefinitions(daco, definitionType); } public DacoUser getUser(Long uid) { Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java,v diff -u -r1.15 -r1.16 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java 16 Mar 2009 05:56:02 -0000 1.15 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java 2 Jul 2009 13:04:30 -0000 1.16 @@ -130,8 +130,8 @@ /* Methods from ToolSessionManager */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { - if (logger.isDebugEnabled()) { - logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId + if (DimdimService.logger.isDebugEnabled()) { + DimdimService.logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId + " toolSessionName = " + toolSessionName + " toolContentId = " + toolContentId); } @@ -189,9 +189,9 @@ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { - if (logger.isDebugEnabled()) { - logger.debug("entering method copyToolContent:" + " fromContentId=" + fromContentId + " toContentId=" - + toContentId); + if (DimdimService.logger.isDebugEnabled()) { + DimdimService.logger.debug("entering method copyToolContent:" + " fromContentId=" + fromContentId + + " toContentId=" + toContentId); } if (toContentId == null) { @@ -238,18 +238,19 @@ * Export the XML fragment for the tool's content, along with any files needed for the content. * * @throws DataMissingException - * if no tool content matches the toolSessionId + * if no tool content matches the toolSessionId * @throws ToolException - * if any other error occurs + * if any other error occurs */ public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { Dimdim dimdim = getDimdimByContentId(toolContentId); if (dimdim == null) { dimdim = getDefaultContent(); } - if (dimdim == null) + if (dimdim == null) { throw new DataMissingException("Unable to find default content for the dimdim tool"); + } // set ResourceToolContentHandler as null to avoid copy file node in // repository again. @@ -273,7 +274,7 @@ * Import the XML fragment for the tool's content, along with any files needed for the content. * * @throws ToolException - * if any other error occurs + * if any other error occurs */ public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, String toVersion) throws ToolException { @@ -283,9 +284,10 @@ Object toolPOJO = exportContentService.importToolContent(toolContentPath, dimdimToolContentHandler, fromVersion, toVersion); - if (!(toolPOJO instanceof Dimdim)) + if (!(toolPOJO instanceof Dimdim)) { throw new ImportToolContentException("Import Dimdim tool content failed. Deserialized object is " + toolPOJO); + } Dimdim dimdim = (Dimdim) toolPOJO; // reset it to new toolContentId @@ -306,7 +308,8 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { return new TreeMap(); } @@ -343,7 +346,7 @@ toolContentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); if (toolContentId == null) { String error = "Could not retrieve default content id for this tool"; - logger.error(error); + DimdimService.logger.error(error); throw new DimdimException(error); } return toolContentId; @@ -354,7 +357,7 @@ Dimdim defaultContent = getDimdimByContentId(defaultContentID); if (defaultContent == null) { String error = "Could not retrieve default content record for this tool"; - logger.error(error); + DimdimService.logger.error(error); throw new DimdimException(error); } return defaultContent; @@ -364,7 +367,7 @@ if (newContentID == null) { String error = "Cannot copy the Dimdim tools default content: + " + "newContentID is null"; - logger.error(error); + DimdimService.logger.error(error); throw new DimdimException(error); } @@ -420,8 +423,9 @@ } public DimdimAttachment uploadFileToContent(Long toolContentId, FormFile file, String type) { - if (file == null || StringUtils.isEmpty(file.getFileName())) + if (file == null || StringUtils.isEmpty(file.getFileName())) { throw new DimdimException("Could not find upload file: " + file); + } NodeKey nodeKey = processFile(file, type); @@ -445,7 +449,7 @@ // Get Dimdim server url String serverURL = getConfigValue(Constants.CFG_SERVER_URL); if (serverURL == null) { - logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined"); + DimdimService.logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined"); throw new DimdimException("Standard server url not defined"); } @@ -463,7 +467,7 @@ return serverURL + path; } else { - logger.error("getDimdimJoinConferenceURL: result: " + result); + DimdimService.logger.error("getDimdimJoinConferenceURL: result: " + result); } return null; } @@ -473,13 +477,13 @@ String serverURL = getConfigValue(Constants.CFG_SERVER_URL); if (serverURL == null) { - logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined"); + DimdimService.logger.error("Config item : '" + Constants.CFG_SERVER_URL + "' not defined"); throw new DimdimException("Standard server url not defined"); } String version = getConfigValue(Constants.CFG_VERSION); if (version == null) { - logger.error("Config value " + Constants.CFG_VERSION + " returned null"); + DimdimService.logger.error("Config value " + Constants.CFG_VERSION + " returned null"); throw new DimdimException("Server version not defined"); } @@ -507,7 +511,7 @@ + "&screenShareEnabled=" + "true" + "&participantListEnabled=true" + "&dialInfoVisible=true"); } else { - logger.error("Unknown version type: " + version); + DimdimService.logger.error("Unknown version type: " + version); throw new DimdimException("Unknown version type"); } @@ -537,7 +541,7 @@ @SuppressWarnings("unchecked") public DimdimConfig getConfig(String key) { - List list = (List) dimdimConfigDAO.findByProperty(DimdimConfig.class, "key", key); + List list = dimdimConfigDAO.findByProperty(DimdimConfig.class, "key", key); if (list.isEmpty()) { return null; } else { @@ -547,7 +551,7 @@ @SuppressWarnings("unchecked") public String getConfigValue(String key) { - List list = (List) dimdimConfigDAO.findByProperty(DimdimConfig.class, "key", key); + List list = dimdimConfigDAO.findByProperty(DimdimConfig.class, "key", key); if (list.isEmpty()) { return null; } else { @@ -569,8 +573,8 @@ private String sendRequest(URL url) throws IOException { - if (logger.isDebugEnabled()) { - logger.debug("request = " + url); + if (DimdimService.logger.isDebugEnabled()) { + DimdimService.logger.debug("request = " + url); } URLConnection connection = url.openConnection(); @@ -579,12 +583,13 @@ String response = ""; String line = ""; - while ((line = in.readLine()) != null) + while ((line = in.readLine()) != null) { response += line; + } in.close(); - if (logger.isDebugEnabled()) { - logger.debug("response = " + response); + if (DimdimService.logger.isDebugEnabled()) { + DimdimService.logger.debug("response = " + response); } return response; @@ -675,7 +680,7 @@ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { - logger + DimdimService.logger .warn("Setting the reflective field on a dimdim. This doesn't make sense as the dimdim is for reflection and we don't reflect on reflection!"); Dimdim dimdim = getDimdimByContentId(toolContentId); if (dimdim == null) { @@ -695,7 +700,7 @@ } public void setDimdimAttachmentDAO(IDimdimAttachmentDAO attachmentDAO) { - this.dimdimAttachmentDAO = attachmentDAO; + dimdimAttachmentDAO = attachmentDAO; } public IDimdimDAO getDimdimDAO() { @@ -719,7 +724,7 @@ } public void setDimdimSessionDAO(IDimdimSessionDAO sessionDAO) { - this.dimdimSessionDAO = sessionDAO; + dimdimSessionDAO = sessionDAO; } public IDimdimConfigDAO getDimdimConfigDAO() { @@ -743,7 +748,7 @@ } public void setDimdimUserDAO(IDimdimUserDAO userDAO) { - this.dimdimUserDAO = userDAO; + dimdimUserDAO = userDAO; } public ILearnerService getLearnerService() { @@ -769,12 +774,12 @@ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { this.coreNotebookService = coreNotebookService; } - + public IRepositoryService getRepositoryService() { - return repositoryService; + return repositoryService; } public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; + this.repositoryService = repositoryService; } } Index: lams_tool_gmap/src/java/org/lamsfoundation/lams/tool/gmap/service/GmapService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_gmap/src/java/org/lamsfoundation/lams/tool/gmap/service/GmapService.java,v diff -u -r1.16 -r1.17 --- lams_tool_gmap/src/java/org/lamsfoundation/lams/tool/gmap/service/GmapService.java 2 Jul 2009 08:19:16 -0000 1.16 +++ lams_tool_gmap/src/java/org/lamsfoundation/lams/tool/gmap/service/GmapService.java 2 Jul 2009 13:04:12 -0000 1.17 @@ -91,747 +91,686 @@ import org.lamsfoundation.lams.web.util.AttributeNames; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** * An implementation of the IGmapService interface. * - * As a requirement, all LAMS tool's service bean must implement - * ToolContentManager and ToolSessionManager. + * As a requirement, all LAMS tool's service bean must implement ToolContentManager and ToolSessionManager. */ -public class GmapService implements ToolSessionManager, ToolContentManager, - IGmapService, ToolContentImport102Manager { +public class GmapService implements ToolSessionManager, ToolContentManager, IGmapService, ToolContentImport102Manager { - static Logger logger = Logger.getLogger(GmapService.class.getName()); + static Logger logger = Logger.getLogger(GmapService.class.getName()); - private IGmapDAO gmapDAO = null; - - private IGmapMarkerDAO gmapMarkerDAO = null; + private IGmapDAO gmapDAO = null; - private IGmapSessionDAO gmapSessionDAO = null; + private IGmapMarkerDAO gmapMarkerDAO = null; - private IGmapUserDAO gmapUserDAO = null; + private IGmapSessionDAO gmapSessionDAO = null; - private IGmapAttachmentDAO gmapAttachmentDAO = null; + private IGmapUserDAO gmapUserDAO = null; - private ILearnerService learnerService; + private IGmapAttachmentDAO gmapAttachmentDAO = null; - private ILamsToolService toolService; + private ILearnerService learnerService; - private IToolContentHandler gmapToolContentHandler = null; + private ILamsToolService toolService; - private IRepositoryService repositoryService = null; + private IToolContentHandler gmapToolContentHandler = null; - private IAuditService auditService = null; + private IRepositoryService repositoryService = null; - private IExportToolContentService exportContentService; + private IAuditService auditService = null; - private ICoreNotebookService coreNotebookService; - - private IGmapConfigItemDAO gmapConfigItemDAO; + private IExportToolContentService exportContentService; - public GmapService() { - super(); - // TODO Auto-generated constructor stub + private ICoreNotebookService coreNotebookService; + + private IGmapConfigItemDAO gmapConfigItemDAO; + + public GmapService() { + super(); + // TODO Auto-generated constructor stub + } + + /* ************ Methods from ToolSessionManager ************* */ + public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { + if (GmapService.logger.isDebugEnabled()) { + GmapService.logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId + + " toolSessionName = " + toolSessionName + " toolContentId = " + toolContentId); } - /* ************ Methods from ToolSessionManager ************* */ - public void createToolSession(Long toolSessionId, String toolSessionName, - Long toolContentId) throws ToolException { - if (logger.isDebugEnabled()) { - logger.debug("entering method createToolSession:" - + " toolSessionId = " + toolSessionId - + " toolSessionName = " + toolSessionName - + " toolContentId = " + toolContentId); - } + GmapSession session = new GmapSession(); + session.setSessionId(toolSessionId); + session.setSessionName(toolSessionName); + // learner starts + // TODO need to also set other fields. + Gmap gmap = gmapDAO.getByContentId(toolContentId); + session.setGmap(gmap); + gmapSessionDAO.saveOrUpdate(session); - GmapSession session = new GmapSession(); - session.setSessionId(toolSessionId); - session.setSessionName(toolSessionName); - // learner starts - // TODO need to also set other fields. - Gmap gmap = gmapDAO.getByContentId(toolContentId); - session.setGmap(gmap); - gmapSessionDAO.saveOrUpdate(session); - - Set markers = gmap.getGmapMarkers(); - if(markers != null && markers.size() > 0){ - for(GmapMarker marker : markers){ - if(marker.isAuthored() && marker.getGmapSession() == null){ - GmapMarker newMarker = (GmapMarker)marker.clone(); - newMarker.setGmapSession(session); - saveOrUpdateGmapMarker(newMarker); - } - } + Set markers = gmap.getGmapMarkers(); + if (markers != null && markers.size() > 0) { + for (GmapMarker marker : markers) { + if (marker.isAuthored() && marker.getGmapSession() == null) { + GmapMarker newMarker = (GmapMarker) marker.clone(); + newMarker.setGmapSession(session); + saveOrUpdateGmapMarker(newMarker); } + } } + } - public String leaveToolSession(Long toolSessionId, Long learnerId) - throws DataMissingException, ToolException { - return learnerService.completeToolSession(toolSessionId, learnerId); - } + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { + return learnerService.completeToolSession(toolSessionId, learnerId); + } - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) - throws DataMissingException, ToolException { - // TODO Auto-generated method stub - return null; + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + // TODO Auto-generated method stub + return null; + } + + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, + ToolException { + // TODO Auto-generated method stub + return null; + } + + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + gmapSessionDAO.deleteBySessionID(toolSessionId); + // TODO check if cascade worked + } + + /** + * Get the tool output for the given tool output names. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) + */ + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { + return new TreeMap(); + } + + /** + * Get the tool output for the given tool output name. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) + */ + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return null; + } + + /* ************ Methods from ToolContentManager ************************* */ + + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { + + if (GmapService.logger.isDebugEnabled()) { + GmapService.logger.debug("entering method copyToolContent:" + " fromContentId=" + fromContentId + + " toContentId=" + toContentId); } - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) - throws DataMissingException, ToolException { - // TODO Auto-generated method stub - return null; + if (toContentId == null) { + String error = "Failed to copy tool content: toContentID is null"; + throw new ToolException(error); } - public void removeToolSession(Long toolSessionId) - throws DataMissingException, ToolException { - gmapSessionDAO.deleteBySessionID(toolSessionId); - // TODO check if cascade worked + Gmap fromContent = null; + if (fromContentId != null) { + fromContent = gmapDAO.getByContentId(fromContentId); } + if (fromContent == null) { + // create the fromContent using the default tool content + fromContent = getDefaultContent(); + } + Gmap toContent = Gmap.newInstance(fromContent, toContentId, gmapToolContentHandler); + gmapDAO.saveOrUpdate(toContent); + } - /** - * Get the tool output for the given tool output names. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) - */ - public SortedMap getToolOutput(List names, - Long toolSessionId, Long learnerId) { - return new TreeMap(); + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { + Gmap gmap = gmapDAO.getByContentId(toolContentId); + if (gmap == null) { + throw new ToolException("Could not find tool with toolContentID: " + toolContentId); } + gmap.setDefineLater(value); + gmapDAO.saveOrUpdate(gmap); + } - /** - * Get the tool output for the given tool output name. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) - */ - public ToolOutput getToolOutput(String name, Long toolSessionId, - Long learnerId) { - return null; + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { + Gmap gmap = gmapDAO.getByContentId(toolContentId); + if (gmap == null) { + throw new ToolException("Could not find tool with toolContentID: " + toolContentId); } + gmap.setRunOffline(value); + gmapDAO.saveOrUpdate(gmap); + } - /* ************ Methods from ToolContentManager ************************* */ + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException { + // TODO Auto-generated method stub + } - public void copyToolContent(Long fromContentId, Long toContentId) - throws ToolException { + /** + * Export the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws DataMissingException + * if no tool content matches the toolSessionId + * @throws ToolException + * if any other error occurs + */ - if (logger.isDebugEnabled()) { - logger.debug("entering method copyToolContent:" + " fromContentId=" - + fromContentId + " toContentId=" + toContentId); - } + public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { + Gmap gmap = gmapDAO.getByContentId(toolContentId); + if (gmap == null) { + gmap = getDefaultContent(); + } + if (gmap == null) { + throw new DataMissingException("Unable to find default content for the gmap tool"); + } - if (toContentId == null) { - String error = "Failed to copy tool content: toContentID is null"; - throw new ToolException(error); - } + // set ResourceToolContentHandler as null to avoid copy file node in + // repository again. + gmap = Gmap.newInstance(gmap, toolContentId, null); + gmap.setToolContentHandler(null); + gmap.setGmapSessions(null); + gmap.setCreateBy(null); + gmap.setToolContentHandler(null); - Gmap fromContent = null; - if ( fromContentId != null ) { - fromContent = gmapDAO.getByContentId(fromContentId); - } - if (fromContent == null) { - // create the fromContent using the default tool content - fromContent = getDefaultContent(); - } - Gmap toContent = Gmap.newInstance(fromContent, toContentId, - gmapToolContentHandler); - gmapDAO.saveOrUpdate(toContent); + Set atts = gmap.getGmapAttachments(); + for (GmapAttachment att : atts) { + att.setGmap(null); } - public void setAsDefineLater(Long toolContentId, boolean value) - throws DataMissingException, ToolException { - Gmap gmap = gmapDAO.getByContentId(toolContentId); - if (gmap == null) { - throw new ToolException("Could not find tool with toolContentID: " - + toolContentId); - } - gmap.setDefineLater(value); - gmapDAO.saveOrUpdate(gmap); - } + Set markers = gmap.getGmapMarkers(); + Set authorItems = new HashSet(); - public void setAsRunOffline(Long toolContentId, boolean value) - throws DataMissingException, ToolException { - Gmap gmap = gmapDAO.getByContentId(toolContentId); - if (gmap == null) { - throw new ToolException("Could not find tool with toolContentID: " - + toolContentId); - } - gmap.setRunOffline(value); - gmapDAO.saveOrUpdate(gmap); + for (GmapMarker gmapMarker : markers) { + if (gmapMarker.isAuthored()) { + gmapMarker.setCreatedBy(null); + gmapMarker.setGmap(null); + gmapMarker.setUpdatedBy(null); + gmapMarker.setGmapSession(null); + authorItems.add(gmapMarker); + } } + gmap.setGmapMarkers(authorItems); - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + try { + exportContentService + .registerFileClassForExport(GmapAttachment.class.getName(), "fileUuid", "fileVersionId"); + exportContentService.exportToolContent(toolContentId, gmap, gmapToolContentHandler, rootPath); + } catch (ExportToolContentException e) { + throw new ToolException(e); } + } - /** - * Export the XML fragment for the tool's content, along with any files - * needed for the content. - * - * @throws DataMissingException - * if no tool content matches the toolSessionId - * @throws ToolException - * if any other error occurs - */ + /** + * Import the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws ToolException + * if any other error occurs + */ + public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException { + try { + exportContentService.registerFileClassForImport(GmapAttachment.class.getName(), "fileUuid", + "fileVersionId", "fileName", "fileType", null, null); - public void exportToolContent(Long toolContentId, String rootPath) - throws DataMissingException, ToolException { - Gmap gmap = gmapDAO.getByContentId(toolContentId); - if (gmap == null) { - gmap = getDefaultContent(); - } - if (gmap == null) - throw new DataMissingException("Unable to find default content for the gmap tool"); + Object toolPOJO = exportContentService.importToolContent(toolContentPath, gmapToolContentHandler, + fromVersion, toVersion); + if (!(toolPOJO instanceof Gmap)) { + throw new ImportToolContentException("Import Gmap tool content failed. Deserialized object is " + + toolPOJO); + } + Gmap gmap = (Gmap) toolPOJO; - // set ResourceToolContentHandler as null to avoid copy file node in - // repository again. - gmap = Gmap.newInstance(gmap, toolContentId, - null); - gmap.setToolContentHandler(null); - gmap.setGmapSessions(null); - gmap.setCreateBy(null); - gmap.setToolContentHandler(null); - - Set atts = gmap.getGmapAttachments(); - for (GmapAttachment att : atts) { - att.setGmap(null); - } - - Set markers = gmap.getGmapMarkers(); - Set authorItems = new HashSet(); - - for (GmapMarker gmapMarker:markers) - { - if (gmapMarker.isAuthored()) - { - gmapMarker.setCreatedBy(null); - gmapMarker.setGmap(null); - gmapMarker.setUpdatedBy(null); - gmapMarker.setGmapSession(null); - authorItems.add(gmapMarker); - } - } - gmap.setGmapMarkers(authorItems); + // reset it to new toolContentId + gmap.setToolContentId(toolContentId); - try { - exportContentService.registerFileClassForExport( - GmapAttachment.class.getName(), "fileUuid", - "fileVersionId"); - exportContentService.exportToolContent(toolContentId, - gmap, gmapToolContentHandler, rootPath); - } catch (ExportToolContentException e) { - throw new ToolException(e); + // Create a user for gmap to be created by: + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + GmapUser gmapUser = new GmapUser(user, null); + gmapUserDAO.saveOrUpdate(gmapUser); + + gmap.setCreateBy(gmapUser.getUid()); + // gmap.setCreateBy(new Long(newUserUid.longValue())); + + // Fixing up any trailing spaces + if (gmap.getGmapMarkers() != null) { + for (GmapMarker marker : gmap.getGmapMarkers()) { + if (marker.getInfoWindowMessage() != null) { + marker.setInfoWindowMessage(marker.getInfoWindowMessage().trim()); + } } + } + + gmapDAO.saveOrUpdate(gmap); + } catch (ImportToolContentException e) { + throw new ToolException(e); } + } - /** - * Import the XML fragment for the tool's content, along with any files - * needed for the content. - * - * @throws ToolException - * if any other error occurs - */ - public void importToolContent(Long toolContentId, Integer newUserUid, - String toolContentPath,String fromVersion,String toVersion) throws ToolException { - try { - exportContentService.registerFileClassForImport( - GmapAttachment.class.getName(), "fileUuid", - "fileVersionId", "fileName", "fileType", null, null); + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition + */ + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { + return new TreeMap(); + } - Object toolPOJO = exportContentService.importToolContent( - toolContentPath, gmapToolContentHandler,fromVersion,toVersion); - if (!(toolPOJO instanceof Gmap)) - throw new ImportToolContentException( - "Import Gmap tool content failed. Deserialized object is " - + toolPOJO); - Gmap gmap = (Gmap) toolPOJO; + /* ********** IGmapService Methods ********************************* */ - // reset it to new toolContentId - gmap.setToolContentId(toolContentId); - - // Create a user for gmap to be created by: - HttpSession ss = SessionManager.getSession(); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - GmapUser gmapUser = new GmapUser(user,null); - gmapUserDAO.saveOrUpdate(gmapUser); - - gmap.setCreateBy(gmapUser.getUid()); - //gmap.setCreateBy(new Long(newUserUid.longValue())); - - // Fixing up any trailing spaces - if (gmap.getGmapMarkers() != null) { - for (GmapMarker marker : gmap.getGmapMarkers()){ - if (marker.getInfoWindowMessage() != null) { - marker.setInfoWindowMessage(marker.getInfoWindowMessage().trim()); - } - } - } + public Long getDefaultContentIdBySignature(String toolSignature) { + Long toolContentId = null; + toolContentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); + if (toolContentId == null) { + String error = "Could not retrieve default content id for this tool"; + GmapService.logger.error(error); + throw new GmapException(error); + } + return toolContentId; + } - gmapDAO.saveOrUpdate(gmap); - } catch (ImportToolContentException e) { - throw new ToolException(e); - } + public Gmap getDefaultContent() { + Long defaultContentID = getDefaultContentIdBySignature(GmapConstants.TOOL_SIGNATURE); + Gmap defaultContent = getGmapByContentId(defaultContentID); + if (defaultContent == null) { + String error = "Could not retrieve default content record for this tool"; + GmapService.logger.error(error); + throw new GmapException(error); } + return defaultContent; + } - /** Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are always - * available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular activity - * such as the answer to the third question contains the word Koala and hence the need for the toolContentId - * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition - */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - return new TreeMap(); + public Gmap copyDefaultContent(Long newContentID) { + + if (newContentID == null) { + String error = "Cannot copy the Gmap tools default content: + " + "newContentID is null"; + GmapService.logger.error(error); + throw new GmapException(error); } - /* ********** IGmapService Methods ********************************* */ + Gmap defaultContent = getDefaultContent(); + // create new gmap using the newContentID + Gmap newContent = new Gmap(); + newContent = Gmap.newInstance(defaultContent, newContentID, gmapToolContentHandler); + gmapDAO.saveOrUpdate(newContent); + return newContent; + } - - public Long getDefaultContentIdBySignature(String toolSignature) { - Long toolContentId = null; - toolContentId = new Long(toolService - .getToolDefaultContentIdBySignature(toolSignature)); - if (toolContentId == null) { - String error = "Could not retrieve default content id for this tool"; - logger.error(error); - throw new GmapException(error); - } - return toolContentId; + public Gmap getGmapByContentId(Long toolContentID) { + Gmap gmap = gmapDAO.getByContentId(toolContentID); + if (gmap == null) { + GmapService.logger.debug("Could not find the content with toolContentID:" + toolContentID); } + return gmap; + } - public Gmap getDefaultContent() { - Long defaultContentID = getDefaultContentIdBySignature(GmapConstants.TOOL_SIGNATURE); - Gmap defaultContent = getGmapByContentId(defaultContentID); - if (defaultContent == null) { - String error = "Could not retrieve default content record for this tool"; - logger.error(error); - throw new GmapException(error); - } - return defaultContent; + public GmapSession getSessionBySessionId(Long toolSessionId) { + GmapSession gmapSession = gmapSessionDAO.getBySessionId(toolSessionId); + if (gmapSession == null) { + GmapService.logger.debug("Could not find the gmap session with toolSessionID:" + toolSessionId); } + return gmapSession; + } - public Gmap copyDefaultContent(Long newContentID) { + public GmapUser getUserByUserIdAndSessionId(Long userId, Long toolSessionId) { + return gmapUserDAO.getByUserIdAndSessionId(userId, toolSessionId); + } - if (newContentID == null) { - String error = "Cannot copy the Gmap tools default content: + " - + "newContentID is null"; - logger.error(error); - throw new GmapException(error); - } + public GmapUser getUserByLoginNameAndSessionId(String loginName, Long toolSessionId) { + return gmapUserDAO.getByLoginNameAndSessionId(loginName, toolSessionId); + } - Gmap defaultContent = getDefaultContent(); - // create new gmap using the newContentID - Gmap newContent = new Gmap(); - newContent = Gmap.newInstance(defaultContent, newContentID, - gmapToolContentHandler); - gmapDAO.saveOrUpdate(newContent); - return newContent; - } + public GmapUser getUserByUID(Long uid) { + return gmapUserDAO.getByUID(uid); + } - public Gmap getGmapByContentId(Long toolContentID) { - Gmap gmap = (Gmap) gmapDAO - .getByContentId(toolContentID); - if (gmap == null) { - logger.debug("Could not find the content with toolContentID:" - + toolContentID); - } - return gmap; + public GmapAttachment uploadFileToContent(Long toolContentId, FormFile file, String type) { + if (file == null || StringUtils.isEmpty(file.getFileName())) { + throw new GmapException("Could not find upload file: " + file); } - public GmapSession getSessionBySessionId(Long toolSessionId) { - GmapSession gmapSession = gmapSessionDAO - .getBySessionId(toolSessionId); - if (gmapSession == null) { - logger - .debug("Could not find the gmap session with toolSessionID:" - + toolSessionId); - } - return gmapSession; - } + NodeKey nodeKey = processFile(file, type); - public GmapUser getUserByUserIdAndSessionId(Long userId, - Long toolSessionId) { - return gmapUserDAO.getByUserIdAndSessionId(userId, toolSessionId); - } + GmapAttachment attachment = new GmapAttachment(); + attachment.setFileType(type); + attachment.setFileUuid(nodeKey.getUuid()); + attachment.setFileVersionId(nodeKey.getVersion()); + attachment.setFileName(file.getFileName()); - public GmapUser getUserByLoginNameAndSessionId(String loginName, - Long toolSessionId) { - return gmapUserDAO.getByLoginNameAndSessionId(loginName, - toolSessionId); - } + return attachment; + } - public GmapUser getUserByUID(Long uid) { - return gmapUserDAO.getByUID(uid); + public void deleteFromRepository(Long uuid, Long versionID) throws GmapException { + ITicket ticket = getRepositoryLoginTicket(); + try { + repositoryService.deleteVersion(ticket, uuid, versionID); + } catch (Exception e) { + throw new GmapException("Exception occured while deleting files from" + " the repository " + e.getMessage()); } + } - public GmapAttachment uploadFileToContent(Long toolContentId, - FormFile file, String type) { - if (file == null || StringUtils.isEmpty(file.getFileName())) - throw new GmapException("Could not find upload file: " + file); + public void deleteInstructionFile(Long contentID, Long uuid, Long versionID, String type) { + gmapDAO.deleteInstructionFile(contentID, uuid, versionID, type); - NodeKey nodeKey = processFile(file, type); + } - GmapAttachment attachment = new GmapAttachment(); - attachment.setFileType(type); - attachment.setFileUuid(nodeKey.getUuid()); - attachment.setFileVersionId(nodeKey.getVersion()); - attachment.setFileName(file.getFileName()); + public void saveOrUpdateGmap(Gmap gmap) { + gmapDAO.saveOrUpdate(gmap); + } - return attachment; - } + public void saveOrUpdateGmapMarker(GmapMarker gmapMarker) { + gmapMarkerDAO.saveOrUpdate(gmapMarker); + } - public void deleteFromRepository(Long uuid, Long versionID) - throws GmapException { - ITicket ticket = getRepositoryLoginTicket(); - try { - repositoryService.deleteVersion(ticket, uuid, versionID); - } catch (Exception e) { - throw new GmapException( - "Exception occured while deleting files from" - + " the repository " + e.getMessage()); - } - } + public List getGmapMarkersBySessionId(Long sessionId) { + return gmapMarkerDAO.getByToolSessionId(sessionId); + } - public void deleteInstructionFile(Long contentID, Long uuid, - Long versionID, String type) { - gmapDAO.deleteInstructionFile(contentID, uuid, versionID, type); + public void saveOrUpdateGmapSession(GmapSession gmapSession) { + gmapSessionDAO.saveOrUpdate(gmapSession); + } - } + public void saveOrUpdateGmapUser(GmapUser gmapUser) { + gmapUserDAO.saveOrUpdate(gmapUser); + } - public void saveOrUpdateGmap(Gmap gmap) { - gmapDAO.saveOrUpdate(gmap); - } - - public void saveOrUpdateGmapMarker(GmapMarker gmapMarker) { - gmapMarkerDAO.saveOrUpdate(gmapMarker); - } - - public List getGmapMarkersBySessionId(Long sessionId) { - return gmapMarkerDAO.getByToolSessionId(sessionId); - } - - public void saveOrUpdateGmapSession(GmapSession gmapSession) { - gmapSessionDAO.saveOrUpdate(gmapSession); - } + public GmapUser createGmapUser(UserDTO user, GmapSession gmapSession) { + GmapUser gmapUser = new GmapUser(user, gmapSession); + saveOrUpdateGmapUser(gmapUser); + return gmapUser; + } - public void saveOrUpdateGmapUser(GmapUser gmapUser) { - gmapUserDAO.saveOrUpdate(gmapUser); - } + public GmapConfigItem getConfigItem(String key) { + return gmapConfigItemDAO.getConfigItemByKey(key); + } - public GmapUser createGmapUser(UserDTO user, - GmapSession gmapSession) { - GmapUser gmapUser = new GmapUser(user, gmapSession); - saveOrUpdateGmapUser(gmapUser); - return gmapUser; - } + public void saveOrUpdateGmapConfigItem(GmapConfigItem item) { + gmapConfigItemDAO.saveOrUpdate(item); + } - public GmapConfigItem getConfigItem(String key) - { - return gmapConfigItemDAO.getConfigItemByKey(key); - } - - public void saveOrUpdateGmapConfigItem(GmapConfigItem item) - { - gmapConfigItemDAO.saveOrUpdate(item); - } - - - - public IAuditService getAuditService() { - return auditService; - } + public IAuditService getAuditService() { + return auditService; + } - public void setAuditService(IAuditService auditService) { - this.auditService = auditService; + public void setAuditService(IAuditService auditService) { + this.auditService = auditService; + } + + private NodeKey processFile(FormFile file, String type) { + NodeKey node = null; + if (file != null && !StringUtils.isEmpty(file.getFileName())) { + String fileName = file.getFileName(); + try { + node = getGmapToolContentHandler().uploadFile(file.getInputStream(), fileName, file.getContentType(), + type); + } catch (InvalidParameterException e) { + throw new GmapException("InvalidParameterException occured while trying to upload File" + + e.getMessage()); + } catch (FileNotFoundException e) { + throw new GmapException("FileNotFoundException occured while trying to upload File" + e.getMessage()); + } catch (RepositoryCheckedException e) { + throw new GmapException("RepositoryCheckedException occured while trying to upload File" + + e.getMessage()); + } catch (IOException e) { + throw new GmapException("IOException occured while trying to upload File" + e.getMessage()); + } } + return node; + } - private NodeKey processFile(FormFile file, String type) { - NodeKey node = null; - if (file != null && !StringUtils.isEmpty(file.getFileName())) { - String fileName = file.getFileName(); - try { - node = getGmapToolContentHandler().uploadFile( - file.getInputStream(), fileName, file.getContentType(), - type); - } catch (InvalidParameterException e) { - throw new GmapException( - "InvalidParameterException occured while trying to upload File" - + e.getMessage()); - } catch (FileNotFoundException e) { - throw new GmapException( - "FileNotFoundException occured while trying to upload File" - + e.getMessage()); - } catch (RepositoryCheckedException e) { - throw new GmapException( - "RepositoryCheckedException occured while trying to upload File" - + e.getMessage()); - } catch (IOException e) { - throw new GmapException( - "IOException occured while trying to upload File" - + e.getMessage()); - } + /* + * (non-Javadoc) + * + * @see org.lamsfoundation.lams.tool.gmap.service.IGmapService#updateMarkerListFromXML(java.lang.String, + * org.lamsfoundation.lams.tool.gmap.model.Gmap, org.lamsfoundation.lams.tool.gmap.model.GmapUser, boolean, + * org.lamsfoundation.lams.tool.gmap.model.GmapSession) + */ + public void updateMarkerListFromXML(String markerXML, Gmap gmap, GmapUser guser, boolean isAuthored, + GmapSession session) { + + if (markerXML != null && !markerXML.equals("")) { + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document document = db.parse(new InputSource(new StringReader(markerXML))); + NodeList list = document.getElementsByTagName("marker"); + + for (int i = 0; i < list.getLength(); i++) { + NamedNodeMap markerNode = (list.item(i)).getAttributes(); + + Long uid = Long.parseLong(markerNode.getNamedItem("markerUID").getNodeValue()); + String markerTitle = markerNode.getNamedItem("title").getNodeValue(); + String infoMessage = markerNode.getNamedItem("infoMessage").getNodeValue(); + Double latitude = Double.parseDouble(markerNode.getNamedItem("latitude").getNodeValue()); + Double longitude = Double.parseDouble(markerNode.getNamedItem("longitude").getNodeValue()); + + String markerState = markerNode.getNamedItem("state").getNodeValue(); + + if (markerState.equals("remove")) { + gmap.removeMarker(uid); + continue; + } + + GmapMarker marker = null; + if (markerState.equals("save")) { + marker = new GmapMarker(); + marker.setCreatedBy(guser); + marker.setCreated(new Date()); + marker.setAuthored(isAuthored); + } else if (markerState.equals("update")) { + marker = gmap.getMarkerByUid(uid); + } + + marker.setGmapSession(session); + marker.setTitle(markerTitle); + marker.setInfoWindowMessage(infoMessage); + marker.setLatitude(latitude); + marker.setLongitude(longitude); + marker.setGmap(gmap); + marker.setUpdated(new Date()); + marker.setUpdatedBy(guser); + saveOrUpdateGmapMarker(marker); } - return node; + } catch (Exception e) { + // TODO: improve error handling + GmapService.logger.error("Could not get marker xml object to update", e); + throw new GmapException("Could not get marker xml object to update", e); + } + } else { + GmapService.logger.debug("MarkerXML string was empty"); } - - /* - * (non-Javadoc) - * @see org.lamsfoundation.lams.tool.gmap.service.IGmapService#updateMarkerListFromXML(java.lang.String, org.lamsfoundation.lams.tool.gmap.model.Gmap, org.lamsfoundation.lams.tool.gmap.model.GmapUser, boolean, org.lamsfoundation.lams.tool.gmap.model.GmapSession) - */ - public void updateMarkerListFromXML(String markerXML, Gmap gmap, GmapUser guser, boolean isAuthored, GmapSession session) - { - - if (markerXML != null && !markerXML.equals("")) - { - try - { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document document = db.parse(new InputSource(new StringReader(markerXML))); - NodeList list = document.getElementsByTagName("marker"); - - for (int i =0; iTicket to login and access the Content Repository. - * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. - * - * @return ITicket The ticket for repostory access - * @throws SubmitFilesException - */ - private ITicket getRepositoryLoginTicket() throws GmapException { - ICredentials credentials = new SimpleCredentials( - GmapToolContentHandler.repositoryUser, - GmapToolContentHandler.repositoryId); - try { - ITicket ticket = repositoryService.login(credentials, - GmapToolContentHandler.repositoryWorkspaceName); - return ticket; - } catch (AccessDeniedException ae) { - throw new GmapException("Access Denied to repository." - + ae.getMessage()); - } catch (WorkspaceNotFoundException we) { - throw new GmapException("Workspace not found." - + we.getMessage()); - } catch (LoginException e) { - throw new GmapException("Login failed." + e.getMessage()); - } + /** + * This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket to login and + * access the Content Repository. + * + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. + * + * @return ITicket The ticket for repostory access + * @throws SubmitFilesException + */ + private ITicket getRepositoryLoginTicket() throws GmapException { + ICredentials credentials = new SimpleCredentials(GmapToolContentHandler.repositoryUser, + GmapToolContentHandler.repositoryId); + try { + ITicket ticket = repositoryService.login(credentials, GmapToolContentHandler.repositoryWorkspaceName); + return ticket; + } catch (AccessDeniedException ae) { + throw new GmapException("Access Denied to repository." + ae.getMessage()); + } catch (WorkspaceNotFoundException we) { + throw new GmapException("Workspace not found." + we.getMessage()); + } catch (LoginException e) { + throw new GmapException("Login failed." + e.getMessage()); } + } - /* ===============Methods implemented from ToolContentImport102Manager =============== */ - + /* ===============Methods implemented from ToolContentImport102Manager =============== */ /** * Import the data for a 1.0.2 Gmap */ - public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) - { - Date now = new Date(); - Gmap gmap = new Gmap(); - gmap.setContentInUse(Boolean.FALSE); - gmap.setCreateBy(new Long(user.getUserID().longValue())); - gmap.setCreateDate(now); - gmap.setDefineLater(Boolean.FALSE); - gmap.setInstructions(WebUtil.convertNewlines((String)importValues.get(ToolContentImport102Manager.CONTENT_BODY))); - gmap.setLockOnFinished(Boolean.TRUE); - gmap.setOfflineInstructions(null); - gmap.setOnlineInstructions(null); - gmap.setRunOffline(Boolean.FALSE); - gmap.setTitle((String)importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); - gmap.setToolContentId(toolContentId); - gmap.setUpdateDate(now); - gmapDAO.saveOrUpdate(gmap); + public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { + Date now = new Date(); + Gmap gmap = new Gmap(); + gmap.setContentInUse(Boolean.FALSE); + gmap.setCreateBy(new Long(user.getUserID().longValue())); + gmap.setCreateDate(now); + gmap.setDefineLater(Boolean.FALSE); + gmap.setInstructions(WebUtil.convertNewlines((String) importValues + .get(ToolContentImport102Manager.CONTENT_BODY))); + gmap.setLockOnFinished(Boolean.TRUE); + gmap.setOfflineInstructions(null); + gmap.setOnlineInstructions(null); + gmap.setRunOffline(Boolean.FALSE); + gmap.setTitle((String) importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); + gmap.setToolContentId(toolContentId); + gmap.setUpdateDate(now); + gmapDAO.saveOrUpdate(gmap); } /** Set the description, throws away the title value as this is not supported in 2.0 */ - public void setReflectiveData(Long toolContentId, String title, String description) - throws ToolException, DataMissingException { + public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, + DataMissingException { - logger.warn("Setting the reflective field on a gmap. This doesn't make sense as the gmap is for reflection and we don't reflect on reflection!"); - Gmap gmap = getGmapByContentId(toolContentId); - if ( gmap == null ) { - throw new DataMissingException("Unable to set reflective data titled "+title - +" on activity toolContentId "+toolContentId - +" as the tool content does not exist."); - } - - gmap.setInstructions(description); + GmapService.logger + .warn("Setting the reflective field on a gmap. This doesn't make sense as the gmap is for reflection and we don't reflect on reflection!"); + Gmap gmap = getGmapByContentId(toolContentId); + if (gmap == null) { + throw new DataMissingException("Unable to set reflective data titled " + title + + " on activity toolContentId " + toolContentId + " as the tool content does not exist."); + } + + gmap.setInstructions(description); } - - //========================================================================================= - /* ********** Used by Spring to "inject" the linked objects ************* */ - public IGmapAttachmentDAO getGmapAttachmentDAO() { - return gmapAttachmentDAO; - } + // ========================================================================================= + /* ********** Used by Spring to "inject" the linked objects ************* */ - public void setGmapAttachmentDAO(IGmapAttachmentDAO attachmentDAO) { - this.gmapAttachmentDAO = attachmentDAO; - } + public IGmapAttachmentDAO getGmapAttachmentDAO() { + return gmapAttachmentDAO; + } - public IGmapDAO getGmapDAO() { - return gmapDAO; - } + public void setGmapAttachmentDAO(IGmapAttachmentDAO attachmentDAO) { + gmapAttachmentDAO = attachmentDAO; + } - public void setGmapDAO(IGmapDAO gmapDAO) { - this.gmapDAO = gmapDAO; - } + public IGmapDAO getGmapDAO() { + return gmapDAO; + } - public IToolContentHandler getGmapToolContentHandler() { - return gmapToolContentHandler; - } + public void setGmapDAO(IGmapDAO gmapDAO) { + this.gmapDAO = gmapDAO; + } - public void setGmapToolContentHandler( - IToolContentHandler gmapToolContentHandler) { - this.gmapToolContentHandler = gmapToolContentHandler; - } + public IToolContentHandler getGmapToolContentHandler() { + return gmapToolContentHandler; + } - public IGmapSessionDAO getGmapSessionDAO() { - return gmapSessionDAO; - } + public void setGmapToolContentHandler(IToolContentHandler gmapToolContentHandler) { + this.gmapToolContentHandler = gmapToolContentHandler; + } - public void setGmapSessionDAO(IGmapSessionDAO sessionDAO) { - this.gmapSessionDAO = sessionDAO; - } + public IGmapSessionDAO getGmapSessionDAO() { + return gmapSessionDAO; + } - public ILamsToolService getToolService() { - return toolService; - } + public void setGmapSessionDAO(IGmapSessionDAO sessionDAO) { + gmapSessionDAO = sessionDAO; + } - public void setToolService(ILamsToolService toolService) { - this.toolService = toolService; - } + public ILamsToolService getToolService() { + return toolService; + } - public IGmapUserDAO getGmapUserDAO() { - return gmapUserDAO; - } + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } - public void setGmapUserDAO(IGmapUserDAO userDAO) { - this.gmapUserDAO = userDAO; - } + public IGmapUserDAO getGmapUserDAO() { + return gmapUserDAO; + } - public ILearnerService getLearnerService() { - return learnerService; - } + public void setGmapUserDAO(IGmapUserDAO userDAO) { + gmapUserDAO = userDAO; + } - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } + public ILearnerService getLearnerService() { + return learnerService; + } - public IExportToolContentService getExportContentService() { - return exportContentService; - } + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } - public void setExportContentService( - IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; - } + public IExportToolContentService getExportContentService() { + return exportContentService; + } - public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; - } + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } - public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; - } - - public IRepositoryService getRepositoryService() { - return repositoryService; - } + public ICoreNotebookService getCoreNotebookService() { + return coreNotebookService; + } - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } + public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { + this.coreNotebookService = coreNotebookService; + } - public IGmapMarkerDAO getGmapMarkerDAO() { - return gmapMarkerDAO; - } + public IRepositoryService getRepositoryService() { + return repositoryService; + } - public void setGmapMarkerDAO(IGmapMarkerDAO gmapMarkerDAO) { - this.gmapMarkerDAO = gmapMarkerDAO; - } - - public IGmapConfigItemDAO getGmapConfigItemDAO() { - return gmapConfigItemDAO; - } + public void setRepositoryService(IRepositoryService repositoryService) { + this.repositoryService = repositoryService; + } - public void setGmapConfigItemDAO(IGmapConfigItemDAO gmapConfigItemDAO) { - this.gmapConfigItemDAO = gmapConfigItemDAO; - } + public IGmapMarkerDAO getGmapMarkerDAO() { + return gmapMarkerDAO; + } - public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { - return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); - } + public void setGmapMarkerDAO(IGmapMarkerDAO gmapMarkerDAO) { + this.gmapMarkerDAO = gmapMarkerDAO; + } - public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID){ - List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if (list == null || list.isEmpty()) { - return null; - } else { - return list.get(0); - } - } + public IGmapConfigItemDAO getGmapConfigItemDAO() { + return gmapConfigItemDAO; + } - /** - * @param notebookEntry - */ - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); + public void setGmapConfigItemDAO(IGmapConfigItemDAO gmapConfigItemDAO) { + this.gmapConfigItemDAO = gmapConfigItemDAO; + } + + public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { + return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); + } + + public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { + List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); + if (list == null || list.isEmpty()) { + return null; + } else { + return list.get(0); } + } + + /** + * @param notebookEntry + */ + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } } Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryOutputFactory.java,v diff -u -r1.3 -r1.4 --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryOutputFactory.java 12 Dec 2008 15:31:28 -0000 1.3 +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryOutputFactory.java 2 Jul 2009 13:00:12 -0000 1.4 @@ -48,7 +48,7 @@ /** * @see org.lamsfoundation.lams.tool.OutputDefinitionFactory#getToolOutputDefinitions(java.lang.Object) */ - public SortedMap getToolOutputDefinitions(Object toolContentObject) { + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) { TreeMap definitionMap = new TreeMap(); Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java,v diff -u -r1.18 -r1.19 --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java 19 Dec 2008 17:13:36 -0000 1.18 +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java 2 Jul 2009 13:00:12 -0000 1.19 @@ -37,7 +37,6 @@ import java.util.Map; import java.util.Set; import java.util.SortedMap; -import java.util.SortedSet; import java.util.TreeSet; import javax.imageio.ImageIO; @@ -118,11 +117,11 @@ */ public class ImageGalleryServiceImpl implements IImageGalleryService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager { - + private final static String MEDIUM_FILENAME_PREFIX = "medium_"; - + private final static String THUMBNAIL_FILENAME_PREFIX = "thumbnail_"; - + static Logger log = Logger.getLogger(ImageGalleryServiceImpl.class.getName()); private ImageGalleryDAO imageGalleryDao; @@ -132,7 +131,7 @@ private ImageCommentDAO imageCommentDao; private ImageRatingDAO imageRatingDao; - + private ImageVoteDAO imageVoteDao; private ImageGalleryAttachmentDAO imageGalleryAttachmentDao; @@ -149,7 +148,7 @@ private ImageGalleryToolContentHandler imageGalleryToolContentHandler; private MessageService messageService; - + private ImageGalleryOutputFactory imageGalleryOutputFactory; // system services @@ -166,9 +165,9 @@ private IExportToolContentService exportContentService; private ICoreNotebookService coreNotebookService; - + private IEventNotificationService eventNotificationService; - + private ILessonService lessonService; // ******************************************************************************* @@ -185,8 +184,7 @@ * @return file node * @throws ImscpApplicationException */ - private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) - throws ImageGalleryException { + private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws ImageGalleryException { ITicket tic = getRepositoryLoginTicket(); @@ -300,8 +298,8 @@ try { repositoryService.deleteVersion(ticket, fileUuid, fileVersionId); } catch (Exception e) { - throw new ImageGalleryException("Exception occured while deleting files from" - + " the repository " + e.getMessage()); + throw new ImageGalleryException("Exception occured while deleting files from" + " the repository " + + e.getMessage()); } } @@ -313,43 +311,43 @@ imageGalleryAttachmentDao.removeObject(ImageGalleryAttachment.class, attachmentUid); } - + public ImageGalleryItem getImageGalleryItemByUid(Long itemUid) { return imageGalleryItemDao.getByUid(itemUid); - } + } public void saveOrUpdateImageGalleryItem(ImageGalleryItem image) { imageGalleryItemDao.saveObject(image); } - + public ImageRating getImageRatingByImageAndUser(Long imageUid, Long userId) { return imageRatingDao.getImageRatingByImageAndUser(imageUid, userId); } public void saveOrUpdateImageRating(ImageRating rating) { imageRatingDao.saveObject(rating); } - + public ImageVote getImageVoteByImageAndUser(Long imageUid, Long userId) { return imageVoteDao.getImageVoteByImageAndUser(imageUid, userId); } public int getNumberVotesByUserId(Long userId) { return imageVoteDao.getNumImageVotesByUserId(userId); } - + public void saveOrUpdateImageVote(ImageVote vote) { imageVoteDao.saveObject(vote); } - + public ImageComment getImageCommentByUid(Long commentUid) { return imageCommentDao.getCommentByUid(commentUid); } public void saveImageComment(ImageComment comment) { imageCommentDao.saveObject(comment); } - + public void deleteImageComment(Long uid) { imageCommentDao.removeObject(ImageComment.class, uid); } @@ -408,7 +406,7 @@ } return nextUrl; } - + public List getUserListBySessionId(Long sessionId) { return imageGalleryUserDao.getBySessionID(sessionId); } @@ -441,7 +439,7 @@ public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if ((list == null) || list.isEmpty()) { + if (list == null || list.isEmpty()) { return null; } else { return list.get(0); @@ -471,17 +469,17 @@ // one new group for one session. group = new ArrayList(); Set groupImages = getImagesForGroup(imageGallery, session.getSessionId()); - + for (ImageGalleryItem image : groupImages) { Summary sum = new Summary(session.getSessionId(), session.getSessionName(), image); - + int numberOfVotes = imageVoteDao.getNumImageVotesByImageUid(image.getUid(), session.getSessionId()); sum.setNumberOfVotes(numberOfVotes); - - Object[] ratingForGroup = getRatingForGroup(image.getUid(),session.getSessionId()); - sum.setNumberRatings(((Long)ratingForGroup[0]).intValue()); - sum.setAverageRating(((Float)ratingForGroup[1]).floatValue()); - + + Object[] ratingForGroup = getRatingForGroup(image.getUid(), session.getSessionId()); + sum.setNumberRatings(((Long) ratingForGroup[0]).intValue()); + sum.setAverageRating(((Float) ratingForGroup[1]).floatValue()); + group.add(sum); } // if there is no any item available, then just put session name into Summary @@ -493,25 +491,25 @@ return groupList; } - + public List> getImageSummary(Long contentId, Long imageUid) { List> imageSummary = new ArrayList>(); List group = new ArrayList(); ImageGalleryItem image = imageGalleryItemDao.getByUid(imageUid); - + List sessionList; if (image.isCreateByAuthor()) { sessionList = imageGallerySessionDao.getByContentId(contentId); } else { sessionList = new ArrayList(); sessionList.add(image.getCreateBy().getSession()); } - + for (ImageGallerySession session : sessionList) { // one new group for one session. group = new ArrayList(); - Object[] ratingForGroup = getRatingForGroup(image.getUid(),session.getSessionId()); - + Object[] ratingForGroup = getRatingForGroup(image.getUid(), session.getSessionId()); + List users = imageGalleryUserDao.getBySessionID(session.getSessionId()); for (ImageGalleryUser user : users) { UserImageContributionDTO userContribution = createUserContribution(image, user, session, ratingForGroup); @@ -554,15 +552,16 @@ return map; } - - public List>> exportBySessionId(Long sessionId, ImageGalleryUser user, boolean skipHide) { + + public List>> exportBySessionId(Long sessionId, ImageGalleryUser user, + boolean skipHide) { ImageGallerySession session = imageGallerySessionDao.getSessionBySessionId(sessionId); if (session == null) { ImageGalleryServiceImpl.log.error("Failed get ImageGallerySession by ID [" + sessionId + "]"); return null; } - - //sessionList-->imageList-->contributionList + + // sessionList-->imageList-->contributionList ImageGallery imageGallery = session.getImageGallery(); List>> sessionList = new ArrayList(); List> imageList = new ArrayList(); @@ -589,30 +588,31 @@ public List>> exportByContentId(Long contentId) { ImageGallery imageGallery = imageGalleryDao.getByContentId(contentId); - List>> sessionList = new ArrayList(); - + List>> sessionList = new ArrayList(); + List imageGallerySessionList = imageGallerySessionDao.getByContentId(contentId); - for(ImageGallerySession imageSession : imageGallerySessionList) { + for (ImageGallerySession imageSession : imageGallerySessionList) { List> imageList = new ArrayList(); Set dbImages = new TreeSet(new ImageGalleryItemComparator()); dbImages.addAll(imageGallery.getImageGalleryItems()); for (ImageGalleryItem image : dbImages) { List userContributionList = new ArrayList(); Object[] ratingForGroup = getRatingForGroup(image.getUid(), imageSession.getSessionId()); - + List userList = imageGalleryUserDao.getBySessionID(imageSession.getSessionId()); for (ImageGalleryUser user : userList) { - UserImageContributionDTO userContribution = createUserContribution(image, user, imageSession, ratingForGroup); + UserImageContributionDTO userContribution = createUserContribution(image, user, imageSession, + ratingForGroup); userContribution.setImage(image); - userContributionList.add(userContribution); + userContributionList.add(userContribution); } imageList.add(userContributionList); - + } sessionList.add(imageList); - } + } return sessionList; } @@ -628,7 +628,7 @@ image.setOriginalFileUuid(nodeKey.getUuid()); String fileName = file.getFileName(); - + ImageGalleryConfigItem mediumImageDimensionsKey = getConfigItem(ImageGalleryConfigItem.KEY_MEDIUM_IMAGE_DIMENSIONS); int mediumImageDimensions = Integer.parseInt(mediumImageDimensionsKey.getConfigValue()); @@ -638,11 +638,12 @@ image.setOriginalImageWidth(originalImage.getWidth(null)); image.setOriginalImageHeight(originalImage.getHeight(null)); InputStream mediumIS = ResizePictureUtil.resizePicture(originalImage, mediumImageDimensions); - String mediumFileName = MEDIUM_FILENAME_PREFIX + fileName.substring(0, fileName.indexOf('.')) + ".jpg"; - NodeKey mediumNodeKey = imageGalleryToolContentHandler.uploadFile(mediumIS, mediumFileName, - file.getContentType(), IToolContentHandler.TYPE_ONLINE); + String mediumFileName = ImageGalleryServiceImpl.MEDIUM_FILENAME_PREFIX + + fileName.substring(0, fileName.indexOf('.')) + ".jpg"; + NodeKey mediumNodeKey = imageGalleryToolContentHandler.uploadFile(mediumIS, mediumFileName, file + .getContentType(), IToolContentHandler.TYPE_ONLINE); image.setMediumFileUuid(mediumNodeKey.getUuid()); - + ImageGalleryConfigItem thumbnailImageDimensionsKey = getConfigItem(ImageGalleryConfigItem.KEY_THUMBNAIL_IMAGE_DIMENSIONS); int thumbnailImageDimensions = Integer.parseInt(thumbnailImageDimensionsKey.getConfigValue()); @@ -652,19 +653,24 @@ image.setMediumImageWidth(mediumImage.getWidth(null)); image.setMediumImageHeight(mediumImage.getHeight(null)); InputStream thumbnailIS = ResizePictureUtil.resizePicture(mediumImage, thumbnailImageDimensions); - String thumbnailFileName = THUMBNAIL_FILENAME_PREFIX + fileName.substring(0, fileName.indexOf('.')) + ".jpg"; - NodeKey thumbnailNodeKey = imageGalleryToolContentHandler.uploadFile(thumbnailIS, thumbnailFileName, - file.getContentType(), IToolContentHandler.TYPE_ONLINE); + String thumbnailFileName = ImageGalleryServiceImpl.THUMBNAIL_FILENAME_PREFIX + + fileName.substring(0, fileName.indexOf('.')) + ".jpg"; + NodeKey thumbnailNodeKey = imageGalleryToolContentHandler.uploadFile(thumbnailIS, thumbnailFileName, file + .getContentType(), IToolContentHandler.TYPE_ONLINE); image.setThumbnailFileUuid(thumbnailNodeKey.getUuid()); - + } catch (RepositoryCheckedException e) { - ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.repository.checked.exception") + ":" + e.toString()); - throw new UploadImageGalleryFileException(messageService.getMessage("error.msg.repository.checked.exception")); + ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.repository.checked.exception") + ":" + + e.toString()); + throw new UploadImageGalleryFileException(messageService + .getMessage("error.msg.repository.checked.exception")); } catch (NumberFormatException e) { - ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.number.format.exception") + ":" + e.toString()); + ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.number.format.exception") + ":" + + e.toString()); throw new UploadImageGalleryFileException(messageService.getMessage("error.msg.number.format.exception")); } catch (IOException e) { - ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.io.exception.resizing") + ":" + e.toString()); + ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.io.exception.resizing") + ":" + + e.toString()); throw new ImageGalleryException(messageService.getMessage("error.msg.io.exception.resizing")); } } @@ -679,7 +685,7 @@ * @throws InvalidParameterException */ private NodeKey uploadFormFile(FormFile file, String fileType) throws UploadImageGalleryFileException { - if ((file == null) || StringUtils.isEmpty(file.getFileName())) { + if (file == null || StringUtils.isEmpty(file.getFileName())) { throw new UploadImageGalleryFileException(messageService.getMessage("error.msg.upload.file.not.found", new Object[] { file })); } @@ -738,7 +744,7 @@ public void setImageRatingDao(ImageRatingDAO imageRatingDao) { this.imageRatingDao = imageRatingDao; } - + public void setImageVoteDao(ImageVoteDAO imageVoteDao) { this.imageVoteDao = imageVoteDao; } @@ -800,29 +806,29 @@ Set images = toolContentObj.getImageGalleryItems(); for (ImageGalleryItem image : images) { image.setComments(null); - + ImageGalleryAttachment originalFile = new ImageGalleryAttachment(); originalFile.setFileUuid(image.getOriginalFileUuid()); originalFile.setFileVersionId(image.getFileVersionId()); originalFile.setFileName(image.getFileName()); originalFile.setFileType(IToolContentHandler.TYPE_ONLINE); image.setOriginalFile(originalFile); - + ImageGalleryAttachment mediumFile = new ImageGalleryAttachment(); mediumFile.setFileUuid(image.getMediumFileUuid()); mediumFile.setFileVersionId(image.getFileVersionId()); - mediumFile.setFileName(MEDIUM_FILENAME_PREFIX + image.getFileName()); - mediumFile.setFileType(IToolContentHandler.TYPE_ONLINE); + mediumFile.setFileName(ImageGalleryServiceImpl.MEDIUM_FILENAME_PREFIX + image.getFileName()); + mediumFile.setFileType(IToolContentHandler.TYPE_ONLINE); image.setMediumFile(mediumFile); ImageGalleryAttachment thumbnailFile = new ImageGalleryAttachment(); thumbnailFile.setFileUuid(image.getThumbnailFileUuid()); thumbnailFile.setFileVersionId(image.getFileVersionId()); - thumbnailFile.setFileName(THUMBNAIL_FILENAME_PREFIX + image.getFileName()); - thumbnailFile.setFileType(IToolContentHandler.TYPE_ONLINE); + thumbnailFile.setFileName(ImageGalleryServiceImpl.THUMBNAIL_FILENAME_PREFIX + image.getFileName()); + thumbnailFile.setFileType(IToolContentHandler.TYPE_ONLINE); image.setThumbnailFile(thumbnailFile); } - + try { exportContentService.registerFileClassForExport(ImageGalleryAttachment.class.getName(), "fileUuid", "fileVersionId"); @@ -843,8 +849,8 @@ Object toolPOJO = exportContentService.importToolContent(toolContentPath, imageGalleryToolContentHandler, fromVersion, toVersion); if (!(toolPOJO instanceof ImageGallery)) { - throw new ImportToolContentException( - "Import ImageGallery tool content failed. Deserialized object is " + toolPOJO); + throw new ImportToolContentException("Import ImageGallery tool content failed. Deserialized object is " + + toolPOJO); } ImageGallery toolContentObj = (ImageGallery) toolPOJO; @@ -867,11 +873,11 @@ Set images = toolContentObj.getImageGalleryItems(); for (ImageGalleryItem image : images) { image.setCreateBy(user); - + image.setOriginalFileUuid(image.getOriginalFile().getFileUuid()); image.setMediumFileUuid(image.getMediumFile().getFileUuid()); image.setThumbnailFileUuid(image.getThumbnailFile().getFileUuid()); - + image.setOriginalFile(null); image.setMediumFile(null); image.setThumbnailFile(null); @@ -890,12 +896,13 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { ImageGallery imageGallery = getImageGalleryByContentId(toolContentId); if (imageGallery == null) { imageGallery = getDefaultImageGallery(); } - return getImageGalleryOutputFactory().getToolOutputDefinitions(imageGallery); + return getImageGalleryOutputFactory().getToolOutputDefinitions(imageGallery, definitionType); } public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { @@ -1071,15 +1078,15 @@ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { this.coreNotebookService = coreNotebookService; } - + public IEventNotificationService getEventNotificationService() { return eventNotificationService; } public void setEventNotificationService(IEventNotificationService eventNotificationService) { this.eventNotificationService = eventNotificationService; } - + public List getMonitorsByToolSessionId(Long sessionId) { return getLessonService().getMonitorsByToolSessionId(sessionId); } @@ -1095,7 +1102,7 @@ public String getLocalisedMessage(String key, Object[] args) { return messageService.getMessage(key, args); } - + public ImageGalleryOutputFactory getImageGalleryOutputFactory() { return imageGalleryOutputFactory; } @@ -1111,10 +1118,10 @@ public void saveOrUpdateImageGalleryConfigItem(ImageGalleryConfigItem item) { imageGalleryConfigItemDAO.saveOrUpdate(item); } - + public Set getImagesForGroup(ImageGallery imageGallery, Long sessionId) { - TreeSet images = new TreeSet(new ImageGalleryItemComparator()); - + TreeSet images = new TreeSet(new ImageGalleryItemComparator()); + List grouppedUsers = getUserListBySessionId(sessionId); Set allImages = imageGallery.getImageGalleryItems(); @@ -1125,10 +1132,10 @@ } } } - + return images; } - + /** * {@inheritDoc} */ @@ -1146,14 +1153,13 @@ } } - - if (! numberRatings.equals(new Long(0))) { + if (!numberRatings.equals(new Long(0))) { averageRating = averageRating / numberRatings; } - - return new Object[] {numberRatings, averageRating}; + + return new Object[] { numberRatings, averageRating }; } - + // ***************************************************************************** // private methods // ***************************************************************************** @@ -1178,28 +1184,29 @@ throw new ImageGalleryException(error); } return contentId; - } - - private UserImageContributionDTO createUserContribution(ImageGalleryItem image, ImageGalleryUser user, ImageGallerySession session, Object[] ratingForGroup) { + } + + private UserImageContributionDTO createUserContribution(ImageGalleryItem image, ImageGalleryUser user, + ImageGallerySession session, Object[] ratingForGroup) { UserImageContributionDTO userContribution = new UserImageContributionDTO(session.getSessionName(), user); - + int numberOfVotesForImage = imageVoteDao.getNumImageVotesByImageUid(image.getUid(), session.getSessionId()); userContribution.setNumberOfVotesForImage(numberOfVotesForImage); - userContribution.setNumberRatings(((Long)ratingForGroup[0]).intValue()); - userContribution.setAverageRating(((Float)ratingForGroup[1]).floatValue()); - + userContribution.setNumberRatings(((Long) ratingForGroup[0]).intValue()); + userContribution.setAverageRating(((Float) ratingForGroup[1]).floatValue()); + ImageRating rating = imageRatingDao.getImageRatingByImageAndUser(image.getUid(), user.getUserId()); if (rating != null) { userContribution.setRating(rating.getRating()); } - + boolean isVotedForThisImage = false; ImageVote imageVote = imageVoteDao.getImageVoteByImageAndUser(image.getUid(), user.getUserId()); - if ((imageVote != null) && imageVote.isVoted()) { + if (imageVote != null && imageVote.isVoted()) { isVotedForThisImage = true; } userContribution.setVotedForThisImage(isVotedForThisImage); - + Set dbComments = image.getComments(); TreeSet comments = new TreeSet(new ImageCommentComparator()); for (ImageComment comment : dbComments) { @@ -1208,8 +1215,8 @@ } } userContribution.setComments(comments); - + return userContribution; } - + } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/MCOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/MCOutputFactory.java,v diff -u -r1.5 -r1.6 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/MCOutputFactory.java 2 Jul 2009 08:19:17 -0000 1.5 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/MCOutputFactory.java 2 Jul 2009 13:02:15 -0000 1.6 @@ -46,7 +46,7 @@ /** * @see org.lamsfoundation.lams.tool.OutputDefinitionFactory#getToolOutputDefinitions(java.lang.Object) */ - public SortedMap getToolOutputDefinitions(Object toolContentObject) { + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) { TreeMap definitionMap = new TreeMap(); ToolOutputDefinition definition = buildBooleanOutputDefinition(OUTPUT_NAME_LEARNER_ALL_CORRECT); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java,v diff -u -r1.103 -r1.104 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 16 Mar 2009 05:56:05 -0000 1.103 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 2 Jul 2009 13:02:15 -0000 1.104 @@ -21,14 +21,14 @@ * ***********************************************************************/ /* $$Id$$ */ package org.lamsfoundation.lams.tool.mc.service; + import java.io.InputStream; import java.util.Date; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.SortedMap; -import java.util.TreeMap; import java.util.TreeSet; import java.util.Vector; @@ -46,7 +46,6 @@ import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; -import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; @@ -96,2364 +95,1938 @@ * * @author Ozgur Demirtas * - * The POJO implementation of Mc service. All business logics of MCQ tool - * are implemented in this class. It translate the request from presentation - * layer and perform appropriate database operation. + * The POJO implementation of Mc service. All business logics of MCQ tool are implemented in this class. It translate + * the request from presentation layer and perform appropriate database operation. * */ -public class McServicePOJO implements - IMcService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager, McAppConstants - +public class McServicePOJO implements IMcService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager, + McAppConstants + { - static Logger logger = Logger.getLogger(McServicePOJO.class.getName()); - - /*repository access related constants */ - private final String repositoryUser = "lamc11"; - private final char[] repositoryId = {'l','a','m','c','_','1', '1'}; - private final String repositoryWorkspace = "lamc11"; - private IRepositoryService repositoryService; - private ICredentials cred; - - private IMcContentDAO mcContentDAO; - private IMcQueContentDAO mcQueContentDAO; - private IMcOptionsContentDAO mcOptionsContentDAO; - private IMcSessionDAO mcSessionDAO; - private IMcUserDAO mcUserDAO; - private IMcUsrAttemptDAO mcUsrAttemptDAO; - private IMcUploadedFileDAO mcUploadedFileDAO; - private MCOutputFactory mcOutputFactory; - - private IAuditService auditService; - private IUserManagementService userManagementService; - private ILearnerService learnerService; - private ILamsToolService toolService; + static Logger logger = Logger.getLogger(McServicePOJO.class.getName()); + + /* repository access related constants */ + private final String repositoryUser = "lamc11"; + private final char[] repositoryId = { 'l', 'a', 'm', 'c', '_', '1', '1' }; + private final String repositoryWorkspace = "lamc11"; + private IRepositoryService repositoryService; + private ICredentials cred; + + private IMcContentDAO mcContentDAO; + private IMcQueContentDAO mcQueContentDAO; + private IMcOptionsContentDAO mcOptionsContentDAO; + private IMcSessionDAO mcSessionDAO; + private IMcUserDAO mcUserDAO; + private IMcUsrAttemptDAO mcUsrAttemptDAO; + private IMcUploadedFileDAO mcUploadedFileDAO; + private MCOutputFactory mcOutputFactory; + + private IAuditService auditService; + private IUserManagementService userManagementService; + private ILearnerService learnerService; + private ILamsToolService toolService; private IToolContentHandler mcToolContentHandler = null; private IExportToolContentService exportContentService; - + private ICoreNotebookService coreNotebookService; - private MessageService messageService; - - public McServicePOJO(){} - + private MessageService messageService; + + public McServicePOJO() { + } + public void configureContentRepository() throws McApplicationException { - logger.debug("retrieved repService: " + repositoryService); - cred = new SimpleCredentials(repositoryUser, repositoryId); - logger.debug("retrieved cred: "+ cred); - try - { - repositoryService.createCredentials(cred); - logger.debug("created credentails."); - repositoryService.addWorkspace(cred,repositoryWorkspace); - logger.debug("created workspace."); - } catch (ItemExistsException ie) { - logger.warn("Tried to configure repository but it " - +" appears to be already configured. Exception thrown by repository being ignored. ", ie); - } catch (RepositoryCheckedException e) { - String error = "Error occured while trying to configure repository." - +" Unable to recover from error: "+e.getMessage(); - logger.error(error, e); - throw new McApplicationException(error,e); - } - } - - - public void createMc(McContent mcContent) throws McApplicationException - { - try - { - logger.debug("using mcContent defineLater:" + mcContent.isDefineLater()); - mcContentDAO.saveMcContent(mcContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is creating mc content: " - + e.getMessage(), - e); - } + McServicePOJO.logger.debug("retrieved repService: " + repositoryService); + cred = new SimpleCredentials(repositoryUser, repositoryId); + McServicePOJO.logger.debug("retrieved cred: " + cred); + try { + repositoryService.createCredentials(cred); + McServicePOJO.logger.debug("created credentails."); + repositoryService.addWorkspace(cred, repositoryWorkspace); + McServicePOJO.logger.debug("created workspace."); + } catch (ItemExistsException ie) { + McServicePOJO.logger.warn("Tried to configure repository but it " + + " appears to be already configured. Exception thrown by repository being ignored. ", ie); + } catch (RepositoryCheckedException e) { + String error = "Error occured while trying to configure repository." + " Unable to recover from error: " + + e.getMessage(); + McServicePOJO.logger.error(error, e); + throw new McApplicationException(error, e); + } } - - - public McContent retrieveMc(Long toolContentId) throws McApplicationException - { - try - { - return mcContentDAO.findMcContentById(toolContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is loading mc content: " - + e.getMessage(), - e); - } + + public void createMc(McContent mcContent) throws McApplicationException { + try { + McServicePOJO.logger.debug("using mcContent defineLater:" + mcContent.isDefineLater()); + mcContentDAO.saveMcContent(mcContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is creating mc content: " + e.getMessage(), e); + } } - - - public void updateMcContent(McContent mcContent) throws McApplicationException - { - try - { - mcContentDAO.updateMcContent(mcContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating mc content: " - + e.getMessage(), - e); - } + + public McContent retrieveMc(Long toolContentId) throws McApplicationException { + try { + return mcContentDAO.findMcContentById(toolContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is loading mc content: " + e.getMessage(), e); + } } - - public void createMcQue(McQueContent mcQueContent) throws McApplicationException - { - try - { - mcQueContentDAO.saveMcQueContent(mcQueContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is creating mc que content: " - + e.getMessage(), - e); - } + public void updateMcContent(McContent mcContent) throws McApplicationException { + try { + mcContentDAO.updateMcContent(mcContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is updating mc content: " + e.getMessage(), e); + } } - - public void updateMcQueContent(McQueContent mcQueContent) throws McApplicationException - { - try - { - mcQueContentDAO.updateMcQueContent(mcQueContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating mc que content: " - + e.getMessage(), - e); - } - + + public void createMcQue(McQueContent mcQueContent) throws McApplicationException { + try { + mcQueContentDAO.saveMcQueContent(mcQueContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is creating mc que content: " + + e.getMessage(), e); + } } - - public List retrieveMcQueContentsByToolContentId(long mcContentId) throws McApplicationException - { - try - { - return mcQueContentDAO.getMcQueContentsByContentId(mcContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is loading mc que usr: " - + e.getMessage(), - e); - } + public void updateMcQueContent(McQueContent mcQueContent) throws McApplicationException { + try { + mcQueContentDAO.updateMcQueContent(mcQueContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is updating mc que content: " + + e.getMessage(), e); + } + } - - - public McQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long mcContentUid) throws McApplicationException - { - try - { - return mcQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, mcContentUid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting mc que content by display order: " - + e.getMessage(), - e); - } + public List retrieveMcQueContentsByToolContentId(long mcContentId) throws McApplicationException { + try { + return mcQueContentDAO.getMcQueContentsByContentId(mcContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is loading mc que usr: " + e.getMessage(), e); } - - - public McQueContent getMcQueContentByUID(Long uid) throws McApplicationException - { - try - { - return mcQueContentDAO.getMcQueContentByUID(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting mc que content by uid: " - + e.getMessage(), - e); - } } - - - public List getAllQuestionEntriesSorted(final long mcContentId) throws McApplicationException - { - try - { - return mcQueContentDAO.getAllQuestionEntriesSorted(mcContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting all question entries: " - + e.getMessage(), - e); - } + + public McQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long mcContentUid) + throws McApplicationException { + try { + return mcQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, mcContentUid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting mc que content by display order: " + + e.getMessage(), e); } - - - - public void saveOrUpdateMcQueContent(McQueContent mcQueContent) throws McApplicationException - { - try - { - mcQueContentDAO.saveOrUpdateMcQueContent(mcQueContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating mc que content: " - + e.getMessage(), - e); - } + } + + public McQueContent getMcQueContentByUID(Long uid) throws McApplicationException { + try { + return mcQueContentDAO.getMcQueContentByUID(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting mc que content by uid: " + + e.getMessage(), e); } - - - public void removeQuestionContentByMcUid(final Long mcContentUid) throws McApplicationException - { - try - { - mcQueContentDAO.removeQuestionContentByMcUid(mcContentUid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing mc que content by mc content id: " - + e.getMessage(), - e); - } + } + + public List getAllQuestionEntriesSorted(final long mcContentId) throws McApplicationException { + try { + return mcQueContentDAO.getAllQuestionEntriesSorted(mcContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting all question entries: " + + e.getMessage(), e); } - - public void resetAllQuestions(final Long mcContentUid) throws McApplicationException - { - try - { - mcQueContentDAO.resetAllQuestions(mcContentUid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is resetting all questions: " - + e.getMessage(), - e); - } + } + + public void saveOrUpdateMcQueContent(McQueContent mcQueContent) throws McApplicationException { + try { + mcQueContentDAO.saveOrUpdateMcQueContent(mcQueContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is updating mc que content: " + + e.getMessage(), e); } - - - - public void cleanAllQuestions(final Long mcContentUid) throws McApplicationException - { - try - { - mcQueContentDAO.cleanAllQuestions(mcContentUid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is cleaning all questions: " - + e.getMessage(), - e); - } + } + + public void removeQuestionContentByMcUid(final Long mcContentUid) throws McApplicationException { + try { + mcQueContentDAO.removeQuestionContentByMcUid(mcContentUid); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is removing mc que content by mc content id: " + e.getMessage(), e); } - - - public List getNextAvailableDisplayOrder(final long mcContentId) throws McApplicationException - { - try - { - return mcQueContentDAO.getNextAvailableDisplayOrder(mcContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting the next available display order: " - + e.getMessage(), - e); - } + } + + public void resetAllQuestions(final Long mcContentUid) throws McApplicationException { + try { + mcQueContentDAO.resetAllQuestions(mcContentUid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is resetting all questions: " + + e.getMessage(), e); } - - - public void createMcSession(McSession mcSession) throws McApplicationException - { - try - { - mcSessionDAO.saveMcSession(mcSession); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is creating mc session: " - + e.getMessage(), - e); - } } - - public McSession getMcSessionByUID(Long uid) throws McApplicationException - { - try - { - return mcSessionDAO.getMcSessionByUID(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting mcSession my uid: " - + e.getMessage(), - e); - } + public void cleanAllQuestions(final Long mcContentUid) throws McApplicationException { + try { + mcQueContentDAO.cleanAllQuestions(mcContentUid); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is cleaning all questions: " + e.getMessage(), e); + } } + public List getNextAvailableDisplayOrder(final long mcContentId) throws McApplicationException { + try { + return mcQueContentDAO.getNextAvailableDisplayOrder(mcContentId); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is getting the next available display order: " + e.getMessage(), e); + } + } - public void createMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException - { - try - { - mcUserDAO.saveMcUser(mcQueUsr); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is creating mc QueUsr: " - + e.getMessage(), - e); - } + public void createMcSession(McSession mcSession) throws McApplicationException { + try { + mcSessionDAO.saveMcSession(mcSession); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is creating mc session: " + e.getMessage(), e); + } } - public void updateMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException - { - try - { - mcUserDAO.updateMcUser(mcQueUsr); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating mc QueUsr: " - + e.getMessage(), - e); - } + public McSession getMcSessionByUID(Long uid) throws McApplicationException { + try { + return mcSessionDAO.getMcSessionByUID(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting mcSession my uid: " + + e.getMessage(), e); + } } - - public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionId) throws McApplicationException - { - try - { - return mcUserDAO.getMcUserBySession(queUsrId, mcSessionId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting mc QueUsr: " - + e.getMessage(), - e); - } + public void createMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException { + try { + mcUserDAO.saveMcUser(mcQueUsr); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is creating mc QueUsr: " + e.getMessage(), e); } - - - public McQueUsr getMcUserByUID(Long uid) throws McApplicationException - { - try - { - return mcUserDAO.getMcUserByUID(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting the mc QueUsr by uid." - + e.getMessage(), - e); - } } - - public McQueUsr retrieveMcQueUsr(Long userId) throws McApplicationException - { - try - { - McQueUsr mcQueUsr=mcUserDAO.findMcUserById(userId); - return mcQueUsr; - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is retrieving McQueUsr: " - + e.getMessage(), - e); - } + + public void updateMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException { + try { + mcUserDAO.updateMcUser(mcQueUsr); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is updating mc QueUsr: " + e.getMessage(), e); + } } - - - public void createMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException - { - try - { - mcUsrAttemptDAO.saveMcUsrAttempt(mcUsrAttempt); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is creating mc UsrAttempt: " - + e.getMessage(), - e); - } + + public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionId) throws McApplicationException { + try { + return mcUserDAO.getMcUserBySession(queUsrId, mcSessionId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting mc QueUsr: " + e.getMessage(), e); + } } - - - public void updateMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException - { - try - { - mcUsrAttemptDAO.updateMcUsrAttempt(mcUsrAttempt); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating mc UsrAttempt: " - + e.getMessage(), - e); - } + + public McQueUsr getMcUserByUID(Long uid) throws McApplicationException { + try { + return mcUserDAO.getMcUserByUID(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting the mc QueUsr by uid." + + e.getMessage(), e); + } } - - public List getAttemptByAttemptOrder(final Long queUsrId, final Long mcQueContentId, final Integer attemptOrder) throws McApplicationException - { - try - { - return mcUsrAttemptDAO.getAttemptByAttemptOrder(queUsrId, mcQueContentId, attemptOrder); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " - + e.getMessage(), - e); - } + + public McQueUsr retrieveMcQueUsr(Long userId) throws McApplicationException { + try { + McQueUsr mcQueUsr = mcUserDAO.findMcUserById(userId); + return mcQueUsr; + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is retrieving McQueUsr: " + e.getMessage(), e); } - - public List getLatestAttemptsForAUser(final Long queUserUid) throws McApplicationException - { - try - { - return mcUsrAttemptDAO.getLatestAttemptsForAUser(queUserUid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " - + e.getMessage(), - e); - } + } + + public void createMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException { + try { + mcUsrAttemptDAO.saveMcUsrAttempt(mcUsrAttempt); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is creating mc UsrAttempt: " + e.getMessage(), e); } - - /** - *

gets all the attempts for one questions for one user in one tool session queUsrId, - * ordered by the attempt id. If there is more than one option selected for a question, the attempts - * are "batched".

- * - * @param queUsrId - * @return - */ - public List getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(final Long queUsrUid, final Long mcQueContentId) throws McApplicationException - { - try - { - return mcUsrAttemptDAO.getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(queUsrUid, mcQueContentId); - } - catch(DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting attempts. " - + e.getMessage(),e); - } - } - + } - public List getLatestAttemptsForAUserForOneQuestionContent(Long queUsrUid, Long mcQueContentId) throws McApplicationException - { - try - { - return mcUsrAttemptDAO.getLatestAttemptsForAUserForOneQuestionContent(queUsrUid, mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " - + e.getMessage(), - e); - } + public void updateMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException { + try { + mcUsrAttemptDAO.updateMcUsrAttempt(mcUsrAttempt); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is updating mc UsrAttempt: " + e.getMessage(), e); } - - public McQueContent retrieveMcQueContentByUID(Long uid) throws McApplicationException - { - try - { - return mcQueContentDAO.getMcQueContentByUID(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is retrieving by uid mc question content: " - + e.getMessage(), - e); - } } - - - public void cleanAllQuestionsSimple(final Long mcContentId) throws McApplicationException - { - try - { - mcQueContentDAO.cleanAllQuestionsSimple(mcContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is cleaning mc question content by mcContentId : " - + e.getMessage(), - e); - } + + public List getAttemptByAttemptOrder(final Long queUsrId, final Long mcQueContentId, final Integer attemptOrder) + throws McApplicationException { + try { + return mcUsrAttemptDAO.getAttemptByAttemptOrder(queUsrId, mcQueContentId, attemptOrder); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " + + e.getMessage(), e); } - - public List getAllQuestionEntries(final Long uid) throws McApplicationException - { - try - { - return (List) mcQueContentDAO.getAllQuestionEntries(uid.longValue()); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting by uid mc question content: " - + e.getMessage(), - e); - } + } + + public List getLatestAttemptsForAUser(final Long queUserUid) throws McApplicationException { + try { + return mcUsrAttemptDAO.getLatestAttemptsForAUser(queUserUid); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " + + e.getMessage(), e); } - - - public void removeMcQueContentByUID(Long uid) throws McApplicationException - { - try - { - mcQueContentDAO.removeMcQueContentByUID(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing by uid mc question content: " - + e.getMessage(), - e); - } + } + + /** + *

+ * gets all the attempts for one questions for one user in one tool session queUsrId, ordered by the + * attempt id. If there is more than one option selected for a question, the attempts are "batched". + *

+ * + * @param queUsrId + * @return + */ + public List getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(final Long queUsrUid, + final Long mcQueContentId) throws McApplicationException { + try { + return mcUsrAttemptDAO.getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(queUsrUid, mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting attempts. " + e.getMessage(), e); } - + } - public List refreshQuestionContent(final Long mcContentId) throws McApplicationException - { - try - { - return mcQueContentDAO.refreshQuestionContent(mcContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is refreshing mc question content: " - + e.getMessage(), - e); - } - + public List getLatestAttemptsForAUserForOneQuestionContent(Long queUsrUid, Long mcQueContentId) + throws McApplicationException { + try { + return mcUsrAttemptDAO.getLatestAttemptsForAUserForOneQuestionContent(queUsrUid, mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " + + e.getMessage(), e); } - - public void removeMcQueContent(McQueContent mcQueContent) throws McApplicationException - { - try - { - mcQueContentDAO.removeMcQueContent(mcQueContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing mc question content: " - + e.getMessage(), - e); - } + } + + public McQueContent retrieveMcQueContentByUID(Long uid) throws McApplicationException { + try { + return mcQueContentDAO.getMcQueContentByUID(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is retrieving by uid mc question content: " + + e.getMessage(), e); } - - public void removeMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException - { - try - { - mcOptionsContentDAO.removeMcOptionsContent(mcOptsContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing" - + " the mc options content: " - + e.getMessage(),e); - } } - - - public List populateCandidateAnswersDTO(Long mcQueContentId) throws McApplicationException - { - try - { - return mcOptionsContentDAO.populateCandidateAnswersDTO(mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is populating candidate answers dto" - + e.getMessage(),e); - } + + public void cleanAllQuestionsSimple(final Long mcContentId) throws McApplicationException { + try { + mcQueContentDAO.cleanAllQuestionsSimple(mcContentId); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is cleaning mc question content by mcContentId : " + e.getMessage(), e); + } } - public List getPersistedSelectedOptions(Long mcQueContentId) throws McApplicationException - { - try - { - return mcOptionsContentDAO.getPersistedSelectedOptions(mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is gettong persisted selected" - + " the mc options content: " - + e.getMessage(),e); - } - + public List getAllQuestionEntries(final Long uid) throws McApplicationException { + try { + return mcQueContentDAO.getAllQuestionEntries(uid.longValue()); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting by uid mc question content: " + + e.getMessage(), e); } - - - - public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentId) - { - try - { - return mcQueContentDAO.getQuestionContentByQuestionText(question, mcContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is retrieving question content by question text: " - + e.getMessage(), - e); - } } - - - public McSession retrieveMcSession(Long mcSessionId) throws McApplicationException - { - try - { - return mcSessionDAO.findMcSessionById(mcSessionId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is retrieving by id mc session : " - + e.getMessage(), - e); - } + + public void removeMcQueContentByUID(Long uid) throws McApplicationException { + try { + mcQueContentDAO.removeMcQueContentByUID(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing by uid mc question content: " + + e.getMessage(), e); + } } - - - public McSession findMcSessionById(Long mcSessionId) throws McApplicationException - { - try - { - return mcSessionDAO.findMcSessionById(mcSessionId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is retrieving by id mc session : " - + e.getMessage(), - e); - } - + + public List refreshQuestionContent(final Long mcContentId) throws McApplicationException { + try { + return mcQueContentDAO.refreshQuestionContent(mcContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is refreshing mc question content: " + + e.getMessage(), e); } - - public McContent retrieveMcBySessionId(Long mcSessionId) throws McApplicationException - { - try - { - return mcContentDAO.getMcContentBySession(mcSessionId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is retrieving mc by session id: " - + e.getMessage(), - e); - } + } - - public void updateMc(McContent mc) throws McApplicationException - { - try - { - mcContentDAO.updateMcContent(mc); - } - catch(DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating" - + " the mc content: " - + e.getMessage(),e); - } + + public void removeMcQueContent(McQueContent mcQueContent) throws McApplicationException { + try { + mcQueContentDAO.removeMcQueContent(mcQueContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing mc question content: " + + e.getMessage(), e); + } } - - public void updateMcSession(McSession mcSession) throws McApplicationException - { - try - { - mcSessionDAO.updateMcSession(mcSession); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating mc session : " - + e.getMessage(), - e); - } + public void removeMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException { + try { + mcOptionsContentDAO.removeMcOptionsContent(mcOptsContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing" + " the mc options content: " + + e.getMessage(), e); + } } - - public void deleteMc(McContent mc) throws McApplicationException - { - try - { - mcContentDAO.removeMc(mc); - } - catch(DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing" - + " the mc content: " - + e.getMessage(),e); - } + + public List populateCandidateAnswersDTO(Long mcQueContentId) throws McApplicationException { + try { + return mcOptionsContentDAO.populateCandidateAnswersDTO(mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is populating candidate answers dto" + + e.getMessage(), e); + } } - - public void deleteMcById(Long mcId) throws McApplicationException - { - try - { - mcContentDAO.removeMcById(mcId); - } - catch(DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing by id" - + " the mc content: " - + e.getMessage(),e); - } + + public List getPersistedSelectedOptions(Long mcQueContentId) throws McApplicationException { + try { + return mcOptionsContentDAO.getPersistedSelectedOptions(mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is gettong persisted selected" + + " the mc options content: " + e.getMessage(), e); + } + } - - public void removeAttempt (McUsrAttempt attempt) throws McApplicationException - { - try - { - mcUsrAttemptDAO.removeMcUsrAttempt(attempt); - } - catch(DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing" - + " the attempt: " - + e.getMessage(),e); - } + + public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentId) { + try { + return mcQueContentDAO.getQuestionContentByQuestionText(question, mcContentId); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is retrieving question content by question text: " + e.getMessage(), e); } - - + } + + public McSession retrieveMcSession(Long mcSessionId) throws McApplicationException { + try { + return mcSessionDAO.findMcSessionById(mcSessionId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is retrieving by id mc session : " + + e.getMessage(), e); + } + } + + public McSession findMcSessionById(Long mcSessionId) throws McApplicationException { + try { + return mcSessionDAO.findMcSessionById(mcSessionId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is retrieving by id mc session : " + + e.getMessage(), e); + } + + } + + public McContent retrieveMcBySessionId(Long mcSessionId) throws McApplicationException { + try { + return mcContentDAO.getMcContentBySession(mcSessionId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is retrieving mc by session id: " + + e.getMessage(), e); + } + } + + public void updateMc(McContent mc) throws McApplicationException { + try { + mcContentDAO.updateMcContent(mc); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is updating" + " the mc content: " + + e.getMessage(), e); + } + } + + public void updateMcSession(McSession mcSession) throws McApplicationException { + try { + mcSessionDAO.updateMcSession(mcSession); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is updating mc session : " + e.getMessage(), + e); + } + } + + public void deleteMc(McContent mc) throws McApplicationException { + try { + mcContentDAO.removeMc(mc); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing" + " the mc content: " + + e.getMessage(), e); + } + } + + public void deleteMcById(Long mcId) throws McApplicationException { + try { + mcContentDAO.removeMcById(mcId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing by id" + " the mc content: " + + e.getMessage(), e); + } + } + + public void removeAttempt(McUsrAttempt attempt) throws McApplicationException { + try { + mcUsrAttemptDAO.removeMcUsrAttempt(attempt); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing" + " the attempt: " + + e.getMessage(), e); + } + } + /** * Return the top, lowest and average mark for all learners for one particular tool session. * * @param request * @return top mark, lowest mark, average mark in that order */ - public Integer[] getMarkStatistics(McSession mcSession) - { - logger.debug("getting mark statistics on mcSession: " + mcSession.getUid()); - return mcUserDAO.getMarkStatisticsForSession(mcSession.getUid()); + public Integer[] getMarkStatistics(McSession mcSession) { + McServicePOJO.logger.debug("getting mark statistics on mcSession: " + mcSession.getUid()); + return mcUserDAO.getMarkStatisticsForSession(mcSession.getUid()); } - - public void deleteMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException - { - try - { - mcUserDAO.removeMcUser(mcQueUsr); - } - catch(DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing" - + " the user: " - + e.getMessage(),e); - } + + public void deleteMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException { + try { + mcUserDAO.removeMcUser(mcQueUsr); + } catch (DataAccessException e) { + throw new McApplicationException( + "Exception occured when lams is removing" + " the user: " + e.getMessage(), e); + } } - - - public void saveMcContent(McContent mc) throws McApplicationException - { - try - { - mcContentDAO.saveMcContent(mc); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is saving" - + " the mc content: " - + e.getMessage(),e); - } + + public void saveMcContent(McContent mc) throws McApplicationException { + try { + mcContentDAO.saveMcContent(mc); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is saving" + " the mc content: " + + e.getMessage(), e); + } } - - - public List findMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException - { - try - { - List list=mcOptionsContentDAO.findMcOptionsContentByQueId(mcQueContentId); - return list; - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is finding by que id" - + " the mc options: " - + e.getMessage(),e); - } + + public List findMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException { + try { + List list = mcOptionsContentDAO.findMcOptionsContentByQueId(mcQueContentId); + return list; + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is finding by que id" + " the mc options: " + + e.getMessage(), e); + } } - - - public McOptsContent getMcOptionsContentByUID(Long uid) throws McApplicationException - { - try - { - return mcOptionsContentDAO.getMcOptionsContentByUID(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting opt content by uid" - + e.getMessage(),e); - } + + public McOptsContent getMcOptionsContentByUID(Long uid) throws McApplicationException { + try { + return mcOptionsContentDAO.getMcOptionsContentByUID(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting opt content by uid" + + e.getMessage(), e); } - - public List findMcOptionUidsByQueId(Long mcQueContentId) throws McApplicationException - { - try - { - return mcOptionsContentDAO.findMcOptionUidsByQueId(mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting opt uids" - + e.getMessage(),e); - } } - - public McQueContent findMcQuestionContentByUid(Long uid) throws McApplicationException - { - try - { - return mcQueContentDAO.findMcQuestionContentByUid(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting que content by uid" - + e.getMessage(),e); - } + + public List findMcOptionUidsByQueId(Long mcQueContentId) throws McApplicationException { + try { + return mcOptionsContentDAO.findMcOptionUidsByQueId(mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting opt uids" + e.getMessage(), e); + } } - - public void saveMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException - { - try - { - mcOptionsContentDAO.saveMcOptionsContent(mcOptsContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is saving" - + " the mc options content: " - + e.getMessage(),e); - } + + public McQueContent findMcQuestionContentByUid(Long uid) throws McApplicationException { + try { + return mcQueContentDAO.findMcQuestionContentByUid(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting que content by uid" + + e.getMessage(), e); } - - public McOptsContent getOptionContentByOptionText(final String option, final Long mcQueContentUid) - { - try - { - return mcOptionsContentDAO.getOptionContentByOptionText(option, mcQueContentUid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is returning the" - + " option by option text: " - + e.getMessage(),e); - } } - - public List getCorrectOption(Long mcQueContentId) - { - try - { - return mcOptionsContentDAO.getCorrectOption(mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is returning the " - + " correct option: " - + e.getMessage(),e); - } - } - - public void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException - { - try - { - mcOptionsContentDAO.updateMcOptionsContent(mcOptsContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is updating" - + " the mc options content: " - + e.getMessage(),e); - } + public void saveMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException { + try { + mcOptionsContentDAO.saveMcOptionsContent(mcOptsContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is saving" + " the mc options content: " + + e.getMessage(), e); } + } - public List findMcOptionCorrectByQueId(Long mcQueContentId) throws McApplicationException - { - try - { - return mcOptionsContentDAO.findMcOptionCorrectByQueId(mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is getting correct/incorrect options list" - + " the mc options content: " - + e.getMessage(),e); - } - + public McOptsContent getOptionContentByOptionText(final String option, final Long mcQueContentUid) { + try { + return mcOptionsContentDAO.getOptionContentByOptionText(option, mcQueContentUid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is returning the" + + " option by option text: " + e.getMessage(), e); + } } - - public void deleteMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException - { - try - { - mcOptionsContentDAO.removeMcOptionsContent(mcOptsContent); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing" - + " the mc options content: " - + e.getMessage(),e); - } + + public List getCorrectOption(Long mcQueContentId) { + try { + return mcOptionsContentDAO.getCorrectOption(mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is returning the " + " correct option: " + + e.getMessage(), e); } - - - public List findMcOptionNamesByQueId(Long mcQueContentId) throws McApplicationException - { - try - { - return mcOptionsContentDAO.findMcOptionNamesByQueId(mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is finding" - + " the mc options name: " - + e.getMessage(),e); - } - + } + + public void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException { + try { + mcOptionsContentDAO.updateMcOptionsContent(mcOptsContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is updating" + " the mc options content: " + + e.getMessage(), e); } - - - public void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException - { - try - { - mcOptionsContentDAO.removeMcOptionsContentByQueId(mcQueContentId); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing by que id" - + " the mc options content: " - + e.getMessage(),e); - } } - - - public void deleteMcOptionsContentByUID(Long uid) throws McApplicationException - { - try - { - mcOptionsContentDAO.removeMcOptionsContentByUID(uid); - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is removing by uid" - + " the mc options content: " - + e.getMessage(),e); - } + + public List findMcOptionCorrectByQueId(Long mcQueContentId) throws McApplicationException { + try { + return mcOptionsContentDAO.findMcOptionCorrectByQueId(mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is getting correct/incorrect options list" + + " the mc options content: " + e.getMessage(), e); } - public User getCurrentUserData(String username) throws McApplicationException - { - try - { - logger.debug("getCurrentUserData: " + username); - /** - * this will return null if the username not found - */ - User user=userManagementService.getUserByLogin(username); - if (user == null) - { - logger.error("No user with the username: "+ username + " exists."); - throw new McApplicationException("No user with that username exists."); - } - return user; - } - catch (DataAccessException e) - { - throw new McApplicationException("Unable to find current user information" - + " Root Cause: [" - + e.getMessage() + "]", - e); - } } + public void deleteMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException { + try { + mcOptionsContentDAO.removeMcOptionsContent(mcOptsContent); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing" + " the mc options content: " + + e.getMessage(), e); + } + } + + public List findMcOptionNamesByQueId(Long mcQueContentId) throws McApplicationException { + try { + return mcOptionsContentDAO.findMcOptionNamesByQueId(mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is finding" + " the mc options name: " + + e.getMessage(), e); + } + + } + + public void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException { + try { + mcOptionsContentDAO.removeMcOptionsContentByQueId(mcQueContentId); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing by que id" + + " the mc options content: " + e.getMessage(), e); + } + } + + public void deleteMcOptionsContentByUID(Long uid) throws McApplicationException { + try { + mcOptionsContentDAO.removeMcOptionsContentByUID(uid); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is removing by uid" + + " the mc options content: " + e.getMessage(), e); + } + } + + public User getCurrentUserData(String username) throws McApplicationException { + try { + McServicePOJO.logger.debug("getCurrentUserData: " + username); + /** + * this will return null if the username not found + */ + User user = userManagementService.getUserByLogin(username); + if (user == null) { + McServicePOJO.logger.error("No user with the username: " + username + " exists."); + throw new McApplicationException("No user with that username exists."); + } + return user; + } catch (DataAccessException e) { + throw new McApplicationException("Unable to find current user information" + " Root Cause: [" + + e.getMessage() + "]", e); + } + } + /** * * Unused method + * * @param lessonId * @return * @throws McApplicationException */ - public Lesson getCurrentLesson(long lessonId) throws McApplicationException - { - try - { - /**this is a mock implementation to make the project compile and - work. When the Lesson service is ready, we need to switch to - real service implementation. - */ - return new Lesson(); - /**return lsDAO.find(lsessionId); */ - } - catch (DataAccessException e) - { - throw new McApplicationException("Exception occured when lams is loading" - + " learning session:" - + e.getMessage(), - e); - } + public Lesson getCurrentLesson(long lessonId) throws McApplicationException { + try { + /** + * this is a mock implementation to make the project compile and work. When the Lesson service is ready, we + * need to switch to real service implementation. + */ + return new Lesson(); + /** return lsDAO.find(lsessionId); */ + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is loading" + " learning session:" + + e.getMessage(), e); + } } - - /** - * checks the parameter content in the user responses table - * @param mcContent - * @return boolean - * @throws McApplicationException - */ - public boolean studentActivityOccurredGlobal(McContent mcContent) throws McApplicationException - { - Iterator questionIterator=mcContent.getMcQueContents().iterator(); - while (questionIterator.hasNext()) - { - McQueContent mcQueContent=(McQueContent)questionIterator.next(); - Iterator attemptsIterator=mcQueContent.getMcUsrAttempts().iterator(); - while (attemptsIterator.hasNext()) - { - logger.debug("there is at least one attempt"); - /** - * proved the fact that there is at least one attempt for this content. - */ - return true; - } - } - logger.debug("there is no response for this content"); - return false; + /** + * checks the parameter content in the user responses table + * + * @param mcContent + * @return boolean + * @throws McApplicationException + */ + public boolean studentActivityOccurredGlobal(McContent mcContent) throws McApplicationException { + Iterator questionIterator = mcContent.getMcQueContents().iterator(); + while (questionIterator.hasNext()) { + McQueContent mcQueContent = (McQueContent) questionIterator.next(); + Iterator attemptsIterator = mcQueContent.getMcUsrAttempts().iterator(); + while (attemptsIterator.hasNext()) { + McServicePOJO.logger.debug("there is at least one attempt"); + /** + * proved the fact that there is at least one attempt for this content. + */ + return true; + } } - + McServicePOJO.logger.debug("there is no response for this content"); + return false; + } - public int countIncompleteSession(McContent mc) throws McApplicationException - { - //int countIncompleteSession=mcSessionDAO.countIncompleteSession(mc); - int countIncompleteSession=2; - return countIncompleteSession; + public int countIncompleteSession(McContent mc) throws McApplicationException { + // int countIncompleteSession=mcSessionDAO.countIncompleteSession(mc); + int countIncompleteSession = 2; + return countIncompleteSession; + } + + /** + * checks the parameter content in the tool sessions table + * + * find out if any student has ever used (logged in through the url and replied) to this content return true even if + * you have only one content passed as parameter referenced in the tool sessions table + * + * @param mc + * @return boolean + * @throws McApplicationException + */ + public boolean studentActivityOccurred(McContent mc) throws McApplicationException { + // int countStudentActivity=mcSessionDAO.studentActivityOccurred(mc); + int countStudentActivity = 2; + + if (countStudentActivity > 0) { + return true; } - - /** - * checks the parameter content in the tool sessions table - * - * find out if any student has ever used (logged in through the url and replied) to this content - * return true even if you have only one content passed as parameter referenced in the tool sessions table - * @param mc - * @return boolean - * @throws McApplicationException - */ - public boolean studentActivityOccurred(McContent mc) throws McApplicationException - { - //int countStudentActivity=mcSessionDAO.studentActivityOccurred(mc); - int countStudentActivity=2; - - if (countStudentActivity > 0) - return true; - return false; + return false; + } + + /** + * implemented as part of the Tool Contract copyToolContent(Long fromContentId, Long toContentId) throws + * ToolException + * + * @param fromContentId + * @param toContentId + * @return + * @throws ToolException + * + */ + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { + McServicePOJO.logger.debug("start of copyToolContent with ids: " + fromContentId + " and " + toContentId); + + if (fromContentId == null) { + McServicePOJO.logger.error("fromContentId is null."); + McServicePOJO.logger.debug("attempt retrieving tool's default content id with signatute : " + + McAppConstants.MY_SIGNATURE); + long defaultContentId = 0; + try { + defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + fromContentId = new Long(defaultContentId); + } catch (Exception e) { + McServicePOJO.logger.error("default content id has not been setup for signature: " + + McAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + McAppConstants.MY_SIGNATURE + " Can't continue!"); + } } - - /** - * implemented as part of the Tool Contract - * copyToolContent(Long fromContentId, Long toContentId) throws ToolException - * @param fromContentId - * @param toContentId - * @return - * @throws ToolException - * - */ - public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException - { - logger.debug("start of copyToolContent with ids: " + fromContentId + " and " + toContentId); + if (toContentId == null) { + McServicePOJO.logger.error("throwing ToolException: toContentId is null"); + throw new ToolException("toContentId is missing"); + } + McServicePOJO.logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId); - if (fromContentId == null) - { - logger.error("fromContentId is null."); - logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - long defaultContentId=0; - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - fromContentId= new Long(defaultContentId); - } - catch(Exception e) - { - logger.error("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } - } - - if (toContentId == null) - { - logger.error("throwing ToolException: toContentId is null"); - throw new ToolException("toContentId is missing"); - } - logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId); - - try - { - McContent fromContent = mcContentDAO.findMcContentById(fromContentId); - - if (fromContent == null) - { - logger.error("fromContent is null."); - logger.error("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - long defaultContentId=0; - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - fromContentId= new Long(defaultContentId); - } - catch(Exception e) - { - logger.error("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } - - fromContent = mcContentDAO.findMcContentById(fromContentId); - logger.debug("using fromContent: " + fromContent); - } - - logger.debug("final - retrieved fromContent: " + fromContent); - logger.debug("final - before new instance using " + fromContent + " and " + toContentId); - logger.debug("final - before new instance using mcToolContentHandler: " + mcToolContentHandler); - - try - { - McContent toContent = McContent.newInstance(mcToolContentHandler, fromContent,toContentId); - if (toContent == null) - { - logger.debug("throwing ToolException: WARNING!, retrieved toContent is null."); - throw new ToolException("WARNING! Fail to create toContent. Can't continue!"); - } - else - { - logger.debug("retrieved toContent: " + toContent); - mcContentDAO.saveMcContent(toContent); - logger.debug("toContent has been saved successfully: " + toContent); - } - logger.debug("end of copyToolContent with ids: " + fromContentId + " and " + toContentId); + try { + McContent fromContent = mcContentDAO.findMcContentById(fromContentId); - } - catch(ItemNotFoundException e) - { - logger.error("exception occurred: " + e); - } - catch(RepositoryCheckedException e) - { - logger.error("exception occurred: " + e); - } - } - catch (DataAccessException e) - { - logger.error("throwing ToolException: Exception occured when lams is copying content between content ids."); - throw new ToolException("Exception occured when lams is copying content between content ids."); - } + if (fromContent == null) { + McServicePOJO.logger.error("fromContent is null."); + McServicePOJO.logger.error("attempt retrieving tool's default content id with signatute : " + + McAppConstants.MY_SIGNATURE); + long defaultContentId = 0; + try { + defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + fromContentId = new Long(defaultContentId); + } catch (Exception e) { + McServicePOJO.logger.error("default content id has not been setup for signature: " + + McAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + McAppConstants.MY_SIGNATURE + " Can't continue!"); + } + + fromContent = mcContentDAO.findMcContentById(fromContentId); + McServicePOJO.logger.debug("using fromContent: " + fromContent); + } + + McServicePOJO.logger.debug("final - retrieved fromContent: " + fromContent); + McServicePOJO.logger.debug("final - before new instance using " + fromContent + " and " + toContentId); + McServicePOJO.logger.debug("final - before new instance using mcToolContentHandler: " + + mcToolContentHandler); + + try { + McContent toContent = McContent.newInstance(mcToolContentHandler, fromContent, toContentId); + if (toContent == null) { + McServicePOJO.logger.debug("throwing ToolException: WARNING!, retrieved toContent is null."); + throw new ToolException("WARNING! Fail to create toContent. Can't continue!"); + } else { + McServicePOJO.logger.debug("retrieved toContent: " + toContent); + mcContentDAO.saveMcContent(toContent); + McServicePOJO.logger.debug("toContent has been saved successfully: " + toContent); + } + McServicePOJO.logger.debug("end of copyToolContent with ids: " + fromContentId + " and " + toContentId); + + } catch (ItemNotFoundException e) { + McServicePOJO.logger.error("exception occurred: " + e); + } catch (RepositoryCheckedException e) { + McServicePOJO.logger.error("exception occurred: " + e); + } + } catch (DataAccessException e) { + McServicePOJO.logger + .error("throwing ToolException: Exception occured when lams is copying content between content ids."); + throw new ToolException("Exception occured when lams is copying content between content ids."); + } } - /** * implemented as part of the tool contract. Removes content and uploaded files from the content repository. * removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException - * @param toContentId - * @param removeSessionData - * @return - * @throws ToolException - */ - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException - { - logger.debug("start of removeToolContent with toolContentId: " + toolContentId + "removeSessionData: " + removeSessionData); - - if (toolContentId == null) - { - logger.error("toolContentId is null"); - throw new ToolException("toolContentId is missing"); - } - - McContent mcContent = mcContentDAO.findMcContentById(toolContentId); - logger.debug("retrieving mcContent: " + mcContent); - - if (mcContent != null) - { - logger.error("start deleting any uploaded file for this content from the content repository"); - Iterator filesIterator=mcContent.getMcAttachments().iterator(); - while (filesIterator.hasNext()) - { - McUploadedFile mcUploadedFile=(McUploadedFile) filesIterator.next(); - logger.debug("iterated mcUploadedFile : " + mcUploadedFile); - String filesUuid=mcUploadedFile.getUuid(); - if ((filesUuid != null) && (filesUuid.length() > 0)) - { - try - { - mcToolContentHandler.deleteFile(new Long(filesUuid)); - } - catch(RepositoryCheckedException e) - { - logger.error("exception occured deleting files from content repository : " + e); - throw new ToolException("undeletable file in the content repository"); - } - } - } - logger.debug("end deleting any uploaded files for this content."); - - Iterator sessionIterator=mcContent.getMcSessions().iterator(); - while (sessionIterator.hasNext()) - { - if (removeSessionData == false) - { - logger.debug("removeSessionData is false, throwing SessionDataExistsException."); - throw new SessionDataExistsException(); - } - - McSession mcSession=(McSession)sessionIterator.next(); - logger.debug("iterated mcSession : " + mcSession); - - Iterator sessionUsersIterator=mcSession.getMcQueUsers().iterator(); - while (sessionUsersIterator.hasNext()) - { - McQueUsr mcQueUsr=(McQueUsr) sessionUsersIterator.next(); - logger.debug("iterated mcQueUsr : " + mcQueUsr); - - Iterator sessionUsersAttemptsIterator=mcQueUsr.getMcUsrAttempts().iterator(); - while (sessionUsersAttemptsIterator.hasNext()) - { - McUsrAttempt mcUsrAttempt=(McUsrAttempt)sessionUsersAttemptsIterator.next(); - logger.debug("iterated mcUsrAttempt : " + mcUsrAttempt); - removeAttempt(mcUsrAttempt); - logger.debug("removed mcUsrAttempt : " + mcUsrAttempt); - } - } - } - logger.debug("removed all existing responses of toolContent with toolContentId:" + - toolContentId); - mcContentDAO.removeMcById(toolContentId); - logger.debug("removed mcContent:" + mcContent); - } - else - { - logger.error("Warning!!!, We should have not come here. mcContent is null."); - throw new ToolException("toolContentId is missing"); - } + * + * @param toContentId + * @param removeSessionData + * @return + * @throws ToolException + */ + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException { + McServicePOJO.logger.debug("start of removeToolContent with toolContentId: " + toolContentId + + "removeSessionData: " + removeSessionData); + + if (toolContentId == null) { + McServicePOJO.logger.error("toolContentId is null"); + throw new ToolException("toolContentId is missing"); } + McContent mcContent = mcContentDAO.findMcContentById(toolContentId); + McServicePOJO.logger.debug("retrieving mcContent: " + mcContent); - + if (mcContent != null) { + McServicePOJO.logger.error("start deleting any uploaded file for this content from the content repository"); + Iterator filesIterator = mcContent.getMcAttachments().iterator(); + while (filesIterator.hasNext()) { + McUploadedFile mcUploadedFile = (McUploadedFile) filesIterator.next(); + McServicePOJO.logger.debug("iterated mcUploadedFile : " + mcUploadedFile); + String filesUuid = mcUploadedFile.getUuid(); + if (filesUuid != null && filesUuid.length() > 0) { + try { + mcToolContentHandler.deleteFile(new Long(filesUuid)); + } catch (RepositoryCheckedException e) { + McServicePOJO.logger.error("exception occured deleting files from content repository : " + e); + throw new ToolException("undeletable file in the content repository"); + } + } + } + McServicePOJO.logger.debug("end deleting any uploaded files for this content."); + + Iterator sessionIterator = mcContent.getMcSessions().iterator(); + while (sessionIterator.hasNext()) { + if (removeSessionData == false) { + McServicePOJO.logger.debug("removeSessionData is false, throwing SessionDataExistsException."); + throw new SessionDataExistsException(); + } + + McSession mcSession = (McSession) sessionIterator.next(); + McServicePOJO.logger.debug("iterated mcSession : " + mcSession); + + Iterator sessionUsersIterator = mcSession.getMcQueUsers().iterator(); + while (sessionUsersIterator.hasNext()) { + McQueUsr mcQueUsr = (McQueUsr) sessionUsersIterator.next(); + McServicePOJO.logger.debug("iterated mcQueUsr : " + mcQueUsr); + + Iterator sessionUsersAttemptsIterator = mcQueUsr.getMcUsrAttempts().iterator(); + while (sessionUsersAttemptsIterator.hasNext()) { + McUsrAttempt mcUsrAttempt = (McUsrAttempt) sessionUsersAttemptsIterator.next(); + McServicePOJO.logger.debug("iterated mcUsrAttempt : " + mcUsrAttempt); + removeAttempt(mcUsrAttempt); + McServicePOJO.logger.debug("removed mcUsrAttempt : " + mcUsrAttempt); + } + } + } + McServicePOJO.logger.debug("removed all existing responses of toolContent with toolContentId:" + + toolContentId); + mcContentDAO.removeMcById(toolContentId); + McServicePOJO.logger.debug("removed mcContent:" + mcContent); + } else { + McServicePOJO.logger.error("Warning!!!, We should have not come here. mcContent is null."); + throw new ToolException("toolContentId is missing"); + } + } + /** - * TO BE DEFINED-FUTURE API - * gets called from monitoring module + * TO BE DEFINED-FUTURE API gets called from monitoring module * * update the tool session status to COMPLETE for this tool session * - * @param Long toolSessionId + * @param Long + * toolSessionId */ - public void setAsForceCompleteSession(Long toolSessionId) throws McApplicationException - { - McSession mcSession=retrieveMcSession(toolSessionId); - mcSession.setSessionStatus(McSession.COMPLETED); - updateMcSession(mcSession); - } + public void setAsForceCompleteSession(Long toolSessionId) throws McApplicationException { + McSession mcSession = retrieveMcSession(toolSessionId); + mcSession.setSessionStatus(McSession.COMPLETED); + updateMcSession(mcSession); + } - /** * TO BE DEFINED * - * update the tool session status to COMPLETE for this user - * IMPLEMENT THIS!!!! Is this from ToolContentManager??? + * update the tool session status to COMPLETE for this user IMPLEMENT THIS!!!! Is this from ToolContentManager??? * - + * * @param userId */ - public void setAsForceComplete(Long userId) throws McApplicationException - { - McQueUsr mcQueUsr=retrieveMcQueUsr(userId); - - if (mcQueUsr != null) - { - logger.error("retrieved mcQueUsr : " + mcQueUsr); - logger.error("retrieved mcQueUsr has the tool session : " + mcQueUsr.getMcSession()); - McSession mcSession=mcQueUsr.getMcSession(); - if (mcSession != null) - { - Long usersToolSessionId=mcSession.getMcSessionId(); - logger.debug("retrieved tool session has tool session id : " + usersToolSessionId); - - mcSession=retrieveMcSession(usersToolSessionId); - logger.debug("retrieved mcSession is : " + mcSession); - mcSession.setSessionStatus(McSession.COMPLETED); - logger.debug("updated mcSession to COMPLETED : "); - updateMcSession(mcSession); - logger.debug("updated mcSession to COMPLETED in the db : "); - - McContent mcContent=mcSession.getMcContent(); - logger.debug("mcSession uses mcContent : " + mcContent); - logger.debug("mcSession uses mcContentId : " + mcContent.getMcContentId()); - - /** - * if all the sessions of this content is COMPLETED, unlock the content - * - */ - int countIncompleteSession=countIncompleteSession(mcContent); - logger.debug("mcSession countIncompleteSession : " + countIncompleteSession); - - if (countIncompleteSession == 0) - { - mcContent.setContentInUse(false); - updateMc(mcContent); - logger.debug("mcContent has been updated for contentInUse" + mcContent); - } - } - else - { - logger.error("WARNING!: retrieved mcSession is null."); - throw new McApplicationException("Fail to setAsForceComplete" - + " based on null mcSession."); - } - } - else - { - logger.error("WARNING!: retrieved mcQueUsr is null."); - throw new McApplicationException("Fail to setAsForceComplete" - + " based on null mcQueUsr."); - } + public void setAsForceComplete(Long userId) throws McApplicationException { + McQueUsr mcQueUsr = retrieveMcQueUsr(userId); + + if (mcQueUsr != null) { + McServicePOJO.logger.error("retrieved mcQueUsr : " + mcQueUsr); + McServicePOJO.logger.error("retrieved mcQueUsr has the tool session : " + mcQueUsr.getMcSession()); + McSession mcSession = mcQueUsr.getMcSession(); + if (mcSession != null) { + Long usersToolSessionId = mcSession.getMcSessionId(); + McServicePOJO.logger.debug("retrieved tool session has tool session id : " + usersToolSessionId); + + mcSession = retrieveMcSession(usersToolSessionId); + McServicePOJO.logger.debug("retrieved mcSession is : " + mcSession); + mcSession.setSessionStatus(McSession.COMPLETED); + McServicePOJO.logger.debug("updated mcSession to COMPLETED : "); + updateMcSession(mcSession); + McServicePOJO.logger.debug("updated mcSession to COMPLETED in the db : "); + + McContent mcContent = mcSession.getMcContent(); + McServicePOJO.logger.debug("mcSession uses mcContent : " + mcContent); + McServicePOJO.logger.debug("mcSession uses mcContentId : " + mcContent.getMcContentId()); + + /** + * if all the sessions of this content is COMPLETED, unlock the content + * + */ + int countIncompleteSession = countIncompleteSession(mcContent); + McServicePOJO.logger.debug("mcSession countIncompleteSession : " + countIncompleteSession); + + if (countIncompleteSession == 0) { + mcContent.setContentInUse(false); + updateMc(mcContent); + McServicePOJO.logger.debug("mcContent has been updated for contentInUse" + mcContent); + } + } else { + McServicePOJO.logger.error("WARNING!: retrieved mcSession is null."); + throw new McApplicationException("Fail to setAsForceComplete" + " based on null mcSession."); + } + } else { + McServicePOJO.logger.error("WARNING!: retrieved mcQueUsr is null."); + throw new McApplicationException("Fail to setAsForceComplete" + " based on null mcQueUsr."); + } } - + /** - * Implemented as part of the tool contract. Sets the defineLater to true on this content. - * setAsDefineLater(Long toolContentId) throws DataMissingException, ToolException + * Implemented as part of the tool contract. Sets the defineLater to true on this content. setAsDefineLater(Long + * toolContentId) throws DataMissingException, ToolException + * * @param toolContentId - * @return + * @return * @throws ToolException */ - public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException - { - if (toolContentId == null) - { - logger.error("throwing DataMissingException: WARNING!: retrieved toolContentId is null."); - throw new DataMissingException("toolContentId is missing"); - } - - McContent mcContent=retrieveMc(toolContentId); - if (mcContent == null) - { - logger.error("throwing DataMissingException: WARNING!: retrieved mcContent is null."); - throw new DataMissingException("mcContent is missing"); - } - mcContent.setDefineLater(value); - saveMcContent(mcContent); + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { + if (toolContentId == null) { + McServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved toolContentId is null."); + throw new DataMissingException("toolContentId is missing"); + } + + McContent mcContent = retrieveMc(toolContentId); + if (mcContent == null) { + McServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved mcContent is null."); + throw new DataMissingException("mcContent is missing"); + } + mcContent.setDefineLater(value); + saveMcContent(mcContent); } - + /** - * Implemented as part of the tool contract. Sets the runOffline to true on this content. - * setAsRunOffline(Long toolContentId) throws DataMissingException, ToolException + * Implemented as part of the tool contract. Sets the runOffline to true on this content. setAsRunOffline(Long + * toolContentId) throws DataMissingException, ToolException * * @param toolContentId - * return - * @throws ToolException + * return + * @throws ToolException */ - public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException - { - if (toolContentId == null) - { - logger.error("throwing DataMissingException: WARNING!: retrieved toolContentId is null."); - throw new DataMissingException("toolContentId is missing"); - } - McContent mcContent = mcContentDAO.findMcContentById(toolContentId); - if (mcContent == null) - { - logger.error("throwing DataMissingException: WARNING!: retrieved mcContent is null."); - throw new DataMissingException("mcContent is missing"); - } - mcContent.setRunOffline(value); - saveMcContent(mcContent); + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { + if (toolContentId == null) { + McServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved toolContentId is null."); + throw new DataMissingException("toolContentId is missing"); + } + McContent mcContent = mcContentDAO.findMcContentById(toolContentId); + if (mcContent == null) { + McServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved mcContent is null."); + throw new DataMissingException("mcContent is missing"); + } + mcContent.setRunOffline(value); + saveMcContent(mcContent); } - - - /** - * Export the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws DataMissingException if no tool content matches the toolSessionId - * @throws ToolException if any other error occurs + + /** + * Export the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws DataMissingException + * if no tool content matches the toolSessionId + * @throws ToolException + * if any other error occurs */ - public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { - McContent toolContentObj = mcContentDAO.findMcContentById(toolContentId); - if(toolContentObj == null) { - long defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - toolContentObj = mcContentDAO.findMcContentById(defaultContentId); - } - if(toolContentObj == null) - throw new DataMissingException("Unable to find default content for the multiple choice tool"); - - try { - //set ToolContentHandler as null to avoid copy file node in repository again. - toolContentObj = McContent.newInstance(null,toolContentObj,toolContentId); - toolContentObj.setMcSessions(null); - Set files = toolContentObj.getMcAttachments(); - for(McUploadedFile file : files){ - file.setMcContent(null); - } - exportContentService.registerFileClassForExport(McUploadedFile.class.getName(),"uuid",null); - exportContentService.exportToolContent( toolContentId, toolContentObj,mcToolContentHandler, rootPath); - } catch (ExportToolContentException e) { - throw new ToolException(e); - } catch (ItemNotFoundException e) { - throw new ToolException(e); - } catch (RepositoryCheckedException e) { - throw new ToolException(e); - } + public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { + McContent toolContentObj = mcContentDAO.findMcContentById(toolContentId); + if (toolContentObj == null) { + long defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + toolContentObj = mcContentDAO.findMcContentById(defaultContentId); } + if (toolContentObj == null) { + throw new DataMissingException("Unable to find default content for the multiple choice tool"); + } + try { + // set ToolContentHandler as null to avoid copy file node in repository again. + toolContentObj = McContent.newInstance(null, toolContentObj, toolContentId); + toolContentObj.setMcSessions(null); + Set files = toolContentObj.getMcAttachments(); + for (McUploadedFile file : files) { + file.setMcContent(null); + } + exportContentService.registerFileClassForExport(McUploadedFile.class.getName(), "uuid", null); + exportContentService.exportToolContent(toolContentId, toolContentObj, mcToolContentHandler, rootPath); + } catch (ExportToolContentException e) { + throw new ToolException(e); + } catch (ItemNotFoundException e) { + throw new ToolException(e); + } catch (RepositoryCheckedException e) { + throw new ToolException(e); + } + } + /** - * Import the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws ToolException if any other error occurs + * Import the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws ToolException + * if any other error occurs */ - public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath,String fromVersion,String toVersion) throws ToolException { - try { - //register File node class - exportContentService.registerFileClassForImport(McUploadedFile.class.getName() - ,"uuid",null,"fileName","fileProperty",null,null); - - //register version filter class - exportContentService.registerImportVersionFilterClass(McImportContentVersionFilter.class); - - Object toolPOJO = exportContentService.importToolContent(toolContentPath,mcToolContentHandler,fromVersion,toVersion); - if(!(toolPOJO instanceof McContent)) - throw new ImportToolContentException("Import MC tool content failed. Deserialized object is " + toolPOJO); - McContent toolContentObj = (McContent) toolPOJO; - -// reset it to new toolContentId - toolContentObj.setMcContentId(toolContentId); - toolContentObj.setCreatedBy(newUserUid); - Set files = toolContentObj.getMcAttachments(); - for(McUploadedFile file : files){ - //file.setMcContentId(toolContentId); - file.setMcContent(toolContentObj); - } - mcContentDAO.saveMcContent(toolContentObj); - } catch (ImportToolContentException e) { - throw new ToolException(e); - } + public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException { + try { + // register File node class + exportContentService.registerFileClassForImport(McUploadedFile.class.getName(), "uuid", null, "fileName", + "fileProperty", null, null); + + // register version filter class + exportContentService.registerImportVersionFilterClass(McImportContentVersionFilter.class); + + Object toolPOJO = exportContentService.importToolContent(toolContentPath, mcToolContentHandler, + fromVersion, toVersion); + if (!(toolPOJO instanceof McContent)) { + throw new ImportToolContentException("Import MC tool content failed. Deserialized object is " + + toolPOJO); + } + McContent toolContentObj = (McContent) toolPOJO; + + // reset it to new toolContentId + toolContentObj.setMcContentId(toolContentId); + toolContentObj.setCreatedBy(newUserUid); + Set files = toolContentObj.getMcAttachments(); + for (McUploadedFile file : files) { + // file.setMcContentId(toolContentId); + file.setMcContent(toolContentObj); + } + mcContentDAO.saveMcContent(toolContentObj); + } catch (ImportToolContentException e) { + throw new ToolException(e); } + } - /** Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are always - * available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular activity - * such as the answer to the third question contains the word Koala and hence the need for the toolContentId + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - McContent content = retrieveMc(toolContentId); - if ( content == null ) { - long defaultToolContentId = getToolDefaultContentIdBySignature(MY_SIGNATURE); - content = retrieveMc(defaultToolContentId); - } - return getMcOutputFactory().getToolOutputDefinitions(content); + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { + McContent content = retrieveMc(toolContentId); + if (content == null) { + long defaultToolContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + content = retrieveMc(defaultToolContentId); } - + return getMcOutputFactory().getToolOutputDefinitions(content, definitionType); + } + /** + * it is possible that the tool session id already exists in the tool sessions table as the users from the same + * session are involved. existsSession(long toolSessionId) + * + * @param toolSessionId + * @return boolean + */ + public boolean existsSession(Long toolSessionId) { + McSession mcSession = retrieveMcSession(toolSessionId); - /** - * it is possible that the tool session id already exists in the tool sessions table - * as the users from the same session are involved. - * existsSession(long toolSessionId) - * @param toolSessionId - * @return boolean - */ - public boolean existsSession(Long toolSessionId) - { - McSession mcSession= retrieveMcSession(toolSessionId); - - if (mcSession == null) - { - logger.error("mcSession does not exist yet: " + toolSessionId); - return false; - } - else - { - logger.debug("retrieving an existing mcSession: " + mcSession + " " + toolSessionId); - } - return true; + if (mcSession == null) { + McServicePOJO.logger.error("mcSession does not exist yet: " + toolSessionId); + return false; + } else { + McServicePOJO.logger.debug("retrieving an existing mcSession: " + mcSession + " " + toolSessionId); } - + return true; + } + /** - * Implemented as part of the tool contract. - * Gets called only in the Learner mode. - * All the learners in the same group have the same toolSessionId. + * Implemented as part of the tool contract. Gets called only in the Learner mode. All the learners in the same + * group have the same toolSessionId. * - * @param toolSessionId the generated tool session id. - * @param toolSessionName the tool session name. - * @param toolContentId the tool content id specified. - * @throws ToolException if an error occurs e.g. defaultContent is missing. + * @param toolSessionId + * the generated tool session id. + * @param toolSessionName + * the tool session name. + * @param toolContentId + * the tool content id specified. + * @throws ToolException + * if an error occurs e.g. defaultContent is missing. * */ - public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException - { - logger.debug("start of createToolSession with ids: " + toolSessionId + " and " + toolContentId); - logger.debug("toolSessionName: " + toolSessionName); - - if (toolSessionId == null) - { - logger.error("toolSessionId is null"); - throw new ToolException("toolSessionId is missing"); - } - - long defaultContentId=0; - if (toolContentId == null) - { - logger.error("toolContentId is null."); - logger.error("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - toolContentId=new Long(defaultContentId); - logger.debug("updated toolContentId to: " + toolContentId); - } - catch(Exception e) - { - logger.error("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } - } - logger.debug("final toolSessionId and toolContentId: " + toolSessionId + " " + toolContentId); - - McContent mcContent = mcContentDAO.findMcContentById(toolContentId); - logger.debug("retrieved mcContent: " + mcContent); - - if (mcContent == null) - { - logger.error("mcContent is null."); - logger.error("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - toolContentId=new Long(defaultContentId); - logger.debug("updated toolContentId to: " + toolContentId); - } - catch(Exception e) - { - logger.error("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } + public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { + McServicePOJO.logger.debug("start of createToolSession with ids: " + toolSessionId + " and " + toolContentId); + McServicePOJO.logger.debug("toolSessionName: " + toolSessionName); - mcContent = mcContentDAO.findMcContentById(toolContentId); - } - logger.debug("final - retrieved mcContent: " + mcContent); + if (toolSessionId == null) { + McServicePOJO.logger.error("toolSessionId is null"); + throw new ToolException("toolSessionId is missing"); + } - - /* - * create a new a new tool session if it does not already exist in the tool session table - */ - if (!existsSession(toolSessionId)) - { - try - { - McSession mcSession = new McSession(toolSessionId, - new Date(System.currentTimeMillis()), - McSession.INCOMPLETE, - toolSessionName, - mcContent, - new TreeSet()); + long defaultContentId = 0; + if (toolContentId == null) { + McServicePOJO.logger.error("toolContentId is null."); + McServicePOJO.logger.error("attempt retrieving tool's default content id with signatute : " + + McAppConstants.MY_SIGNATURE); - logger.debug("created mcSession: " + mcSession); - mcSessionDAO.saveMcSession(mcSession); - logger.debug("created mcSession in the db: " + mcSession); - - } - catch(Exception e) - { - logger.error("Error creating new toolsession in the db"); - throw new ToolException("Error creating new toolsession in the db: " + e); - } - } - } + try { + defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + toolContentId = new Long(defaultContentId); + McServicePOJO.logger.debug("updated toolContentId to: " + toolContentId); + } catch (Exception e) { + McServicePOJO.logger.error("default content id has not been setup for signature: " + + McAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + McAppConstants.MY_SIGNATURE + " Can't continue!"); + } + } + McServicePOJO.logger.debug("final toolSessionId and toolContentId: " + toolSessionId + " " + toolContentId); + McContent mcContent = mcContentDAO.findMcContentById(toolContentId); + McServicePOJO.logger.debug("retrieved mcContent: " + mcContent); + if (mcContent == null) { + McServicePOJO.logger.error("mcContent is null."); + McServicePOJO.logger.error("attempt retrieving tool's default content id with signatute : " + + McAppConstants.MY_SIGNATURE); + + try { + defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + toolContentId = new Long(defaultContentId); + McServicePOJO.logger.debug("updated toolContentId to: " + toolContentId); + } catch (Exception e) { + McServicePOJO.logger.error("default content id has not been setup for signature: " + + McAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + McAppConstants.MY_SIGNATURE + " Can't continue!"); + } + + mcContent = mcContentDAO.findMcContentById(toolContentId); + } + McServicePOJO.logger.debug("final - retrieved mcContent: " + mcContent); + + /* + * create a new a new tool session if it does not already exist in the tool session table + */ + if (!existsSession(toolSessionId)) { + try { + McSession mcSession = new McSession(toolSessionId, new Date(System.currentTimeMillis()), + McSession.INCOMPLETE, toolSessionName, mcContent, new TreeSet()); + + McServicePOJO.logger.debug("created mcSession: " + mcSession); + mcSessionDAO.saveMcSession(mcSession); + McServicePOJO.logger.debug("created mcSession in the db: " + mcSession); + + } catch (Exception e) { + McServicePOJO.logger.error("Error creating new toolsession in the db"); + throw new ToolException("Error creating new toolsession in the db: " + e); + } + } + } + /** - * Implemented as part of the tool contract. - * removeToolSession(Long toolSessionId) throws DataMissingException, ToolException + * Implemented as part of the tool contract. removeToolSession(Long toolSessionId) throws DataMissingException, + * ToolException + * * @param toolSessionId - * @param toolContentId - * return + * @param toolContentId + * return * @throws ToolException */ - public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException - { - logger.debug("start of removeToolSession with id: " + toolSessionId); - if (toolSessionId == null) - { - logger.error("toolSessionId is null"); - throw new DataMissingException("toolSessionId is missing"); - } - - - McSession mcSession=null; - try - { - mcSession=retrieveMcSession(toolSessionId); - logger.debug("retrieved mcSession: " + mcSession); - } - catch(McApplicationException e) - { - throw new DataMissingException("error retrieving mcSession: " + e); - } - catch(Exception e) - { - throw new ToolException("error retrieving mcSession: " + e); - } - - if (mcSession == null) - { - logger.error("mcSession is null"); - throw new DataMissingException("mcSession is missing"); - } - - try - { - mcSessionDAO.removeMcSession(mcSession); - logger.debug("mcSession " + mcSession + " has been deleted successfully."); - } - catch(McApplicationException e) - { - throw new ToolException("error deleting mcSession:" + e); - } + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + McServicePOJO.logger.debug("start of removeToolSession with id: " + toolSessionId); + if (toolSessionId == null) { + McServicePOJO.logger.error("toolSessionId is null"); + throw new DataMissingException("toolSessionId is missing"); } - + McSession mcSession = null; + try { + mcSession = retrieveMcSession(toolSessionId); + McServicePOJO.logger.debug("retrieved mcSession: " + mcSession); + } catch (McApplicationException e) { + throw new DataMissingException("error retrieving mcSession: " + e); + } catch (Exception e) { + throw new ToolException("error retrieving mcSession: " + e); + } + + if (mcSession == null) { + McServicePOJO.logger.error("mcSession is null"); + throw new DataMissingException("mcSession is missing"); + } + + try { + mcSessionDAO.removeMcSession(mcSession); + McServicePOJO.logger.debug("mcSession " + mcSession + " has been deleted successfully."); + } catch (McApplicationException e) { + throw new ToolException("error deleting mcSession:" + e); + } + } + /** - * Implemtented as part of the tool contract. - * leaveToolSession(Long toolSessionId,Long learnerId) throws DataMissingException, ToolException + * Implemtented as part of the tool contract. leaveToolSession(Long toolSessionId,Long learnerId) throws + * DataMissingException, ToolException + * * @param toolSessionId - * @param learnerId - * return String + * @param learnerId + * return String * @throws ToolException * */ - public String leaveToolSession(Long toolSessionId,Long learnerId) throws DataMissingException, ToolException - { - logger.debug("start of leaveToolSession with toolSessionId:" + toolSessionId + " and learnerId:" + learnerId); - logger.debug("make sure learnerService is available. Is it?" + learnerService); - - if (learnerService == null) - return "dummyNextUrl"; - - if (learnerId == null) - { - logger.error("learnerId is null"); - throw new DataMissingException("learnerId is missing"); - } - - if (toolSessionId == null) - { - logger.error("toolSessionId is null"); - throw new DataMissingException("toolSessionId is missing"); - } - - McSession mcSession=null; - try - { - mcSession=retrieveMcSession(toolSessionId); - logger.debug("retrieved mcSession: " + mcSession); - } - catch(McApplicationException e) - { - throw new DataMissingException("error retrieving mcSession: " + e); - } - catch(Exception e) - { - throw new ToolException("error retrieving mcSession: " + e); - } - mcSession.setSessionStatus(COMPLETED); - mcSessionDAO.updateMcSession(mcSession); - logger.debug("updated mcSession to COMPLETED" + mcSession); - - String nextUrl= learnerService.completeToolSession(toolSessionId,learnerId); - logger.debug("nextUrl: " + nextUrl); - if (nextUrl == null) - { - logger.error("nextUrl is null"); - throw new ToolException("nextUrl is null"); - } - return nextUrl; + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { + McServicePOJO.logger.debug("start of leaveToolSession with toolSessionId:" + toolSessionId + " and learnerId:" + + learnerId); + McServicePOJO.logger.debug("make sure learnerService is available. Is it?" + learnerService); + + if (learnerService == null) { + return "dummyNextUrl"; + } + + if (learnerId == null) { + McServicePOJO.logger.error("learnerId is null"); + throw new DataMissingException("learnerId is missing"); + } + + if (toolSessionId == null) { + McServicePOJO.logger.error("toolSessionId is null"); + throw new DataMissingException("toolSessionId is missing"); + } + + McSession mcSession = null; + try { + mcSession = retrieveMcSession(toolSessionId); + McServicePOJO.logger.debug("retrieved mcSession: " + mcSession); + } catch (McApplicationException e) { + throw new DataMissingException("error retrieving mcSession: " + e); + } catch (Exception e) { + throw new ToolException("error retrieving mcSession: " + e); + } + mcSession.setSessionStatus(McAppConstants.COMPLETED); + mcSessionDAO.updateMcSession(mcSession); + McServicePOJO.logger.debug("updated mcSession to COMPLETED" + mcSession); + + String nextUrl = learnerService.completeToolSession(toolSessionId, learnerId); + McServicePOJO.logger.debug("nextUrl: " + nextUrl); + if (nextUrl == null) { + McServicePOJO.logger.error("nextUrl is null"); + throw new ToolException("nextUrl is null"); + } + return nextUrl; } - /** * exportToolSession(Long toolSessionId) throws DataMissingException, ToolException + * * @param toolSessionId - * return ToolSessionExportOutputData + * return ToolSessionExportOutputData * @throws ToolException */ - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException - { - throw new ToolException("not yet implemented"); + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + throw new ToolException("not yet implemented"); } - /** * exportToolSession(Long toolSessionId) throws DataMissingException, ToolException + * * @param toolSessionIds - * return ToolSessionExportOutputData + * return ToolSessionExportOutputData * @throws ToolException */ - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException - { - throw new ToolException("not yet implemented"); + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, + ToolException { + throw new ToolException("not yet implemented"); } - - /** - * Get the tool output for the given tool output names. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) - */ - public SortedMap getToolOutput(List names, - Long toolSessionId, Long learnerId) { - - return mcOutputFactory.getToolOutput(names, this, toolSessionId, learnerId); - } - /** - * Get the tool output for the given tool output name. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) - */ - public ToolOutput getToolOutput(String name, Long toolSessionId, - Long learnerId) { - return mcOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); - } + /** + * Get the tool output for the given tool output names. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) + */ + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { + return mcOutputFactory.getToolOutput(names, this, toolSessionId, learnerId); + } - public IToolVO getToolBySignature(String toolSignature) throws McApplicationException - { - logger.debug("attempt retrieving tool with signature : " + toolSignature); - IToolVO tool=toolService.getToolBySignature(toolSignature); - logger.debug("retrieved tool: " + tool); - return tool; + /** + * Get the tool output for the given tool output name. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) + */ + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return mcOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); } - - public long getToolDefaultContentIdBySignature(String toolSignature) throws McApplicationException - { - long contentId=0; - contentId=toolService.getToolDefaultContentIdBySignature(toolSignature); - logger.debug("tool default contentId : " + contentId); - return contentId; + + public IToolVO getToolBySignature(String toolSignature) throws McApplicationException { + McServicePOJO.logger.debug("attempt retrieving tool with signature : " + toolSignature); + IToolVO tool = toolService.getToolBySignature(toolSignature); + McServicePOJO.logger.debug("retrieved tool: " + tool); + return tool; } - public McQueContent getToolDefaultQuestionContent(long contentId) throws McApplicationException - { - McQueContent mcQueContent=mcQueContentDAO.getToolDefaultQuestionContent(contentId); - logger.debug("retrieved mcQueContent : " + mcQueContent); - return mcQueContent; + public long getToolDefaultContentIdBySignature(String toolSignature) throws McApplicationException { + long contentId = 0; + contentId = toolService.getToolDefaultContentIdBySignature(toolSignature); + McServicePOJO.logger.debug("tool default contentId : " + contentId); + return contentId; } - - public void removeAttachment(McContent content, McUploadedFile attachment) throws RepositoryCheckedException - { - try - { - attachment.setMcContent(null); - content.getMcAttachments().remove(attachment); - mcToolContentHandler.deleteFile(new Long(attachment.getUuid())); - saveMcContent(content); - } - catch (DataAccessException e) - { - throw new McApplicationException("EXCEPTION: An exception has occurred while trying to remove this attachment" - + e.getMessage(), e); - } + public McQueContent getToolDefaultQuestionContent(long contentId) throws McApplicationException { + McQueContent mcQueContent = mcQueContentDAO.getToolDefaultQuestionContent(contentId); + McServicePOJO.logger.debug("retrieved mcQueContent : " + mcQueContent); + return mcQueContent; + } + + public void removeAttachment(McContent content, McUploadedFile attachment) throws RepositoryCheckedException { + try { + attachment.setMcContent(null); + content.getMcAttachments().remove(attachment); + mcToolContentHandler.deleteFile(new Long(attachment.getUuid())); + saveMcContent(content); + } catch (DataAccessException e) { + throw new McApplicationException( + "EXCEPTION: An exception has occurred while trying to remove this attachment" + e.getMessage(), e); } - - - public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType) throws RepositoryCheckedException - { - return mcToolContentHandler.uploadFile(istream, filename, contentType, fileType); + } + + public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType) + throws RepositoryCheckedException { + return mcToolContentHandler.uploadFile(istream, filename, contentType, fileType); + } + + public NodeKey copyFile(Long uuid) throws RepositoryCheckedException { + return mcToolContentHandler.copyFile(uuid); + } + + /** + * This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket to login and + * access the Content Repository. + * + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. + * + * @return ITicket The ticket for repostory access + * @throws SubmitFilesException + */ + public ITicket getRepositoryLoginTicket() throws McApplicationException { + ICredentials credentials = new SimpleCredentials(repositoryUser, repositoryId); + try { + ITicket ticket = repositoryService.login(credentials, repositoryWorkspace); + McServicePOJO.logger.debug("retrieved ticket: " + ticket); + return ticket; + } catch (AccessDeniedException e) { + throw new McApplicationException("Access Denied to repository." + e.getMessage()); + } catch (WorkspaceNotFoundException e) { + throw new McApplicationException("Workspace not found." + e.getMessage()); + } catch (LoginException e) { + throw new McApplicationException("Login failed." + e.getMessage()); } - - - public NodeKey copyFile(Long uuid) throws RepositoryCheckedException - { - return mcToolContentHandler.copyFile(uuid); - } - - /** - * This method verifies the credentials of the SubmitFiles Tool and gives it - * the Ticket to login and access the Content Repository. - * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. - * - * @return ITicket The ticket for repostory access - * @throws SubmitFilesException - */ - public ITicket getRepositoryLoginTicket() throws McApplicationException { - ICredentials credentials = new SimpleCredentials( - repositoryUser, - repositoryId); - try { - ITicket ticket = repositoryService.login(credentials, - repositoryWorkspace); - logger.debug("retrieved ticket: " + ticket); - return ticket; - } catch (AccessDeniedException e) { - throw new McApplicationException("Access Denied to repository." - + e.getMessage()); - } catch (WorkspaceNotFoundException e) { - throw new McApplicationException("Workspace not found." - + e.getMessage()); - } catch (LoginException e) { - throw new McApplicationException("Login failed." + e.getMessage()); - } - } - - - /** - * This method deletes the content with the given uuid and - * versionID from the content repository - * - * @param uuid - * The uuid of the node to be deleted - * @param versionID - * The version_id of the node to be deleted. - * @throws SubmitFilesException - */ - public void deleteFromRepository(Long uuid, Long versionID) - throws McApplicationException { - ITicket ticket = getRepositoryLoginTicket(); - logger.debug("retrieved ticket: " + ticket); - try { - String files[] = repositoryService.deleteVersion(ticket, uuid,versionID); - logger.debug("retrieved files: " + files); - } catch (Exception e) { - throw new McApplicationException( - "Exception occured while deleting files from" - + " the repository " + e.getMessage()); - } - } - - - /** - * This method is called everytime a new content has to be added to the - * repository. In order to do so first of all a valid ticket is obtained - * from the Repository hence authenticating the tool(SubmitFiles) and then - * the corresponding file is added to the repository. - * - * @param stream - * The InputStream representing the data to be - * added - * @param fileName - * The name of the file being added - * @param mimeType - * The MIME type of the file (eg. TXT, DOC, GIF etc) - * @return NodeKey Represents the two part key - UUID and Version. - * @throws SubmitFilesException - */ - public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws McApplicationException { - logger.debug("attempt getting the ticket"); - ITicket ticket = getRepositoryLoginTicket(); - logger.debug("retrieved ticket: " + ticket); - - try { - NodeKey nodeKey = repositoryService.addFileItem(ticket, stream, - fileName, null, null); - logger.debug("retrieved nodeKey from repository service: " + nodeKey); - return nodeKey; - } catch (Exception e) { - throw new McApplicationException("Exception occured while trying to" - + " upload file into the repository" + e.getMessage()); - } - } + } - public InputStream downloadFile(Long uuid, Long versionID)throws McApplicationException{ - ITicket ticket = getRepositoryLoginTicket(); - try{ - IVersionedNode node = repositoryService.getFileItem(ticket,uuid,null); - logger.debug("retrieved node: " + node); - return node.getFile(); - }catch(AccessDeniedException e){ - throw new McApplicationException("AccessDeniedException occured while trying to download file " + e.getMessage()); - }catch(FileException e){ - throw new McApplicationException("FileException occured while trying to download file " + e.getMessage()); - }catch(ItemNotFoundException e){ - throw new McApplicationException("ItemNotFoundException occured while trying to download file " + e.getMessage()); - } + /** + * This method deletes the content with the given uuid and versionID from the content + * repository + * + * @param uuid + * The uuid of the node to be deleted + * @param versionID + * The version_id of the node to be deleted. + * @throws SubmitFilesException + */ + public void deleteFromRepository(Long uuid, Long versionID) throws McApplicationException { + ITicket ticket = getRepositoryLoginTicket(); + McServicePOJO.logger.debug("retrieved ticket: " + ticket); + try { + String files[] = repositoryService.deleteVersion(ticket, uuid, versionID); + McServicePOJO.logger.debug("retrieved files: " + files); + } catch (Exception e) { + throw new McApplicationException("Exception occured while deleting files from" + " the repository " + + e.getMessage()); } - - - - /** - * adds a new entry to the uploaded files table - */ - public void persistFile(String uuid, boolean isOnlineFile, String fileName, McContent mcContent) throws McApplicationException { - - logger.debug("attempt persisting file to the db: " + uuid + " " + isOnlineFile + " " + fileName + " " + mcContent); - McUploadedFile mcUploadedFile= new McUploadedFile(uuid, isOnlineFile, fileName, mcContent); - logger.debug("created mcUploadedFile: " + mcUploadedFile); - mcUploadedFileDAO.saveUploadFile(mcUploadedFile); - logger.debug("persisted mcUploadedFile: " + mcUploadedFile); - } + } - /** - * @return Returns the logger. - */ - public static Logger getLogger() { - return logger; + /** + * This method is called everytime a new content has to be added to the repository. In order to do so first of all a + * valid ticket is obtained from the Repository hence authenticating the tool(SubmitFiles) and then the + * corresponding file is added to the repository. + * + * @param stream + * The InputStream representing the data to be added + * @param fileName + * The name of the file being added + * @param mimeType + * The MIME type of the file (eg. TXT, DOC, GIF etc) + * @return NodeKey Represents the two part key - UUID and Version. + * @throws SubmitFilesException + */ + public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws McApplicationException { + McServicePOJO.logger.debug("attempt getting the ticket"); + ITicket ticket = getRepositoryLoginTicket(); + McServicePOJO.logger.debug("retrieved ticket: " + ticket); + + try { + NodeKey nodeKey = repositoryService.addFileItem(ticket, stream, fileName, null, null); + McServicePOJO.logger.debug("retrieved nodeKey from repository service: " + nodeKey); + return nodeKey; + } catch (Exception e) { + throw new McApplicationException("Exception occured while trying to" + " upload file into the repository" + + e.getMessage()); } - /** - * @param logger The logger to set. - */ - public static void setLogger(Logger logger) { - McServicePOJO.logger = logger; - } - /** - * @return Returns the cred. - */ - public ICredentials getCred() { - return cred; - } - /** - * @param cred The cred to set. - */ - public void setCred(ICredentials cred) { - this.cred = cred; - } - - /* - !!! COMPLETE THIS !!! - public IMcUploadedFileDAO getMcUploadedFileDAO() { - return mcUploadedFileDAO; - } - - public void setMcUploadedFileDAO(IMcUploadedFileDAO mcUploadedFileDAO) { - this.mcUploadedFileDAO = mcUploadedFileDAO; - } - - */ - - - /** - * @return Returns the repositoryId. - */ - public char[] getRepositoryId() { - return repositoryId; - } - /** - * @return Returns the repositoryUser. - */ - public String getRepositoryUser() { - return repositoryUser; - } - /** - * @return Returns the repositoryWorkspace. - */ - public String getRepositoryWorkspace() { - return repositoryWorkspace; - } + } - /** - * @return Returns the toolService. - */ - public ILamsToolService getToolService() { - return toolService; + public InputStream downloadFile(Long uuid, Long versionID) throws McApplicationException { + ITicket ticket = getRepositoryLoginTicket(); + try { + IVersionedNode node = repositoryService.getFileItem(ticket, uuid, null); + McServicePOJO.logger.debug("retrieved node: " + node); + return node.getFile(); + } catch (AccessDeniedException e) { + throw new McApplicationException("AccessDeniedException occured while trying to download file " + + e.getMessage()); + } catch (FileException e) { + throw new McApplicationException("FileException occured while trying to download file " + e.getMessage()); + } catch (ItemNotFoundException e) { + throw new McApplicationException("ItemNotFoundException occured while trying to download file " + + e.getMessage()); } - /** - * @return Returns the userManagementService. - */ - public IUserManagementService getUserManagementService() { - return userManagementService; - } - /** - * @return Returns the mcContentDAO. - */ - public IMcContentDAO getMcContentDAO() { - return mcContentDAO; - } - /** - * @param mcContentDAO The mcContentDAO to set. - */ - public void setMcContentDAO(IMcContentDAO mcContentDAO) { - this.mcContentDAO = mcContentDAO; - } - /** - * @return Returns the mcOptionsContentDAO. - */ - public IMcOptionsContentDAO getMcOptionsContentDAO() { - return mcOptionsContentDAO; - } - /** - * @param mcOptionsContentDAO The mcOptionsContentDAO to set. - */ - public void setMcOptionsContentDAO(IMcOptionsContentDAO mcOptionsContentDAO) { - this.mcOptionsContentDAO = mcOptionsContentDAO; - } - /** - * @return Returns the mcQueContentDAO. - */ - public IMcQueContentDAO getMcQueContentDAO() { - return mcQueContentDAO; - } - /** - * @param mcQueContentDAO The mcQueContentDAO to set. - */ - public void setMcQueContentDAO(IMcQueContentDAO mcQueContentDAO) { - this.mcQueContentDAO = mcQueContentDAO; - } - /** - * @return Returns the mcSessionDAO. - */ - public IMcSessionDAO getMcSessionDAO() { - return mcSessionDAO; - } - /** - * @param mcSessionDAO The mcSessionDAO to set. - */ - public void setMcSessionDAO(IMcSessionDAO mcSessionDAO) { - this.mcSessionDAO = mcSessionDAO; - } - /** - * @return Returns the mcUserDAO. - */ - public IMcUserDAO getMcUserDAO() { - return mcUserDAO; - } - /** - * @param mcUserDAO The mcUserDAO to set. - */ - public void setMcUserDAO(IMcUserDAO mcUserDAO) { - this.mcUserDAO = mcUserDAO; - } - /** - * @return Returns the mcUsrAttemptDAO. - */ - public IMcUsrAttemptDAO getMcUsrAttemptDAO() { - return mcUsrAttemptDAO; - } - /** - * @param mcUsrAttemptDAO The mcUsrAttemptDAO to set. - */ - public void setMcUsrAttemptDAO(IMcUsrAttemptDAO mcUsrAttemptDAO) { - this.mcUsrAttemptDAO = mcUsrAttemptDAO; - } - - /** - * @return Returns the repositoryService. - */ - public IRepositoryService getRepositoryService() { - return repositoryService; - } - /** - * @param repositoryService The repositoryService to set. - */ - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } + } - public void setUserManagementService(IUserManagementService userManagementService) - { - this.userManagementService = userManagementService; + /** + * adds a new entry to the uploaded files table + */ + public void persistFile(String uuid, boolean isOnlineFile, String fileName, McContent mcContent) + throws McApplicationException { + + McServicePOJO.logger.debug("attempt persisting file to the db: " + uuid + " " + isOnlineFile + " " + fileName + + " " + mcContent); + McUploadedFile mcUploadedFile = new McUploadedFile(uuid, isOnlineFile, fileName, mcContent); + McServicePOJO.logger.debug("created mcUploadedFile: " + mcUploadedFile); + mcUploadedFileDAO.saveUploadFile(mcUploadedFile); + McServicePOJO.logger.debug("persisted mcUploadedFile: " + mcUploadedFile); } - - public void setToolService(ILamsToolService toolService) - { - this.toolService = toolService; + + /** + * @return Returns the logger. + */ + public static Logger getLogger() { + return McServicePOJO.logger; } - /** - * @return Returns the mcUploadedFileDAO. - */ - public IMcUploadedFileDAO getMcUploadedFileDAO() { - return mcUploadedFileDAO; - } - /** - * @param mcUploadedFileDAO The mcUploadedFileDAO to set. - */ - public void setMcUploadedFileDAO(IMcUploadedFileDAO mcUploadedFileDAO) { - this.mcUploadedFileDAO = mcUploadedFileDAO; - } + /** + * @param logger + * The logger to set. + */ + public static void setLogger(Logger logger) { + McServicePOJO.logger = logger; + } - /** - * @return Returns the mcToolContentHandler. - */ - public IToolContentHandler getMcToolContentHandler() { - return mcToolContentHandler; - } - /** - * @param mcToolContentHandler The mcToolContentHandler to set. - */ - public void setMcToolContentHandler(IToolContentHandler mcToolContentHandler) { - this.mcToolContentHandler = mcToolContentHandler; - } - /** - * @return Returns the learnerService. - */ - public ILearnerService getLearnerService() { - return learnerService; - } - /** - * @param learnerService The learnerService to set. - */ - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } + /** + * @return Returns the cred. + */ + public ICredentials getCred() { + return cred; + } - public IExportToolContentService getExportContentService() { - return exportContentService; - } + /** + * @param cred + * The cred to set. + */ + public void setCred(ICredentials cred) { + this.cred = cred; + } - public void setExportContentService(IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; - } + /* + * !!! COMPLETE THIS !!! public IMcUploadedFileDAO getMcUploadedFileDAO() { return mcUploadedFileDAO; } + * + * public void setMcUploadedFileDAO(IMcUploadedFileDAO mcUploadedFileDAO) { this.mcUploadedFileDAO = + * mcUploadedFileDAO; } + * + */ - public MCOutputFactory getMcOutputFactory() { - return mcOutputFactory; - } + /** + * @return Returns the repositoryId. + */ + public char[] getRepositoryId() { + return repositoryId; + } - public void setMcOutputFactory( - MCOutputFactory mcOutputFactory) { - this.mcOutputFactory = mcOutputFactory; - } + /** + * @return Returns the repositoryUser. + */ + public String getRepositoryUser() { + return repositoryUser; + } + /** + * @return Returns the repositoryWorkspace. + */ + public String getRepositoryWorkspace() { + return repositoryWorkspace; + } - - /* ===============Methods implemented from ToolContentImport102Manager =============== */ - + /** + * @return Returns the toolService. + */ + public ILamsToolService getToolService() { + return toolService; + } - /** + /** + * @return Returns the userManagementService. + */ + public IUserManagementService getUserManagementService() { + return userManagementService; + } + + /** + * @return Returns the mcContentDAO. + */ + public IMcContentDAO getMcContentDAO() { + return mcContentDAO; + } + + /** + * @param mcContentDAO + * The mcContentDAO to set. + */ + public void setMcContentDAO(IMcContentDAO mcContentDAO) { + this.mcContentDAO = mcContentDAO; + } + + /** + * @return Returns the mcOptionsContentDAO. + */ + public IMcOptionsContentDAO getMcOptionsContentDAO() { + return mcOptionsContentDAO; + } + + /** + * @param mcOptionsContentDAO + * The mcOptionsContentDAO to set. + */ + public void setMcOptionsContentDAO(IMcOptionsContentDAO mcOptionsContentDAO) { + this.mcOptionsContentDAO = mcOptionsContentDAO; + } + + /** + * @return Returns the mcQueContentDAO. + */ + public IMcQueContentDAO getMcQueContentDAO() { + return mcQueContentDAO; + } + + /** + * @param mcQueContentDAO + * The mcQueContentDAO to set. + */ + public void setMcQueContentDAO(IMcQueContentDAO mcQueContentDAO) { + this.mcQueContentDAO = mcQueContentDAO; + } + + /** + * @return Returns the mcSessionDAO. + */ + public IMcSessionDAO getMcSessionDAO() { + return mcSessionDAO; + } + + /** + * @param mcSessionDAO + * The mcSessionDAO to set. + */ + public void setMcSessionDAO(IMcSessionDAO mcSessionDAO) { + this.mcSessionDAO = mcSessionDAO; + } + + /** + * @return Returns the mcUserDAO. + */ + public IMcUserDAO getMcUserDAO() { + return mcUserDAO; + } + + /** + * @param mcUserDAO + * The mcUserDAO to set. + */ + public void setMcUserDAO(IMcUserDAO mcUserDAO) { + this.mcUserDAO = mcUserDAO; + } + + /** + * @return Returns the mcUsrAttemptDAO. + */ + public IMcUsrAttemptDAO getMcUsrAttemptDAO() { + return mcUsrAttemptDAO; + } + + /** + * @param mcUsrAttemptDAO + * The mcUsrAttemptDAO to set. + */ + public void setMcUsrAttemptDAO(IMcUsrAttemptDAO mcUsrAttemptDAO) { + this.mcUsrAttemptDAO = mcUsrAttemptDAO; + } + + /** + * @return Returns the repositoryService. + */ + public IRepositoryService getRepositoryService() { + return repositoryService; + } + + /** + * @param repositoryService + * The repositoryService to set. + */ + public void setRepositoryService(IRepositoryService repositoryService) { + this.repositoryService = repositoryService; + } + + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } + + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } + + /** + * @return Returns the mcUploadedFileDAO. + */ + public IMcUploadedFileDAO getMcUploadedFileDAO() { + return mcUploadedFileDAO; + } + + /** + * @param mcUploadedFileDAO + * The mcUploadedFileDAO to set. + */ + public void setMcUploadedFileDAO(IMcUploadedFileDAO mcUploadedFileDAO) { + this.mcUploadedFileDAO = mcUploadedFileDAO; + } + + /** + * @return Returns the mcToolContentHandler. + */ + public IToolContentHandler getMcToolContentHandler() { + return mcToolContentHandler; + } + + /** + * @param mcToolContentHandler + * The mcToolContentHandler to set. + */ + public void setMcToolContentHandler(IToolContentHandler mcToolContentHandler) { + this.mcToolContentHandler = mcToolContentHandler; + } + + /** + * @return Returns the learnerService. + */ + public ILearnerService getLearnerService() { + return learnerService; + } + + /** + * @param learnerService + * The learnerService to set. + */ + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } + + public IExportToolContentService getExportContentService() { + return exportContentService; + } + + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } + + public MCOutputFactory getMcOutputFactory() { + return mcOutputFactory; + } + + public void setMcOutputFactory(MCOutputFactory mcOutputFactory) { + this.mcOutputFactory = mcOutputFactory; + } + + /* ===============Methods implemented from ToolContentImport102Manager =============== */ + + /** * Import the data for a 1.0.2 Chat */ - public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) - { - Date now = new Date(); - McContent toolContentObj = new McContent(); - toolContentObj.setContentInUse(false); - toolContentObj.setCreatedBy(user.getUserID().longValue()); - toolContentObj.setCreationDate(now); - toolContentObj.setDefineLater(false); - toolContentObj.setInstructions(WebUtil.convertNewlines((String)importValues.get(ToolContentImport102Manager.CONTENT_BODY))); - toolContentObj.setOfflineInstructions(null); - toolContentObj.setOnlineInstructions(null); - toolContentObj.setReflect(false); - toolContentObj.setReflectionSubject(null); - toolContentObj.setRunOffline(false); - toolContentObj.setTitle((String)importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); - - toolContentObj.setContent(null); - toolContentObj.setUpdateDate(now); - toolContentObj.setMcContentId(toolContentId); - toolContentObj.setQuestionsSequenced(false); - toolContentObj.setShowMarks(false); - toolContentObj.setRandomize(false); - toolContentObj.setDisplayAnswers(false); - // I can't find a use for setShowReport anywhere - toolContentObj.setShowReport(false); - - - try { - Boolean bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_Q_ALLOW_REDO); - toolContentObj.setRetries(bool!=null?bool:false); + public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { + Date now = new Date(); + McContent toolContentObj = new McContent(); + toolContentObj.setContentInUse(false); + toolContentObj.setCreatedBy(user.getUserID().longValue()); + toolContentObj.setCreationDate(now); + toolContentObj.setDefineLater(false); + toolContentObj.setInstructions(WebUtil.convertNewlines((String) importValues + .get(ToolContentImport102Manager.CONTENT_BODY))); + toolContentObj.setOfflineInstructions(null); + toolContentObj.setOnlineInstructions(null); + toolContentObj.setReflect(false); + toolContentObj.setReflectionSubject(null); + toolContentObj.setRunOffline(false); + toolContentObj.setTitle((String) importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); - bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_Q_FEEDBACK); - //toolContentObj.setShowFeedback(bool!=null?bool:false); + toolContentObj.setContent(null); + toolContentObj.setUpdateDate(now); + toolContentObj.setMcContentId(toolContentId); + toolContentObj.setQuestionsSequenced(false); + toolContentObj.setShowMarks(false); + toolContentObj.setRandomize(false); + toolContentObj.setDisplayAnswers(false); + // I can't find a use for setShowReport anywhere + toolContentObj.setShowReport(false); - Integer minPassMark = WDDXProcessor.convertToInteger(importValues, ToolContentImport102Manager.CONTENT_Q_MIN_PASSMARK); - toolContentObj.setPassMark(minPassMark != null ? minPassMark : new Integer(0)); - - // leave as empty, no need to set them to anything. - //setMcUploadedFiles(Set mcSessions); - //setMcSessions(Set mcSessions); - - mcContentDAO.saveMcContent(toolContentObj); + try { + Boolean bool = WDDXProcessor.convertToBoolean(importValues, + ToolContentImport102Manager.CONTENT_Q_ALLOW_REDO); + toolContentObj.setRetries(bool != null ? bool : false); - // set up questions - Vector questions = (Vector) importValues.get(CONTENT_Q_QUESTION_INFO); - if ( questions != null ) { - - Iterator iter = questions.iterator(); - while (iter.hasNext()) { - Hashtable questionMap = (Hashtable) iter.next(); - create102Question(questionMap, toolContentObj ); - } - - } - - } catch (WDDXProcessorConversionException e) { - logger.error("Unable to content for activity "+toolContentObj.getTitle()+"properly due to a WDDXProcessorConversionException.",e); - throw new ToolException("Invalid import data format for activity "+toolContentObj.getTitle()+"- WDDX caused an exception. Some data from the design will have been lost. See log for more details."); - } + bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_Q_FEEDBACK); + // toolContentObj.setShowFeedback(bool!=null?bool:false); - mcContentDAO.saveMcContent(toolContentObj); + Integer minPassMark = WDDXProcessor.convertToInteger(importValues, + ToolContentImport102Manager.CONTENT_Q_MIN_PASSMARK); + toolContentObj.setPassMark(minPassMark != null ? minPassMark : new Integer(0)); + + // leave as empty, no need to set them to anything. + // setMcUploadedFiles(Set mcSessions); + // setMcSessions(Set mcSessions); + + mcContentDAO.saveMcContent(toolContentObj); + + // set up questions + Vector questions = (Vector) importValues.get(ToolContentImport102Manager.CONTENT_Q_QUESTION_INFO); + if (questions != null) { + + Iterator iter = questions.iterator(); + while (iter.hasNext()) { + Hashtable questionMap = (Hashtable) iter.next(); + create102Question(questionMap, toolContentObj); + } + + } + + } catch (WDDXProcessorConversionException e) { + McServicePOJO.logger.error("Unable to content for activity " + toolContentObj.getTitle() + + "properly due to a WDDXProcessorConversionException.", e); + throw new ToolException( + "Invalid import data format for activity " + + toolContentObj.getTitle() + + "- WDDX caused an exception. Some data from the design will have been lost. See log for more details."); + } + + mcContentDAO.saveMcContent(toolContentObj); } + private void create102Question(Hashtable questionMap, McContent toolContentObj) + throws WDDXProcessorConversionException { + McQueContent question = new McQueContent(); + question.setDisplayOrder(WDDXProcessor.convertToInteger(questionMap, + ToolContentImport102Manager.CONTENT_Q_ORDER)); - private void create102Question( Hashtable questionMap, McContent toolContentObj) throws WDDXProcessorConversionException { - McQueContent question = new McQueContent(); - question.setDisplayOrder( WDDXProcessor.convertToInteger(questionMap, ToolContentImport102Manager.CONTENT_Q_ORDER) ); - - question.setFeedback((String)questionMap.get(CONTENT_Q_FEEDBACK)); - question.setQuestion(WebUtil.convertNewlines((String)questionMap.get(CONTENT_Q_QUESTION))); - - // In 1.0.2 all questions are implicitly assumed to be 1 and be of equal weight - question.setMark(new Integer(1)); - - String correctAnswer = (String)questionMap.get(CONTENT_Q_ANSWER); + question.setFeedback((String) questionMap.get(ToolContentImport102Manager.CONTENT_Q_FEEDBACK)); + question.setQuestion(WebUtil.convertNewlines((String) questionMap + .get(ToolContentImport102Manager.CONTENT_Q_QUESTION))); - Vector candidates = (Vector)questionMap.get(CONTENT_Q_CANDIDATES); - if ( candidates != null ) { - Iterator candIterator = candidates.iterator(); - while (candIterator.hasNext()) { - Hashtable candidate = (Hashtable) candIterator.next(); - String optionText = (String)candidate.get(CONTENT_Q_ANSWER); - if ( optionText != null && optionText.length() > 0 ) { - // 1.0.2 has a display order but 2.0 doesn't ToolContentImport102Manager.CONTENT_Q_ORDER - McOptsContent options = new McOptsContent(); - options.setCorrectOption(correctAnswer != null && correctAnswer.equals(optionText)); - options.setMcQueOptionText(optionText); - options.setMcQueContent(question); - question.getMcOptionsContents().add(options); - } - } + // In 1.0.2 all questions are implicitly assumed to be 1 and be of equal weight + question.setMark(new Integer(1)); + + String correctAnswer = (String) questionMap.get(ToolContentImport102Manager.CONTENT_Q_ANSWER); + + Vector candidates = (Vector) questionMap.get(ToolContentImport102Manager.CONTENT_Q_CANDIDATES); + if (candidates != null) { + Iterator candIterator = candidates.iterator(); + while (candIterator.hasNext()) { + Hashtable candidate = (Hashtable) candIterator.next(); + String optionText = (String) candidate.get(ToolContentImport102Manager.CONTENT_Q_ANSWER); + if (optionText != null && optionText.length() > 0) { + // 1.0.2 has a display order but 2.0 doesn't ToolContentImport102Manager.CONTENT_Q_ORDER + McOptsContent options = new McOptsContent(); + options.setCorrectOption(correctAnswer != null && correctAnswer.equals(optionText)); + options.setMcQueOptionText(optionText); + options.setMcQueContent(question); + question.getMcOptionsContents().add(options); } - - toolContentObj.getMcQueContents().add(question); - question.setMcContent(toolContentObj); - question.setMcContentId(toolContentObj.getUid()); + } + } + + toolContentObj.getMcQueContents().add(question); + question.setMcContent(toolContentObj); + question.setMcContentId(toolContentObj.getUid()); } - + /** Set the description, throws away the title value as this is not supported in 2.0 */ - public void setReflectiveData(Long toolContentId, String title, String description) - throws ToolException, DataMissingException { - - McContent toolContentObj = null; - if ( toolContentId != null ) { - toolContentObj=retrieveMc(toolContentId); - } - if ( toolContentObj == null ) { - throw new DataMissingException("Unable to set reflective data titled "+title - +" on activity toolContentId "+toolContentId - +" as the tool content does not exist."); - } - - toolContentObj.setReflect(true); - toolContentObj.setReflectionSubject(description); + public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, + DataMissingException { + + McContent toolContentObj = null; + if (toolContentId != null) { + toolContentObj = retrieveMc(toolContentId); + } + if (toolContentObj == null) { + throw new DataMissingException("Unable to set reflective data titled " + title + + " on activity toolContentId " + toolContentId + " as the tool content does not exist."); + } + + toolContentObj.setReflect(true); + toolContentObj.setReflectionSubject(description); } - - public List retrieveMcUploadedFiles(McContent mc) throws McApplicationException { - try { - return mcUploadedFileDAO.retrieveMcUploadedFiles(mc); - } - catch (DataAccessException e) { - throw new McApplicationException("Exception occured when lams is loading mc uploaded files: " - + e.getMessage(), - e); - } + try { + return mcUploadedFileDAO.retrieveMcUploadedFiles(mc); + } catch (DataAccessException e) { + throw new McApplicationException("Exception occured when lams is loading mc uploaded files: " + + e.getMessage(), e); + } } - - /** * adds a new entry to the uploaded files table */ public void persistFile(McContent content, McUploadedFile file) throws McApplicationException { - logger.debug("in persistFile: " + file); - logger.debug("in persistFile, content: " + content); - - content.getMcAttachments().add(file); - file.setMcContent(content); - mcContentDAO.saveOrUpdateMc(content); - logger.debug("persisted mcUploadedFile: " + file); + McServicePOJO.logger.debug("in persistFile: " + file); + McServicePOJO.logger.debug("in persistFile, content: " + content); + + content.getMcAttachments().add(file); + file.setMcContent(content); + mcContentDAO.saveOrUpdateMc(content); + McServicePOJO.logger.debug("persisted mcUploadedFile: " + file); } - - + /** * removes an entry from the uploaded files table */ public void removeFile(Long submissionId) throws McApplicationException { - mcUploadedFileDAO.removeUploadFile(submissionId); - logger.debug("removed mcUploadedFile: " + submissionId); + mcUploadedFileDAO.removeUploadFile(submissionId); + McServicePOJO.logger.debug("removed mcUploadedFile: " + submissionId); } - - public Long createNotebookEntry(Long id, Integer idType, String signature, - Integer userID, String entry) { - logger.debug("coreNotebookService: " + coreNotebookService); - return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); - } - - - + public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { + McServicePOJO.logger.debug("coreNotebookService: " + coreNotebookService); + return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); + } - public NotebookEntry getEntry(Long id, Integer idType, String signature, - Integer userID) { - - List list = coreNotebookService.getEntry(id, idType, signature, userID); - if (list == null || list.isEmpty()) { - return null; - } else { - return list.get(0); - } - } + public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID) { - - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); + List list = coreNotebookService.getEntry(id, idType, signature, userID); + if (list == null || list.isEmpty()) { + return null; + } else { + return list.get(0); } + } - + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } + /** * @return Returns the coreNotebookService. */ public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; + return coreNotebookService; } + /** - * @param coreNotebookService The coreNotebookService to set. + * @param coreNotebookService + * The coreNotebookService to set. */ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; + this.coreNotebookService = coreNotebookService; } - + /** * @return Returns the auditService. */ public IAuditService getAuditService() { - return auditService; + return auditService; } + /** - * @param auditService The auditService to set. + * @param auditService + * The auditService to set. */ public void setAuditService(IAuditService auditService) { - this.auditService = auditService; + this.auditService = auditService; } - - /** + + /** * @return Returns the MessageService. */ public MessageService getMessageService() { - return messageService; + return messageService; } + /** - * @param messageService The MessageService to set. + * @param messageService + * The MessageService to set. */ public void setMessageService(MessageService messageService) { - this.messageService = messageService; + this.messageService = messageService; } } \ No newline at end of file Index: lams_tool_laqa/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/conf/language/lams/ApplicationResources.properties,v diff -u -r1.24 -r1.25 --- lams_tool_laqa/conf/language/lams/ApplicationResources.properties 11 Mar 2009 14:29:39 -0000 1.24 +++ lams_tool_laqa/conf/language/lams/ApplicationResources.properties 2 Jul 2009 12:59:37 -0000 1.25 @@ -189,8 +189,7 @@ error.condition.duplicated.name =Duplicated name. Please choose unique one. error.condition.no.questions.selected =There are no questions selected. Please select at least one. error.condition =Error creating condition. -output.desc.text.search.output.definition.qa =Answers contain certain words -text.search.output.definition.qa.default.condition =First answer contains word "LAMS" + textsearch.heading =Answers that... textsearch.all.words =have all these words: textsearch.phrase =have this exact wording or phrase: @@ -240,4 +239,9 @@ error.noStudentActivity =Sorry, the report can not be generated.
No learner has attempted the activity yet. msg.planner.clear.entry=Clear question content (will be removed from activity after save) + +output.desc.user.answers.output.definition.qa =Answers contain certain words +user.answers.output.definition.qa.default.condition =First answer contains word "LAMS" +output.desc.all.answers.output.definition.qa =All users' answers +output.desc.questions.output.definition.qa =Questions asked #======= End labels: Exported 232 labels for en AU ===== Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java,v diff -u -r1.82 -r1.83 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 4 Nov 2008 00:41:19 -0000 1.82 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 2 Jul 2009 12:59:36 -0000 1.83 @@ -279,8 +279,10 @@ public static final String PARAM_ORDER_ID = "orderId"; public static final String ATTR_DELETED_CONDITION_LIST = "deletedConditionList"; public static final int QUESTION_CUTOFF_INDEX = 40; - public static final String TEXT_SEARCH_DEFINITION_NAME = "text.search.output.definition.qa"; - public static final String TEXT_SEARCH_DEFAULT_CONDITION_DISPLAY_NAME_KEY = "text.search.output.definition.qa.default.condition"; + public static final String USER_ANSWERS_DEFINITION_NAME = "user.answers.output.definition.qa"; + public static final String USER_ANSWERS_DEFAULT_CONDITION_DISPLAY_NAME_KEY = "user.answers.output.definition.qa.default.condition"; + public static final String GROUP_ANSWERS_DEFINITION_NAME = "group.answers.output.definition.qa"; + public static final String QUESTIONS_DEFINITION_NAME = "questions.output.definition.qa"; public static final String ATTR_WIZARD_CATEGORIES = "wizardCategories"; public static final String ATTR_WIZARD_ENABLED = "wizardEnabled"; } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java,v diff -u -r1.9 -r1.10 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java 19 Feb 2009 04:25:02 -0000 1.9 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java 2 Jul 2009 12:59:36 -0000 1.10 @@ -30,6 +30,7 @@ import java.util.SortedMap; import java.util.TreeMap; +import org.apache.commons.lang.StringUtils; import org.lamsfoundation.lams.learningdesign.BranchCondition; import org.lamsfoundation.lams.tool.OutputFactory; import org.lamsfoundation.lams.tool.ToolOutput; @@ -44,8 +45,9 @@ import org.lamsfoundation.lams.tool.qa.QaUsrResp; /** - * Output factory for Q&A tool. Currently it provides only one type of output - a user answers represented by an array - * of strings (output type "OUTPUT_COMPLEX"). + * Output factory for Q&A tool. For conditions it provides only one type of output - a user answers represented by an + * array of strings (output type "OUTPUT_COMPLEX"). For data flow between tools it provides all users' answers (from + * current group) and questions asked. * * @author Marcin Cieslak */ @@ -55,24 +57,39 @@ * {@inheritDoc} */ @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); if (toolContentObject != null) { - ToolOutputDefinition allAnswersDefinition = buildComplexOutputDefinition(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME); QaContent qaContent = (QaContent) toolContentObject; - // adding all existing conditions - allAnswersDefinition.setDefaultConditions(new ArrayList(qaContent.getConditions())); - // if no conditions were created in the tool instance, a default condition is added; - if (allAnswersDefinition.getDefaultConditions().isEmpty() && !qaContent.getQaQueContents().isEmpty()) { + // Different definitions are provided, depending how the output will be used + switch (definitionType) { + case ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION: { + ToolOutputDefinition userAnswersDefinition = buildComplexOutputDefinition(QaAppConstants.USER_ANSWERS_DEFINITION_NAME); - QaCondition defaultCondition = createDefaultComplexCondition(qaContent); - qaContent.getConditions().add(defaultCondition); + // adding all existing conditions + userAnswersDefinition.setDefaultConditions(new ArrayList(qaContent.getConditions())); + // if no conditions were created in the tool instance, a default condition is added; + if (userAnswersDefinition.getDefaultConditions().isEmpty() && !qaContent.getQaQueContents().isEmpty()) { - allAnswersDefinition.getDefaultConditions().add(defaultCondition); + QaCondition defaultCondition = createDefaultComplexUserAnswersCondition(qaContent); + qaContent.getConditions().add(defaultCondition); + + userAnswersDefinition.getDefaultConditions().add(defaultCondition); + } + userAnswersDefinition.setShowConditionNameOnly(true); + definitionMap.put(QaAppConstants.USER_ANSWERS_DEFINITION_NAME, userAnswersDefinition); } - allAnswersDefinition.setShowConditionNameOnly(true); - definitionMap.put(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, allAnswersDefinition); + break; + case ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_DATA_FLOW: { + ToolOutputDefinition groupAnswersDefinition = buildComplexOutputDefinition(QaAppConstants.GROUP_ANSWERS_DEFINITION_NAME); + definitionMap.put(QaAppConstants.GROUP_ANSWERS_DEFINITION_NAME, groupAnswersDefinition); + + ToolOutputDefinition questionsDefinition = buildComplexOutputDefinition(QaAppConstants.QUESTIONS_DEFINITION_NAME); + definitionMap.put(QaAppConstants.QUESTIONS_DEFINITION_NAME, questionsDefinition); + } + break; + } } return definitionMap; @@ -84,39 +101,39 @@ */ public SortedMap getToolOutput(List names, IQaService qaService, Long toolSessionId, Long learnerId) { - + // result TreeMap outputs = new TreeMap(); - // cached tool output for all text search conditions - ToolOutput allAnswersOutput = null; + // tool output cache + TreeMap baseOutputs = new TreeMap(); + if (names == null) { // output will be set for all the existing conditions QaContent qaContent = qaService.getQaContentBySessionId(toolSessionId); Set conditions = qaContent.getConditions(); for (QaCondition condition : conditions) { String name = condition.getName(); - if (isTextSearchConditionName(name) && allAnswersOutput != null) { - outputs.put(name, allAnswersOutput); + String[] nameParts = splitConditionName(name); + + if (baseOutputs.get(nameParts[0]) != null) { + outputs.put(name, baseOutputs.get(nameParts[0])); } else { ToolOutput output = getToolOutput(name, qaService, toolSessionId, learnerId); if (output != null) { outputs.put(name, output); - if (isTextSearchConditionName(name)) { - allAnswersOutput = output; - } + baseOutputs.put(nameParts[0], output); } } } } else { for (String name : names) { - if (isTextSearchConditionName(name) && allAnswersOutput != null) { - outputs.put(name, allAnswersOutput); + String[] nameParts = splitConditionName(name); + if (baseOutputs.get(nameParts[0]) != null) { + outputs.put(name, baseOutputs.get(nameParts[0])); } else { ToolOutput output = getToolOutput(name, qaService, toolSessionId, learnerId); if (output != null) { outputs.put(name, output); - if (isTextSearchConditionName(name)) { - allAnswersOutput = output; - } + baseOutputs.put(nameParts[0], output); } } } @@ -126,7 +143,8 @@ } public ToolOutput getToolOutput(String name, IQaService qaService, Long toolSessionId, Long learnerId) { - if (isTextSearchConditionName(name)) { + String[] nameParts = splitConditionName(name); + if (QaAppConstants.USER_ANSWERS_DEFINITION_NAME.equals(nameParts[0])) { // user answers are loaded from the DB and array of strings is created QaSession session = qaService.retrieveQaSession(toolSessionId); @@ -145,7 +163,68 @@ answers[question.getDisplayOrder() - 1] = answer; } } - return new ToolOutput(name, getI18NText(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, true), answers, false); + return new ToolOutput(name, getI18NText(QaAppConstants.USER_ANSWERS_DEFINITION_NAME, true), answers, false); + } else if (QaAppConstants.GROUP_ANSWERS_DEFINITION_NAME.equals(nameParts[0])) { + // all users' answers are loaded from the DB and array of strings is created + + QaSession session = qaService.retrieveQaSession(toolSessionId); + QaContent qaContent = session.getQaContent(); + Set questions = qaContent.getQaQueContents(); + Set users = session.getQaQueUsers(); + String[] answers = new String[questions.size() * users.size()]; + int answerCount = 0; + for (QaQueContent question : questions) { + int userIndex = 0; + for (QaQueUsr user : users) { + List attempts = null; + if (user != null) { + attempts = qaService.getAttemptsForUserAndQuestionContent(user.getUid(), question.getUid()); + } + if (attempts != null && !attempts.isEmpty()) { + // only the last attempt is taken into consideration + String answer = attempts.get(attempts.size() - 1).getAnswer(); + if (!StringUtils.isBlank(answer)) { + // check for duplicate answers + boolean duplicate = false; + for (String previousAnswer : answers) { + if (answer.equalsIgnoreCase(previousAnswer)) { + duplicate = true; + break; + } + } + if (!duplicate) { + answers[question.getDisplayOrder() - 1 + userIndex * questions.size()] = answer; + answerCount++; + } + } + } + userIndex++; + } + } + if (answerCount < answers.length) { + String[] trimmedAnswers = new String[answerCount]; + int answerIndex = 0; + for (String answer : answers) { + if (answer != null) { + trimmedAnswers[answerIndex++] = answer; + } + } + answers = trimmedAnswers; + } + + return new ToolOutput(name, getI18NText(QaAppConstants.GROUP_ANSWERS_DEFINITION_NAME, true), answers, false); + } else if (QaAppConstants.QUESTIONS_DEFINITION_NAME.equals(nameParts[0])) { + // Questions asked in this Q&A activity + QaSession session = qaService.retrieveQaSession(toolSessionId); + QaContent qaContent = session.getQaContent(); + Set questions = qaContent.getQaQueContents(); + String[] questionArray = new String[questions.size()]; + int questionIndex = 0; + for (QaQueContent question : questions) { + questionArray[questionIndex++] = question.getQuestion(); + } + return new ToolOutput(name, getI18NText(QaAppConstants.QUESTIONS_DEFINITION_NAME, true), questionArray, + false); } return null; } @@ -155,33 +234,28 @@ return super.splitConditionName(conditionName); } - protected String buildConditionName(String uniquePart) { - return super.buildConditionName(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, uniquePart); + protected String buildUserAnswersConditionName(String uniquePart) { + return super.buildConditionName(QaAppConstants.USER_ANSWERS_DEFINITION_NAME, uniquePart); } - private boolean isTextSearchConditionName(String name) { - return name != null && name.startsWith(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME); - } - /** - * Creates a default condition so teachers know how to use complex - * conditions for this tool. + * Creates a default condition so teachers know how to use complex conditions for this tool. * * @param qaContent * content of the tool * @return default Q&A condition */ - protected QaCondition createDefaultComplexCondition(QaContent qaContent) { + protected QaCondition createDefaultComplexUserAnswersCondition(QaContent qaContent) { if (qaContent.getQaQueContents().isEmpty()) { return null; } Set questions = new HashSet(); questions.add((QaQueContent) qaContent.getQaQueContents().iterator().next()); - String name = buildConditionName(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, qaContent.getQaContentId() + String name = buildConditionName(QaAppConstants.USER_ANSWERS_DEFINITION_NAME, qaContent.getQaContentId() .toString()); // Default condition checks if the first answer contains word "LAMS" return new QaCondition(null, null, 1, name, getI18NText( - QaAppConstants.TEXT_SEARCH_DEFAULT_CONDITION_DISPLAY_NAME_KEY, false), "LAMS", null, null, null, + QaAppConstants.USER_ANSWERS_DEFAULT_CONDITION_DISPLAY_NAME_KEY, false), "LAMS", null, null, null, questions); } } \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java,v diff -u -r1.88 -r1.89 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 16 Mar 2009 05:56:00 -0000 1.88 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 2 Jul 2009 12:59:37 -0000 1.89 @@ -49,7 +49,6 @@ import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; -import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; @@ -97,19 +96,15 @@ import org.springframework.dao.DataAccessException; /** - * The POJO implementation of Survey service. All business logics of survey tool - * are implemented in this class. It translate the request from presentation - * layer and perform approporiate database operation. + * The POJO implementation of Survey service. All business logics of survey tool are implemented in this class. It + * translate the request from presentation layer and perform approporiate database operation. * - * Two construtors are provided in this class. The constuctor with Hibernate - * session object allows survey tool to handle long run application transaction. - * The developer can store Hibernate session in http session and pass across - * different http request. This implementation also make the testing out side - * JBoss container much easier. + * Two construtors are provided in this class. The constuctor with Hibernate session object allows survey tool to handle + * long run application transaction. The developer can store Hibernate session in http session and pass across different + * http request. This implementation also make the testing out side JBoss container much easier. * - * Every method is implemented as a Hibernate session transaction. It open an - * new persistent session or connect to existing persistent session in the - * begining and it close or disconnect to the persistent session in the end. + * Every method is implemented as a Hibernate session transaction. It open an new persistent session or connect to + * existing persistent session in the begining and it close or disconnect to the persistent session in the end. * * @author Ozgur Demirtas * @@ -657,9 +652,8 @@ } /** - * checks the paramter content in the user responses table boolean - * studentActivityOccurredGlobal(QaContent qaContent) throws - * QaApplicationException + * checks the paramter content in the user responses table boolean studentActivityOccurredGlobal(QaContent + * qaContent) throws QaApplicationException * * @param qa * @return boolean @@ -680,8 +674,8 @@ } /** - * counts the number of sessions marked INCOMPLETE for a content int - * countIncompleteSession(QaContent qa) throws QaApplicationException + * counts the number of sessions marked INCOMPLETE for a content int countIncompleteSession(QaContent qa) throws + * QaApplicationException * * @param qa * @return int @@ -695,13 +689,11 @@ } /** - * checks the parameter content in the tool sessions table. find out if any - * student has ever used (logged in through the url and replied) to this - * content return true even if you have only one content passed as parameter - * referenced in the tool sessions table + * checks the parameter content in the tool sessions table. find out if any student has ever used (logged in through + * the url and replied) to this content return true even if you have only one content passed as parameter referenced + * in the tool sessions table * - * boolean studentActivityOccurred(QaContent qa) throws - * QaApplicationException + * boolean studentActivityOccurred(QaContent qa) throws QaApplicationException * * @param qa * @return boolean @@ -718,15 +710,12 @@ } /** - * gets called ONLY when a lesson is being created in monitoring mode. - * Should create the new content(toContent) based on what the author has - * created her content with. In q/a tool's case that is content + question's - * content but not user responses. The deep copy should go only as far as - * default content (or author created content) already goes. - * ToolContentManager CONTRACT + * gets called ONLY when a lesson is being created in monitoring mode. Should create the new content(toContent) + * based on what the author has created her content with. In q/a tool's case that is content + question's content + * but not user responses. The deep copy should go only as far as default content (or author created content) + * already goes. ToolContentManager CONTRACT * - * similar to public void removeToolContent(Long toolContentID) gets called - * by Container+Flash + * similar to public void removeToolContent(Long toolContentID) gets called by Container+Flash * */ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException @@ -776,7 +765,7 @@ fromContent = qaDAO.loadQaById(fromContentId.longValue()); } if (fromContentId.equals(defaultContentId) && fromContent != null && fromContent.getConditions().isEmpty()) { - fromContent.getConditions().add(getQaOutputFactory().createDefaultComplexCondition(fromContent)); + fromContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(fromContent)); } QaContent toContent = QaContent.newInstance(qaToolContentHandler, fromContent, toContentId); if (toContent == null) { @@ -799,16 +788,15 @@ } /** - * setAsForceCompleteSession(Long toolSessionId) throws - * QaApplicationException update the tool session status to COMPLETE for - * this tool session + * setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException update the tool session status to + * COMPLETE for this tool session * * @param Long * toolSessionId */ public void setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException { - QaServicePOJO.logger.debug("Request for setAsForceCompleteSession has come for toolSessionId: " - + toolSessionId); + QaServicePOJO.logger + .debug("Request for setAsForceCompleteSession has come for toolSessionId: " + toolSessionId); QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue()); qaSession.setSession_status(QaSession.COMPLETED); @@ -817,8 +805,8 @@ } /** - * setAsForceComplete(Long userId) throws QaApplicationException update the - * tool session status to COMPLETE for this user + * setAsForceComplete(Long userId) throws QaApplicationException update the tool session status to COMPLETE for this + * user * * @param userId */ @@ -857,8 +845,7 @@ } /** - * setAsDefineLater(Long toolContentID) throws DataMissingException, - * ToolException + * setAsDefineLater(Long toolContentID) throws DataMissingException, ToolException * * @param toolContentID * return void @@ -879,8 +866,8 @@ } /** - * setAsRunOffline(Long toolContentID) throws DataMissingException, - * ToolException set the runOffline to true on this content + * setAsRunOffline(Long toolContentID) throws DataMissingException, ToolException set the runOffline to true on this + * content * * @param toolContentID * return void @@ -902,13 +889,12 @@ /** * - * removeToolContent(Long toolContentID) gets automatically called only in - * monitoring mode when the author chooses to delete a lesson. + * removeToolContent(Long toolContentID) gets automatically called only in monitoring mode when the author chooses + * to delete a lesson. * - * The idea is to remove content + its relevant sessions + in q/a tools's - * case the question's content from the db. ToolContentManager CONTRACT this - * gets called automatically by Flash when a deletion is detected in the - * tool interface. + * The idea is to remove content + its relevant sessions + in q/a tools's case the question's content from the db. + * ToolContentManager CONTRACT this gets called automatically by Flash when a deletion is detected in the tool + * interface. */ public void removeToolContent(Long toolContentID) { QaServicePOJO.logger.debug("start of removeToolContent with toolContentID: " + toolContentID); @@ -963,9 +949,8 @@ } /** - * removeToolContent(Long toolContentID, boolean removeSessionData) throws - * SessionDataExistsException, ToolException Will need an update on the core - * tool signature: reason : when qaContent is null throw an exception + * removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, ToolException + * Will need an update on the core tool signature: reason : when qaContent is null throw an exception * */ public void removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, @@ -1014,8 +999,7 @@ } /** - * Export the XML fragment for the tool's content, along with any files - * needed for the content. + * Export the XML fragment for the tool's content, along with any files needed for the content. * * @throws DataMissingException * if no tool content matches the toolSessionId @@ -1029,7 +1013,7 @@ long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); toolContentObj = retrieveQa(defaultToolContentId); if (toolContentObj != null && toolContentObj.getConditions().isEmpty()) { - toolContentObj.getConditions().add(getQaOutputFactory().createDefaultComplexCondition(toolContentObj)); + toolContentObj.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(toolContentObj)); } } if (toolContentObj == null) { @@ -1067,8 +1051,7 @@ } /** - * Import the XML fragment for the tool's content, along with any files - * needed for the content. + * Import the XML fragment for the tool's content, along with any files needed for the content. * * @throws ToolException * if any other error occurs @@ -1110,31 +1093,29 @@ } /** - * Get the definitions for possible output for an activity, based on the - * toolContentId. These may be definitions that are always available for the - * tool (e.g. number of marks for Multiple Choice) or a custom definition - * created for a particular activity such as the answer to the third - * question contains the word Koala and hence the need for the toolContentId + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId * - * @return SortedMap of ToolOutputDefinitions with the key being the name of - * each definition + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { QaContent qaContent = qaDAO.getQaById(toolContentId); if (qaContent == null) { long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); qaContent = retrieveQa(defaultToolContentId); if (qaContent != null && qaContent.getConditions().isEmpty()) { - qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexCondition(qaContent)); + qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(qaContent)); } } - return getQaOutputFactory().getToolOutputDefinitions(qaContent); + return getQaOutputFactory().getToolOutputDefinitions(qaContent, definitionType); } /** - * it is possible that the tool session id already exists in the tool - * sessions table as the users from the same session are involved. - * existsSession(long toolSessionId) + * it is possible that the tool session id already exists in the tool sessions table as the users from the same + * session are involved. existsSession(long toolSessionId) * * @param toolSessionId * @return boolean @@ -1154,12 +1135,10 @@ } /** - * createToolSession(Long toolSessionId,String toolSessionName, Long - * toolContentID) throws ToolException ToolSessionManager CONTRACT : creates - * a tool session with the incoming toolSessionId in the tool session table + * createToolSession(Long toolSessionId,String toolSessionName, Long toolContentID) throws ToolException + * ToolSessionManager CONTRACT : creates a tool session with the incoming toolSessionId in the tool session table * - * gets called only in the Learner mode. All the learners in the same group - * have the same toolSessionId. + * gets called only in the Learner mode. All the learners in the same group have the same toolSessionId. * */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentID) throws ToolException { @@ -1210,7 +1189,7 @@ qaContent = qaDAO.loadQaById(toolContentID.longValue()); if (qaContent.getConditions().isEmpty()) { - qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexCondition(qaContent)); + qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(qaContent)); } } @@ -1261,9 +1240,8 @@ /** * Complete the tool session. * - * Part of the ToolSessionManager contract. Called by controller service to - * force complete the qa session, or by the web front end to complete the qa - * session + * Part of the ToolSessionManager contract. Called by controller service to force complete the qa session, or by the + * web front end to complete the qa session * */ public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { @@ -1318,8 +1296,8 @@ /** * Get the tool output for the given tool output names. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) */ public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { return getQaOutputFactory().getToolOutput(names, this, toolSessionId, learnerId); @@ -1328,8 +1306,8 @@ /** * Get the tool output for the given tool output name. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) */ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return getQaOutputFactory().getToolOutput(name, this, toolSessionId, learnerId); @@ -1361,12 +1339,11 @@ } /** - * This method verifies the credentials of the SubmitFiles Tool and gives it - * the Ticket to login and access the Content Repository. + * This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket to login and + * access the Content Repository. * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. * * @return ITicket The ticket for repostory access * @throws SubmitFilesException @@ -1386,8 +1363,8 @@ } /** - * This method deletes the content with the given uuid and - * versionID from the content repository + * This method deletes the content with the given uuid and versionID from the content + * repository * * @param uuid * The uuid of the node to be deleted @@ -1708,8 +1685,7 @@ } /** - * Set the description, throws away the title value as this is not supported - * in 2.0 + * Set the description, throws away the title value as this is not supported in 2.0 */ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { @@ -1793,7 +1769,7 @@ } } } while (uniqueNumber == null); - return getQaOutputFactory().buildConditionName(uniqueNumber); + return getQaOutputFactory().buildUserAnswersConditionName(uniqueNumber); } public void deleteCondition(QaCondition condition) { @@ -1803,7 +1779,7 @@ } public QaCondition createDefaultComplexCondition(QaContent qaContent) { - return getQaOutputFactory().createDefaultComplexCondition(qaContent); + return getQaOutputFactory().createDefaultComplexUserAnswersCondition(qaContent); } /** @@ -1835,8 +1811,7 @@ } /** - * Saves the entire set of QaWizardCategories (including the child cognitive - * skills and questions) + * Saves the entire set of QaWizardCategories (including the child cognitive skills and questions) * * @param categories */ Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java,v diff -u -r1.60 -r1.61 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java 10 Oct 2008 00:37:15 -0000 1.60 +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java 2 Jul 2009 13:03:47 -0000 1.61 @@ -946,7 +946,8 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { return new TreeMap(); } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapOutputFactory.java,v diff -u -r1.2 -r1.3 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapOutputFactory.java 12 May 2009 01:39:01 -0000 1.2 +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapOutputFactory.java 2 Jul 2009 13:03:27 -0000 1.3 @@ -42,7 +42,7 @@ protected final static String OUTPUT_NAME_LEARNER_NUM_NODES = "number.of.nodes"; @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java,v diff -u -r1.6 -r1.7 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java 12 May 2009 01:39:01 -0000 1.6 +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java 2 Jul 2009 13:03:27 -0000 1.7 @@ -315,18 +315,20 @@ MindmapNode mindmapNode = (MindmapNode) iterator.next(); String mindmapUserName = null; - if (mindmapNode.getUser() == null) + if (mindmapNode.getUser() == null) { mindmapUserName = getMindmapMessageService().getMessage("node.instructor.label"); - else + } else { mindmapUserName = mindmapNode.getUser().getFirstName() + " " + mindmapNode.getUser().getLastName(); + } NodeModel nodeModel = null; if (mindmapUser != null) { int edit = 1; - if (mindmapNode.getUser() == mindmapUser) + if (mindmapNode.getUser() == mindmapUser) { edit = 1; - else + } else { edit = 0; + } nodeModel = new NodeModel(new NodeConceptModel(mindmapNode.getUniqueId(), mindmapNode.getText(), mindmapNode.getColor(), mindmapUserName, edit)); @@ -346,26 +348,28 @@ public void getChildMindmapNodes(List branches, MindmapNode rootMindmapNode, MindmapUser mindmapUser, Mindmap mindmap, MindmapSession mindmapSession) { for (Iterator iterator = branches.iterator(); iterator.hasNext();) { - NodeModel nodeModel = (NodeModel) iterator.next(); + NodeModel nodeModel = iterator.next(); NodeConceptModel nodeConceptModel = nodeModel.getConcept(); // saving branch List curMindmapNodeList = null; - if (mindmapUser == null) + if (mindmapUser == null) { curMindmapNodeList = getMindmapNodeByUniqueId(nodeConceptModel.getId(), mindmap.getUid()); - else + } else { curMindmapNodeList = getMindmapNodeByUniqueIdMindmapIdUserId(nodeConceptModel.getId(), mindmap.getUid(), mindmapUser.getUid()); + } MindmapNode currentMindmapNode = null; if (curMindmapNodeList != null && curMindmapNodeList.size() > 0) { currentMindmapNode = (MindmapNode) curMindmapNodeList.get(0); } - this.nodesToDeleteCondition += " and uniqueId <> " + nodeConceptModel.getId(); + nodesToDeleteCondition += " and uniqueId <> " + nodeConceptModel.getId(); currentMindmapNode = saveMindmapNode(currentMindmapNode, rootMindmapNode, nodeConceptModel.getId(), nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap, mindmapSession); // if there are child nodes, redo for every child - if (nodeModel.getBranch() != null) + if (nodeModel.getBranch() != null) { getChildMindmapNodes(nodeModel.getBranch(), currentMindmapNode, mindmapUser, mindmap, mindmapSession); + } } } @@ -416,9 +420,9 @@ * Export the XML fragment for the tool's content, along with any files needed for the content. * * @throws DataMissingException - * if no tool content matches the toolSessionId + * if no tool content matches the toolSessionId * @throws ToolException - * if any other error occurs + * if any other error occurs */ public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { Mindmap mindmap = mindmapDAO.getByContentId(toolContentId); @@ -471,7 +475,7 @@ * Import the XML fragment for the tool's content, along with any files needed for the content. * * @throws ToolException - * if any other error occurs + * if any other error occurs */ public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, String toVersion) throws ToolException { @@ -525,12 +529,13 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { Mindmap mindmap = getMindmapDAO().getByContentId(toolContentId); if (mindmap == null) { mindmap = getDefaultContent(); } - return getMindmapOutputFactory().getToolOutputDefinitions(mindmap); + return getMindmapOutputFactory().getToolOutputDefinitions(mindmap, definitionType); } /* IMindmapService Methods */ @@ -902,11 +907,11 @@ public List getMindmapNodeByParentId(Long parentId, Long mindmapId) { return mindmapNodeDAO.getMindmapNodeByParentId(parentId, mindmapId); } - + public List getMindmapNodeByParentIdMindmapIdSessionId(Long parentId, Long mindmapId, Long sessionId) { return mindmapNodeDAO.getMindmapNodeByParentIdMindmapIdSessionId(parentId, mindmapId, sessionId); } - + public List getMindmapNodeByUniqueId(Long uniqueId, Long mindmapId) { return mindmapNodeDAO.getMindmapNodeByUniqueId(uniqueId, mindmapId); } @@ -928,7 +933,7 @@ } public String getNodesToDeleteCondition() { - return this.nodesToDeleteCondition; + return nodesToDeleteCondition; } public void setNodesToDeleteCondition(String nodesToDeleteCondition) { Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java,v diff -u -r1.43 -r1.44 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 5 Sep 2007 08:07:11 -0000 1.43 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 2 Jul 2009 13:00:33 -0000 1.44 @@ -68,1183 +68,1049 @@ import org.lamsfoundation.lams.util.WebUtil; import org.springframework.dao.DataAccessException; - - /** * An implementation of the NoticeboardService interface. * * As a requirement, all LAMS tool's service bean must implement ToolContentManager and ToolSessionManager. + * * @author mtruong - * + * */ -public class NoticeboardServicePOJO implements INoticeboardService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager { +public class NoticeboardServicePOJO implements INoticeboardService, ToolContentManager, ToolSessionManager, + ToolContentImport102Manager { - private NoticeboardContent nbContent; - private INoticeboardContentDAO nbContentDAO=null; - - private NoticeboardSession nbSession; - private INoticeboardSessionDAO nbSessionDAO = null; - - private ILearnerService learnerService; - private ILamsToolService toolService; - - private NoticeboardUser nbUser; - private INoticeboardUserDAO nbUserDAO=null; - - private INoticeboardAttachmentDAO nbAttachmentDAO = null; - private IToolContentHandler nbToolContentHandler = null; - - private IExportToolContentService exportContentService; - private static Logger log = Logger.getLogger(NoticeboardServicePOJO.class); - - private ICoreNotebookService coreNotebookService; + private NoticeboardContent nbContent; + private INoticeboardContentDAO nbContentDAO = null; - - /* ============================================================================== - * Methods for access to NoticeboardContent objects - * ============================================================================== - */ - - - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboard(Long) - */ - public NoticeboardContent retrieveNoticeboard(Long nbContentId) throws NbApplicationException - { - if (nbContentId == null) - { - String error = "Unable to continue. The tool content id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - nbContent = nbContentDAO.findNbContentById(nbContentId); - - } - catch (DataAccessException e) - { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " - + e.getMessage(), - e); - } - - return nbContent; + private NoticeboardSession nbSession; + private INoticeboardSessionDAO nbSessionDAO = null; + + private ILearnerService learnerService; + private ILamsToolService toolService; + + private NoticeboardUser nbUser; + private INoticeboardUserDAO nbUserDAO = null; + + private INoticeboardAttachmentDAO nbAttachmentDAO = null; + private IToolContentHandler nbToolContentHandler = null; + + private IExportToolContentService exportContentService; + private static Logger log = Logger.getLogger(NoticeboardServicePOJO.class); + + private ICoreNotebookService coreNotebookService; + + /* + * ============================================================================== Methods for access to + * NoticeboardContent objects ============================================================================== + */ + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboard(Long) + */ + public NoticeboardContent retrieveNoticeboard(Long nbContentId) throws NbApplicationException { + if (nbContentId == null) { + String error = "Unable to continue. The tool content id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardBySessionID(Long) - */ - public NoticeboardContent retrieveNoticeboardBySessionID(Long nbSessionId) - { - if (nbSessionId == null) - { - String error = "Unable to continue. The tool session id is missing"; - log.error(error); - throw new NbApplicationException(error); + + try { + nbContent = nbContentDAO.findNbContentById(nbContentId); + + } catch (DataAccessException e) { + throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " + + e.getMessage(), e); + } + + return nbContent; + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardBySessionID(Long) + */ + public NoticeboardContent retrieveNoticeboardBySessionID(Long nbSessionId) { + if (nbSessionId == null) { + String error = "Unable to continue. The tool session id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); + } + + try { + nbContent = nbContentDAO.getNbContentBySession(nbSessionId); + } catch (DataAccessException e) { + throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " + + e.getMessage(), e); + } + + return nbContent; + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) + */ + public void saveNoticeboard(NoticeboardContent nbContent) { + try { + if (nbContent.getUid() == null) { + nbContentDAO.saveNbContent(nbContent); + } else { + nbContentDAO.updateNbContent(nbContent); } - - try - { - nbContent = nbContentDAO.getNbContentBySession(nbSessionId); - } - catch (DataAccessException e) - { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " - + e.getMessage(), - e); - } - - return nbContent; + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to save the noticeboard content object: " + + e.getMessage(), e); } - - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ - public void saveNoticeboard(NoticeboardContent nbContent) - { - try - { - if ( nbContent.getUid() == null ) { - nbContentDAO.saveNbContent(nbContent); - } else { - nbContentDAO.updateNbContent(nbContent); - } - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to save the noticeboard content object: " - + e.getMessage(), e); - } + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboardSessions(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) + */ + public void removeNoticeboardSessionsFromContent(NoticeboardContent nbContent) { + try { + nbContent.getNbSessions().clear(); + // updateNoticeboard(nbContent); + + nbContentDAO.removeNbSessions(nbContent); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove the sessions associated with this noticeboard content object: " + + e.getMessage(), e); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboardSessions(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ - public void removeNoticeboardSessionsFromContent(NoticeboardContent nbContent) - { - try - { - nbContent.getNbSessions().clear(); - //updateNoticeboard(nbContent); - - nbContentDAO.removeNbSessions(nbContent); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove the sessions associated with this noticeboard content object: " - + e.getMessage(), e); - } - + + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) + */ + public void removeNoticeboard(Long nbContentId) { + if (nbContentId == null) { + String error = "Unable to continue. The tool content id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /** + + try { + nbContentDAO.removeNoticeboard(nbContentId); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove this noticeboard content object: " + + e.getMessage(), e); + } + } + + /** * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ - public void removeNoticeboard(Long nbContentId) - { - if (nbContentId == null) - { - String error = "Unable to continue. The tool content id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - nbContentDAO.removeNoticeboard(nbContentId); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard content object: " - + e.getMessage(), e); - } + public void removeNoticeboard(NoticeboardContent nbContent) { + try { + nbContentDAO.removeNoticeboard(nbContent); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove this noticeboard content object: " + + e.getMessage(), e); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ - public void removeNoticeboard(NoticeboardContent nbContent) - { - try - { - nbContentDAO.removeNoticeboard(nbContent); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard content object: " - + e.getMessage(), e); - } + } + + /* + * ============================================================================== Methods for access to + * NoticeboardSession objects ============================================================================== + */ + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardSession(Long) + */ + public NoticeboardSession retrieveNoticeboardSession(Long nbSessionId) { + if (nbSessionId == null) { + String error = "Unable to continue. The tool session id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - - /* ============================================================================== - * Methods for access to NoticeboardSession objects - * ============================================================================== - */ - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardSession(Long) - */ - public NoticeboardSession retrieveNoticeboardSession(Long nbSessionId) - { - if (nbSessionId == null) - { - String error = "Unable to continue. The tool session id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - nbSession = nbSessionDAO.findNbSessionById(nbSessionId); - } - catch (DataAccessException e) - { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard session object: " - + e.getMessage(), - e); - } - - return nbSession; + + try { + nbSession = nbSessionDAO.findNbSessionById(nbSessionId); + } catch (DataAccessException e) { + throw new NbApplicationException( + "An exception has occured when trying to retrieve noticeboard session object: " + e.getMessage(), e); } - - - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ - public void saveNoticeboardSession(NoticeboardSession nbSession) - { - try - { - NoticeboardContent content = nbSession.getNbContent(); - // content.getNbSessions().add(nbSession); - // content. - - /* updateNoticeboard(content); */ - nbSessionDAO.saveNbSession(nbSession); - } - catch(DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to save this noticeboard session: " - +e.getMessage(), e); - } + + return nbSession; + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void saveNoticeboardSession(NoticeboardSession nbSession) { + try { + NoticeboardContent content = nbSession.getNbContent(); + // content.getNbSessions().add(nbSession); + // content. + + /* updateNoticeboard(content); */ + nbSessionDAO.saveNbSession(nbSession); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to save this noticeboard session: " + + e.getMessage(), e); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ - public void updateNoticeboardSession(NoticeboardSession nbSession) - { - try - { - nbSessionDAO.updateNbSession(nbSession); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to update this noticeboard session: " - +e.getMessage(), e); - } + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void updateNoticeboardSession(NoticeboardSession nbSession) { + try { + nbSessionDAO.updateNbSession(nbSession); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to update this noticeboard session: " + + e.getMessage(), e); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(Long) - */ - public void removeSession(Long nbSessionId) - { - if (nbSessionId == null) - { - String error = "Unable to continue. The tool session id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - NoticeboardSession sessionToDelete = retrieveNoticeboardSession(nbSessionId); - NoticeboardContent contentReferredBySession = sessionToDelete.getNbContent(); - //un-associate the session from content - contentReferredBySession.getNbSessions().remove(sessionToDelete); - nbSessionDAO.removeNbSession(nbSessionId); - // updateNoticeboard(contentReferredBySession); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " - + e.getMessage(), e); - } + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(Long) + */ + public void removeSession(Long nbSessionId) { + if (nbSessionId == null) { + String error = "Unable to continue. The tool session id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ - public void removeSession(NoticeboardSession nbSession) - { - try - { - NoticeboardContent contentReferredBySession = nbSession.getNbContent(); - //un-associate the session from content - contentReferredBySession.getNbSessions().remove(nbSession); - - nbSessionDAO.removeNbSession(nbSession); - // updateNoticeboard(contentReferredBySession); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " - + e.getMessage(), e); - } + + try { + NoticeboardSession sessionToDelete = retrieveNoticeboardSession(nbSessionId); + NoticeboardContent contentReferredBySession = sessionToDelete.getNbContent(); + // un-associate the session from content + contentReferredBySession.getNbSessions().remove(sessionToDelete); + nbSessionDAO.removeNbSession(nbSessionId); + // updateNoticeboard(contentReferredBySession); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " + + e.getMessage(), e); } - - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboardUsersFromSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ - public void removeNoticeboardUsersFromSession(NoticeboardSession nbSession) - { - try - { - nbSession.getNbUsers().clear(); - // updateNoticeboardSession(nbSession); - - nbSessionDAO.removeNbUsers(nbSession); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove the users associated with this noticeboard session instance: " - + e.getMessage(), e); - } - + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void removeSession(NoticeboardSession nbSession) { + try { + NoticeboardContent contentReferredBySession = nbSession.getNbContent(); + // un-associate the session from content + contentReferredBySession.getNbSessions().remove(nbSession); + + nbSessionDAO.removeNbSession(nbSession); + // updateNoticeboard(contentReferredBySession); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " + + e.getMessage(), e); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNbSessionByUserID(java.lang.Long) - */ - public NoticeboardSession retrieveNbSessionByUserID(Long userId) - { - if (userId == null) - { - String error = "Unable to continue. The tool session id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - nbSession = nbSessionDAO.getNbSessionByUser(userId); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve noticeboard session instance " - + e.getMessage(), e); - } - return nbSession; - + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboardUsersFromSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void removeNoticeboardUsersFromSession(NoticeboardSession nbSession) { + try { + nbSession.getNbUsers().clear(); + // updateNoticeboardSession(nbSession); + + nbSessionDAO.removeNbUsers(nbSession); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove the users associated with this noticeboard session instance: " + + e.getMessage(), e); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getSessionIdsFromContent(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ - public List getSessionIdsFromContent(NoticeboardContent content) - { - List list = null; - try - { - list = nbSessionDAO.getSessionsFromContent(content); - } - catch(DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to the list of session ids from content " - + e.getMessage(), e); - } - return list; + + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNbSessionByUserID(java.lang.Long) + */ + public NoticeboardSession retrieveNbSessionByUserID(Long userId) { + if (userId == null) { + String error = "Unable to continue. The tool session id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /* ============================================================================== - * Methods for access to NoticeboardUser objects - * ============================================================================== - */ - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardUser(java.lang.Long) - */ - public NoticeboardUser retrieveNoticeboardUser(Long nbUserId, Long nbSessionId) - { - if (nbUserId == null) - { - String error = "Unable to continue. The user id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - nbUser = nbUserDAO.getNbUser(nbUserId, nbSessionId); - } - catch (DataAccessException e) - { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard user: " - + e.getMessage(), - e); - } - - return nbUser; + + try { + nbSession = nbSessionDAO.getNbSessionByUser(userId); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to retrieve noticeboard session instance " + + e.getMessage(), e); } - - - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboardUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) - */ - public void saveNoticeboardUser(NoticeboardUser nbUser) - { - try - { - NoticeboardSession session = nbUser.getNbSession(); - session.getNbUsers().add(nbUser); - // updateNoticeboardSession(session); - - nbUserDAO.saveNbUser(nbUser); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to save the noticeboard user object: " - + e.getMessage(), e); - } + return nbSession; + + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getSessionIdsFromContent(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ + public List getSessionIdsFromContent(NoticeboardContent content) { + List list = null; + try { + list = nbSessionDAO.getSessionsFromContent(content); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to the list of session ids from content " + + e.getMessage(), e); } - - /** org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNbUserBySession(java.lang.Long, java.lang.Long) */ - public NoticeboardUser retrieveNbUserBySession(Long userId, Long sessionId) - { - try - { - nbUser = nbUserDAO.getNbUserBySession(userId, sessionId); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrive the noticeboard user object: " - + e.getMessage(), e); - } - - return nbUser; + return list; + } + + /* + * ============================================================================== Methods for access to + * NoticeboardUser objects ============================================================================== + */ + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardUser(java.lang.Long) + */ + public NoticeboardUser retrieveNoticeboardUser(Long nbUserId, Long nbSessionId) { + if (nbUserId == null) { + String error = "Unable to continue. The user id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboardUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) - */ - public void updateNoticeboardUser(NoticeboardUser nbUser) - { - try - { - nbUserDAO.updateNbUser(nbUser); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to update the noticeboard user object: " - + e.getMessage(), e); - } + + try { + nbUser = nbUserDAO.getNbUser(nbUserId, nbSessionId); + } catch (DataAccessException e) { + throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard user: " + + e.getMessage(), e); } - - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) - */ - public void removeUser(NoticeboardUser nbUser) - { - try - { - NoticeboardSession session = nbUser.getNbSession(); - session.getNbUsers().remove(nbUser); - - nbUserDAO.removeNbUser(nbUser); - - // updateNoticeboardSession(session); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove the noticeboard user object: " - + e.getMessage(), e); - } + + return nbUser; + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboardUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) + */ + public void saveNoticeboardUser(NoticeboardUser nbUser) { + try { + NoticeboardSession session = nbUser.getNbSession(); + session.getNbUsers().add(nbUser); + // updateNoticeboardSession(session); + + nbUserDAO.saveNbUser(nbUser); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to save the noticeboard user object: " + + e.getMessage(), e); } - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeUser(java.lang.Long) - */ - public void removeUser(Long nbUserId, Long toolSessionId) - { - if (nbUserId == null) - { - String error = "Unable to continue. The user id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - try - { - NoticeboardUser user = retrieveNoticeboardUser(nbUserId, toolSessionId); - NoticeboardSession session = user.getNbSession(); - session.getNbUsers().remove(user); - nbUserDAO.removeNbUser(nbUserId); - - // updateNoticeboardSession(session); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove the noticeboard user object: " - + e.getMessage(), e); - } + } + + /** + * org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNbUserBySession(java.lang.Long, + * java.lang.Long) + */ + public NoticeboardUser retrieveNbUserBySession(Long userId, Long sessionId) { + try { + nbUser = nbUserDAO.getNbUserBySession(userId, sessionId); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to retrive the noticeboard user object: " + + e.getMessage(), e); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#addSession(java.lang.Long, org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public void addSession(Long nbContentId, NoticeboardSession session) - { - if (nbContentId == null || session == null) - { - String error = "Unable to continue. The tool content id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - nbContentDAO.addNbSession(nbContentId, session); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to create session: " - + e.getMessage(), e); - } - } - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#addUser(java.lang.Long, org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public void addUser(Long nbSessionId, NoticeboardUser user) - { + return nbUser; + } - if (nbSessionId == null) - { - String error = "Unable to continue. The tool session id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - try - { - nbSessionDAO.addNbUsers(nbSessionId, user); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to create user: " - + e.getMessage(), e); - } + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboardUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) + */ + public void updateNoticeboardUser(NoticeboardUser nbUser) { + try { + nbUserDAO.updateNbUser(nbUser); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to update the noticeboard user object: " + + e.getMessage(), e); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getNumberOfUsersInSession(org.lamsfoundation.lams.tool.noticeboard.oticeboardSession) */ - public int getNumberOfUsersInSession(NoticeboardSession session) - { - int numberOfUsers; - try - { - numberOfUsers = nbUserDAO.getNumberOfUsers(session); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to get the number of users in the session: " - + e.getMessage(), e); - } - return numberOfUsers; + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) + */ + public void removeUser(NoticeboardUser nbUser) { + try { + NoticeboardSession session = nbUser.getNbSession(); + session.getNbUsers().remove(nbUser); + + nbUserDAO.removeNbUser(nbUser); + + // updateNoticeboardSession(session); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove the noticeboard user object: " + + e.getMessage(), e); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#calculateTotalNumberOfUsers(java.lang.Long) */ - public int calculateTotalNumberOfUsers(Long toolContentId) - { + } - if (toolContentId == null) - { - String error = "Unable to continue. The tool content id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - int totalNumberOfUsers = 0; - try - { - nbContent = retrieveNoticeboard(toolContentId); - List listOfSessionIds = getSessionIdsFromContent(nbContent); - - Iterator i = listOfSessionIds.iterator(); - - while(i.hasNext()) - { - Long sessionId = (Long)i.next(); - int usersInThisSession = getNumberOfUsersInSession(retrieveNoticeboardSession(sessionId)); - totalNumberOfUsers = totalNumberOfUsers + usersInThisSession; - } - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while calculating the total number of users in tool activity " - + e.getMessage(), e); - } - return totalNumberOfUsers; + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeUser(java.lang.Long) + */ + public void removeUser(Long nbUserId, Long toolSessionId) { + if (nbUserId == null) { + String error = "Unable to continue. The user id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - public List getUsersBySession(Long sessionId) { - - if (sessionId!=null) { - try { - return nbUserDAO.getNbUsersBySession(sessionId); - } catch (DataAccessException e) { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to get the list of users in the session: " - + e.getMessage(), e); - } - } else { - log.error("Unable to continue. Session id is missing"); - } - return null; + try { + NoticeboardUser user = retrieveNoticeboardUser(nbUserId, toolSessionId); + NoticeboardSession session = user.getNbSession(); + session.getNbUsers().remove(user); + nbUserDAO.removeNbUser(nbUserId); + + // updateNoticeboardSession(session); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove the noticeboard user object: " + + e.getMessage(), e); } - - /* ============================================================================== - * Methods for access to NoticeboardUser objects - * ============================================================================== - */ - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachment(java.lang.Long) */ - public NoticeboardAttachment retrieveAttachment(Long attachmentId) - { - if (attachmentId == null) - { - String error = "Unable to continue. The attachment id is missing"; - log.error(error); - throw new NbApplicationException(error); - } - - try - { - return nbAttachmentDAO.retrieveAttachment(attachmentId); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve the attachment " - + e.getMessage(), e); - } + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#addSession(java.lang.Long, + * org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void addSession(Long nbContentId, NoticeboardSession session) { + + if (nbContentId == null || session == null) { + String error = "Unable to continue. The tool content id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachmentByUuid(java.lang.Long) */ - public NoticeboardAttachment retrieveAttachmentByUuid(Long uuid) - { - if (uuid == null) - { - String error = "Unable to continue. The uuid is missing"; - log.error(error); - throw new NbApplicationException(error); - } - try - { - return nbAttachmentDAO.retrieveAttachmentByUuid(uuid); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve the attachment " - + e.getMessage(), e); - } + + try { + nbContentDAO.addNbSession(nbContentId, session); + } catch (DataAccessException e) { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to create session: " + + e.getMessage(), e); } - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachment(java.lang.String) */ - public NoticeboardAttachment retrieveAttachmentByFilename(String filename) - { - if (filename == null || filename.trim().length() == 0) - { - String error = "Unable to continue. The filename is missing"; - log.error(error); - throw new NbApplicationException(error); - } - try - { - return nbAttachmentDAO.retrieveAttachmentByFilename(filename); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve the attachment with filename " + filename + " " - + e.getMessage(), e); - } + } + + /** + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#addUser(java.lang.Long, + * org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + public void addUser(Long nbSessionId, NoticeboardUser user) { + + if (nbSessionId == null) { + String error = "Unable to continue. The tool session id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getAttachmentIdsFromContent(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ - public List getAttachmentIdsFromContent(NoticeboardContent nbContent) - { - try - { - return nbAttachmentDAO.getAttachmentIdsFromContent(nbContent); - } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve the list of attachment ids " - + e.getMessage(), e); - } + try { + nbSessionDAO.addNbUsers(nbSessionId, user); + } catch (DataAccessException e) { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to create user: " + + e.getMessage(), e); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) */ - public void saveAttachment(NoticeboardContent content, NoticeboardAttachment attachment) - { - try - { - content.getNbAttachments().add(attachment); - attachment.setNbContent(content); - saveNoticeboard(content); + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getNumberOfUsersInSession(org.lamsfoundation.lams.tool.noticeboard.oticeboardSession) */ + public int getNumberOfUsersInSession(NoticeboardSession session) { + int numberOfUsers; + try { + numberOfUsers = nbUserDAO.getNumberOfUsers(session); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to get the number of users in the session: " + + e.getMessage(), e); + } + return numberOfUsers; + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#calculateTotalNumberOfUsers(java.lang.Long) */ + public int calculateTotalNumberOfUsers(Long toolContentId) { + + if (toolContentId == null) { + String error = "Unable to continue. The tool content id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); + } + + int totalNumberOfUsers = 0; + try { + nbContent = retrieveNoticeboard(toolContentId); + List listOfSessionIds = getSessionIdsFromContent(nbContent); + + Iterator i = listOfSessionIds.iterator(); + + while (i.hasNext()) { + Long sessionId = (Long) i.next(); + int usersInThisSession = getNumberOfUsersInSession(retrieveNoticeboardSession(sessionId)); + totalNumberOfUsers = totalNumberOfUsers + usersInThisSession; } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to save the attachment " - + e.getMessage(), e); - } + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while calculating the total number of users in tool activity " + + e.getMessage(), e); } - - /** @throws RepositoryCheckedException - * @throws - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) */ - public void removeAttachment(NoticeboardContent content, NoticeboardAttachment attachment) throws RepositoryCheckedException - { - try - { - attachment.setNbContent(null); - content.getNbAttachments().remove(attachment); - saveNoticeboard(content); + return totalNumberOfUsers; + } + + public List getUsersBySession(Long sessionId) { + + if (sessionId != null) { + try { + return nbUserDAO.getNbUsersBySession(sessionId); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to get the list of users in the session: " + + e.getMessage(), e); } - catch (DataAccessException e) - { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this attachment" - + e.getMessage(), e); - } + } else { + NoticeboardServicePOJO.log.error("Unable to continue. Session id is missing"); } - - /** @throws RepositoryCheckedException - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#uploadFile(java.io.InputStream, java.lang.String, java.lang.String, java.lang.String) */ - public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType) throws RepositoryCheckedException - { - return nbToolContentHandler.uploadFile(istream, filename, contentType, fileType); + return null; + } + + /* + * ============================================================================== Methods for access to + * NoticeboardUser objects ============================================================================== + */ + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachment(java.lang.Long) */ + public NoticeboardAttachment retrieveAttachment(Long attachmentId) { + if (attachmentId == null) { + String error = "Unable to continue. The attachment id is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /* ===============Methods implemented from ToolContentManager =============== */ - - /** @see org.lamsfoundation.lams.tool.ToolContentManager#copyToolContent(java.lang.Long, java.lang.Long)*/ - public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { - - if (toContentId == null) - throw new ToolException("Failed to copy Noticeboard tool content. Missing parameter: toContentId"); - if (fromContentId == null) - { - //use the default content Id - //fromContentId = NoticeboardConstants.DEFAULT_CONTENT_ID; - fromContentId = getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE); - } - - //fromContentId might not have any content, in this case use default content - //default content id might not have any contnet, throw exception - NoticeboardContent originalNb = null; - - try { - if ((originalNb = retrieveNoticeboard(fromContentId))== null) //the id given does not have content, use default content - { - //use default content id to grab contents - NoticeboardContent defaultContent = retrieveNoticeboard(getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE)); - - if (defaultContent != null) - { - NoticeboardContent newContent = NoticeboardContent.newInstance(defaultContent, toContentId, nbToolContentHandler); - saveNoticeboard(newContent); - } - else - { - throw new ToolException("Default content is missing. Unable to copy tool content"); - } - } - else - { - NoticeboardContent newNbContent = NoticeboardContent.newInstance(originalNb, toContentId, nbToolContentHandler); - saveNoticeboard(newNbContent); - } - } catch (RepositoryCheckedException e) { - log.error("Unable to copy the tool content due to a content repository error. fromContentId "+fromContentId+" toContentId "+toContentId); - throw new ToolException(e); - } - - + + try { + return nbAttachmentDAO.retrieveAttachment(attachmentId); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to retrieve the attachment " + e.getMessage(), e); } - - /** @see org.lamsfoundation.lams.tool.ToolContentManager#setAsDefineLater(java.lang.Long)*/ - public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException - { - NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); - - nbContent.setDefineLater(value); - //nbContent.setContentInUse(false); //if define later is set to true, then contentInUse flag should be false - saveNoticeboard(nbContent); - + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachmentByUuid(java.lang.Long) */ + public NoticeboardAttachment retrieveAttachmentByUuid(Long uuid) { + if (uuid == null) { + String error = "Unable to continue. The uuid is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - - /** @see org.lamsfoundation.lams.tool.ToolContentManager#setAsRunOffline(java.lang.Long)*/ - public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException - { - NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); - - nbContent.setForceOffline(value); - saveNoticeboard(nbContent); + try { + return nbAttachmentDAO.retrieveAttachmentByUuid(uuid); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to retrieve the attachment " + e.getMessage(), e); } - - /** @see org.lamsfoundation.lams.tool.ToolContentManager#removeToolContent(java.lang.Long)*/ - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException - { - NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); - //if session data exist and removeSessionData=false, throw an exception - if ((!nbContent.getNbSessions().isEmpty()) && !removeSessionData) - throw new SessionDataExistsException("Delete failed: There is session data that belongs to this tool content id"); - - //remove any attachments that belong to this tool entry - Set attachments = nbContent.getNbAttachments(); - Iterator i = attachments.iterator(); - while(i.hasNext()) - { - try - { - removeAttachment(nbContent, (NoticeboardAttachment)i.next()); - } - catch(RepositoryCheckedException e) - { - //TODO: not sure if suppose to throw another type of exception or not - } - } - - removeNoticeboard(toolContentId); + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachment(java.lang.String) */ + public NoticeboardAttachment retrieveAttachmentByFilename(String filename) { + if (filename == null || filename.trim().length() == 0) { + String error = "Unable to continue. The filename is missing"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } + try { + return nbAttachmentDAO.retrieveAttachmentByFilename(filename); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to retrieve the attachment with filename " + + filename + " " + e.getMessage(), e); + } + } - private NoticeboardContent getAndCheckIDandObject(Long toolContentId) throws ToolException, DataMissingException - { - if (toolContentId == null) - throw new ToolException("Tool content ID is missing. Unable to continue"); - - NoticeboardContent nbContent = retrieveNoticeboard(toolContentId); - if (nbContent == null) - throw new DataMissingException("No tool content matches this tool content id"); - - return nbContent; + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getAttachmentIdsFromContent(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ + public List getAttachmentIdsFromContent(NoticeboardContent nbContent) { + try { + return nbAttachmentDAO.getAttachmentIdsFromContent(nbContent); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to retrieve the list of attachment ids " + + e.getMessage(), e); } - - private NoticeboardSession getAndCheckSessionIDandObject(Long toolSessionId) throws ToolException, DataMissingException - { - if (toolSessionId == null) - throw new ToolException("Tool session ID is missing. Unable to continue"); - - NoticeboardSession nbSession = retrieveNoticeboardSession(toolSessionId); - if (nbSession == null) - throw new DataMissingException("No tool session matches this tool session id"); - - return nbSession; - } - - /*private void checkSessionIDandObject(Long toolSessionId) throws ToolException, DataMissingException - { - if (toolSessionId == null) - throw new ToolException("Tool session ID is missing. Unable to continue"); - - NoticeboardSession nbSession = retrieveNoticeboardSession(toolSessionId); - if (nbSession == null) - throw new DataMissingException("No tool session matches this tool session id"); - } */ + } - /** - * Export the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws DataMissingException if no tool content matches the toolSessionId - * @throws ToolException if any other error occurs - */ + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) */ + public void saveAttachment(NoticeboardContent content, NoticeboardAttachment attachment) { + try { + content.getNbAttachments().add(attachment); + attachment.setNbContent(content); + saveNoticeboard(content); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to save the attachment " + e.getMessage(), e); + } + } - public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { - NoticeboardContent toolContentObj = nbContentDAO.findNbContentById(toolContentId); - if(toolContentObj == null) { - Long defaultContentId = getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE); - toolContentObj = retrieveNoticeboard(defaultContentId); - } - if(toolContentObj == null) - throw new DataMissingException("Unable to find default content for the noticeboard tool"); - - try { - //set ResourceToolContentHandler as null to avoid copy file node in repository again. - toolContentObj = NoticeboardContent.newInstance(toolContentObj,toolContentId,null); - toolContentObj.setNbSessions(null); - exportContentService.registerFileClassForExport(NoticeboardAttachment.class.getName(),"uuid","versionId"); - exportContentService.exportToolContent( toolContentId, toolContentObj,nbToolContentHandler, rootPath); - } catch (ExportToolContentException e) { - throw new ToolException(e); - } catch (ItemNotFoundException e) { - throw new ToolException(e); - } catch (RepositoryCheckedException e) { - throw new ToolException(e); - } + /** + * @throws RepositoryCheckedException + * @throws + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) + */ + public void removeAttachment(NoticeboardContent content, NoticeboardAttachment attachment) + throws RepositoryCheckedException { + try { + attachment.setNbContent(null); + content.getNbAttachments().remove(attachment); + saveNoticeboard(content); + } catch (DataAccessException e) { + throw new NbApplicationException( + "EXCEPTION: An exception has occurred while trying to remove this attachment" + e.getMessage(), e); } + } /** - * Import the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws ToolException if any other error occurs + * @throws RepositoryCheckedException + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#uploadFile(java.io.InputStream, + * java.lang.String, java.lang.String, java.lang.String) */ - public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath,String fromVersion,String toVersion) throws ToolException { - try { - exportContentService.registerFileClassForImport(NoticeboardAttachment.class.getName() - ,"uuid","versionId","filename","fileProperty",null,null); - - Object toolPOJO = exportContentService.importToolContent(toolContentPath,nbToolContentHandler,fromVersion,toVersion); - if(!(toolPOJO instanceof NoticeboardContent)) - throw new ImportToolContentException("Import Noteice board tool content failed. Deserialized object is " + toolPOJO); - NoticeboardContent toolContentObj = (NoticeboardContent) toolPOJO; - -// reset it to new toolContentId - toolContentObj.setNbContentId(toolContentId); - nbContentDAO.saveNbContent(toolContentObj); - } catch (ImportToolContentException e) { - throw new ToolException(e); - } + public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType) + throws RepositoryCheckedException { + return nbToolContentHandler.uploadFile(istream, filename, contentType, fileType); + } + + /* ===============Methods implemented from ToolContentManager =============== */ + + /** @see org.lamsfoundation.lams.tool.ToolContentManager#copyToolContent(java.lang.Long, java.lang.Long) */ + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { + + if (toContentId == null) { + throw new ToolException("Failed to copy Noticeboard tool content. Missing parameter: toContentId"); } - - /** Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are always - * available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular activity - * such as the answer to the third question contains the word Koala and hence the need for the toolContentId - * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition - */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - return new TreeMap(); + if (fromContentId == null) { + // use the default content Id + // fromContentId = NoticeboardConstants.DEFAULT_CONTENT_ID; + fromContentId = getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE); } - - - /* ===============Methods implemented from ToolSessionManager =============== */ - - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, java.lang.String, java.lang.Long) */ - public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException - { - if (toolSessionId == null || toolContentId == null) - { - String error = "Failed to create tool session. The tool session id or tool content id is invalid"; - throw new ToolException(error); - } - + // fromContentId might not have any content, in this case use default content + // default content id might not have any contnet, throw exception + NoticeboardContent originalNb = null; - if ((nbContent = retrieveNoticeboard(toolContentId)) == null) + try { + if ((originalNb = retrieveNoticeboard(fromContentId)) == null) // the id given does not have content, use + // default content { - //use default content - NoticeboardContent defaultContent = retrieveNoticeboard(getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE)); - - if (defaultContent != null) - { - NoticeboardSession newSession = new NoticeboardSession(toolSessionId, - toolSessionName, - defaultContent, - new Date(System.currentTimeMillis()), - NoticeboardSession.NOT_ATTEMPTED); - //saveNoticeboardSession(newSession); - defaultContent.getNbSessions().add(newSession); - saveNoticeboard(defaultContent); - - } - else - { - throw new ToolException("Default content is missing. Unable to create tool session"); - } + // use default content id to grab contents + NoticeboardContent defaultContent = retrieveNoticeboard(getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE)); + + if (defaultContent != null) { + NoticeboardContent newContent = NoticeboardContent.newInstance(defaultContent, toContentId, + nbToolContentHandler); + saveNoticeboard(newContent); + } else { + throw new ToolException("Default content is missing. Unable to copy tool content"); + } + } else { + NoticeboardContent newNbContent = NoticeboardContent.newInstance(originalNb, toContentId, + nbToolContentHandler); + saveNoticeboard(newNbContent); } - else - { - NoticeboardSession nbSession = new NoticeboardSession(toolSessionId, - toolSessionName, - nbContent, - new Date(System.currentTimeMillis()), - NoticeboardSession.NOT_ATTEMPTED); - - nbContent.getNbSessions().add(nbSession); - saveNoticeboard(nbContent); - //saveNoticeboardSession(nbSession); - } - - - + } catch (RepositoryCheckedException e) { + NoticeboardServicePOJO.log + .error("Unable to copy the tool content due to a content repository error. fromContentId " + + fromContentId + " toContentId " + toContentId); + throw new ToolException(e); } - - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#leaveToolSession(java.lang.Long, org.lamsfoundation.lams.usermanagement.User)*/ - public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException - { - getAndCheckSessionIDandObject(toolSessionId); - - return learnerService.completeToolSession(toolSessionId, learnerId); + + } + + /** @see org.lamsfoundation.lams.tool.ToolContentManager#setAsDefineLater(java.lang.Long) */ + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { + NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); + + nbContent.setDefineLater(value); + // nbContent.setContentInUse(false); //if define later is set to true, then contentInUse flag should be false + saveNoticeboard(nbContent); + + } + + /** @see org.lamsfoundation.lams.tool.ToolContentManager#setAsRunOffline(java.lang.Long) */ + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { + NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); + + nbContent.setForceOffline(value); + saveNoticeboard(nbContent); + } + + /** @see org.lamsfoundation.lams.tool.ToolContentManager#removeToolContent(java.lang.Long) */ + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException { + NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); + // if session data exist and removeSessionData=false, throw an exception + if (!nbContent.getNbSessions().isEmpty() && !removeSessionData) { + throw new SessionDataExistsException( + "Delete failed: There is session data that belongs to this tool content id"); } - - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#exportToolSession(java.lang.Long)*/ - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws ToolException, DataMissingException - { - getAndCheckSessionIDandObject(toolSessionId); - throw new UnsupportedOperationException("not yet implemented"); + + // remove any attachments that belong to this tool entry + Set attachments = nbContent.getNbAttachments(); + Iterator i = attachments.iterator(); + while (i.hasNext()) { + try { + removeAttachment(nbContent, (NoticeboardAttachment) i.next()); + } catch (RepositoryCheckedException e) { + // TODO: not sure if suppose to throw another type of exception or not + } } - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#exportToolSession(java.util.List) */ - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws ToolException, DataMissingException - { - Iterator i = toolSessionIds.iterator(); - if (i.hasNext()) - { - Long id = (Long)i.next(); - getAndCheckSessionIDandObject(id); - } - - - throw new UnsupportedOperationException("not yet implemented"); + removeNoticeboard(toolContentId); + } + + private NoticeboardContent getAndCheckIDandObject(Long toolContentId) throws ToolException, DataMissingException { + if (toolContentId == null) { + throw new ToolException("Tool content ID is missing. Unable to continue"); } - - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#removeToolSession(java.lang.Long)*/ - public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException - { - NoticeboardSession session = getAndCheckSessionIDandObject(toolSessionId); - removeSession(session); + + NoticeboardContent nbContent = retrieveNoticeboard(toolContentId); + if (nbContent == null) { + throw new DataMissingException("No tool content matches this tool content id"); + } + + return nbContent; } - - /** - * Get the tool output for the given tool output names. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) - */ - public SortedMap getToolOutput(List names, - Long toolSessionId, Long learnerId) { - return new TreeMap(); + + private NoticeboardSession getAndCheckSessionIDandObject(Long toolSessionId) throws ToolException, + DataMissingException { + if (toolSessionId == null) { + throw new ToolException("Tool session ID is missing. Unable to continue"); } - /** - * Get the tool output for the given tool output name. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) - */ - public ToolOutput getToolOutput(String name, Long toolSessionId, - Long learnerId) { - return null; + NoticeboardSession nbSession = retrieveNoticeboardSession(toolSessionId); + if (nbSession == null) { + throw new DataMissingException("No tool session matches this tool session id"); } - /* ===============Methods implemented from ToolContentImport102Manager =============== */ - + return nbSession; + } + /* + * private void checkSessionIDandObject(Long toolSessionId) throws ToolException, DataMissingException { if + * (toolSessionId == null) throw new ToolException("Tool session ID is missing. Unable to continue"); + * + * NoticeboardSession nbSession = retrieveNoticeboardSession(toolSessionId); if (nbSession == null) throw new + * DataMissingException("No tool session matches this tool session id"); } + */ + /** - * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard + * Export the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws DataMissingException + * if no tool content matches the toolSessionId + * @throws ToolException + * if any other error occurs */ - public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) - { - Date now = new Date(); - NoticeboardContent toolContentObj = new NoticeboardContent(); - String content = WebUtil.convertNewlines((String)importValues.get(ToolContentImport102Manager.CONTENT_BODY)); - toolContentObj.setContent(content); - toolContentObj.setContentInUse(false); - toolContentObj.setCreatorUserId(user.getUserID().longValue()); - toolContentObj.setDateCreated(now); - toolContentObj.setDateUpdated(now); - toolContentObj.setDefineLater(false); - toolContentObj.setForceOffline(false); - toolContentObj.setNbContentId(toolContentId); - toolContentObj.setOfflineInstructions(null); - toolContentObj.setOnlineInstructions(null); - toolContentObj.setTitle((String)importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); - toolContentObj.setReflectOnActivity(false); - // leave as empty, no need to set them to anything. - //toolContentObj.setNbSessions(nbSessions); - //toolContentObj.setNbAttachments(nbAttachments); - nbContentDAO.saveNbContent(toolContentObj); + + public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { + NoticeboardContent toolContentObj = nbContentDAO.findNbContentById(toolContentId); + if (toolContentObj == null) { + Long defaultContentId = getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE); + toolContentObj = retrieveNoticeboard(defaultContentId); + } + if (toolContentObj == null) { + throw new DataMissingException("Unable to find default content for the noticeboard tool"); + } + + try { + // set ResourceToolContentHandler as null to avoid copy file node in repository again. + toolContentObj = NoticeboardContent.newInstance(toolContentObj, toolContentId, null); + toolContentObj.setNbSessions(null); + exportContentService.registerFileClassForExport(NoticeboardAttachment.class.getName(), "uuid", "versionId"); + exportContentService.exportToolContent(toolContentId, toolContentObj, nbToolContentHandler, rootPath); + } catch (ExportToolContentException e) { + throw new ToolException(e); + } catch (ItemNotFoundException e) { + throw new ToolException(e); + } catch (RepositoryCheckedException e) { + throw new ToolException(e); + } } - /** Set the description, throws away the title value as this is not supported in 2.0 */ - public void setReflectiveData(Long toolContentId, String title, String description) - throws ToolException, DataMissingException { - - NoticeboardContent toolContentObj = retrieveNoticeboard(toolContentId); - if ( toolContentObj == null ) { - throw new DataMissingException("Unable to set reflective data titled "+title - +" on activity toolContentId "+toolContentId - +" as the tool content does not exist."); - } + /** + * Import the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws ToolException + * if any other error occurs + */ + public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException { + try { + exportContentService.registerFileClassForImport(NoticeboardAttachment.class.getName(), "uuid", "versionId", + "filename", "fileProperty", null, null); - toolContentObj.setReflectOnActivity(Boolean.TRUE); - toolContentObj.setReflectInstructions(description); + Object toolPOJO = exportContentService.importToolContent(toolContentPath, nbToolContentHandler, + fromVersion, toVersion); + if (!(toolPOJO instanceof NoticeboardContent)) { + throw new ImportToolContentException( + "Import Noteice board tool content failed. Deserialized object is " + toolPOJO); + } + NoticeboardContent toolContentObj = (NoticeboardContent) toolPOJO; + + // reset it to new toolContentId + toolContentObj.setNbContentId(toolContentId); + nbContentDAO.saveNbContent(toolContentObj); + } catch (ImportToolContentException e) { + throw new ToolException(e); + } } - - //========================================================================================= - - public Long getToolDefaultContentIdBySignature(String toolSignature) - { - Long contentId = null; - contentId=new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); - if (contentId == null) - { - String error="Could not retrieve default content id for this tool"; - log.error(error); - throw new NbApplicationException(error); - } - return contentId; + + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition + */ + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { + return new TreeMap(); } - /* =============== Used by Spring to "inject" the linked objects =============== */ - - /*public INoticeboardContentDAO getNbContentDAO() - { - return nbContentDAO; + /* ===============Methods implemented from ToolSessionManager =============== */ + + /** + * @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, java.lang.String, + * java.lang.Long) + */ + public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { + if (toolSessionId == null || toolContentId == null) { + String error = "Failed to create tool session. The tool session id or tool content id is invalid"; + throw new ToolException(error); } - */ - public void setNbContentDAO(INoticeboardContentDAO nbContentDAO) - { - this.nbContentDAO = nbContentDAO; + + if ((nbContent = retrieveNoticeboard(toolContentId)) == null) { + // use default content + NoticeboardContent defaultContent = retrieveNoticeboard(getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE)); + + if (defaultContent != null) { + NoticeboardSession newSession = new NoticeboardSession(toolSessionId, toolSessionName, defaultContent, + new Date(System.currentTimeMillis()), NoticeboardSession.NOT_ATTEMPTED); + // saveNoticeboardSession(newSession); + defaultContent.getNbSessions().add(newSession); + saveNoticeboard(defaultContent); + + } else { + throw new ToolException("Default content is missing. Unable to create tool session"); + } + } else { + NoticeboardSession nbSession = new NoticeboardSession(toolSessionId, toolSessionName, nbContent, new Date( + System.currentTimeMillis()), NoticeboardSession.NOT_ATTEMPTED); + + nbContent.getNbSessions().add(nbSession); + saveNoticeboard(nbContent); + // saveNoticeboardSession(nbSession); } - - /*public INoticeboardSessionDAO getNbSessionDAO() - { - return nbSessionDAO; + + } + + /** + * @see org.lamsfoundation.lams.tool.ToolSessionManager#leaveToolSession(java.lang.Long, + * org.lamsfoundation.lams.usermanagement.User) + */ + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { + getAndCheckSessionIDandObject(toolSessionId); + + return learnerService.completeToolSession(toolSessionId, learnerId); + } + + /** @see org.lamsfoundation.lams.tool.ToolSessionManager#exportToolSession(java.lang.Long) */ + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws ToolException, DataMissingException { + getAndCheckSessionIDandObject(toolSessionId); + throw new UnsupportedOperationException("not yet implemented"); + } + + /** @see org.lamsfoundation.lams.tool.ToolSessionManager#exportToolSession(java.util.List) */ + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws ToolException, + DataMissingException { + Iterator i = toolSessionIds.iterator(); + if (i.hasNext()) { + Long id = (Long) i.next(); + getAndCheckSessionIDandObject(id); } - */ - public void setNbSessionDAO(INoticeboardSessionDAO nbSessionDAO) - { - this.nbSessionDAO = nbSessionDAO; + + throw new UnsupportedOperationException("not yet implemented"); + } + + /** @see org.lamsfoundation.lams.tool.ToolSessionManager#removeToolSession(java.lang.Long) */ + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + NoticeboardSession session = getAndCheckSessionIDandObject(toolSessionId); + removeSession(session); + } + + /** + * Get the tool output for the given tool output names. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) + */ + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { + return new TreeMap(); + } + + /** + * Get the tool output for the given tool output name. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) + */ + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return null; + } + + /* ===============Methods implemented from ToolContentImport102Manager =============== */ + + /** + * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard + */ + public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { + Date now = new Date(); + NoticeboardContent toolContentObj = new NoticeboardContent(); + String content = WebUtil.convertNewlines((String) importValues.get(ToolContentImport102Manager.CONTENT_BODY)); + toolContentObj.setContent(content); + toolContentObj.setContentInUse(false); + toolContentObj.setCreatorUserId(user.getUserID().longValue()); + toolContentObj.setDateCreated(now); + toolContentObj.setDateUpdated(now); + toolContentObj.setDefineLater(false); + toolContentObj.setForceOffline(false); + toolContentObj.setNbContentId(toolContentId); + toolContentObj.setOfflineInstructions(null); + toolContentObj.setOnlineInstructions(null); + toolContentObj.setTitle((String) importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); + toolContentObj.setReflectOnActivity(false); + // leave as empty, no need to set them to anything. + // toolContentObj.setNbSessions(nbSessions); + // toolContentObj.setNbAttachments(nbAttachments); + nbContentDAO.saveNbContent(toolContentObj); + } + + /** Set the description, throws away the title value as this is not supported in 2.0 */ + public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, + DataMissingException { + + NoticeboardContent toolContentObj = retrieveNoticeboard(toolContentId); + if (toolContentObj == null) { + throw new DataMissingException("Unable to set reflective data titled " + title + + " on activity toolContentId " + toolContentId + " as the tool content does not exist."); } - - /*public INoticeboardUserDAO getNbUserDAO() - { - return nbUserDAO; + + toolContentObj.setReflectOnActivity(Boolean.TRUE); + toolContentObj.setReflectInstructions(description); + } + + // ========================================================================================= + + public Long getToolDefaultContentIdBySignature(String toolSignature) { + Long contentId = null; + contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); + if (contentId == null) { + String error = "Could not retrieve default content id for this tool"; + NoticeboardServicePOJO.log.error(error); + throw new NbApplicationException(error); } - */ - public void setNbUserDAO(INoticeboardUserDAO nbUserDAO) - { - this.nbUserDAO = nbUserDAO; - } - + return contentId; + } + + /* =============== Used by Spring to "inject" the linked objects =============== */ + + /* + * public INoticeboardContentDAO getNbContentDAO() { return nbContentDAO; } + */ + public void setNbContentDAO(INoticeboardContentDAO nbContentDAO) { + this.nbContentDAO = nbContentDAO; + } + + /* + * public INoticeboardSessionDAO getNbSessionDAO() { return nbSessionDAO; } + */ + public void setNbSessionDAO(INoticeboardSessionDAO nbSessionDAO) { + this.nbSessionDAO = nbSessionDAO; + } + + /* + * public INoticeboardUserDAO getNbUserDAO() { return nbUserDAO; } + */ + public void setNbUserDAO(INoticeboardUserDAO nbUserDAO) { + this.nbUserDAO = nbUserDAO; + } + /** * @return Returns the learnerService. */ - /* public ILearnerService getLearnerService() { - return learnerService; - } */ + /* + * public ILearnerService getLearnerService() { return learnerService; } + */ /** - * @param learnerService The learnerService to set. + * @param learnerService + * The learnerService to set. */ - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } - /* public INoticeboardAttachmentDAO getNbAttachmentDAO() { - return nbAttachmentDAO; - } */ - + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } + + /* + * public INoticeboardAttachmentDAO getNbAttachmentDAO() { return nbAttachmentDAO; } + */ + public void setNbAttachmentDAO(INoticeboardAttachmentDAO nbAttachmentDAO) { - this.nbAttachmentDAO = nbAttachmentDAO; + this.nbAttachmentDAO = nbAttachmentDAO; } + /** - * @param toolService The toolService to set. + * @param toolService + * The toolService to set. */ public void setToolService(ILamsToolService toolService) { - this.toolService = toolService; + this.toolService = toolService; } - public IToolContentHandler getNbToolContentHandler() { - return nbToolContentHandler; - } + public IToolContentHandler getNbToolContentHandler() { + return nbToolContentHandler; + } - public void setNbToolContentHandler(IToolContentHandler nbToolContentHandler) { - this.nbToolContentHandler = nbToolContentHandler; - } - - public IExportToolContentService getExportContentService() { - return exportContentService; - } + public void setNbToolContentHandler(IToolContentHandler nbToolContentHandler) { + this.nbToolContentHandler = nbToolContentHandler; + } - public void setExportContentService(IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; - } - - public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; - } + public IExportToolContentService getExportContentService() { + return exportContentService; + } - public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; - } - - /* =============== Wrappers Methods for Notebook Service (Reflective Option) =============== */ - - public Long createNotebookEntry(Long id, Integer idType, String signature, - Integer userID, String entry) { - return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); - } + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } - public NotebookEntry getEntry(Long id, Integer idType, String signature, - Integer userID) { - - List list = coreNotebookService.getEntry(id, idType, signature, userID); - if (list == null || list.isEmpty()) { - return null; - } else { - return list.get(0); - } + public ICoreNotebookService getCoreNotebookService() { + return coreNotebookService; + } + + public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { + this.coreNotebookService = coreNotebookService; + } + + /* =============== Wrappers Methods for Notebook Service (Reflective Option) =============== */ + + public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { + return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); + } + + public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID) { + + List list = coreNotebookService.getEntry(id, idType, signature, userID); + if (list == null || list.isEmpty()) { + return null; + } else { + return list.get(0); } - - /** - * @param notebookEntry - */ - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); - } + } + + /** + * @param notebookEntry + */ + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } } \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookOutputFactory.java,v diff -u -r1.4 -r1.5 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookOutputFactory.java 27 Mar 2009 03:16:35 -0000 1.4 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookOutputFactory.java 2 Jul 2009 13:03:57 -0000 1.5 @@ -52,7 +52,7 @@ * {@inheritDoc} */ @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); if (toolContentObject != null) { Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java,v diff -u -r1.21 -r1.22 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java 16 Mar 2009 05:56:00 -0000 1.21 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java 2 Jul 2009 13:03:57 -0000 1.22 @@ -47,7 +47,6 @@ import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; -import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; @@ -303,12 +302,13 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { Notebook notebook = getNotebookDAO().getByContentId(toolContentId); if (notebook == null) { notebook = getDefaultContent(); } - return getNotebookOutputFactory().getToolOutputDefinitions(notebook); + return getNotebookOutputFactory().getToolOutputDefinitions(notebook, definitionType); } /* ********** INotebookService Methods ********************************* */ @@ -613,13 +613,13 @@ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { this.coreNotebookService = coreNotebookService; } - + public IRepositoryService getRepositoryService() { - return repositoryService; + return repositoryService; } public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; + this.repositoryService = repositoryService; } public NotebookOutputFactory getNotebookOutputFactory() { @@ -660,7 +660,7 @@ notebookDAO.delete(condition); } } - + public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrOutputFactory.java,v diff -u -r1.1 -r1.2 --- lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrOutputFactory.java 7 Jan 2009 22:37:49 -0000 1.1 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrOutputFactory.java 2 Jul 2009 13:00:02 -0000 1.2 @@ -43,7 +43,7 @@ * {@inheritDoc} */ @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java,v diff -u -r1.5 -r1.6 --- lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java 17 Mar 2009 01:33:35 -0000 1.5 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java 2 Jul 2009 13:00:02 -0000 1.6 @@ -88,8 +88,7 @@ /** * An implementation of the IPixlrService interface. * - * As a requirement, all LAMS tool's service bean must implement - * ToolContentManager and ToolSessionManager. + * As a requirement, all LAMS tool's service bean must implement ToolContentManager and ToolSessionManager. */ public class PixlrService implements ToolSessionManager, ToolContentManager, IPixlrService, ToolContentImport102Manager { @@ -121,7 +120,7 @@ private ICoreNotebookService coreNotebookService; private PixlrOutputFactory pixlrOutputFactory; - + private IPixlrConfigItemDAO pixlrConfigItemDAO; public PixlrService() { @@ -170,8 +169,8 @@ /** * Get the tool output for the given tool output names. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) */ public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { return getPixlrOutputFactory().getToolOutput(names, this, toolSessionId, learnerId); @@ -180,8 +179,8 @@ /** * Get the tool output for the given tool output name. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) */ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return getPixlrOutputFactory().getToolOutput(name, this, toolSessionId, learnerId); @@ -214,7 +213,7 @@ try { toContent.setImageFileName(copyImage(toContent)); } catch (Exception e) { - logger.error("Could not copy image for tool content copy", e); + PixlrService.logger.error("Could not copy image for tool content copy", e); throw new ToolException(e); } @@ -288,8 +287,7 @@ } /** - * Export the XML fragment for the tool's content, along with any files - * needed for the content. + * Export the XML fragment for the tool's content, along with any files needed for the content. * * @throws DataMissingException * if no tool content matches the toolSessionId @@ -326,15 +324,15 @@ if (!tempDirFile.exists()) { tempDirFile.mkdirs(); } - String newFilePath = tempDir + File.separator + EXPORT_IMAGE_FILE_NAME + ext; + String newFilePath = tempDir + File.separator + PixlrService.EXPORT_IMAGE_FILE_NAME + ext; copyFile(imageFile, newFilePath); - pixlr.setImageFileName(EXPORT_IMAGE_FILE_NAME + ext); + pixlr.setImageFileName(PixlrService.EXPORT_IMAGE_FILE_NAME + ext); } } } catch (Exception e) { - logger.error("Could not export pixlr image, image may be missing in export", e); + PixlrService.logger.error("Could not export pixlr image, image may be missing in export", e); } Set atts = pixlr.getPixlrAttachments(); @@ -351,8 +349,7 @@ } /** - * Import the XML fragment for the tool's content, along with any files - * needed for the content. + * Import the XML fragment for the tool's content, along with any files needed for the content. * * @throws ToolException * if any other error occurs @@ -395,7 +392,7 @@ } catch (ImportToolContentException e) { throw new ToolException(e); } catch (Exception e) { - logger.error("Error during import possibly because of file copy error", e); + PixlrService.logger.error("Error during import possibly because of file copy error", e); throw new ToolException(e); } } @@ -410,21 +407,20 @@ } /** - * Get the definitions for possible output for an activity, based on the - * toolContentId. These may be definitions that are always available for the - * tool (e.g. number of marks for Multiple Choice) or a custom definition - * created for a particular activity such as the answer to the third - * question contains the word Koala and hence the need for the toolContentId + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId * - * @return SortedMap of ToolOutputDefinitions with the key being the name of - * each definition + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { Pixlr pixlr = getPixlrDAO().getByContentId(toolContentId); if (pixlr == null) { pixlr = getDefaultContent(); } - return getPixlrOutputFactory().getToolOutputDefinitions(pixlr); + return getPixlrOutputFactory().getToolOutputDefinitions(pixlr, definitionType); } /* ********** IPixlrService Methods ********************************* */ @@ -591,12 +587,11 @@ } /** - * This method verifies the credentials of the SubmitFiles Tool and gives it - * the Ticket to login and access the Content Repository. + * This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket to login and + * access the Content Repository. * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. * * @return ITicket The ticket for repostory access * @throws SubmitFilesException @@ -654,8 +649,7 @@ } /** - * Set the description, throws away the title value as this is not supported - * in 2.0 + * Set the description, throws away the title value as this is not supported in 2.0 */ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { @@ -755,18 +749,18 @@ } public IPixlrConfigItemDAO getPixlrConfigItemDAO() { - return pixlrConfigItemDAO; + return pixlrConfigItemDAO; } public void setPixlrConfigItemDAO(IPixlrConfigItemDAO pixlrConfigItemDAO) { - this.pixlrConfigItemDAO = pixlrConfigItemDAO; + this.pixlrConfigItemDAO = pixlrConfigItemDAO; } public IRepositoryService getRepositoryService() { - return repositoryService; + return repositoryService; } public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } + this.repositoryService = repositoryService; + } } Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java,v diff -u -r1.22 -r1.23 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java 16 Mar 2009 05:56:04 -0000 1.22 +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java 2 Jul 2009 13:00:42 -0000 1.23 @@ -48,7 +48,6 @@ import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; -import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; @@ -313,7 +312,8 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { return new TreeMap(); } @@ -602,13 +602,13 @@ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { this.coreNotebookService = coreNotebookService; } - + public IRepositoryService getRepositoryService() { - return repositoryService; + return repositoryService; } public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; + this.repositoryService = repositoryService; } public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { Index: lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/service/SpreadsheetServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/service/SpreadsheetServiceImpl.java,v diff -u -r1.4 -r1.5 --- lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/service/SpreadsheetServiceImpl.java 23 Jul 2008 04:46:03 -0000 1.4 +++ lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/service/SpreadsheetServiceImpl.java 2 Jul 2009 13:03:05 -0000 1.5 @@ -22,6 +22,7 @@ */ /* $$Id$$ */ package org.lamsfoundation.lams.tool.spreadsheet.service; + import java.io.File; import java.io.FileFilter; import java.io.FileNotFoundException; @@ -98,811 +99,814 @@ * @author Andrey Balan * */ -public class SpreadsheetServiceImpl implements ISpreadsheetService,ToolContentManager, ToolSessionManager, ToolContentImport102Manager { - static Logger log = Logger.getLogger(SpreadsheetServiceImpl.class.getName()); - private SpreadsheetDAO spreadsheetDao; - private SpreadsheetAttachmentDAO spreadsheetAttachmentDao; - private SpreadsheetUserDAO spreadsheetUserDao; - private SpreadsheetSessionDAO spreadsheetSessionDao; - private UserModifiedSpreadsheetDAO userModifiedSpreadsheetDao; - private SpreadsheetMarkDAO spreadsheetMarkDao; - //tool service - private SpreadsheetToolContentHandler spreadsheetToolContentHandler; - private MessageService messageService; - //system services - private IRepositoryService repositoryService; - private ILamsToolService toolService; - private ILearnerService learnerService; - private IAuditService auditService; - private IUserManagementService userManagementService; - private IExportToolContentService exportContentService; - private ICoreNotebookService coreNotebookService; - - //******************************************************************************* - // Service method - //******************************************************************************* - /** Try to get the file. If forceLogin = false and an access denied exception occurs, call this method - * again to get a new ticket and retry file lookup. If forceLogin = true and it then fails - * then throw exception. - * @param uuid - * @param versionId - * @param relativePath - * @param attemptCount - * @return file node - * @throws ImscpApplicationException - */ - private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws SpreadsheetApplicationException { - - ITicket tic = getRepositoryLoginTicket(); - - try { - - return repositoryService.getFileItem(tic, uuid, versionId, relativePath); - - } catch (AccessDeniedException e) { - - String error = "Unable to access repository to get file uuid "+uuid - +" version id "+versionId - +" path " + relativePath+"."; - - error = error+"AccessDeniedException: "+e.getMessage()+" Unable to retry further."; - log.error(error); - throw new SpreadsheetApplicationException(error,e); - - } catch (Exception e) { - - String error = "Unable to access repository to get file uuid "+uuid - +" version id "+versionId - +" path " + relativePath+"." - +" Exception: "+e.getMessage(); - log.error(error); - throw new SpreadsheetApplicationException(error,e); - - } - } - /** - * This method verifies the credentials of the Spreadsheet Tool and gives it - * the Ticket to login and access the Content Repository. - * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. - * - * @return ITicket The ticket for repostory access - * @throws SpreadsheetApplicationException - */ - private ITicket getRepositoryLoginTicket() throws SpreadsheetApplicationException { - ICredentials credentials = new SimpleCredentials( - spreadsheetToolContentHandler.getRepositoryUser(), - spreadsheetToolContentHandler.getRepositoryId()); - try { - ITicket ticket = repositoryService.login(credentials, - spreadsheetToolContentHandler.getRepositoryWorkspaceName()); - return ticket; - } catch (AccessDeniedException ae) { - throw new SpreadsheetApplicationException("Access Denied to repository." - + ae.getMessage()); - } catch (WorkspaceNotFoundException we) { - throw new SpreadsheetApplicationException("Workspace not found." - + we.getMessage()); - } catch (LoginException e) { - throw new SpreadsheetApplicationException("Login failed." + e.getMessage()); - } - } +public class SpreadsheetServiceImpl implements ISpreadsheetService, ToolContentManager, ToolSessionManager, + ToolContentImport102Manager { + static Logger log = Logger.getLogger(SpreadsheetServiceImpl.class.getName()); + private SpreadsheetDAO spreadsheetDao; + private SpreadsheetAttachmentDAO spreadsheetAttachmentDao; + private SpreadsheetUserDAO spreadsheetUserDao; + private SpreadsheetSessionDAO spreadsheetSessionDao; + private UserModifiedSpreadsheetDAO userModifiedSpreadsheetDao; + private SpreadsheetMarkDAO spreadsheetMarkDao; + // tool service + private SpreadsheetToolContentHandler spreadsheetToolContentHandler; + private MessageService messageService; + // system services + private IRepositoryService repositoryService; + private ILamsToolService toolService; + private ILearnerService learnerService; + private IAuditService auditService; + private IUserManagementService userManagementService; + private IExportToolContentService exportContentService; + private ICoreNotebookService coreNotebookService; + // ******************************************************************************* + // Service method + // ******************************************************************************* + /** + * Try to get the file. If forceLogin = false and an access denied exception occurs, call this method again to get a + * new ticket and retry file lookup. If forceLogin = true and it then fails then throw exception. + * + * @param uuid + * @param versionId + * @param relativePath + * @param attemptCount + * @return file node + * @throws ImscpApplicationException + */ + private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) + throws SpreadsheetApplicationException { - public Spreadsheet getSpreadsheetByContentId(Long contentId) { - Spreadsheet rs = spreadsheetDao.getByContentId(contentId); - if(rs == null){ - log.error("Could not find the content by given ID:"+contentId); - } - return rs; - } + ITicket tic = getRepositoryLoginTicket(); + try { - public Spreadsheet getDefaultContent(Long contentId) throws SpreadsheetApplicationException { - if (contentId == null) - { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new SpreadsheetApplicationException(error); - } - - Spreadsheet defaultContent = getDefaultSpreadsheet(); - //save default content by given ID. - Spreadsheet content = new Spreadsheet(); - content = Spreadsheet.newInstance(defaultContent,contentId,spreadsheetToolContentHandler); - return content; + return repositoryService.getFileItem(tic, uuid, versionId, relativePath); + + } catch (AccessDeniedException e) { + + String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + + " path " + relativePath + "."; + + error = error + "AccessDeniedException: " + e.getMessage() + " Unable to retry further."; + SpreadsheetServiceImpl.log.error(error); + throw new SpreadsheetApplicationException(error, e); + + } catch (Exception e) { + + String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + + " path " + relativePath + "." + " Exception: " + e.getMessage(); + SpreadsheetServiceImpl.log.error(error); + throw new SpreadsheetApplicationException(error, e); + } + } - public SpreadsheetAttachment uploadInstructionFile(FormFile uploadFile, String fileType) throws UploadSpreadsheetFileException { - if(uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) - throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.upload.file.not.found",new Object[]{uploadFile})); - - //upload file to repository - NodeKey nodeKey = processFile(uploadFile,fileType); - - //create new attachement - SpreadsheetAttachment file = new SpreadsheetAttachment(); - file.setFileType(fileType); - file.setFileUuid(nodeKey.getUuid()); - file.setFileVersionId(nodeKey.getVersion()); - file.setFileName(uploadFile.getFileName()); - file.setCreated(new Date()); - - return file; + /** + * This method verifies the credentials of the Spreadsheet Tool and gives it the Ticket to login and + * access the Content Repository. + * + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. + * + * @return ITicket The ticket for repostory access + * @throws SpreadsheetApplicationException + */ + private ITicket getRepositoryLoginTicket() throws SpreadsheetApplicationException { + ICredentials credentials = new SimpleCredentials(spreadsheetToolContentHandler.getRepositoryUser(), + spreadsheetToolContentHandler.getRepositoryId()); + try { + ITicket ticket = repositoryService.login(credentials, spreadsheetToolContentHandler + .getRepositoryWorkspaceName()); + return ticket; + } catch (AccessDeniedException ae) { + throw new SpreadsheetApplicationException("Access Denied to repository." + ae.getMessage()); + } catch (WorkspaceNotFoundException we) { + throw new SpreadsheetApplicationException("Workspace not found." + we.getMessage()); + } catch (LoginException e) { + throw new SpreadsheetApplicationException("Login failed." + e.getMessage()); } + } - public void saveOrUpdateUser(SpreadsheetUser spreadsheetUser) { - spreadsheetUserDao.saveObject(spreadsheetUser); + public Spreadsheet getSpreadsheetByContentId(Long contentId) { + Spreadsheet rs = spreadsheetDao.getByContentId(contentId); + if (rs == null) { + SpreadsheetServiceImpl.log.error("Could not find the content by given ID:" + contentId); } - - public void saveOrUpdateUserModifiedSpreadsheet(UserModifiedSpreadsheet userModifiedSpreadsheet) { - userModifiedSpreadsheetDao.saveObject(userModifiedSpreadsheet); + return rs; + } + + public Spreadsheet getDefaultContent(Long contentId) throws SpreadsheetApplicationException { + if (contentId == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + SpreadsheetServiceImpl.log.error(error); + throw new SpreadsheetApplicationException(error); } - - public SpreadsheetUser getUserByIDAndContent(Long userId, Long contentId) { - return (SpreadsheetUser) spreadsheetUserDao.getUserByUserIDAndContentID(userId,contentId); + + Spreadsheet defaultContent = getDefaultSpreadsheet(); + // save default content by given ID. + Spreadsheet content = new Spreadsheet(); + content = Spreadsheet.newInstance(defaultContent, contentId, spreadsheetToolContentHandler); + return content; + } + + public SpreadsheetAttachment uploadInstructionFile(FormFile uploadFile, String fileType) + throws UploadSpreadsheetFileException { + if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) { + throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.upload.file.not.found", + new Object[] { uploadFile })); } - - public SpreadsheetUser getUserByIDAndSession(Long userId, Long sessionId) { - return (SpreadsheetUser) spreadsheetUserDao.getUserByUserIDAndSessionID(userId,sessionId); + + // upload file to repository + NodeKey nodeKey = processFile(uploadFile, fileType); + + // create new attachement + SpreadsheetAttachment file = new SpreadsheetAttachment(); + file.setFileType(fileType); + file.setFileUuid(nodeKey.getUuid()); + file.setFileVersionId(nodeKey.getVersion()); + file.setFileName(uploadFile.getFileName()); + file.setCreated(new Date()); + + return file; + } + + public void saveOrUpdateUser(SpreadsheetUser spreadsheetUser) { + spreadsheetUserDao.saveObject(spreadsheetUser); + } + + public void saveOrUpdateUserModifiedSpreadsheet(UserModifiedSpreadsheet userModifiedSpreadsheet) { + userModifiedSpreadsheetDao.saveObject(userModifiedSpreadsheet); + } + + public SpreadsheetUser getUserByIDAndContent(Long userId, Long contentId) { + return spreadsheetUserDao.getUserByUserIDAndContentID(userId, contentId); + } + + public SpreadsheetUser getUserByIDAndSession(Long userId, Long sessionId) { + return spreadsheetUserDao.getUserByUserIDAndSessionID(userId, sessionId); + } + + public List getUserListBySessionId(Long sessionId) { + List userList = spreadsheetUserDao.getBySessionID(sessionId); + return userList; + } + + public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws SpreadsheetApplicationException { + ITicket ticket = getRepositoryLoginTicket(); + try { + repositoryService.deleteVersion(ticket, fileUuid, fileVersionId); + } catch (Exception e) { + throw new SpreadsheetApplicationException("Exception occured while deleting files from" + + " the repository " + e.getMessage()); } - - public List getUserListBySessionId(Long sessionId) { - List userList = spreadsheetUserDao.getBySessionID(sessionId); - return userList; - } - - public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws SpreadsheetApplicationException { - ITicket ticket = getRepositoryLoginTicket(); - try { - repositoryService.deleteVersion(ticket, fileUuid,fileVersionId); - } catch (Exception e) { - throw new SpreadsheetApplicationException( - "Exception occured while deleting files from" - + " the repository " + e.getMessage()); - } - } + } - public void saveOrUpdateSpreadsheet(Spreadsheet spreadsheet) { - spreadsheetDao.saveObject(spreadsheet); + public void saveOrUpdateSpreadsheet(Spreadsheet spreadsheet) { + spreadsheetDao.saveObject(spreadsheet); + } + + public void deleteSpreadsheetAttachment(Long attachmentUid) { + spreadsheetAttachmentDao.removeObject(SpreadsheetAttachment.class, attachmentUid); + + } + + public List exportForLearner(Long sessionId, SpreadsheetUser learner) { + SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(sessionId); + if (session == null) { + SpreadsheetServiceImpl.log.error("Failed get SpreadsheetSession by ID [" + sessionId + "]"); + return null; } - public void deleteSpreadsheetAttachment(Long attachmentUid) { - spreadsheetAttachmentDao.removeObject(SpreadsheetAttachment.class, attachmentUid); - + Spreadsheet spreadsheet = session.getSpreadsheet(); + List summaryList = new ArrayList(); + + List userList = new ArrayList(); + userList.add(learner); + Summary summary = new Summary(session, spreadsheet, userList); + + // Fill up reflect dto + NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, + SpreadsheetConstants.TOOL_SIGNATURE, learner.getUserId().intValue()); + ReflectDTO reflectDTO = new ReflectDTO(learner); + if (notebookEntry == null) { + reflectDTO.setFinishReflection(false); + reflectDTO.setReflect(null); + } else { + reflectDTO.setFinishReflection(true); + reflectDTO.setReflect(notebookEntry.getEntry()); } + reflectDTO.setReflectInstructions(session.getSpreadsheet().getReflectInstructions()); + summary.getReflectDTOList().add(reflectDTO); + summaryList.add(summary); - public List exportForLearner(Long sessionId, SpreadsheetUser learner) { - SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(sessionId); - if(session == null){ - log.error("Failed get SpreadsheetSession by ID [" +sessionId + "]"); - return null; + return summaryList; + + // initial spreadsheet items list + // List itemList = new ArrayList(); + // Set resList = session.getSpreadsheet().getSpreadsheetItems(); + // for(SpreadsheetItem item:resList){ + // if(skipHide && item.isHide()) + // continue; + // //if item is create by author + // if(item.isCreateByAuthor()){ + // Summary sum = new Summary(session.getSessionId(), session.getSessionName(),item,false); + // itemList.add(sum); + // } + // } + // + // //get this session's all spreadsheet items + // Set sessList =session.getSpreadsheetItems(); + // for(SpreadsheetItem item:sessList){ + // if(skipHide && item.isHide()) + // continue; + // + // //to skip all item create by author + // if(!item.isCreateByAuthor()){ + // Summary sum = new Summary(session.getSessionId(), session.getSessionName(),item,false); + // itemList.add(sum); + // } + // } + + // return itemList; + } + + public List exportForTeacher(Long contentId) { + Spreadsheet spreadsheet = spreadsheetDao.getByContentId(contentId); + List summaryList = new ArrayList(); + + List sessionList = spreadsheetSessionDao.getByContentId(contentId); + // create the user list of all whom were started this task + for (SpreadsheetSession session : sessionList) { + List userList = spreadsheetUserDao.getBySessionID(session.getSessionId()); + Summary summary = new Summary(session, spreadsheet, userList); + + // Fill up reflect dto + for (SpreadsheetUser user : userList) { + NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, + SpreadsheetConstants.TOOL_SIGNATURE, user.getUserId().intValue()); + + ReflectDTO reflectDTO = new ReflectDTO(user); + if (notebookEntry == null) { + reflectDTO.setFinishReflection(false); + reflectDTO.setReflect(null); + } else { + reflectDTO.setFinishReflection(true); + reflectDTO.setReflect(notebookEntry.getEntry()); } - - Spreadsheet spreadsheet = session.getSpreadsheet(); - List summaryList = new ArrayList(); - - List userList = new ArrayList(); - userList.add(learner); - Summary summary = new Summary(session, spreadsheet, userList); - - //Fill up reflect dto - NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - SpreadsheetConstants.TOOL_SIGNATURE, learner.getUserId().intValue()); - ReflectDTO reflectDTO = new ReflectDTO(learner); - if(notebookEntry == null){ - reflectDTO.setFinishReflection(false); - reflectDTO.setReflect(null); - }else{ - reflectDTO.setFinishReflection(true); - reflectDTO.setReflect(notebookEntry.getEntry()); - } reflectDTO.setReflectInstructions(session.getSpreadsheet().getReflectInstructions()); + summary.getReflectDTOList().add(reflectDTO); - summaryList.add(summary); - - return summaryList; - - - - - - - - - - - - - - //initial spreadsheet items list -// List itemList = new ArrayList(); -// Set resList = session.getSpreadsheet().getSpreadsheetItems(); -// for(SpreadsheetItem item:resList){ -// if(skipHide && item.isHide()) -// continue; -// //if item is create by author -// if(item.isCreateByAuthor()){ -// Summary sum = new Summary(session.getSessionId(), session.getSessionName(),item,false); -// itemList.add(sum); -// } -// } -// -// //get this session's all spreadsheet items -// Set sessList =session.getSpreadsheetItems(); -// for(SpreadsheetItem item:sessList){ -// if(skipHide && item.isHide()) -// continue; -// -// //to skip all item create by author -// if(!item.isCreateByAuthor()){ -// Summary sum = new Summary(session.getSessionId(), session.getSessionName(),item,false); -// itemList.add(sum); -// } -// } - -// return itemList; + } + summaryList.add(summary); } - - public List exportForTeacher(Long contentId) { - Spreadsheet spreadsheet = spreadsheetDao.getByContentId(contentId); - List summaryList = new ArrayList(); - - List sessionList = spreadsheetSessionDao.getByContentId(contentId); - //create the user list of all whom were started this task - for(SpreadsheetSession session:sessionList) { - List userList = spreadsheetUserDao.getBySessionID(session.getSessionId()); - Summary summary = new Summary(session, spreadsheet, userList); - - //Fill up reflect dto - for(SpreadsheetUser user : userList) { - NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - SpreadsheetConstants.TOOL_SIGNATURE, user.getUserId().intValue()); - - ReflectDTO reflectDTO = new ReflectDTO(user); - if(notebookEntry == null){ - reflectDTO.setFinishReflection(false); - reflectDTO.setReflect(null); - }else{ - reflectDTO.setFinishReflection(true); - reflectDTO.setReflect(notebookEntry.getEntry()); - } - reflectDTO.setReflectInstructions(session.getSpreadsheet().getReflectInstructions()); - - summary.getReflectDTOList().add(reflectDTO); - } - summaryList.add(summary); - } - - return summaryList; + + return summaryList; + } + + public Spreadsheet getSpreadsheetBySessionId(Long sessionId) { + SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(sessionId); + // to skip CGLib problem + Long contentId = session.getSpreadsheet().getContentId(); + Spreadsheet res = spreadsheetDao.getByContentId(contentId); + return res; + } + + public SpreadsheetSession getSessionBySessionId(Long sessionId) { + return spreadsheetSessionDao.getSessionBySessionId(sessionId); + } + + public void saveOrUpdateSpreadsheetSession(SpreadsheetSession resSession) { + spreadsheetSessionDao.saveObject(resSession); + } + + public String finishToolSession(Long toolSessionId, Long userId) throws SpreadsheetApplicationException { + SpreadsheetUser user = spreadsheetUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); + user.setSessionFinished(true); + spreadsheetUserDao.saveObject(user); + + // SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(toolSessionId); + // session.setStatus(SpreadsheetConstants.COMPLETED); + // spreadsheetSessionDao.saveObject(session); + + String nextUrl = null; + try { + nextUrl = this.leaveToolSession(toolSessionId, userId); + } catch (DataMissingException e) { + throw new SpreadsheetApplicationException(e); + } catch (ToolException e) { + throw new SpreadsheetApplicationException(e); } - - public Spreadsheet getSpreadsheetBySessionId(Long sessionId){ - SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(sessionId); - //to skip CGLib problem - Long contentId = session.getSpreadsheet().getContentId(); - Spreadsheet res = spreadsheetDao.getByContentId(contentId); - return res; - } - public SpreadsheetSession getSessionBySessionId(Long sessionId) { - return spreadsheetSessionDao.getSessionBySessionId(sessionId); - } + return nextUrl; + } + public List getSummary(Long contentId) { + Spreadsheet spreadsheet = spreadsheetDao.getByContentId(contentId); + List sessionList = spreadsheetSessionDao.getByContentId(contentId); - public void saveOrUpdateSpreadsheetSession(SpreadsheetSession resSession) { - spreadsheetSessionDao.saveObject(resSession); + List summaryList = new ArrayList(); + + // create the user list of all whom were started this task + for (SpreadsheetSession session : sessionList) { + List userList = spreadsheetUserDao.getBySessionID(session.getSessionId()); + + Summary summary = new Summary(session, spreadsheet, userList); + summaryList.add(summary); } - public String finishToolSession(Long toolSessionId, Long userId) throws SpreadsheetApplicationException { - SpreadsheetUser user = spreadsheetUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); - user.setSessionFinished(true); - spreadsheetUserDao.saveObject(user); - -// SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(toolSessionId); -// session.setStatus(SpreadsheetConstants.COMPLETED); -// spreadsheetSessionDao.saveObject(session); - - String nextUrl = null; - try { - nextUrl = this.leaveToolSession(toolSessionId,userId); - } catch (DataMissingException e) { - throw new SpreadsheetApplicationException(e); - } catch (ToolException e) { - throw new SpreadsheetApplicationException(e); + return summaryList; + } + + public List getStatistics(Long contentId) { + List sessionList = spreadsheetSessionDao.getByContentId(contentId); + + List statisticList = new ArrayList(); + + for (SpreadsheetSession session : sessionList) { + List userList = spreadsheetUserDao.getBySessionID(session.getSessionId()); + int totalUserModifiedSpreadsheets = 0; + int totalMarkedSpreadsheets = 0; + for (SpreadsheetUser user : userList) { + if (user.getUserModifiedSpreadsheet() != null) { + totalUserModifiedSpreadsheets++; + if (user.getUserModifiedSpreadsheet().getMark() != null) { + totalMarkedSpreadsheets++; + } } - return nextUrl; + } + + StatisticDTO statistic = new StatisticDTO(session.getSessionName(), totalMarkedSpreadsheets, + totalUserModifiedSpreadsheets - totalMarkedSpreadsheets, totalUserModifiedSpreadsheets); + statisticList.add(statistic); } - public List getSummary(Long contentId) { - Spreadsheet spreadsheet = spreadsheetDao.getByContentId(contentId); - List sessionList = spreadsheetSessionDao.getByContentId(contentId); + return statisticList; + } - List summaryList = new ArrayList(); - - //create the user list of all whom were started this task - for(SpreadsheetSession session:sessionList) { - List userList = spreadsheetUserDao.getBySessionID(session.getSessionId()); - - Summary summary = new Summary(session, spreadsheet, userList); - summaryList.add(summary); + public Map> getReflectList(Long contentId, boolean setEntry) { + Map> map = new HashMap>(); + + List sessionList = spreadsheetSessionDao.getByContentId(contentId); + for (SpreadsheetSession session : sessionList) { + Long sessionId = session.getSessionId(); + boolean hasRefection = session.getSpreadsheet().isReflectOnActivity(); + Set list = new TreeSet(new ReflectDTOComparator()); + // get all users in this session + List users = spreadsheetUserDao.getBySessionID(sessionId); + for (SpreadsheetUser user : users) { + ReflectDTO ref = new ReflectDTO(user); + + if (setEntry) { + NotebookEntry entry = getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + SpreadsheetConstants.TOOL_SIGNATURE, user.getUserId().intValue()); + if (entry != null) { + ref.setReflect(entry.getEntry()); + } } - return summaryList; + ref.setHasRefection(hasRefection); + list.add(ref); + } + map.put(sessionId, list); } - - public List getStatistics(Long contentId) { - List sessionList = spreadsheetSessionDao.getByContentId(contentId); - List statisticList = new ArrayList(); - - for(SpreadsheetSession session:sessionList) { - List userList = spreadsheetUserDao.getBySessionID(session.getSessionId()); - int totalUserModifiedSpreadsheets = 0; - int totalMarkedSpreadsheets = 0; - for (SpreadsheetUser user:userList) { - if (user.getUserModifiedSpreadsheet() != null) { - totalUserModifiedSpreadsheets++; - if (user.getUserModifiedSpreadsheet().getMark() != null) - totalMarkedSpreadsheets++; - } - } - - StatisticDTO statistic = new StatisticDTO(session.getSessionName(), totalMarkedSpreadsheets, totalUserModifiedSpreadsheets - totalMarkedSpreadsheets, totalUserModifiedSpreadsheets); - statisticList.add(statistic); - } + return map; + } - return statisticList; + public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, + String entryText) { + return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", + entryText); + } + + public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { + List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); + if (list == null || list.isEmpty()) { + return null; + } else { + return list.get(0); } - - public Map> getReflectList(Long contentId, boolean setEntry){ - Map> map = new HashMap>(); + } - List sessionList = spreadsheetSessionDao.getByContentId(contentId); - for(SpreadsheetSession session:sessionList){ - Long sessionId = session.getSessionId(); - boolean hasRefection = session.getSpreadsheet().isReflectOnActivity(); - Set list = new TreeSet(new ReflectDTOComparator()); - //get all users in this session - List users = spreadsheetUserDao.getBySessionID(sessionId); - for(SpreadsheetUser user : users){ - ReflectDTO ref = new ReflectDTO(user); - - if (setEntry) { - NotebookEntry entry = getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, - SpreadsheetConstants.TOOL_SIGNATURE, user.getUserId().intValue()); - if (entry != null) { - ref.setReflect(entry.getEntry()); - } - } - - ref.setHasRefection(hasRefection); - list.add(ref); - } - map.put(sessionId, list); - } - - return map; + /** + * @param notebookEntry + */ + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } + + public SpreadsheetUser getUser(Long uid) { + return (SpreadsheetUser) spreadsheetUserDao.getObject(SpreadsheetUser.class, uid); + } + + public void releaseMarksForSession(Long sessionId) { + List users = spreadsheetUserDao.getBySessionID(sessionId); + for (SpreadsheetUser user : users) { + if (user.getUserModifiedSpreadsheet() != null && user.getUserModifiedSpreadsheet().getMark() != null) { + SpreadsheetMark mark = user.getUserModifiedSpreadsheet().getMark(); + mark.setDateMarksReleased(new Date()); + spreadsheetMarkDao.saveObject(mark); + } } + } - public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { - return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); + // ***************************************************************************** + // private methods + // ***************************************************************************** + private Spreadsheet getDefaultSpreadsheet() throws SpreadsheetApplicationException { + Long defaultSpreadsheetId = getToolDefaultContentIdBySignature(SpreadsheetConstants.TOOL_SIGNATURE); + Spreadsheet defaultSpreadsheet = getSpreadsheetByContentId(defaultSpreadsheetId); + if (defaultSpreadsheet == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + SpreadsheetServiceImpl.log.error(error); + throw new SpreadsheetApplicationException(error); } - public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID){ - List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if (list == null || list.isEmpty()) { - return null; - } else { - return list.get(0); - } + + return defaultSpreadsheet; + } + + private Long getToolDefaultContentIdBySignature(String toolSignature) throws SpreadsheetApplicationException { + Long contentId = null; + contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); + if (contentId == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + SpreadsheetServiceImpl.log.error(error); + throw new SpreadsheetApplicationException(error); } - - /** - * @param notebookEntry - */ - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); - } - - public SpreadsheetUser getUser(Long uid){ - return (SpreadsheetUser) spreadsheetUserDao.getObject(SpreadsheetUser.class, uid); - } - - public void releaseMarksForSession(Long sessionId){ - List users = spreadsheetUserDao.getBySessionID(sessionId); - for (SpreadsheetUser user: users) { - if ((user.getUserModifiedSpreadsheet() != null) && (user.getUserModifiedSpreadsheet().getMark() != null)) { - SpreadsheetMark mark = user.getUserModifiedSpreadsheet().getMark(); - mark.setDateMarksReleased(new Date()); - spreadsheetMarkDao.saveObject(mark); - } - } - } - - //***************************************************************************** - // private methods - //***************************************************************************** - private Spreadsheet getDefaultSpreadsheet() throws SpreadsheetApplicationException { - Long defaultSpreadsheetId = getToolDefaultContentIdBySignature(SpreadsheetConstants.TOOL_SIGNATURE); - Spreadsheet defaultSpreadsheet = getSpreadsheetByContentId(defaultSpreadsheetId); - if(defaultSpreadsheet == null) - { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new SpreadsheetApplicationException(error); - } - - return defaultSpreadsheet; - } - private Long getToolDefaultContentIdBySignature(String toolSignature) throws SpreadsheetApplicationException - { - Long contentId = null; - contentId=new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); - if (contentId == null) - { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new SpreadsheetApplicationException(error); - } - return contentId; + return contentId; } + /** * Process an uploaded file. * - * @throws SpreadsheetApplicationException + * @throws SpreadsheetApplicationException * @throws FileNotFoundException * @throws IOException * @throws RepositoryCheckedException * @throws InvalidParameterException */ private NodeKey processFile(FormFile file, String fileType) throws UploadSpreadsheetFileException { - NodeKey node = null; - if (file!= null && !StringUtils.isEmpty(file.getFileName())) { - String fileName = file.getFileName(); - try { - node = spreadsheetToolContentHandler.uploadFile(file.getInputStream(), fileName, - file.getContentType(), fileType); - } catch (InvalidParameterException e) { - throw new UploadSpreadsheetFileException (messageService.getMessage("error.msg.invaid.param.upload")); - } catch (FileNotFoundException e) { - throw new UploadSpreadsheetFileException (messageService.getMessage("error.msg.file.not.found")); - } catch (RepositoryCheckedException e) { - throw new UploadSpreadsheetFileException (messageService.getMessage("error.msg.repository")); - } catch (IOException e) { - throw new UploadSpreadsheetFileException (messageService.getMessage("error.msg.io.exception")); - } - } - return node; - } - private NodeKey processPackage(String packageDirectory, String initFile) throws UploadSpreadsheetFileException { - NodeKey node = null; - try { - node = spreadsheetToolContentHandler.uploadPackage(packageDirectory, initFile); - } catch (InvalidParameterException e) { - throw new UploadSpreadsheetFileException (messageService.getMessage("error.msg.invaid.param.upload")); - } catch (RepositoryCheckedException e) { - throw new UploadSpreadsheetFileException (messageService.getMessage("error.msg.repository")); - } - return node; + NodeKey node = null; + if (file != null && !StringUtils.isEmpty(file.getFileName())) { + String fileName = file.getFileName(); + try { + node = spreadsheetToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType(), + fileType); + } catch (InvalidParameterException e) { + throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.invaid.param.upload")); + } catch (FileNotFoundException e) { + throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.file.not.found")); + } catch (RepositoryCheckedException e) { + throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.repository")); + } catch (IOException e) { + throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.io.exception")); + } } + return node; + } - /** - * Find out default.htm/html or index.htm/html in the given directory folder - * @param packageDirectory - * @return - */ - private String findWebsiteInitialItem(String packageDirectory) { - File file = new File(packageDirectory); - if(!file.isDirectory()) - return null; - - File[] initFiles = file.listFiles(new FileFilter(){ - public boolean accept(File pathname) { - if(pathname == null || pathname.getName() == null) - return false; - String name = pathname.getName(); - if(name.endsWith("default.html") - ||name.endsWith("default.htm") - ||name.endsWith("index.html") - ||name.endsWith("index.htm")) - return true; - return false; - } - }); - if(initFiles != null && initFiles.length > 0) - return initFiles[0].getName(); - else - return null; + private NodeKey processPackage(String packageDirectory, String initFile) throws UploadSpreadsheetFileException { + NodeKey node = null; + try { + node = spreadsheetToolContentHandler.uploadPackage(packageDirectory, initFile); + } catch (InvalidParameterException e) { + throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.invaid.param.upload")); + } catch (RepositoryCheckedException e) { + throw new UploadSpreadsheetFileException(messageService.getMessage("error.msg.repository")); } + return node; + } - - //***************************************************************************** - // set methods for Spring Bean - //***************************************************************************** - public void setAuditService(IAuditService auditService) { - this.auditService = auditService; + /** + * Find out default.htm/html or index.htm/html in the given directory folder + * + * @param packageDirectory + * @return + */ + private String findWebsiteInitialItem(String packageDirectory) { + File file = new File(packageDirectory); + if (!file.isDirectory()) { + return null; } - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } - public void setMessageService(MessageService messageService) { - this.messageService = messageService; - } - public MessageService getMessageService() { - return messageService; - } - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } - public void setSpreadsheetAttachmentDao(SpreadsheetAttachmentDAO spreadsheetAttachmentDao) { - this.spreadsheetAttachmentDao = spreadsheetAttachmentDao; - } - public void setSpreadsheetDao(SpreadsheetDAO spreadsheetDao) { - this.spreadsheetDao = spreadsheetDao; - } - public void setSpreadsheetSessionDao(SpreadsheetSessionDAO spreadsheetSessionDao) { - this.spreadsheetSessionDao = spreadsheetSessionDao; - } - public void setSpreadsheetToolContentHandler(SpreadsheetToolContentHandler spreadsheetToolContentHandler) { - this.spreadsheetToolContentHandler = spreadsheetToolContentHandler; - } - public void setSpreadsheetUserDao(SpreadsheetUserDAO spreadsheetUserDao) { - this.spreadsheetUserDao = spreadsheetUserDao; - } - public void setToolService(ILamsToolService toolService) { - this.toolService = toolService; - } - public void setUserModifiedSpreadsheetDao(UserModifiedSpreadsheetDAO userModifiedSpreadsheetDao) { - this.userModifiedSpreadsheetDao = userModifiedSpreadsheetDao; - } - public void setSpreadsheetMarkDao(SpreadsheetMarkDAO spreadsheetMarkDao) { - this.spreadsheetMarkDao = spreadsheetMarkDao; - } - //******************************************************************************* - //ToolContentManager, ToolSessionManager methods - //******************************************************************************* - - public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { - Spreadsheet toolContentObj = spreadsheetDao.getByContentId(toolContentId); - if(toolContentObj == null) { - try { - toolContentObj = getDefaultSpreadsheet(); - } catch (SpreadsheetApplicationException e) { - throw new DataMissingException(e.getMessage()); - } - } - if(toolContentObj == null) - throw new DataMissingException("Unable to find default content for the spreadsheet tool"); - - //set SpreadsheetToolContentHandler as null to avoid copy file node in repository again. - toolContentObj = Spreadsheet.newInstance(toolContentObj,toolContentId,null); - toolContentObj.setToolContentHandler(null); - toolContentObj.setOfflineFileList(null); - toolContentObj.setOnlineFileList(null); - try { - exportContentService.registerFileClassForExport(SpreadsheetAttachment.class.getName(),"fileUuid","fileVersionId"); - exportContentService.exportToolContent( toolContentId, toolContentObj,spreadsheetToolContentHandler, rootPath); - } catch (ExportToolContentException e) { - throw new ToolException(e); + File[] initFiles = file.listFiles(new FileFilter() { + public boolean accept(File pathname) { + if (pathname == null || pathname.getName() == null) { + return false; } - } - - public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath ,String fromVersion,String toVersion) throws ToolException { - - try { - exportContentService.registerFileClassForImport(SpreadsheetAttachment.class.getName() - ,"fileUuid","fileVersionId","fileName","fileType",null,null); - - Object toolPOJO = exportContentService.importToolContent(toolContentPath,spreadsheetToolContentHandler,fromVersion,toVersion); - if(!(toolPOJO instanceof Spreadsheet)) - throw new ImportToolContentException("Import Share spreadsheet tool content failed. Deserialized object is " + toolPOJO); - Spreadsheet toolContentObj = (Spreadsheet) toolPOJO; - -// reset it to new toolContentId - toolContentObj.setContentId(toolContentId); - SpreadsheetUser user = spreadsheetUserDao.getUserByUserIDAndContentID(new Long(newUserUid.longValue()), toolContentId); - if(user == null){ - user = new SpreadsheetUser(); - UserDTO sysUser = ((User)userManagementService.findById(User.class,newUserUid)).getUserDTO(); - user.setFirstName(sysUser.getFirstName()); - user.setLastName(sysUser.getLastName()); - user.setLoginName(sysUser.getLogin()); - user.setUserId(new Long(newUserUid.longValue())); - user.setSpreadsheet(toolContentObj); - } - toolContentObj.setCreatedBy(user); - - spreadsheetDao.saveObject(toolContentObj); - } catch (ImportToolContentException e) { - throw new ToolException(e); + String name = pathname.getName(); + if (name.endsWith("default.html") || name.endsWith("default.htm") || name.endsWith("index.html") + || name.endsWith("index.htm")) { + return true; } + return false; + } + }); + if (initFiles != null && initFiles.length > 0) { + return initFiles[0].getName(); + } else { + return null; } + } - /** Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are always - * available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular activity - * such as the answer to the third question contains the word Koala and hence the need for the toolContentId - * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition - */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - return new TreeMap(); - } - + // ***************************************************************************** + // set methods for Spring Bean + // ***************************************************************************** + public void setAuditService(IAuditService auditService) { + this.auditService = auditService; + } - public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { - if (toContentId == null) - throw new ToolException( - "Failed to create the SharedSpreadsheetFiles tool seession"); + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } - Spreadsheet spreadsheet = null; - if ( fromContentId != null ) { - spreadsheet = spreadsheetDao.getByContentId(fromContentId); - } - if ( spreadsheet == null ) { - try { - spreadsheet = getDefaultSpreadsheet(); - } catch (SpreadsheetApplicationException e) { - throw new ToolException(e); - } - } + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } - Spreadsheet toContent = Spreadsheet.newInstance(spreadsheet,toContentId,spreadsheetToolContentHandler); - spreadsheetDao.saveObject(toContent); - } + public MessageService getMessageService() { + return messageService; + } + public void setRepositoryService(IRepositoryService repositoryService) { + this.repositoryService = repositoryService; + } - public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { - Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); - if(spreadsheet == null){ - throw new ToolException("No found tool content by given content ID:" + toolContentId); - } - spreadsheet.setDefineLater(value); - } + public void setSpreadsheetAttachmentDao(SpreadsheetAttachmentDAO spreadsheetAttachmentDao) { + this.spreadsheetAttachmentDao = spreadsheetAttachmentDao; + } + public void setSpreadsheetDao(SpreadsheetDAO spreadsheetDao) { + this.spreadsheetDao = spreadsheetDao; + } - public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { - Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); - if(spreadsheet == null){ - throw new ToolException("No found tool content by given content ID:" + toolContentId); - } - spreadsheet.setRunOffline(value); - } + public void setSpreadsheetSessionDao(SpreadsheetSessionDAO spreadsheetSessionDao) { + this.spreadsheetSessionDao = spreadsheetSessionDao; + } + public void setSpreadsheetToolContentHandler(SpreadsheetToolContentHandler spreadsheetToolContentHandler) { + this.spreadsheetToolContentHandler = spreadsheetToolContentHandler; + } - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException { - Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); - if(removeSessionData){ - List list = spreadsheetSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while(iter.hasNext()){ - SpreadsheetSession session = (SpreadsheetSession ) iter.next(); - spreadsheetSessionDao.delete(session); - } - } - spreadsheetDao.delete(spreadsheet); + public void setSpreadsheetUserDao(SpreadsheetUserDAO spreadsheetUserDao) { + this.spreadsheetUserDao = spreadsheetUserDao; + } + + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } + + public void setUserModifiedSpreadsheetDao(UserModifiedSpreadsheetDAO userModifiedSpreadsheetDao) { + this.userModifiedSpreadsheetDao = userModifiedSpreadsheetDao; + } + + public void setSpreadsheetMarkDao(SpreadsheetMarkDAO spreadsheetMarkDao) { + this.spreadsheetMarkDao = spreadsheetMarkDao; + } + + // ******************************************************************************* + // ToolContentManager, ToolSessionManager methods + // ******************************************************************************* + + public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { + Spreadsheet toolContentObj = spreadsheetDao.getByContentId(toolContentId); + if (toolContentObj == null) { + try { + toolContentObj = getDefaultSpreadsheet(); + } catch (SpreadsheetApplicationException e) { + throw new DataMissingException(e.getMessage()); + } } + if (toolContentObj == null) { + throw new DataMissingException("Unable to find default content for the spreadsheet tool"); + } - - public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { - SpreadsheetSession session = new SpreadsheetSession(); - session.setSessionId(toolSessionId); - session.setSessionName(toolSessionName); - Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); - session.setSpreadsheet(spreadsheet); - spreadsheetSessionDao.saveObject(session); + // set SpreadsheetToolContentHandler as null to avoid copy file node in repository again. + toolContentObj = Spreadsheet.newInstance(toolContentObj, toolContentId, null); + toolContentObj.setToolContentHandler(null); + toolContentObj.setOfflineFileList(null); + toolContentObj.setOnlineFileList(null); + try { + exportContentService.registerFileClassForExport(SpreadsheetAttachment.class.getName(), "fileUuid", + "fileVersionId"); + exportContentService.exportToolContent(toolContentId, toolContentObj, spreadsheetToolContentHandler, + rootPath); + } catch (ExportToolContentException e) { + throw new ToolException(e); } + } + public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException { - public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { - if(toolSessionId == null){ - log.error("Fail to leave tool Session based on null tool session id."); - throw new ToolException("Fail to remove tool Session based on null tool session id."); - } - if(learnerId == null){ - log.error("Fail to leave tool Session based on null learner."); - throw new ToolException("Fail to remove tool Session based on null learner."); - } - - SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(toolSessionId); - if(session != null){ - session.setStatus(SpreadsheetConstants.COMPLETED); - spreadsheetSessionDao.saveObject(session); - }else{ - log.error("Fail to leave tool Session.Could not find shared spreadsheet " + - "session by given session id: "+toolSessionId); - throw new DataMissingException("Fail to leave tool Session." + - "Could not find shared spreadsheet session by given session id: "+toolSessionId); - } - return learnerService.completeToolSession(toolSessionId,learnerId); + try { + exportContentService.registerFileClassForImport(SpreadsheetAttachment.class.getName(), "fileUuid", + "fileVersionId", "fileName", "fileType", null, null); + + Object toolPOJO = exportContentService.importToolContent(toolContentPath, spreadsheetToolContentHandler, + fromVersion, toVersion); + if (!(toolPOJO instanceof Spreadsheet)) { + throw new ImportToolContentException( + "Import Share spreadsheet tool content failed. Deserialized object is " + toolPOJO); + } + Spreadsheet toolContentObj = (Spreadsheet) toolPOJO; + + // reset it to new toolContentId + toolContentObj.setContentId(toolContentId); + SpreadsheetUser user = spreadsheetUserDao.getUserByUserIDAndContentID(new Long(newUserUid.longValue()), + toolContentId); + if (user == null) { + user = new SpreadsheetUser(); + UserDTO sysUser = ((User) userManagementService.findById(User.class, newUserUid)).getUserDTO(); + user.setFirstName(sysUser.getFirstName()); + user.setLastName(sysUser.getLastName()); + user.setLoginName(sysUser.getLogin()); + user.setUserId(new Long(newUserUid.longValue())); + user.setSpreadsheet(toolContentObj); + } + toolContentObj.setCreatedBy(user); + + spreadsheetDao.saveObject(toolContentObj); + } catch (ImportToolContentException e) { + throw new ToolException(e); } + } + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition + */ + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { + return new TreeMap(); + } - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { - return null; + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { + if (toContentId == null) { + throw new ToolException("Failed to create the SharedSpreadsheetFiles tool seession"); } + Spreadsheet spreadsheet = null; + if (fromContentId != null) { + spreadsheet = spreadsheetDao.getByContentId(fromContentId); + } + if (spreadsheet == null) { + try { + spreadsheet = getDefaultSpreadsheet(); + } catch (SpreadsheetApplicationException e) { + throw new ToolException(e); + } + } - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException { - return null; + Spreadsheet toContent = Spreadsheet.newInstance(spreadsheet, toContentId, spreadsheetToolContentHandler); + spreadsheetDao.saveObject(toContent); + } + + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { + Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); + if (spreadsheet == null) { + throw new ToolException("No found tool content by given content ID:" + toolContentId); } + spreadsheet.setDefineLater(value); + } + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { + Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); + if (spreadsheet == null) { + throw new ToolException("No found tool content by given content ID:" + toolContentId); + } + spreadsheet.setRunOffline(value); + } - public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { - spreadsheetSessionDao.deleteBySessionId(toolSessionId); + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException { + Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); + if (removeSessionData) { + List list = spreadsheetSessionDao.getByContentId(toolContentId); + Iterator iter = list.iterator(); + while (iter.hasNext()) { + SpreadsheetSession session = (SpreadsheetSession) iter.next(); + spreadsheetSessionDao.delete(session); + } } - - /** - * Get the tool output for the given tool output names. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) - */ - public SortedMap getToolOutput(List names, - Long toolSessionId, Long learnerId) { - return new TreeMap(); + spreadsheetDao.delete(spreadsheet); + } + + public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { + SpreadsheetSession session = new SpreadsheetSession(); + session.setSessionId(toolSessionId); + session.setSessionName(toolSessionName); + Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); + session.setSpreadsheet(spreadsheet); + spreadsheetSessionDao.saveObject(session); + } + + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { + if (toolSessionId == null) { + SpreadsheetServiceImpl.log.error("Fail to leave tool Session based on null tool session id."); + throw new ToolException("Fail to remove tool Session based on null tool session id."); } + if (learnerId == null) { + SpreadsheetServiceImpl.log.error("Fail to leave tool Session based on null learner."); + throw new ToolException("Fail to remove tool Session based on null learner."); + } - /** - * Get the tool output for the given tool output name. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) - */ - public ToolOutput getToolOutput(String name, Long toolSessionId, - Long learnerId) { - return null; + SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(toolSessionId); + if (session != null) { + session.setStatus(SpreadsheetConstants.COMPLETED); + spreadsheetSessionDao.saveObject(session); + } else { + SpreadsheetServiceImpl.log.error("Fail to leave tool Session.Could not find shared spreadsheet " + + "session by given session id: " + toolSessionId); + throw new DataMissingException("Fail to leave tool Session." + + "Could not find shared spreadsheet session by given session id: " + toolSessionId); } + return learnerService.completeToolSession(toolSessionId, learnerId); + } - /* ===============Methods implemented from ToolContentImport102Manager =============== */ - + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + return null; + } + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, + ToolException { + return null; + } + + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + spreadsheetSessionDao.deleteBySessionId(toolSessionId); + } + /** - * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard + * Get the tool output for the given tool output names. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) */ - public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { } + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { + return new TreeMap(); + } - /** Set the description, throws away the title value as this is not supported in 2.0 */ - public void setReflectiveData(Long toolContentId, String title, String description) - throws ToolException, DataMissingException { - - Spreadsheet toolContentObj = getSpreadsheetByContentId(toolContentId); - if ( toolContentObj == null ) { - throw new DataMissingException("Unable to set reflective data titled "+title - +" on activity toolContentId "+toolContentId - +" as the tool content does not exist."); - } - - toolContentObj.setReflectOnActivity(Boolean.TRUE); - toolContentObj.setReflectInstructions(description); + /** + * Get the tool output for the given tool output name. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) + */ + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return null; } - - /* =================================================================================== */ + /* ===============Methods implemented from ToolContentImport102Manager =============== */ - public IExportToolContentService getExportContentService() { - return exportContentService; - } + /** + * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard + */ + public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { + } + /** Set the description, throws away the title value as this is not supported in 2.0 */ + public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, + DataMissingException { - public void setExportContentService(IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; + Spreadsheet toolContentObj = getSpreadsheetByContentId(toolContentId); + if (toolContentObj == null) { + throw new DataMissingException("Unable to set reflective data titled " + title + + " on activity toolContentId " + toolContentId + " as the tool content does not exist."); } + toolContentObj.setReflectOnActivity(Boolean.TRUE); + toolContentObj.setReflectInstructions(description); + } - public IUserManagementService getUserManagementService() { - return userManagementService; - } + /* =================================================================================== */ + public IExportToolContentService getExportContentService() { + return exportContentService; + } - public void setUserManagementService(IUserManagementService userManagementService) { - this.userManagementService = userManagementService; - } + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } + public IUserManagementService getUserManagementService() { + return userManagementService; + } - public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; - } + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } + public ICoreNotebookService getCoreNotebookService() { + return coreNotebookService; + } - public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; - } + public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { + this.coreNotebookService = coreNotebookService; + } } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyOutputFactory.java,v diff -u -r1.7 -r1.8 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyOutputFactory.java 2 Jul 2009 08:19:23 -0000 1.7 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyOutputFactory.java 2 Jul 2009 13:00:24 -0000 1.8 @@ -55,7 +55,7 @@ * {@inheritDoc} */ @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); if (toolContentObject != null) { Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java,v diff -u -r1.26 -r1.27 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java 31 Oct 2008 05:57:32 -0000 1.26 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java 2 Jul 2009 13:00:24 -0000 1.27 @@ -739,7 +739,8 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { Survey survey = surveyDao.getByContentId(toolContentId); if (survey == null) { try { @@ -748,7 +749,7 @@ throw new ToolException(e); } } - return getSurveyOutputFactory().getToolOutputDefinitions(survey); + return getSurveyOutputFactory().getToolOutputDefinitions(survey, definitionType); } public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListOutputFactory.java,v diff -u -r1.3 -r1.4 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListOutputFactory.java 15 Apr 2008 11:03:27 -0000 1.3 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListOutputFactory.java 2 Jul 2009 13:04:20 -0000 1.4 @@ -57,7 +57,7 @@ /** * {@inheritDoc} */ - public SortedMap getToolOutputDefinitions(Object toolContentObject) throws ToolException { + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { TreeMap definitionMap = new TreeMap(); ToolOutputDefinition simpleDefinition = buildRangeDefinition(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED, new Long(0), null); Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java,v diff -u -r1.26 -r1.27 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java 26 Jun 2008 02:30:17 -0000 1.26 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java 2 Jul 2009 13:04:20 -0000 1.27 @@ -22,6 +22,7 @@ */ /* $$Id$$ */ package org.lamsfoundation.lams.tool.taskList.service; + import java.io.File; import java.io.FileFilter; import java.io.FileNotFoundException; @@ -30,18 +31,11 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.Vector; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -103,10 +97,7 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.MessageService; -import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.util.audit.IAuditService; -import org.lamsfoundation.lams.util.wddx.WDDXProcessor; -import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException; /** * Class implements org.lamsfoundation.lams.tool.taskList.service.ITaskListService. @@ -115,1143 +106,1197 @@ * @author Andrey Balan * @see org.lamsfoundation.lams.tool.taskList.service.ITaskListService */ -public class TaskListServiceImpl implements ITaskListService,ToolContentManager, ToolSessionManager, ToolContentImport102Manager { - static Logger log = Logger.getLogger(TaskListServiceImpl.class.getName()); - private TaskListDAO taskListDao; - private TaskListItemDAO taskListItemDao; - private TaskListAttachmentDAO taskListAttachmentDao; - private TaskListConditionDAO taskListConditionDAO; - private TaskListUserDAO taskListUserDao; - private TaskListSessionDAO taskListSessionDao; - private TaskListItemVisitDAO taskListItemVisitDao; - private TaskListItemAttachmentDAO taskListItemAttachmentDao; - private TaskListItemCommentDAO taskListItemCommentDAO; - //tool service - private TaskListToolContentHandler taskListToolContentHandler; - private MessageService messageService; - private TaskListOutputFactory taskListOutputFactory; - //system services - private IRepositoryService repositoryService; - private ILamsToolService toolService; - private ILearnerService learnerService; - private IAuditService auditService; - private IUserManagementService userManagementService; - private IExportToolContentService exportContentService; - private ICoreNotebookService coreNotebookService; - - //******************************************************************************* - // Methods implements ITaskListService. - //******************************************************************************* - - /** - * {@inheritDoc} - */ - public TaskList getTaskListByContentId(Long contentId) { - TaskList rs = taskListDao.getByContentId(contentId); - if(rs == null){ - log.error("Could not find the content by given ID:"+contentId); - } - return rs; - } +public class TaskListServiceImpl implements ITaskListService, ToolContentManager, ToolSessionManager, + ToolContentImport102Manager { + static Logger log = Logger.getLogger(TaskListServiceImpl.class.getName()); + private TaskListDAO taskListDao; + private TaskListItemDAO taskListItemDao; + private TaskListAttachmentDAO taskListAttachmentDao; + private TaskListConditionDAO taskListConditionDAO; + private TaskListUserDAO taskListUserDao; + private TaskListSessionDAO taskListSessionDao; + private TaskListItemVisitDAO taskListItemVisitDao; + private TaskListItemAttachmentDAO taskListItemAttachmentDao; + private TaskListItemCommentDAO taskListItemCommentDAO; + // tool service + private TaskListToolContentHandler taskListToolContentHandler; + private MessageService messageService; + private TaskListOutputFactory taskListOutputFactory; + // system services + private IRepositoryService repositoryService; + private ILamsToolService toolService; + private ILearnerService learnerService; + private IAuditService auditService; + private IUserManagementService userManagementService; + private IExportToolContentService exportContentService; + private ICoreNotebookService coreNotebookService; - /** - * {@inheritDoc} - */ - public TaskList getDefaultContent(Long contentId) throws TaskListException { - if (contentId == null) - { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new TaskListException(error); - } - - TaskList defaultContent = getDefaultTaskList(); - //save default content by given ID. - TaskList content = new TaskList(); - content = TaskList.newInstance(defaultContent,contentId,taskListToolContentHandler); - return content; - } + // ******************************************************************************* + // Methods implements ITaskListService. + // ******************************************************************************* - /** - * {@inheritDoc} - */ - public List getAuthoredItems(Long taskListUid) { - return taskListItemDao.getAuthoringItems(taskListUid); + /** + * {@inheritDoc} + */ + public TaskList getTaskListByContentId(Long contentId) { + TaskList rs = taskListDao.getByContentId(contentId); + if (rs == null) { + TaskListServiceImpl.log.error("Could not find the content by given ID:" + contentId); } + return rs; + } - /** - * {@inheritDoc} - */ - public TaskListAttachment uploadInstructionFile(FormFile uploadFile, String fileType) throws UploadTaskListFileException { - if(uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) - throw new UploadTaskListFileException(messageService.getMessage("error.msg.upload.file.not.found",new Object[]{uploadFile})); - - //upload file to repository - NodeKey nodeKey = processFile(uploadFile,fileType); - - //create new attachement - TaskListAttachment file = new TaskListAttachment(); - file.setFileType(fileType); - file.setFileUuid(nodeKey.getUuid()); - file.setFileVersionId(nodeKey.getVersion()); - file.setFileName(uploadFile.getFileName()); - file.setCreated(new Date()); - - return file; + /** + * {@inheritDoc} + */ + public TaskList getDefaultContent(Long contentId) throws TaskListException { + if (contentId == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + TaskListServiceImpl.log.error(error); + throw new TaskListException(error); } - - /** - * {@inheritDoc} - */ - public TaskListItemAttachment uploadTaskListItemFile(FormFile uploadFile, String fileType, TaskListUser user) throws UploadTaskListFileException { - if(uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) - throw new UploadTaskListFileException(messageService.getMessage("error.msg.upload.file.not.found",new Object[]{uploadFile})); - - //upload file to repository - NodeKey nodeKey = processFile(uploadFile,fileType); - - //create new attachement - TaskListItemAttachment file = new TaskListItemAttachment(); - file.setFileType(fileType); - file.setFileUuid(nodeKey.getUuid()); - file.setFileVersionId(nodeKey.getVersion()); - file.setFileName(uploadFile.getFileName()); - file.setCreated(new Timestamp(new Date().getTime())); - file.setCreateBy(user); - return file; - } + TaskList defaultContent = getDefaultTaskList(); + // save default content by given ID. + TaskList content = new TaskList(); + content = TaskList.newInstance(defaultContent, contentId, taskListToolContentHandler); + return content; + } - /** - * {@inheritDoc} - */ - public void createUser(TaskListUser taskListUser) { - taskListUserDao.saveObject(taskListUser); - } + /** + * {@inheritDoc} + */ + public List getAuthoredItems(Long taskListUid) { + return taskListItemDao.getAuthoringItems(taskListUid); + } - /** - * {@inheritDoc} - */ - public TaskListUser getUserByIDAndContent(Long userId, Long contentId) { - return (TaskListUser) taskListUserDao.getUserByUserIDAndContentID(userId,contentId); + /** + * {@inheritDoc} + */ + public TaskListAttachment uploadInstructionFile(FormFile uploadFile, String fileType) + throws UploadTaskListFileException { + if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.upload.file.not.found", + new Object[] { uploadFile })); } - - /** - * {@inheritDoc} - */ - public TaskListUser getUserByIDAndSession(Long userId, Long sessionId) { - return (TaskListUser) taskListUserDao.getUserByUserIDAndSessionID(userId,sessionId); - } - - /** - * {@inheritDoc} - */ - public TaskListUser getUser(Long uid){ - return (TaskListUser) taskListUserDao.getObject(TaskListUser.class, uid); - } - /** - * {@inheritDoc} - */ - public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListException { - ITicket ticket = getRepositoryLoginTicket(); - try { - repositoryService.deleteVersion(ticket, fileUuid,fileVersionId); - } catch (Exception e) { - throw new TaskListException( - "Exception occured while deleting files from" - + " the repository " + e.getMessage()); - } - } + // upload file to repository + NodeKey nodeKey = processFile(uploadFile, fileType); - /** - * {@inheritDoc} - */ - public void saveOrUpdateTaskList(TaskList taskList) { - taskListDao.saveObject(taskList); + // create new attachement + TaskListAttachment file = new TaskListAttachment(); + file.setFileType(fileType); + file.setFileUuid(nodeKey.getUuid()); + file.setFileVersionId(nodeKey.getVersion()); + file.setFileName(uploadFile.getFileName()); + file.setCreated(new Date()); + + return file; + } + + /** + * {@inheritDoc} + */ + public TaskListItemAttachment uploadTaskListItemFile(FormFile uploadFile, String fileType, TaskListUser user) + throws UploadTaskListFileException { + if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.upload.file.not.found", + new Object[] { uploadFile })); } - /** - * {@inheritDoc} - */ - public void deleteTaskListAttachment(Long attachmentUid) { - taskListAttachmentDao.removeObject(TaskListAttachment.class, attachmentUid); + // upload file to repository + NodeKey nodeKey = processFile(uploadFile, fileType); + + // create new attachement + TaskListItemAttachment file = new TaskListItemAttachment(); + file.setFileType(fileType); + file.setFileUuid(nodeKey.getUuid()); + file.setFileVersionId(nodeKey.getVersion()); + file.setFileName(uploadFile.getFileName()); + file.setCreated(new Timestamp(new Date().getTime())); + file.setCreateBy(user); + + return file; + } + + /** + * {@inheritDoc} + */ + public void createUser(TaskListUser taskListUser) { + taskListUserDao.saveObject(taskListUser); + } + + /** + * {@inheritDoc} + */ + public TaskListUser getUserByIDAndContent(Long userId, Long contentId) { + return taskListUserDao.getUserByUserIDAndContentID(userId, contentId); + } + + /** + * {@inheritDoc} + */ + public TaskListUser getUserByIDAndSession(Long userId, Long sessionId) { + return taskListUserDao.getUserByUserIDAndSessionID(userId, sessionId); + } + + /** + * {@inheritDoc} + */ + public TaskListUser getUser(Long uid) { + return (TaskListUser) taskListUserDao.getObject(TaskListUser.class, uid); + } + + /** + * {@inheritDoc} + */ + public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListException { + ITicket ticket = getRepositoryLoginTicket(); + try { + repositoryService.deleteVersion(ticket, fileUuid, fileVersionId); + } catch (Exception e) { + throw new TaskListException("Exception occured while deleting files from" + " the repository " + + e.getMessage()); } - - /** - * {@inheritDoc} - */ - public void deleteTaskListCondition(Long conditionUid) { - taskListConditionDAO.removeObject(TaskListCondition.class, conditionUid); - } - - /** - * {@inheritDoc} - */ - public void deleteTaskListItemAttachment(Long attachmentUid) { - taskListItemAttachmentDao.removeObject(TaskListItemAttachment.class, attachmentUid); - } + } - /** - * {@inheritDoc} - */ - public void saveOrUpdateTaskListItem(TaskListItem item) { - taskListItemDao.saveObject(item); + /** + * {@inheritDoc} + */ + public void saveOrUpdateTaskList(TaskList taskList) { + taskListDao.saveObject(taskList); + } + + /** + * {@inheritDoc} + */ + public void deleteTaskListAttachment(Long attachmentUid) { + taskListAttachmentDao.removeObject(TaskListAttachment.class, attachmentUid); + } + + /** + * {@inheritDoc} + */ + public void deleteTaskListCondition(Long conditionUid) { + taskListConditionDAO.removeObject(TaskListCondition.class, conditionUid); + } + + /** + * {@inheritDoc} + */ + public void deleteTaskListItemAttachment(Long attachmentUid) { + taskListItemAttachmentDao.removeObject(TaskListItemAttachment.class, attachmentUid); + } + + /** + * {@inheritDoc} + */ + public void saveOrUpdateTaskListItem(TaskListItem item) { + taskListItemDao.saveObject(item); + } + + /** + * {@inheritDoc} + */ + public void deleteTaskListItem(Long uid) { + taskListItemDao.removeObject(TaskListItem.class, uid); + } + + /** + * {@inheritDoc} + */ + public TaskList getTaskListBySessionId(Long sessionId) { + TaskListSession session = taskListSessionDao.getSessionBySessionId(sessionId); + // to skip CGLib problem + Long contentId = session.getTaskList().getContentId(); + TaskList taskList = taskListDao.getByContentId(contentId); + return taskList; + } + + /** + * {@inheritDoc} + */ + public TaskListItem getTaskListItemByUid(Long itemUid) { + return taskListItemDao.getByUid(itemUid); + } + + /** + * {@inheritDoc} + */ + public TaskListSession getTaskListSessionBySessionId(Long sessionId) { + return taskListSessionDao.getSessionBySessionId(sessionId); + } + + /** + * {@inheritDoc} + */ + public void saveOrUpdateTaskListSession(TaskListSession resSession) { + taskListSessionDao.saveObject(resSession); + } + + /** + * {@inheritDoc} + */ + public String finishToolSession(Long toolSessionId, Long userId) throws TaskListException { + TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); + user.setSessionFinished(true); + taskListUserDao.saveObject(user); + + // TaskListSession session = taskListSessionDao.getSessionBySessionId(toolSessionId); + // session.setStatus(TaskListConstants.COMPLETED); + // taskListSessionDao.saveObject(session); + + String nextUrl = null; + try { + nextUrl = this.leaveToolSession(toolSessionId, userId); + } catch (DataMissingException e) { + throw new TaskListException(e); + } catch (ToolException e) { + throw new TaskListException(e); } + return nextUrl; + } - /** - * {@inheritDoc} - */ - public void deleteTaskListItem(Long uid) { - taskListItemDao.removeObject(TaskListItem.class,uid); + /** + * {@inheritDoc} + */ + public void setItemComplete(Long taskListItemUid, Long userId, Long sessionId) { + TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(taskListItemUid, userId); + if (log == null) { + log = new TaskListItemVisitLog(); + TaskListItem item = taskListItemDao.getByUid(taskListItemUid); + log.setTaskListItem(item); + TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, sessionId); + log.setUser(user); + log.setSessionId(sessionId); + log.setAccessDate(new Timestamp(new Date().getTime())); } + log.setComplete(true); + taskListItemVisitDao.saveObject(log); + } - /** - * {@inheritDoc} - */ - public TaskList getTaskListBySessionId(Long sessionId){ - TaskListSession session = taskListSessionDao.getSessionBySessionId(sessionId); - //to skip CGLib problem - Long contentId = session.getTaskList().getContentId(); - TaskList taskList = taskListDao.getByContentId(contentId); - return taskList; + /** + * {@inheritDoc} + */ + public void setItemAccess(Long taskListItemUid, Long userId, Long sessionId) { + TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(taskListItemUid, userId); + if (log == null) { + log = new TaskListItemVisitLog(); + TaskListItem item = taskListItemDao.getByUid(taskListItemUid); + log.setTaskListItem(item); + TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, sessionId); + log.setUser(user); + log.setComplete(false); + log.setSessionId(sessionId); + log.setAccessDate(new Timestamp(new Date().getTime())); + taskListItemVisitDao.saveObject(log); } - - /** - * {@inheritDoc} - */ - public TaskListItem getTaskListItemByUid(Long itemUid) { - return taskListItemDao.getByUid(itemUid); - } - - /** - * {@inheritDoc} - */ - public TaskListSession getTaskListSessionBySessionId(Long sessionId) { - return taskListSessionDao.getSessionBySessionId(sessionId); - } + } - /** - * {@inheritDoc} - */ - public void saveOrUpdateTaskListSession(TaskListSession resSession) { - taskListSessionDao.saveObject(resSession); + /** + * {@inheritDoc} + */ + public void retrieveComplete(Set taskListItemList, TaskListUser user) { + for (TaskListItem item : taskListItemList) { + TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(item.getUid(), user.getUserId()); + if (log == null) { + item.setComplete(false); + } else { + item.setComplete(log.isComplete()); + } } - - /** - * {@inheritDoc} - */ - public String finishToolSession(Long toolSessionId, Long userId) throws TaskListException { - TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); - user.setSessionFinished(true); - taskListUserDao.saveObject(user); - -// TaskListSession session = taskListSessionDao.getSessionBySessionId(toolSessionId); -// session.setStatus(TaskListConstants.COMPLETED); -// taskListSessionDao.saveObject(session); - - String nextUrl = null; - try { - nextUrl = this.leaveToolSession(toolSessionId,userId); - } catch (DataMissingException e) { - throw new TaskListException(e); - } catch (ToolException e) { - throw new TaskListException(e); - } - return nextUrl; - } - - /** - * {@inheritDoc} - */ - public void setItemComplete(Long taskListItemUid, Long userId, Long sessionId) { - TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(taskListItemUid,userId); - if(log == null){ - log = new TaskListItemVisitLog(); - TaskListItem item = taskListItemDao.getByUid(taskListItemUid); - log.setTaskListItem(item); - TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, sessionId); - log.setUser(user); - log.setSessionId(sessionId); - log.setAccessDate(new Timestamp(new Date().getTime())); - } - log.setComplete(true); - taskListItemVisitDao.saveObject(log); - } + } - /** - * {@inheritDoc} - */ - public void setItemAccess(Long taskListItemUid, Long userId, Long sessionId){ - TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(taskListItemUid,userId); - if(log == null){ - log = new TaskListItemVisitLog(); - TaskListItem item = taskListItemDao.getByUid(taskListItemUid); - log.setTaskListItem(item); - TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, sessionId); - log.setUser(user); - log.setComplete(false); - log.setSessionId(sessionId); - log.setAccessDate(new Timestamp(new Date().getTime())); - taskListItemVisitDao.saveObject(log); + /** + * {@inheritDoc} + */ + public List getSummary(Long contentId) { + + TaskList taskList = taskListDao.getByContentId(contentId); + List sessionList = taskListSessionDao.getByContentId(contentId); + + List summaryList = new ArrayList(); + + // create the user list of all whom were started this task + for (TaskListSession session : sessionList) { + + List itemList = getItemListForGroup(contentId, session.getSessionId()); + + List userList = taskListUserDao.getBySessionID(session.getSessionId()); + + // Fill up the copmletion table + boolean[][] complete = new boolean[userList.size()][itemList.size()]; + // Fill up the array of visitNumbers + int[] visitNumbers = new int[itemList.size()]; + for (int i = 0; i < userList.size(); i++) { + TaskListUser user = userList.get(i); + + for (int j = 0; j < itemList.size(); j++) { + TaskListItem item = itemList.get(j); + + // retreiving TaskListItemVisitLog for current taskList and user + TaskListItemVisitLog visitLog = taskListItemVisitDao.getTaskListItemLog(item.getUid(), user + .getUserId()); + if (visitLog != null) { + complete[i][j] = visitLog.isComplete(); + if (visitLog.isComplete()) { + visitNumbers[j]++; + } + } else { + complete[i][j] = false; + } } + } + + Summary summary = new Summary(session.getSessionName(), itemList, userList, complete, visitNumbers, + taskList.isMonitorVerificationRequired()); + summaryList.add(summary); } - /** - * {@inheritDoc} - */ - public void retrieveComplete(Set taskListItemList, TaskListUser user) { - for(TaskListItem item:taskListItemList){ - TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(item.getUid(),user.getUserId()); - if(log == null) - item.setComplete(false); - else - item.setComplete(log.isComplete()); - } + return summaryList; + } + + /** + * {@inheritDoc} + */ + public ItemSummary getItemSummary(Long contentId, Long taskListItemUid, boolean isExportProcessing) { + + TaskListItem taskListItem = taskListItemDao.getByUid(taskListItemUid); + + ItemSummary itemSummary = new ItemSummary(); + itemSummary.setTaskListItem(taskListItem); + List groupSummaries = itemSummary.getGroupSummaries(); + + // create sessionList depending on if taskListItem created be author or created during learning + List sessionList = new ArrayList(); + if (taskListItem.isCreateByAuthor()) { + sessionList = taskListSessionDao.getByContentId(contentId); + } else { + TaskListSession userSession = taskListItem.getCreateBy().getSession(); + sessionList.add(userSession); } - - /** - * {@inheritDoc} - */ - public List getSummary(Long contentId) { - - TaskList taskList = taskListDao.getByContentId(contentId); - List sessionList = taskListSessionDao.getByContentId(contentId); - List summaryList = new ArrayList(); - - //create the user list of all whom were started this task - for(TaskListSession session:sessionList) { - - List itemList = getItemListForGroup(contentId, session.getSessionId()); - - List userList = taskListUserDao.getBySessionID(session.getSessionId()); - - //Fill up the copmletion table - boolean[][] complete = new boolean[userList.size()][itemList.size()]; - //Fill up the array of visitNumbers - int[] visitNumbers = new int[itemList.size()]; - for (int i = 0; i < userList.size(); i++) { - TaskListUser user = userList.get(i); - - for (int j = 0; j < itemList.size(); j++) { - TaskListItem item = itemList.get(j); - - //retreiving TaskListItemVisitLog for current taskList and user - TaskListItemVisitLog visitLog = taskListItemVisitDao.getTaskListItemLog(item.getUid(), user.getUserId()); - if (visitLog !=null) { - complete[i][j] = visitLog.isComplete(); - if (visitLog.isComplete()) visitNumbers[j]++; - } else { - complete[i][j] = false; - } - } + // create the user list of all whom were started this task + for (TaskListSession session : sessionList) { + + GroupSummary groupSummary = new GroupSummary(); + groupSummary.setSessionName(session.getSessionName()); + + List usersBelongToGroup = taskListUserDao.getBySessionID(session.getSessionId()); + for (TaskListUser user : usersBelongToGroup) { + + TaskListItemVisitLogSummary taskListItemVisitLogSummary = new TaskListItemVisitLogSummary(); + taskListItemVisitLogSummary.setUser(user); + + TaskListItemVisitLog visitLog = taskListItemVisitDao.getTaskListItemLog(taskListItem.getUid(), user + .getUserId()); + // If TaskListItemVisitLog exists then fill up taskSummaryItem otherwise put false in a completed field + if (visitLog != null) { + taskListItemVisitLogSummary.setCompleted(visitLog.isComplete()); + if (visitLog.isComplete()) { + taskListItemVisitLogSummary.setDate(visitLog.getAccessDate()); + } + + // fill up with comments and attachments made by this user + Set itemComments = taskListItem.getComments(); + for (TaskListItemComment comment : itemComments) { + if (user.getUserId().equals(comment.getCreateBy().getUserId())) { + taskListItemVisitLogSummary.getComments().add(comment); } - - Summary summary = new Summary(session.getSessionName(), itemList, userList, complete, visitNumbers, taskList.isMonitorVerificationRequired()); - summaryList.add(summary); - } + } - return summaryList; - } - - /** - * {@inheritDoc} - */ - public ItemSummary getItemSummary(Long contentId, Long taskListItemUid, boolean isExportProcessing) { - - TaskListItem taskListItem = taskListItemDao.getByUid(taskListItemUid); - - ItemSummary itemSummary = new ItemSummary(); - itemSummary.setTaskListItem(taskListItem); - List groupSummaries = itemSummary.getGroupSummaries(); - - //create sessionList depending on if taskListItem created be author or created during learning - List sessionList = new ArrayList(); - if (taskListItem.isCreateByAuthor()) { - sessionList = taskListSessionDao.getByContentId(contentId); + Set itemAttachments = taskListItem.getAttachments(); + for (TaskListItemAttachment attachment : itemAttachments) { + if (user.getUserId().equals(attachment.getCreateBy().getUserId())) { + taskListItemVisitLogSummary.getAttachments().add(attachment); + } + } } else { - TaskListSession userSession = taskListItem.getCreateBy().getSession(); - sessionList.add(userSession); + taskListItemVisitLogSummary.setCompleted(false); } - - //create the user list of all whom were started this task - for(TaskListSession session:sessionList) { - - GroupSummary groupSummary = new GroupSummary(); - groupSummary.setSessionName(session.getSessionName()); - - List usersBelongToGroup = taskListUserDao.getBySessionID(session.getSessionId()); - for(TaskListUser user : usersBelongToGroup) { - - TaskListItemVisitLogSummary taskListItemVisitLogSummary = new TaskListItemVisitLogSummary(); - taskListItemVisitLogSummary.setUser(user); - - TaskListItemVisitLog visitLog = taskListItemVisitDao.getTaskListItemLog(taskListItem.getUid(), user.getUserId()); - //If TaskListItemVisitLog exists then fill up taskSummaryItem otherwise put false in a completed field - if (visitLog !=null) { - taskListItemVisitLogSummary.setCompleted(visitLog.isComplete()); - if (visitLog.isComplete()) taskListItemVisitLogSummary.setDate(visitLog.getAccessDate()); - - //fill up with comments and attachments made by this user - Set itemComments = taskListItem.getComments(); - for(TaskListItemComment comment : itemComments) { - if (user.getUserId().equals(comment.getCreateBy().getUserId())) taskListItemVisitLogSummary.getComments().add(comment); - } - Set itemAttachments = taskListItem.getAttachments(); - for(TaskListItemAttachment attachment : itemAttachments) { - if (user.getUserId().equals(attachment.getCreateBy().getUserId())) taskListItemVisitLogSummary.getAttachments().add(attachment); - } - } else { - taskListItemVisitLogSummary.setCompleted(false); - } - - //if we're doing export then fill up all itemSummaries with reflection information - if (isExportProcessing) { + // if we're doing export then fill up all itemSummaries with reflection information + if (isExportProcessing) { - NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - TaskListConstants.TOOL_SIGNATURE, user.getUserId().intValue()); - - ReflectDTO reflectDTO = new ReflectDTO(user); - if(notebookEntry == null){ - reflectDTO.setFinishReflection(false); - reflectDTO.setReflect(null); - }else{ - reflectDTO.setFinishReflection(true); - reflectDTO.setReflect(notebookEntry.getEntry()); - } - reflectDTO.setReflectInstructions(session.getTaskList().getReflectInstructions()); - - taskListItemVisitLogSummary.setReflectDTO(reflectDTO); - } - - groupSummary.getTaskListItemVisitLogSummaries().add(taskListItemVisitLogSummary); - } - groupSummaries.add(groupSummary); + NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, + TaskListConstants.TOOL_SIGNATURE, user.getUserId().intValue()); + + ReflectDTO reflectDTO = new ReflectDTO(user); + if (notebookEntry == null) { + reflectDTO.setFinishReflection(false); + reflectDTO.setReflect(null); + } else { + reflectDTO.setFinishReflection(true); + reflectDTO.setReflect(notebookEntry.getEntry()); + } + reflectDTO.setReflectInstructions(session.getTaskList().getReflectInstructions()); + + taskListItemVisitLogSummary.setReflectDTO(reflectDTO); } - - - return itemSummary; + + groupSummary.getTaskListItemVisitLogSummaries().add(taskListItemVisitLogSummary); + } + groupSummaries.add(groupSummary); } - - /** - * {@inheritDoc} - */ - public List exportForTeacher(Long contentId) { - TaskList taskList = taskListDao.getByContentId(contentId); - ArrayList itemList = new ArrayList(); - itemList.addAll(taskList.getTaskListItems()); - - //retrieve all the sessions associated with this taskList - List sessionList = taskListSessionDao.getByContentId(contentId); - //create the list containing all taskListItems - for(TaskListSession session:sessionList) { - Set newItems = session.getTaskListItems(); - for(TaskListItem item : newItems) { - if (!itemList.contains(item)) itemList.add(item); - } + + return itemSummary; + } + + /** + * {@inheritDoc} + */ + public List exportForTeacher(Long contentId) { + TaskList taskList = taskListDao.getByContentId(contentId); + ArrayList itemList = new ArrayList(); + itemList.addAll(taskList.getTaskListItems()); + + // retrieve all the sessions associated with this taskList + List sessionList = taskListSessionDao.getByContentId(contentId); + // create the list containing all taskListItems + for (TaskListSession session : sessionList) { + Set newItems = session.getTaskListItems(); + for (TaskListItem item : newItems) { + if (!itemList.contains(item)) { + itemList.add(item); } - - List itemSummaries = new ArrayList(); - for(TaskListItem item:itemList) { - itemSummaries.add(getItemSummary(contentId, item.getUid(), true)); - } - - return itemSummaries; + } } - - /** - * {@inheritDoc} - */ - public List exportForLearner(Long sessionId, TaskListUser learner) { - Long contentId = getTaskListBySessionId(sessionId).getContentId(); - - TaskList taskList = taskListDao.getByContentId(contentId); - List itemList = getItemListForGroup(contentId, sessionId); - - List itemSummaries = new ArrayList(); - for(TaskListItem item:itemList) { - itemSummaries.add(getItemSummary(contentId, item.getUid(), true)); - } - - //get rid of information that doesn't belong to the current user - for(ItemSummary itemSummary:itemSummaries) { - - //get rid of groups that user doesn't belong to - GroupSummary newGroupSummary = new GroupSummary(); - for(GroupSummary groupSummary:itemSummary.getGroupSummaries()) { - - for(TaskListItemVisitLogSummary taskListItemVisitLogSummary:groupSummary.getTaskListItemVisitLogSummaries()) { - if (learner.equals(taskListItemVisitLogSummary.getUser())) { - newGroupSummary.setSessionName(groupSummary.getSessionName()); - newGroupSummary.getTaskListItemVisitLogSummaries().add(taskListItemVisitLogSummary); - } - } - } - itemSummary.getGroupSummaries().clear(); - itemSummary.getGroupSummaries().add(newGroupSummary); - - } - - return itemSummaries; + + List itemSummaries = new ArrayList(); + for (TaskListItem item : itemList) { + itemSummaries.add(getItemSummary(contentId, item.getUid(), true)); } - - /** - * {@inheritDoc} - */ - public int getNumTasksCompletedByUser(Long toolSessionId, Long userUid) { - return getTaskListItemVisitDao().getTasksCompletedCountByUser(toolSessionId, userUid); - } - - /** - * {@inheritDoc} - */ - public boolean checkCondition(String conditionName, Long toolSessionId, Long userUid) { - TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userUid, toolSessionId); - TaskList taskList = taskListSessionDao.getSessionBySessionId(toolSessionId).getTaskList(); - Set conditions = taskList.getConditions(); - TaskListCondition condition = null; - for (TaskListCondition cond:conditions) { - if (cond.getName().equals(conditionName)) { - condition = cond; - break; - } - } - boolean result = true; - if (condition != null) { - Iterator it = condition.getTaskListItems().iterator(); - while(it.hasNext()) { - TaskListItem item = (TaskListItem) it.next(); - - TaskListItemVisitLog visitLog = taskListItemVisitDao.getTaskListItemLog(item.getUid(), userUid); - if (visitLog != null) { - //result is being calculated depending on visitLog value - result &= visitLog.isComplete(); - } else { - //user hadn't complete this task. So this means the condition isn't met. - result = false; - break; - } - } - } else { - //there is no such a condition - result = false; - } - - return result; + return itemSummaries; + } + + /** + * {@inheritDoc} + */ + public List exportForLearner(Long sessionId, TaskListUser learner) { + Long contentId = getTaskListBySessionId(sessionId).getContentId(); + + TaskList taskList = taskListDao.getByContentId(contentId); + List itemList = getItemListForGroup(contentId, sessionId); + + List itemSummaries = new ArrayList(); + for (TaskListItem item : itemList) { + itemSummaries.add(getItemSummary(contentId, item.getUid(), true)); } - /** - * {@inheritDoc} - */ - public List getUserListBySessionItem(Long sessionId, Long itemUid) { - List logList = taskListItemVisitDao.getTaskListItemLogBySession(sessionId,itemUid); - List userList = new ArrayList(logList.size()); - for(TaskListItemVisitLog visit : logList){ - TaskListUser user = visit.getUser(); - user.setAccessDate(visit.getAccessDate()); - userList.add(user); + // get rid of information that doesn't belong to the current user + for (ItemSummary itemSummary : itemSummaries) { + + // get rid of groups that user doesn't belong to + GroupSummary newGroupSummary = new GroupSummary(); + for (GroupSummary groupSummary : itemSummary.getGroupSummaries()) { + + for (TaskListItemVisitLogSummary taskListItemVisitLogSummary : groupSummary + .getTaskListItemVisitLogSummaries()) { + if (learner.equals(taskListItemVisitLogSummary.getUser())) { + newGroupSummary.setSessionName(groupSummary.getSessionName()); + newGroupSummary.getTaskListItemVisitLogSummaries().add(taskListItemVisitLogSummary); + } } - return userList; + } + itemSummary.getGroupSummaries().clear(); + itemSummary.getGroupSummaries().add(newGroupSummary); + } - - /** - * {@inheritDoc} - */ - public List getUserListBySessionId(Long sessionId) { - return taskListUserDao.getBySessionID(sessionId); - } - /** - * {@inheritDoc} - */ - public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { - return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); + return itemSummaries; + } + + /** + * {@inheritDoc} + */ + public int getNumTasksCompletedByUser(Long toolSessionId, Long userUid) { + return getTaskListItemVisitDao().getTasksCompletedCountByUser(toolSessionId, userUid); + } + + /** + * {@inheritDoc} + */ + public boolean checkCondition(String conditionName, Long toolSessionId, Long userUid) { + TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userUid, toolSessionId); + TaskList taskList = taskListSessionDao.getSessionBySessionId(toolSessionId).getTaskList(); + Set conditions = taskList.getConditions(); + TaskListCondition condition = null; + for (TaskListCondition cond : conditions) { + if (cond.getName().equals(conditionName)) { + condition = cond; + break; + } } - - /** - * {@inheritDoc} - */ - public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID){ - List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if (list == null || list.isEmpty()) { - return null; + + boolean result = true; + if (condition != null) { + Iterator it = condition.getTaskListItems().iterator(); + while (it.hasNext()) { + TaskListItem item = (TaskListItem) it.next(); + + TaskListItemVisitLog visitLog = taskListItemVisitDao.getTaskListItemLog(item.getUid(), userUid); + if (visitLog != null) { + // result is being calculated depending on visitLog value + result &= visitLog.isComplete(); } else { - return list.get(0); + // user hadn't complete this task. So this means the condition isn't met. + result = false; + break; } + } + } else { + // there is no such a condition + result = false; } - - /** - * {@inheritDoc} - */ - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); + + return result; + } + + /** + * {@inheritDoc} + */ + public List getUserListBySessionItem(Long sessionId, Long itemUid) { + List logList = taskListItemVisitDao.getTaskListItemLogBySession(sessionId, itemUid); + List userList = new ArrayList(logList.size()); + for (TaskListItemVisitLog visit : logList) { + TaskListUser user = visit.getUser(); + user.setAccessDate(visit.getAccessDate()); + userList.add(user); } - - //***************************************************************************** - // Set methods for Spring Bean - //***************************************************************************** - - public void setAuditService(IAuditService auditService) { - this.auditService = auditService; - } - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } - public void setMessageService(MessageService messageService) { - this.messageService = messageService; - } - public TaskListOutputFactory getTaskListOutputFactory() { - return taskListOutputFactory; - } - public void setTaskListOutputFactory(TaskListOutputFactory taskListOutputFactory) { - this.taskListOutputFactory = taskListOutputFactory; - } - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } - public void setTaskListAttachmentDao(TaskListAttachmentDAO taskListAttachmentDao) { - this.taskListAttachmentDao = taskListAttachmentDao; - } - public void setTaskListConditionDao(TaskListConditionDAO taskListConditionDAO) { - this.taskListConditionDAO = taskListConditionDAO; - } - public void setTaskListDao(TaskListDAO taskListDao) { - this.taskListDao = taskListDao; - } - public void setTaskListItemDao(TaskListItemDAO taskListItemDao) { - this.taskListItemDao = taskListItemDao; - } - public void setTaskListSessionDao(TaskListSessionDAO taskListSessionDao) { - this.taskListSessionDao = taskListSessionDao; - } - public void setTaskListToolContentHandler(TaskListToolContentHandler taskListToolContentHandler) { - this.taskListToolContentHandler = taskListToolContentHandler; - } - public void setTaskListUserDao(TaskListUserDAO taskListUserDao) { - this.taskListUserDao = taskListUserDao; - } - public void setToolService(ILamsToolService toolService) { - this.toolService = toolService; - } + return userList; + } - public TaskListItemVisitDAO getTaskListItemVisitDao() { - return taskListItemVisitDao; + /** + * {@inheritDoc} + */ + public List getUserListBySessionId(Long sessionId) { + return taskListUserDao.getBySessionID(sessionId); + } + + /** + * {@inheritDoc} + */ + public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, + String entryText) { + return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", + entryText); + } + + /** + * {@inheritDoc} + */ + public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { + List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); + if (list == null || list.isEmpty()) { + return null; + } else { + return list.get(0); } - public void setTaskListItemVisitDao(TaskListItemVisitDAO taskListItemVisitDao) { - this.taskListItemVisitDao = taskListItemVisitDao; - } - - /* =================================================================================== */ + } + /** + * {@inheritDoc} + */ + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } + + // ***************************************************************************** + // Set methods for Spring Bean + // ***************************************************************************** + + public void setAuditService(IAuditService auditService) { + this.auditService = auditService; + } + + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } + + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } + + public TaskListOutputFactory getTaskListOutputFactory() { + return taskListOutputFactory; + } + + public void setTaskListOutputFactory(TaskListOutputFactory taskListOutputFactory) { + this.taskListOutputFactory = taskListOutputFactory; + } + + public void setRepositoryService(IRepositoryService repositoryService) { + this.repositoryService = repositoryService; + } + + public void setTaskListAttachmentDao(TaskListAttachmentDAO taskListAttachmentDao) { + this.taskListAttachmentDao = taskListAttachmentDao; + } + + public void setTaskListConditionDao(TaskListConditionDAO taskListConditionDAO) { + this.taskListConditionDAO = taskListConditionDAO; + } + + public void setTaskListDao(TaskListDAO taskListDao) { + this.taskListDao = taskListDao; + } + + public void setTaskListItemDao(TaskListItemDAO taskListItemDao) { + this.taskListItemDao = taskListItemDao; + } + + public void setTaskListSessionDao(TaskListSessionDAO taskListSessionDao) { + this.taskListSessionDao = taskListSessionDao; + } + + public void setTaskListToolContentHandler(TaskListToolContentHandler taskListToolContentHandler) { + this.taskListToolContentHandler = taskListToolContentHandler; + } + + public void setTaskListUserDao(TaskListUserDAO taskListUserDao) { + this.taskListUserDao = taskListUserDao; + } + + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } + + public TaskListItemVisitDAO getTaskListItemVisitDao() { + return taskListItemVisitDao; + } + + public void setTaskListItemVisitDao(TaskListItemVisitDAO taskListItemVisitDao) { + this.taskListItemVisitDao = taskListItemVisitDao; + } + + /* =================================================================================== */ + public IExportToolContentService getExportContentService() { - return exportContentService; - } + return exportContentService; + } - public void setExportContentService(IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; - } + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } - public IUserManagementService getUserManagementService() { - return userManagementService; - } + public IUserManagementService getUserManagementService() { + return userManagementService; + } - public void setUserManagementService(IUserManagementService userManagementService) { - this.userManagementService = userManagementService; - } + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } - public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; - } + public ICoreNotebookService getCoreNotebookService() { + return coreNotebookService; + } - public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; + public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { + this.coreNotebookService = coreNotebookService; + } + + public MessageService getMessageService() { + return messageService; + } + + // ******************************************************************************* + // Methods implementing ToolContentManager, ToolSessionManager + // ******************************************************************************* + + public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { + TaskList toolContentObj = taskListDao.getByContentId(toolContentId); + if (toolContentObj == null) { + try { + toolContentObj = getDefaultTaskList(); + } catch (TaskListException e) { + throw new DataMissingException(e.getMessage()); + } } - - public MessageService getMessageService() { - return messageService; + if (toolContentObj == null) { + throw new DataMissingException("Unable to find default content for the taskList tool"); } - //******************************************************************************* - // Methods implementing ToolContentManager, ToolSessionManager - //******************************************************************************* - - public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { - TaskList toolContentObj = taskListDao.getByContentId(toolContentId); - if(toolContentObj == null) { - try { - toolContentObj = getDefaultTaskList(); - } catch (TaskListException e) { - throw new DataMissingException(e.getMessage()); - } - } - if(toolContentObj == null) - throw new DataMissingException("Unable to find default content for the taskList tool"); - - //set TaskListToolContentHandler as null to avoid copy file node in repository again. - toolContentObj = TaskList.newInstance(toolContentObj,toolContentId,null); - toolContentObj.setToolContentHandler(null); - toolContentObj.setOfflineFileList(null); - toolContentObj.setOnlineFileList(null); - Set taskListItems = toolContentObj.getTaskListItems(); - for (TaskListItem taskListItem : taskListItems) { - taskListItem.setComments(null); - taskListItem.setAttachments(null); - } - - try { - exportContentService.registerFileClassForExport(TaskListAttachment.class.getName(),"fileUuid","fileVersionId"); - exportContentService.exportToolContent( toolContentId, toolContentObj,taskListToolContentHandler, rootPath); - } catch (ExportToolContentException e) { - throw new ToolException(e); - } + // set TaskListToolContentHandler as null to avoid copy file node in repository again. + toolContentObj = TaskList.newInstance(toolContentObj, toolContentId, null); + toolContentObj.setToolContentHandler(null); + toolContentObj.setOfflineFileList(null); + toolContentObj.setOnlineFileList(null); + Set taskListItems = toolContentObj.getTaskListItems(); + for (TaskListItem taskListItem : taskListItems) { + taskListItem.setComments(null); + taskListItem.setAttachments(null); } - /** - * {@inheritDoc} - */ - public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath ,String fromVersion,String toVersion) throws ToolException { - - try { - exportContentService.registerFileClassForImport(TaskListAttachment.class.getName(),"fileUuid","fileVersionId","fileName","fileType",null,null); - - Object toolPOJO = exportContentService.importToolContent(toolContentPath,taskListToolContentHandler,fromVersion,toVersion); - if(!(toolPOJO instanceof TaskList)) - throw new ImportToolContentException("Import Share taskList tool content failed. Deserialized object is " + toolPOJO); - TaskList toolContentObj = (TaskList) toolPOJO; - -// reset it to new toolContentId - toolContentObj.setContentId(toolContentId); - TaskListUser user = taskListUserDao.getUserByUserIDAndContentID(new Long(newUserUid.longValue()), toolContentId); - if(user == null){ - user = new TaskListUser(); - UserDTO sysUser = ((User)userManagementService.findById(User.class,newUserUid)).getUserDTO(); - user.setFirstName(sysUser.getFirstName()); - user.setLastName(sysUser.getLastName()); - user.setLoginName(sysUser.getLogin()); - user.setUserId(new Long(newUserUid.longValue())); - user.setTaskList(toolContentObj); - } - toolContentObj.setCreatedBy(user); - - //reset all taskListItem createBy user - Set items = toolContentObj.getTaskListItems(); - for(TaskListItem item:items){ - item.setCreateBy(user); - } - taskListDao.saveObject(toolContentObj); - } catch (ImportToolContentException e) { - throw new ToolException(e); - } + try { + exportContentService.registerFileClassForExport(TaskListAttachment.class.getName(), "fileUuid", + "fileVersionId"); + exportContentService.exportToolContent(toolContentId, toolContentObj, taskListToolContentHandler, rootPath); + } catch (ExportToolContentException e) { + throw new ToolException(e); } - - /** - * Get the definitions for possible output for an activity, based on the - * toolContentId. These may be definitions that are always available for the - * tool (e.g. number of marks for Multiple Choice) or a custom definition - * created for a particular activity such as the answer to the third - * question contains the word Koala and hence the need for the toolContentId - * - * @return SortedMap of ToolOutputDefinitions with the key being the name of - * each definition - * @throws TaskListException - */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - TaskList taskList = getTaskListByContentId(toolContentId); - if ( taskList == null ) { - taskList = getDefaultTaskList(); - } - return getTaskListOutputFactory().getToolOutputDefinitions(taskList); - } - - /** - * {@inheritDoc} - */ - public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { - if (toContentId == null) - throw new ToolException( - "Failed to create the SharedTaskListFiles tool seession"); + } - TaskList taskList = null; - if ( fromContentId != null ) { - taskList = taskListDao.getByContentId(fromContentId); - } - if ( taskList == null ) { - try { - taskList = getDefaultTaskList(); - } catch (TaskListException e) { - throw new ToolException(e); - } - } + /** + * {@inheritDoc} + */ + public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException { - TaskList toContent = TaskList.newInstance(taskList,toContentId,taskListToolContentHandler); - taskListDao.saveObject(toContent); - - //save taskList items as well - Set items = toContent.getTaskListItems(); - if(items != null){ - Iterator iter = items.iterator(); - while(iter.hasNext()){ - TaskListItem item = (TaskListItem) iter.next(); -// createRootTopic(toContent.getUid(),null,msg); - } - } + try { + exportContentService.registerFileClassForImport(TaskListAttachment.class.getName(), "fileUuid", + "fileVersionId", "fileName", "fileType", null, null); + + Object toolPOJO = exportContentService.importToolContent(toolContentPath, taskListToolContentHandler, + fromVersion, toVersion); + if (!(toolPOJO instanceof TaskList)) { + throw new ImportToolContentException( + "Import Share taskList tool content failed. Deserialized object is " + toolPOJO); + } + TaskList toolContentObj = (TaskList) toolPOJO; + + // reset it to new toolContentId + toolContentObj.setContentId(toolContentId); + TaskListUser user = taskListUserDao.getUserByUserIDAndContentID(new Long(newUserUid.longValue()), + toolContentId); + if (user == null) { + user = new TaskListUser(); + UserDTO sysUser = ((User) userManagementService.findById(User.class, newUserUid)).getUserDTO(); + user.setFirstName(sysUser.getFirstName()); + user.setLastName(sysUser.getLastName()); + user.setLoginName(sysUser.getLogin()); + user.setUserId(new Long(newUserUid.longValue())); + user.setTaskList(toolContentObj); + } + toolContentObj.setCreatedBy(user); + + // reset all taskListItem createBy user + Set items = toolContentObj.getTaskListItems(); + for (TaskListItem item : items) { + item.setCreateBy(user); + } + taskListDao.saveObject(toolContentObj); + } catch (ImportToolContentException e) { + throw new ToolException(e); } + } - /** - * {@inheritDoc} - */ - public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { - TaskList taskList = taskListDao.getByContentId(toolContentId); - if(taskList == null){ - throw new ToolException("No found tool content by given content ID:" + toolContentId); - } - taskList.setDefineLater(value); + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition + * @throws TaskListException + */ + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { + TaskList taskList = getTaskListByContentId(toolContentId); + if (taskList == null) { + taskList = getDefaultTaskList(); } + return getTaskListOutputFactory().getToolOutputDefinitions(taskList, definitionType); + } - /** - * {@inheritDoc} - */ - public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { - TaskList taskList = taskListDao.getByContentId(toolContentId); - if(taskList == null){ - throw new ToolException("No found tool content by given content ID:" + toolContentId); - } - taskList.setRunOffline(value); + /** + * {@inheritDoc} + */ + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { + if (toContentId == null) { + throw new ToolException("Failed to create the SharedTaskListFiles tool seession"); } - /** - * {@inheritDoc} - */ - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException { - TaskList taskList = taskListDao.getByContentId(toolContentId); - if(removeSessionData){ - List list = taskListSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while(iter.hasNext()){ - TaskListSession session = (TaskListSession ) iter.next(); - taskListSessionDao.delete(session); - } - } - taskListDao.delete(taskList); + TaskList taskList = null; + if (fromContentId != null) { + taskList = taskListDao.getByContentId(fromContentId); } + if (taskList == null) { + try { + taskList = getDefaultTaskList(); + } catch (TaskListException e) { + throw new ToolException(e); + } + } - /** - * {@inheritDoc} - */ - public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { - TaskListSession session = new TaskListSession(); - session.setSessionId(toolSessionId); - session.setSessionName(toolSessionName); - TaskList taskList = taskListDao.getByContentId(toolContentId); - session.setTaskList(taskList); - taskListSessionDao.saveObject(session); + TaskList toContent = TaskList.newInstance(taskList, toContentId, taskListToolContentHandler); + taskListDao.saveObject(toContent); + + // save taskList items as well + Set items = toContent.getTaskListItems(); + if (items != null) { + Iterator iter = items.iterator(); + while (iter.hasNext()) { + TaskListItem item = (TaskListItem) iter.next(); + // createRootTopic(toContent.getUid(),null,msg); + } } + } - /** - * {@inheritDoc} - */ - public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { - if(toolSessionId == null){ - log.error("Fail to leave tool Session based on null tool session id."); - throw new ToolException("Fail to remove tool Session based on null tool session id."); - } - if(learnerId == null){ - log.error("Fail to leave tool Session based on null learner."); - throw new ToolException("Fail to remove tool Session based on null learner."); - } - - TaskListSession session = taskListSessionDao.getSessionBySessionId(toolSessionId); - if(session != null){ - session.setStatus(TaskListConstants.COMPLETED); - taskListSessionDao.saveObject(session); - }else{ - log.error("Fail to leave tool Session.Could not find shared taskList " + - "session by given session id: "+toolSessionId); - throw new DataMissingException("Fail to leave tool Session." + - "Could not find shared taskList session by given session id: "+toolSessionId); - } - return learnerService.completeToolSession(toolSessionId,learnerId); + /** + * {@inheritDoc} + */ + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { + TaskList taskList = taskListDao.getByContentId(toolContentId); + if (taskList == null) { + throw new ToolException("No found tool content by given content ID:" + toolContentId); } + taskList.setDefineLater(value); + } - /** - * {@inheritDoc} - */ - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { - return null; + /** + * {@inheritDoc} + */ + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { + TaskList taskList = taskListDao.getByContentId(toolContentId); + if (taskList == null) { + throw new ToolException("No found tool content by given content ID:" + toolContentId); } + taskList.setRunOffline(value); + } - /** - * {@inheritDoc} - */ - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException { - return null; + /** + * {@inheritDoc} + */ + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException { + TaskList taskList = taskListDao.getByContentId(toolContentId); + if (removeSessionData) { + List list = taskListSessionDao.getByContentId(toolContentId); + Iterator iter = list.iterator(); + while (iter.hasNext()) { + TaskListSession session = (TaskListSession) iter.next(); + taskListSessionDao.delete(session); + } } + taskListDao.delete(taskList); + } - /** - * {@inheritDoc} - */ - public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { - taskListSessionDao.deleteBySessionId(toolSessionId); + /** + * {@inheritDoc} + */ + public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { + TaskListSession session = new TaskListSession(); + session.setSessionId(toolSessionId); + session.setSessionName(toolSessionName); + TaskList taskList = taskListDao.getByContentId(toolContentId); + session.setTaskList(taskList); + taskListSessionDao.saveObject(session); + } + + /** + * {@inheritDoc} + */ + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { + if (toolSessionId == null) { + TaskListServiceImpl.log.error("Fail to leave tool Session based on null tool session id."); + throw new ToolException("Fail to remove tool Session based on null tool session id."); } - - /** - * Get the tool output for the given tool output names. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) - */ - public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { - return taskListOutputFactory.getToolOutput(names, this, toolSessionId, learnerId); + if (learnerId == null) { + TaskListServiceImpl.log.error("Fail to leave tool Session based on null learner."); + throw new ToolException("Fail to remove tool Session based on null learner."); } - /** - * Get the tool output for the given tool output name. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) - */ - public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { - return taskListOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); + TaskListSession session = taskListSessionDao.getSessionBySessionId(toolSessionId); + if (session != null) { + session.setStatus(TaskListConstants.COMPLETED); + taskListSessionDao.saveObject(session); + } else { + TaskListServiceImpl.log.error("Fail to leave tool Session.Could not find shared taskList " + + "session by given session id: " + toolSessionId); + throw new DataMissingException("Fail to leave tool Session." + + "Could not find shared taskList session by given session id: " + toolSessionId); } + return learnerService.completeToolSession(toolSessionId, learnerId); + } - //******************************************************************************* - // Methods implementing ToolContentImport102Manager - //******************************************************************************* - /** - * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard. Was left only - * for the reasons of implementing ToolContentImport102Manager interface. - */ - public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { } - + * {@inheritDoc} + */ + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + return null; + } + + /** + * {@inheritDoc} + */ + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, + ToolException { + return null; + } + + /** + * {@inheritDoc} + */ + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + taskListSessionDao.deleteBySessionId(toolSessionId); + } + + /** + * Get the tool output for the given tool output names. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) + */ + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { + return taskListOutputFactory.getToolOutput(names, this, toolSessionId, learnerId); + } + + /** + * Get the tool output for the given tool output name. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) + */ + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return taskListOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); + } + + // ******************************************************************************* + // Methods implementing ToolContentImport102Manager + // ******************************************************************************* + + /** + * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard. Was left only for the reasons of implementing + * ToolContentImport102Manager interface. + */ + public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { + } + /** Set the description, throws away the title value as this is not supported in 2.0 */ - public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { - - TaskList toolContentObj = getTaskListByContentId(toolContentId); - if ( toolContentObj == null ) { - throw new DataMissingException("Unable to set reflective data titled "+title - +" on activity toolContentId "+toolContentId - +" as the tool content does not exist."); - } + public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, + DataMissingException { - toolContentObj.setReflectOnActivity(Boolean.TRUE); - toolContentObj.setReflectInstructions(description); + TaskList toolContentObj = getTaskListByContentId(toolContentId); + if (toolContentObj == null) { + throw new DataMissingException("Unable to set reflective data titled " + title + + " on activity toolContentId " + toolContentId + " as the tool content does not exist."); + } + + toolContentObj.setReflectOnActivity(Boolean.TRUE); + toolContentObj.setReflectInstructions(description); } - //***************************************************************************** - // Private methods - //***************************************************************************** - - private TaskList getDefaultTaskList() throws TaskListException { - Long defaultTaskListId = getToolDefaultContentIdBySignature(TaskListConstants.TOOL_SIGNATURE); - TaskList defaultTaskList = getTaskListByContentId(defaultTaskListId); - if(defaultTaskList == null) { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new TaskListException(error); - } - - return defaultTaskList; + // ***************************************************************************** + // Private methods + // ***************************************************************************** + + private TaskList getDefaultTaskList() throws TaskListException { + Long defaultTaskListId = getToolDefaultContentIdBySignature(TaskListConstants.TOOL_SIGNATURE); + TaskList defaultTaskList = getTaskListByContentId(defaultTaskListId); + if (defaultTaskList == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + TaskListServiceImpl.log.error(error); + throw new TaskListException(error); } - + + return defaultTaskList; + } + private Long getToolDefaultContentIdBySignature(String toolSignature) throws TaskListException { - Long contentId = null; - contentId=new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); - if (contentId == null) - { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new TaskListException(error); - } - return contentId; + Long contentId = null; + contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); + if (contentId == null) { + String error = messageService.getMessage("error.msg.default.content.not.find"); + TaskListServiceImpl.log.error(error); + throw new TaskListException(error); + } + return contentId; } - - /** - * Returns list of tasks from authoring + the tasks added by members of that group. - * - * @param contentId - * @param sessionId sessionId which defines Group - * @return - */ - private List getItemListForGroup(Long contentId, Long sessionId) { - - //create the list containing all taskListItems - TaskList taskList = taskListDao.getByContentId(contentId); - ArrayList itemList = new ArrayList(); - itemList.addAll(taskList.getTaskListItems()); - - List sessionList = taskListSessionDao.getByContentId(contentId); - for(TaskListSession session:sessionList) { - Set newItems = session.getTaskListItems(); - for(TaskListItem item : newItems) { - if (!itemList.contains(item)) itemList.add(item); - } + + /** + * Returns list of tasks from authoring + the tasks added by members of that group. + * + * @param contentId + * @param sessionId + * sessionId which defines Group + * @return + */ + private List getItemListForGroup(Long contentId, Long sessionId) { + + // create the list containing all taskListItems + TaskList taskList = taskListDao.getByContentId(contentId); + ArrayList itemList = new ArrayList(); + itemList.addAll(taskList.getTaskListItems()); + + List sessionList = taskListSessionDao.getByContentId(contentId); + for (TaskListSession session : sessionList) { + Set newItems = session.getTaskListItems(); + for (TaskListItem item : newItems) { + if (!itemList.contains(item)) { + itemList.add(item); } - - List userList = taskListUserDao.getBySessionID(sessionId); - - ArrayList groupItemList = new ArrayList(); - for (TaskListItem item:itemList) { - - if (item.isCreateByAuthor()) { - groupItemList.add(item); - } else { - for (TaskListUser user:userList) { - if (user.getUserId().equals(item.getCreateBy().getUserId())) { - groupItemList.add(item); - break; - } - } - } + } + } + + List userList = taskListUserDao.getBySessionID(sessionId); + + ArrayList groupItemList = new ArrayList(); + for (TaskListItem item : itemList) { + + if (item.isCreateByAuthor()) { + groupItemList.add(item); + } else { + for (TaskListUser user : userList) { + if (user.getUserId().equals(item.getCreateBy().getUserId())) { + groupItemList.add(item); + break; + } } - - return groupItemList; + } } - + + return groupItemList; + } + /** * Process an uploaded file. * - * @throws TaskListException + * @throws TaskListException * @throws FileNotFoundException * @throws IOException * @throws RepositoryCheckedException * @throws InvalidParameterException */ private NodeKey processFile(FormFile file, String fileType) throws UploadTaskListFileException { - NodeKey node = null; - if (file!= null && !StringUtils.isEmpty(file.getFileName())) { - String fileName = file.getFileName(); - try { - node = taskListToolContentHandler.uploadFile(file.getInputStream(), fileName, - file.getContentType(), fileType); - } catch (InvalidParameterException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.invaid.param.upload")); - } catch (FileNotFoundException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.file.not.found")); - } catch (RepositoryCheckedException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.repository")); - } catch (IOException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.io.exception")); - } - } - return node; + NodeKey node = null; + if (file != null && !StringUtils.isEmpty(file.getFileName())) { + String fileName = file.getFileName(); + try { + node = taskListToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType(), + fileType); + } catch (InvalidParameterException e) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.invaid.param.upload")); + } catch (FileNotFoundException e) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.file.not.found")); + } catch (RepositoryCheckedException e) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.repository")); + } catch (IOException e) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.io.exception")); + } + } + return node; } - - private NodeKey processPackage(String packageDirectory, String initFile) throws UploadTaskListFileException { - NodeKey node = null; - try { - node = taskListToolContentHandler.uploadPackage(packageDirectory, initFile); - } catch (InvalidParameterException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.invaid.param.upload")); - } catch (RepositoryCheckedException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.repository")); - } - return node; + + private NodeKey processPackage(String packageDirectory, String initFile) throws UploadTaskListFileException { + NodeKey node = null; + try { + node = taskListToolContentHandler.uploadPackage(packageDirectory, initFile); + } catch (InvalidParameterException e) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.invaid.param.upload")); + } catch (RepositoryCheckedException e) { + throw new UploadTaskListFileException(messageService.getMessage("error.msg.repository")); } + return node; + } - /** - * Find out default.htm/html or index.htm/html in the given directory folder - * @param packageDirectory - * @return - */ - private String findWebsiteInitialItem(String packageDirectory) { - File file = new File(packageDirectory); - if(!file.isDirectory()) - return null; - - File[] initFiles = file.listFiles(new FileFilter(){ - public boolean accept(File pathname) { - if(pathname == null || pathname.getName() == null) - return false; - String name = pathname.getName(); - if(name.endsWith("default.html") - ||name.endsWith("default.htm") - ||name.endsWith("index.html") - ||name.endsWith("index.htm")) - return true; - return false; - } - }); - if(initFiles != null && initFiles.length > 0) - return initFiles[0].getName(); - else - return null; + /** + * Find out default.htm/html or index.htm/html in the given directory folder + * + * @param packageDirectory + * @return + */ + private String findWebsiteInitialItem(String packageDirectory) { + File file = new File(packageDirectory); + if (!file.isDirectory()) { + return null; } - private class ReflectDTOComparator implements Comparator{ - public int compare(ReflectDTO o1, ReflectDTO o2) { - - if(o1 != null && o2 != null){ - return o1.getFullName().compareTo(o2.getFullName()); - }else if(o1 != null) - return 1; - else - return -1; + File[] initFiles = file.listFiles(new FileFilter() { + public boolean accept(File pathname) { + if (pathname == null || pathname.getName() == null) { + return false; } + String name = pathname.getName(); + if (name.endsWith("default.html") || name.endsWith("default.htm") || name.endsWith("index.html") + || name.endsWith("index.htm")) { + return true; + } + return false; + } + }); + if (initFiles != null && initFiles.length > 0) { + return initFiles[0].getName(); + } else { + return null; } - - //******************************************************************************* - // Service method - //******************************************************************************* - /** Try to get the file. If forceLogin = false and an access denied exception occurs, call this method - * again to get a new ticket and retry file lookup. If forceLogin = true and it then fails - * then throw exception. - * @param uuid - * @param versionId - * @param relativePath - * @param attemptCount - * @return file node - * @throws ImscpApplicationException - */ - private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws TaskListException { - - ITicket tic = getRepositoryLoginTicket(); - - try { - return repositoryService.getFileItem(tic, uuid, versionId, relativePath); - } catch (AccessDeniedException e) { - - String error = "Unable to access repository to get file uuid "+uuid - +" version id "+versionId - +" path " + relativePath+"."; - - error = error+"AccessDeniedException: "+e.getMessage()+" Unable to retry further."; - log.error(error); - throw new TaskListException(error,e); - - } catch (Exception e) { - - String error = "Unable to access repository to get file uuid "+uuid - +" version id "+versionId - +" path " + relativePath+"." - +" Exception: "+e.getMessage(); - log.error(error); - throw new TaskListException(error,e); - - } + } + + private class ReflectDTOComparator implements Comparator { + public int compare(ReflectDTO o1, ReflectDTO o2) { + + if (o1 != null && o2 != null) { + return o1.getFullName().compareTo(o2.getFullName()); + } else if (o1 != null) { + return 1; + } else { + return -1; + } } - - /** - * This method verifies the credentials of the TaskList Tool and gives it - * the Ticket to login and access the Content Repository. - * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. - * - * @return ITicket The ticket for repostory access - * @throws TaskListException - */ - private ITicket getRepositoryLoginTicket() throws TaskListException { - ICredentials credentials = new SimpleCredentials(taskListToolContentHandler.getRepositoryUser(), taskListToolContentHandler.getRepositoryId()); - try { - ITicket ticket = repositoryService.login(credentials, taskListToolContentHandler.getRepositoryWorkspaceName()); - return ticket; - } catch (AccessDeniedException ae) { - throw new TaskListException("Access Denied to repository." + ae.getMessage()); - } catch (WorkspaceNotFoundException we) { - throw new TaskListException("Workspace not found." + we.getMessage()); - } catch (LoginException e) { - throw new TaskListException("Login failed." + e.getMessage()); - } + } + + // ******************************************************************************* + // Service method + // ******************************************************************************* + /** + * Try to get the file. If forceLogin = false and an access denied exception occurs, call this method again to get a + * new ticket and retry file lookup. If forceLogin = true and it then fails then throw exception. + * + * @param uuid + * @param versionId + * @param relativePath + * @param attemptCount + * @return file node + * @throws ImscpApplicationException + */ + private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws TaskListException { + + ITicket tic = getRepositoryLoginTicket(); + + try { + return repositoryService.getFileItem(tic, uuid, versionId, relativePath); + } catch (AccessDeniedException e) { + + String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + + " path " + relativePath + "."; + + error = error + "AccessDeniedException: " + e.getMessage() + " Unable to retry further."; + TaskListServiceImpl.log.error(error); + throw new TaskListException(error, e); + + } catch (Exception e) { + + String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + + " path " + relativePath + "." + " Exception: " + e.getMessage(); + TaskListServiceImpl.log.error(error); + throw new TaskListException(error, e); + } + } + + /** + * This method verifies the credentials of the TaskList Tool and gives it the Ticket to login and + * access the Content Repository. + * + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. + * + * @return ITicket The ticket for repostory access + * @throws TaskListException + */ + private ITicket getRepositoryLoginTicket() throws TaskListException { + ICredentials credentials = new SimpleCredentials(taskListToolContentHandler.getRepositoryUser(), + taskListToolContentHandler.getRepositoryId()); + try { + ITicket ticket = repositoryService.login(credentials, taskListToolContentHandler + .getRepositoryWorkspaceName()); + return ticket; + } catch (AccessDeniedException ae) { + throw new TaskListException("Access Denied to repository." + ae.getMessage()); + } catch (WorkspaceNotFoundException we) { + throw new TaskListException("Workspace not found." + we.getMessage()); + } catch (LoginException e) { + throw new TaskListException("Login failed." + e.getMessage()); + } + } } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderOutputFactory.java,v diff -u -r1.3 -r1.4 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderOutputFactory.java 2 Jul 2009 08:18:27 -0000 1.3 +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderOutputFactory.java 2 Jul 2009 13:04:03 -0000 1.4 @@ -44,19 +44,22 @@ * {@inheritDoc} */ @Override - public SortedMap getToolOutputDefinitions(Object toolContentObject) + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { SortedMap definitionMap = new TreeMap(); - - ToolOutputDefinition numberOfRecordingsDefinition = buildRangeDefinition(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, new Long(0), null); + + ToolOutputDefinition numberOfRecordingsDefinition = buildRangeDefinition( + VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, new Long(0), null); definitionMap.put(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, numberOfRecordingsDefinition); - - ToolOutputDefinition numberOfCommentsDefinition = buildRangeDefinition(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, new Long(0), null); + + ToolOutputDefinition numberOfCommentsDefinition = buildRangeDefinition( + VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, new Long(0), null); definitionMap.put(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, numberOfCommentsDefinition); - ToolOutputDefinition numberOfRatingsDefinition = buildRangeDefinition(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, new Long(0), null); + ToolOutputDefinition numberOfRatingsDefinition = buildRangeDefinition( + VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, new Long(0), null); definitionMap.put(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, numberOfRatingsDefinition); - + return definitionMap; } @@ -68,51 +71,55 @@ Long toolSessionId, Long learnerId) { TreeMap outputs = new TreeMap(); - + if (names == null || names.contains(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME)) { - outputs.put(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, getNbRecordings(videoRecorderService, learnerId, toolSessionId)); + outputs.put(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, getNbRecordings(videoRecorderService, + learnerId, toolSessionId)); } if (names == null || names.contains(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME)) { - outputs.put(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, getNbComments(videoRecorderService, learnerId, toolSessionId)); + outputs.put(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, getNbComments(videoRecorderService, + learnerId, toolSessionId)); } if (names == null || names.contains(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME)) { - outputs.put(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, getNbRatings(videoRecorderService, learnerId, toolSessionId)); + outputs.put(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, getNbRatings(videoRecorderService, + learnerId, toolSessionId)); } - + return outputs; } - public ToolOutput getToolOutput(String name, IVideoRecorderService videoRecorderService, Long toolSessionId, Long learnerId) { - ToolOutput toolOutput = null; - if (name != null && name.equals(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME)) { + public ToolOutput getToolOutput(String name, IVideoRecorderService videoRecorderService, Long toolSessionId, + Long learnerId) { + ToolOutput toolOutput = null; + if (name != null && name.equals(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME)) { toolOutput = getNbRecordings(videoRecorderService, learnerId, toolSessionId); - }else if (name != null && name.equals(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME)) { + } else if (name != null && name.equals(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME)) { toolOutput = getNbComments(videoRecorderService, learnerId, toolSessionId); - }else if (name != null && name.equals(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME)) { + } else if (name != null && name.equals(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME)) { toolOutput = getNbRatings(videoRecorderService, learnerId, toolSessionId); } - + return toolOutput; } - + private ToolOutput getNbRecordings(IVideoRecorderService videoRecorderService, Long learnerId, Long toolSessionId) { - Long nb = videoRecorderService.getNbRecordings(learnerId, toolSessionId); - return new ToolOutput(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, getI18NText( - VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, true), new Long(nb)); + Long nb = videoRecorderService.getNbRecordings(learnerId, toolSessionId); + return new ToolOutput(VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, getI18NText( + VideoRecorderConstants.NB_RECORDINGS_DEFINITION_NAME, true), new Long(nb)); } - + private ToolOutput getNbComments(IVideoRecorderService videoRecorderService, Long learnerId, Long toolSessionId) { - Long nb = videoRecorderService.getNbComments(learnerId, toolSessionId); - return new ToolOutput(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, getI18NText( - VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, true), new Long(nb)); + Long nb = videoRecorderService.getNbComments(learnerId, toolSessionId); + return new ToolOutput(VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, getI18NText( + VideoRecorderConstants.NB_COMMENTS_DEFINITION_NAME, true), new Long(nb)); } - + private ToolOutput getNbRatings(IVideoRecorderService videoRecorderService, Long learnerId, Long toolSessionId) { - Long nb = videoRecorderService.getNbRatings(learnerId, toolSessionId); - return new ToolOutput(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, getI18NText( - VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, true), new Long(nb)); + Long nb = videoRecorderService.getNbRatings(learnerId, toolSessionId); + return new ToolOutput(VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, getI18NText( + VideoRecorderConstants.NB_RATINGS_DEFINITION_NAME, true), new Long(nb)); } } Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java,v diff -u -r1.7 -r1.8 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java 2 Jul 2009 08:18:27 -0000 1.7 +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java 2 Jul 2009 13:04:03 -0000 1.8 @@ -27,7 +27,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.Hashtable; import java.util.List; @@ -48,7 +47,6 @@ import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; -import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; @@ -107,15 +105,15 @@ private IVideoRecorderDAO videoRecorderDAO = null; private IVideoRecorderSessionDAO videoRecorderSessionDAO = null; - + private IVideoRecorderRecordingDAO videoRecorderRecordingDAO = null; private IVideoRecorderUserDAO videoRecorderUserDAO = null; private IVideoRecorderAttachmentDAO videoRecorderAttachmentDAO = null; - + private IVideoRecorderRatingDAO videoRecorderRatingDAO = null; - + private IVideoRecorderCommentDAO videoRecorderCommentDAO = null; private ILearnerService learnerService; @@ -135,7 +133,7 @@ private VideoRecorderOutputFactory videoRecorderOutputFactory; private Random generator = new Random(); - + private MessageService messageService; public VideoRecorderService() { @@ -146,15 +144,15 @@ /* ************ Methods from ToolSessionManager ************* */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { if (VideoRecorderService.logger.isDebugEnabled()) { - VideoRecorderService.logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId - + " toolSessionName = " + toolSessionName + " toolContentId = " + toolContentId); + VideoRecorderService.logger.debug("entering method createToolSession:" + " toolSessionId = " + + toolSessionId + " toolSessionName = " + toolSessionName + " toolContentId = " + toolContentId); } VideoRecorderSession session = new VideoRecorderSession(); session.setSessionId(toolSessionId); session.setSessionName(toolSessionName); session.setContentFolderId(FileUtil.generateUniqueContentFolderID()); - + // learner starts // TODO need to also set other fields. VideoRecorder videoRecorder = videoRecorderDAO.getByContentId(toolContentId); @@ -220,24 +218,23 @@ if (fromContentId != null) { fromContent = videoRecorderDAO.getByContentId(fromContentId); } - + List list = videoRecorderRecordingDAO.getByToolContentId(fromContentId); - + VideoRecorderRecording vrr; - if(!list.isEmpty()){ - vrr = list.get(0); - VideoRecorderRecording clonedRecording = new VideoRecorderRecording(vrr); - clonedRecording.setUid(null); - clonedRecording.setToolContentId(toContentId); - videoRecorderRecordingDAO.saveOrUpdate(clonedRecording); + if (!list.isEmpty()) { + vrr = list.get(0); + VideoRecorderRecording clonedRecording = new VideoRecorderRecording(vrr); + clonedRecording.setUid(null); + clonedRecording.setToolContentId(toContentId); + videoRecorderRecordingDAO.saveOrUpdate(clonedRecording); } - + if (fromContent == null) { // create the fromContent using the default tool content fromContent = getDefaultContent(); } - - + VideoRecorder toContent = VideoRecorder.newInstance(fromContent, toContentId, videoRecorderToolContentHandler); videoRecorderDAO.saveOrUpdate(toContent); } @@ -289,27 +286,29 @@ videoRecorder.setToolContentId(null); videoRecorder.setToolContentHandler(null); videoRecorder.setVideoRecorderSessions(null); - - VideoRecorderRecording authorRecording = (VideoRecorderRecording)getFirstRecordingByToolContentId(toolContentId).clone(); - if(authorRecording != null) { - authorRecording = (VideoRecorderRecording) authorRecording.clone(); - - authorRecording.setToolContentId(null); - authorRecording.setComments(null); - authorRecording.setRatings(null); - + + VideoRecorderRecording authorRecording = (VideoRecorderRecording) getFirstRecordingByToolContentId( + toolContentId).clone(); + if (authorRecording != null) { + authorRecording = (VideoRecorderRecording) authorRecording.clone(); + + authorRecording.setToolContentId(null); + authorRecording.setComments(null); + authorRecording.setRatings(null); + } - + videoRecorder.setAuthorRecording(authorRecording); - + Set atts = videoRecorder.getVideoRecorderAttachments(); for (VideoRecorderAttachment att : atts) { att.setVideoRecorder(null); } try { exportContentService.registerFileClassForExport(VideoRecorderAttachment.class.getName(), "fileUuid", "fileVersionId"); - exportContentService.exportToolContent(toolContentId, videoRecorder, videoRecorderToolContentHandler, rootPath); + exportContentService.exportToolContent(toolContentId, videoRecorder, videoRecorderToolContentHandler, + rootPath); } catch (ExportToolContentException e) { throw new ToolException(e); } @@ -330,24 +329,24 @@ Object toolPOJO = exportContentService.importToolContent(toolContentPath, videoRecorderToolContentHandler, fromVersion, toVersion); if (!(toolPOJO instanceof VideoRecorder)) { - throw new ImportToolContentException("Import VideoRecorder tool content failed. Deserialized object is " - + toolPOJO); + throw new ImportToolContentException( + "Import VideoRecorder tool content failed. Deserialized object is " + toolPOJO); } VideoRecorder videoRecorder = (VideoRecorder) toolPOJO; - + VideoRecorderRecording recording = videoRecorder.getAuthorRecording(); - + // reset it to new toolContentId videoRecorder.setToolContentId(toolContentId); - - if(recording != null) { - videoRecorder.getAuthorRecording().setToolContentId(toolContentId); + + if (recording != null) { + videoRecorder.getAuthorRecording().setToolContentId(toolContentId); } - + videoRecorderDAO.saveOrUpdate(videoRecorder); - - if(recording != null){ - videoRecorderRecordingDAO.saveOrUpdate(recording); + + if (recording != null) { + videoRecorderRecordingDAO.saveOrUpdate(recording); } } catch (ImportToolContentException e) { throw new ToolException(e); @@ -362,12 +361,13 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { VideoRecorder videoRecorder = getVideoRecorderDAO().getByContentId(toolContentId); if (videoRecorder == null) { videoRecorder = getDefaultContent(); } - return getVideoRecorderOutputFactory().getToolOutputDefinitions(videoRecorder); + return getVideoRecorderOutputFactory().getToolOutputDefinitions(videoRecorder, definitionType); } /* ********** IVideoRecorderService Methods ********************************* */ @@ -404,7 +404,7 @@ throw new VideoRecorderException(error); } if (defaultContent.getConditions().isEmpty()) { - // needed? + // needed? } return defaultContent; } @@ -436,7 +436,8 @@ public VideoRecorderSession getSessionBySessionId(Long toolSessionId) { VideoRecorderSession videoRecorderSession = videoRecorderSessionDAO.getBySessionId(toolSessionId); if (videoRecorderSession == null) { - VideoRecorderService.logger.debug("Could not find the videoRecorder session with toolSessionID:" + toolSessionId); + VideoRecorderService.logger.debug("Could not find the videoRecorder session with toolSessionID:" + + toolSessionId); } return videoRecorderSession; } @@ -452,79 +453,80 @@ public VideoRecorderUser getUserByUID(Long uid) { return videoRecorderUserDAO.getByUID(uid); } - - public VideoRecorderRecording getRecordingById(Long recordingId){ + + public VideoRecorderRecording getRecordingById(Long recordingId) { return videoRecorderRecordingDAO.getRecordingById(recordingId); } - - public void deleteVideoRecorderRecording(VideoRecorderRecording videoRecorderRecording){ + + public void deleteVideoRecorderRecording(VideoRecorderRecording videoRecorderRecording) { videoRecorderRecordingDAO.delete(videoRecorderRecording); return; } - public VideoRecorderRating getRatingById(Long ratingId){ + public VideoRecorderRating getRatingById(Long ratingId) { return videoRecorderRatingDAO.getRatingById(ratingId); } - - public VideoRecorderComment getCommentById(Long commentId){ + + public VideoRecorderComment getCommentById(Long commentId) { return videoRecorderCommentDAO.getCommentById(commentId); } - - public Set getRatingsByUserId(Long userId){ + + public Set getRatingsByUserId(Long userId) { return videoRecorderRatingDAO.getRatingsByUserId(userId); } - - public Set getRatingsByToolSessionId(Long toolSessionId){ - Set list = videoRecorderRatingDAO.getRatingsByToolSessionId(toolSessionId); - return VideoRecorderRatingDTO.getVideoRecorderRatingDTOs(list); + + public Set getRatingsByToolSessionId(Long toolSessionId) { + Set list = videoRecorderRatingDAO.getRatingsByToolSessionId(toolSessionId); + return VideoRecorderRatingDTO.getVideoRecorderRatingDTOs(list); } - - public Set getCommentsByUserId(Long userId){ + + public Set getCommentsByUserId(Long userId) { return videoRecorderCommentDAO.getCommentsByUserId(userId); } - - public Set getCommentsByToolSessionId(Long toolSessionId){ - Set list = videoRecorderCommentDAO.getCommentsByToolSessionId(toolSessionId); - return VideoRecorderCommentDTO.getVideoRecorderCommentDTOs(list); + + public Set getCommentsByToolSessionId(Long toolSessionId) { + Set list = videoRecorderCommentDAO.getCommentsByToolSessionId(toolSessionId); + return VideoRecorderCommentDTO.getVideoRecorderCommentDTOs(list); } - - public List getRecordingsByToolSessionId(Long toolSessionId, Long toolContentId){ - List list = videoRecorderRecordingDAO.getByToolSessionId(toolSessionId); - list.addAll(videoRecorderRecordingDAO.getByToolContentId(toolContentId)); - - return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); + + public List getRecordingsByToolSessionId(Long toolSessionId, Long toolContentId) { + List list = videoRecorderRecordingDAO.getByToolSessionId(toolSessionId); + list.addAll(videoRecorderRecordingDAO.getByToolContentId(toolContentId)); + + return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); } - - public List getRecordingsByToolSessionIdAndUserId(Long toolSessionId, Long userId, Long toolContentId){ - List list = videoRecorderRecordingDAO.getBySessionAndUserIds(toolSessionId, userId); - list.addAll(videoRecorderRecordingDAO.getByToolContentId(toolContentId)); - - return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); + + public List getRecordingsByToolSessionIdAndUserId(Long toolSessionId, Long userId, + Long toolContentId) { + List list = videoRecorderRecordingDAO.getBySessionAndUserIds(toolSessionId, userId); + list.addAll(videoRecorderRecordingDAO.getByToolContentId(toolContentId)); + + return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); } - - public List getRecordingsByToolContentId(Long toolContentId){ - List list = videoRecorderRecordingDAO.getByToolContentId(toolContentId); - return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); + + public List getRecordingsByToolContentId(Long toolContentId) { + List list = videoRecorderRecordingDAO.getByToolContentId(toolContentId); + return VideoRecorderRecordingDTO.getVideoRecorderRecordingDTOs(list); } - - public VideoRecorderRecording getFirstRecordingByToolContentId(Long toolContentId){ - List list = videoRecorderRecordingDAO.getByToolContentId(toolContentId); - if(!list.isEmpty()){ - return list.get(0); - }else{ - return null; - } + + public VideoRecorderRecording getFirstRecordingByToolContentId(Long toolContentId) { + List list = videoRecorderRecordingDAO.getByToolContentId(toolContentId); + if (!list.isEmpty()) { + return list.get(0); + } else { + return null; + } } - + public VideoRecorderAttachment uploadFileToContent(Long toolContentId, FormFile file, String type) { if (file == null || StringUtils.isEmpty(file.getFileName())) { throw new VideoRecorderException("Could not find upload file: " + file); } NodeKey nodeKey = processFile(file, type); - VideoRecorderAttachment attachment = new VideoRecorderAttachment(nodeKey.getVersion(), type, file.getFileName(), nodeKey - .getUuid(), new Date()); + VideoRecorderAttachment attachment = new VideoRecorderAttachment(nodeKey.getVersion(), type, + file.getFileName(), nodeKey.getUuid(), new Date()); return attachment; } @@ -553,19 +555,19 @@ public void saveOrUpdateVideoRecorderUser(VideoRecorderUser videoRecorderUser) { videoRecorderUserDAO.saveOrUpdate(videoRecorderUser); } - - public void saveOrUpdateVideoRecorderRecording(VideoRecorderRecording videoRecorderRecording){ - videoRecorderRecordingDAO.saveOrUpdate(videoRecorderRecording); + + public void saveOrUpdateVideoRecorderRecording(VideoRecorderRecording videoRecorderRecording) { + videoRecorderRecordingDAO.saveOrUpdate(videoRecorderRecording); } - public void saveOrUpdateVideoRecorderComment(VideoRecorderComment videoRecorderComment){ - videoRecorderCommentDAO.saveOrUpdate(videoRecorderComment); + public void saveOrUpdateVideoRecorderComment(VideoRecorderComment videoRecorderComment) { + videoRecorderCommentDAO.saveOrUpdate(videoRecorderComment); } - - public void saveOrUpdateVideoRecorderRating(VideoRecorderRating videoRecorderRating){ - videoRecorderRatingDAO.saveOrUpdate(videoRecorderRating); + + public void saveOrUpdateVideoRecorderRating(VideoRecorderRating videoRecorderRating) { + videoRecorderRatingDAO.saveOrUpdate(videoRecorderRating); } - + public VideoRecorderUser createVideoRecorderUser(UserDTO user, VideoRecorderSession videoRecorderSession) { VideoRecorderUser videoRecorderUser = new VideoRecorderUser(user, videoRecorderSession); saveOrUpdateVideoRecorderUser(videoRecorderUser); @@ -617,7 +619,8 @@ ICredentials credentials = new SimpleCredentials(VideoRecorderToolContentHandler.repositoryUser, VideoRecorderToolContentHandler.repositoryId); try { - ITicket ticket = repositoryService.login(credentials, VideoRecorderToolContentHandler.repositoryWorkspaceName); + ITicket ticket = repositoryService.login(credentials, + VideoRecorderToolContentHandler.repositoryWorkspaceName); return ticket; } catch (AccessDeniedException ae) { throw new VideoRecorderException("Access Denied to repository." + ae.getMessage()); @@ -710,9 +713,9 @@ } public void setVideoRecorderRecordingDAO(IVideoRecorderRecordingDAO videoRecorderRecordingDAO) { - this.videoRecorderRecordingDAO = videoRecorderRecordingDAO; + this.videoRecorderRecordingDAO = videoRecorderRecordingDAO; } - + public ILamsToolService getToolService() { return toolService; } @@ -728,23 +731,23 @@ public void setVideoRecorderUserDAO(IVideoRecorderUserDAO userDAO) { videoRecorderUserDAO = userDAO; } - - public void setMessageService(MessageService messageService) { - this.messageService = messageService; - } - - public MessageService getMessageService() { - return messageService; - } - + + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } + + public MessageService getMessageService() { + return messageService; + } + public IVideoRecorderCommentDAO getVideoRecorderCommentDAO() { return videoRecorderCommentDAO; } public void setVideoRecorderCommentDAO(IVideoRecorderCommentDAO commentDAO) { videoRecorderCommentDAO = commentDAO; } - + public IVideoRecorderRatingDAO getVideoRecorderRatingDAO() { return videoRecorderRatingDAO; } @@ -786,11 +789,11 @@ } public IRepositoryService getRepositoryService() { - return repositoryService; + return repositoryService; } public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; + this.repositoryService = repositoryService; } public void releaseConditionsFromCache(VideoRecorder videoRecorder) { @@ -806,154 +809,156 @@ videoRecorderDAO.delete(condition); } } - + public Long getNbRecordings(Long userID, Long sessionId) { - return videoRecorderRecordingDAO.getNbRecordings(userID, sessionId); + return videoRecorderRecordingDAO.getNbRecordings(userID, sessionId); } - + public Long getNbComments(Long userID, Long sessionId) { - return videoRecorderCommentDAO.getNbComments(userID, sessionId); + return videoRecorderCommentDAO.getNbComments(userID, sessionId); } public Long getNbRatings(Long userID, Long sessionId) { - return videoRecorderRatingDAO.getNbRatings(userID, sessionId); - } - + return videoRecorderRatingDAO.getNbRatings(userID, sessionId); + } + public boolean isGroupedActivity(long toolContentID) { - return toolService.isGroupedActivity(toolContentID); + return toolService.isGroupedActivity(toolContentID); } - /** - * @return String of xml with all needed language elements - */ - public String getLanguageXML(){ - ArrayList languageCollection = new ArrayList(); - languageCollection.add(new String("button.ok")); - languageCollection.add(new String("button.save")); - languageCollection.add(new String("button.cancel")); - languageCollection.add(new String("button.yes")); - languageCollection.add(new String("button.no")); - languageCollection.add(new String("videorecorder.stop.recording")); - languageCollection.add(new String("videorecorder.start.recording")); - languageCollection.add(new String("videorecorder.stop.camera")); - languageCollection.add(new String("videorecorder.view.camera")); - languageCollection.add(new String("videorecorder.author")); - languageCollection.add(new String("videorecorder.description")); - languageCollection.add(new String("videorecorder.title")); - languageCollection.add(new String("videorecorder.new.recording.details")); - languageCollection.add(new String("videorecorder.comment")); - languageCollection.add(new String("videorecorder.date")); - languageCollection.add(new String("videorecorder.rating")); - languageCollection.add(new String("videorecorder.play")); - languageCollection.add(new String("videorecorder.stop")); - languageCollection.add(new String("videorecorder.pause")); - languageCollection.add(new String("videorecorder.resume")); - languageCollection.add(new String("videorecorder.video.information")); - languageCollection.add(new String("videorecorder.sort.by")); - languageCollection.add(new String("videorecorder.recording.controls")); - languageCollection.add(new String("videorecorder.videos")); - languageCollection.add(new String("videorecorder.add.comment")); - languageCollection.add(new String("videorecorder.video")); - languageCollection.add(new String("videorecorder.export.video")); - languageCollection.add(new String("videorecorder.delete.video")); - languageCollection.add(new String("videorecorder.enter.something.here")); - languageCollection.add(new String("videorecorder.message.sure.delete")); - languageCollection.add(new String("videorecorder.confirm")); - languageCollection.add(new String("videorecorder.update")); - languageCollection.add(new String("videorecorder.refresh")); - languageCollection.add(new String("videorecorder.web.application.not.available")); - languageCollection.add(new String("videorecorder.net.connection.not.connected")); - languageCollection.add(new String("videorecorder.net.connection.closed")); - languageCollection.add(new String("videorecorder.playing")); - languageCollection.add(new String("videorecorder.ready")); - languageCollection.add(new String("videorecorder.paused")); - languageCollection.add(new String("videorecorder.recording")); - languageCollection.add(new String("videorecorder.buffering")); - languageCollection.add(new String("videorecorder.waiting")); - languageCollection.add(new String("videorecorder.tooltip.sort.author")); - languageCollection.add(new String("videorecorder.tooltip.sort.title")); - languageCollection.add(new String("videorecorder.tooltip.sort.date")); - languageCollection.add(new String("videorecorder.tooltip.play")); - languageCollection.add(new String("videorecorder.tooltip.pause")); - languageCollection.add(new String("videorecorder.tooltip.resume")); - languageCollection.add(new String("videorecorder.tooltip.start.camera")); - languageCollection.add(new String("videorecorder.tooltip.stop.camera")); - languageCollection.add(new String("videorecorder.tooltip.add.comment")); - languageCollection.add(new String("videorecorder.tooltip.add.rating")); - languageCollection.add(new String("videorecorder.tooltip.refresh")); - languageCollection.add(new String("videorecorder.tooltip.save.recording")); - languageCollection.add(new String("videorecorder.tooltip.save.comment")); - languageCollection.add(new String("videorecorder.tooltip.cancel.comment")); - languageCollection.add(new String("videorecorder.tooltip.start.recording")); - languageCollection.add(new String("videorecorder.tooltip.stop.recording")); - languageCollection.add(new String("videorecorder.tooltip.delete.recording")); - languageCollection.add(new String("videorecorder.tooltip.export.recording")); - languageCollection.add(new String("videorecorder.tooltip.click.to.ready.recording")); - languageCollection.add(new String("videorecorder.tooltip.rate.recording")); - languageCollection.add(new String("videorecorder.tooltip.already.rated")); - languageCollection.add(new String("videorecorder.disabled")); - languageCollection.add(new String("videorecorder.camera.not.available")); - languageCollection.add(new String("videorecorder.mic.not.available")); - - String languageOutput = ""; - - for(int i = 0; i < languageCollection.size(); i++){ - languageOutput += "" + messageService.getMessage(languageCollection.get(i)) + ""; - } - - languageOutput += ""; - - return languageOutput; + /** + * @return String of xml with all needed language elements + */ + public String getLanguageXML() { + ArrayList languageCollection = new ArrayList(); + languageCollection.add(new String("button.ok")); + languageCollection.add(new String("button.save")); + languageCollection.add(new String("button.cancel")); + languageCollection.add(new String("button.yes")); + languageCollection.add(new String("button.no")); + languageCollection.add(new String("videorecorder.stop.recording")); + languageCollection.add(new String("videorecorder.start.recording")); + languageCollection.add(new String("videorecorder.stop.camera")); + languageCollection.add(new String("videorecorder.view.camera")); + languageCollection.add(new String("videorecorder.author")); + languageCollection.add(new String("videorecorder.description")); + languageCollection.add(new String("videorecorder.title")); + languageCollection.add(new String("videorecorder.new.recording.details")); + languageCollection.add(new String("videorecorder.comment")); + languageCollection.add(new String("videorecorder.date")); + languageCollection.add(new String("videorecorder.rating")); + languageCollection.add(new String("videorecorder.play")); + languageCollection.add(new String("videorecorder.stop")); + languageCollection.add(new String("videorecorder.pause")); + languageCollection.add(new String("videorecorder.resume")); + languageCollection.add(new String("videorecorder.video.information")); + languageCollection.add(new String("videorecorder.sort.by")); + languageCollection.add(new String("videorecorder.recording.controls")); + languageCollection.add(new String("videorecorder.videos")); + languageCollection.add(new String("videorecorder.add.comment")); + languageCollection.add(new String("videorecorder.video")); + languageCollection.add(new String("videorecorder.export.video")); + languageCollection.add(new String("videorecorder.delete.video")); + languageCollection.add(new String("videorecorder.enter.something.here")); + languageCollection.add(new String("videorecorder.message.sure.delete")); + languageCollection.add(new String("videorecorder.confirm")); + languageCollection.add(new String("videorecorder.update")); + languageCollection.add(new String("videorecorder.refresh")); + languageCollection.add(new String("videorecorder.web.application.not.available")); + languageCollection.add(new String("videorecorder.net.connection.not.connected")); + languageCollection.add(new String("videorecorder.net.connection.closed")); + languageCollection.add(new String("videorecorder.playing")); + languageCollection.add(new String("videorecorder.ready")); + languageCollection.add(new String("videorecorder.paused")); + languageCollection.add(new String("videorecorder.recording")); + languageCollection.add(new String("videorecorder.buffering")); + languageCollection.add(new String("videorecorder.waiting")); + languageCollection.add(new String("videorecorder.tooltip.sort.author")); + languageCollection.add(new String("videorecorder.tooltip.sort.title")); + languageCollection.add(new String("videorecorder.tooltip.sort.date")); + languageCollection.add(new String("videorecorder.tooltip.play")); + languageCollection.add(new String("videorecorder.tooltip.pause")); + languageCollection.add(new String("videorecorder.tooltip.resume")); + languageCollection.add(new String("videorecorder.tooltip.start.camera")); + languageCollection.add(new String("videorecorder.tooltip.stop.camera")); + languageCollection.add(new String("videorecorder.tooltip.add.comment")); + languageCollection.add(new String("videorecorder.tooltip.add.rating")); + languageCollection.add(new String("videorecorder.tooltip.refresh")); + languageCollection.add(new String("videorecorder.tooltip.save.recording")); + languageCollection.add(new String("videorecorder.tooltip.save.comment")); + languageCollection.add(new String("videorecorder.tooltip.cancel.comment")); + languageCollection.add(new String("videorecorder.tooltip.start.recording")); + languageCollection.add(new String("videorecorder.tooltip.stop.recording")); + languageCollection.add(new String("videorecorder.tooltip.delete.recording")); + languageCollection.add(new String("videorecorder.tooltip.export.recording")); + languageCollection.add(new String("videorecorder.tooltip.click.to.ready.recording")); + languageCollection.add(new String("videorecorder.tooltip.rate.recording")); + languageCollection.add(new String("videorecorder.tooltip.already.rated")); + languageCollection.add(new String("videorecorder.disabled")); + languageCollection.add(new String("videorecorder.camera.not.available")); + languageCollection.add(new String("videorecorder.mic.not.available")); + + String languageOutput = ""; + + for (int i = 0; i < languageCollection.size(); i++) { + languageOutput += "" + + messageService.getMessage(languageCollection.get(i)) + ""; } - - public String getLanguageXMLForFCK(){ - ArrayList languageCollection = new ArrayList(); - languageCollection.add(new String("button.ok")); - languageCollection.add(new String("button.save")); - languageCollection.add(new String("button.cancel")); - languageCollection.add(new String("button.yes")); - languageCollection.add(new String("button.no")); - languageCollection.add(new String("videorecorder.video.player")); - languageCollection.add(new String("videorecorder.video.recorder")); - languageCollection.add(new String("videorecorder.web.application.not.available")); - languageCollection.add(new String("videorecorder.net.connection.not.connected")); - languageCollection.add(new String("videorecorder.net.connection.closed")); - languageCollection.add(new String("videorecorder.playing")); - languageCollection.add(new String("videorecorder.ready")); - languageCollection.add(new String("videorecorder.paused")); - languageCollection.add(new String("videorecorder.recording")); - languageCollection.add(new String("videorecorder.buffering")); - languageCollection.add(new String("videorecorder.waiting")); - languageCollection.add(new String("videorecorder.description")); - languageCollection.add(new String("videorecorder.title")); - languageCollection.add(new String("videorecorder.new.recording.details")); - languageCollection.add(new String("videorecorder.recording.complete.authoring")); - languageCollection.add(new String("videorecorder.enter.something.here")); - languageCollection.add(new String("videorecorder.recording.complete.fck")); - languageCollection.add(new String("videorecorder.tooltip.play")); - languageCollection.add(new String("videorecorder.tooltip.pause")); - languageCollection.add(new String("videorecorder.tooltip.resume")); - languageCollection.add(new String("videorecorder.tooltip.save.recording")); - languageCollection.add(new String("videorecorder.tooltip.start.recording")); - languageCollection.add(new String("videorecorder.tooltip.start.recording.again")); - languageCollection.add(new String("videorecorder.tooltip.start.recording.next")); - languageCollection.add(new String("videorecorder.tooltip.stop.recording")); - languageCollection.add(new String("videorecorder.disabled")); - languageCollection.add(new String("videorecorder.camera.not.available")); - languageCollection.add(new String("videorecorder.mic.not.available")); - - String languageOutput = ""; - - for(int i = 0; i < languageCollection.size(); i++){ - languageOutput += "" + messageService.getMessage(languageCollection.get(i)) + ""; - } - - languageOutput += ""; - - return languageOutput; + + languageOutput += ""; + + return languageOutput; + } + + public String getLanguageXMLForFCK() { + ArrayList languageCollection = new ArrayList(); + languageCollection.add(new String("button.ok")); + languageCollection.add(new String("button.save")); + languageCollection.add(new String("button.cancel")); + languageCollection.add(new String("button.yes")); + languageCollection.add(new String("button.no")); + languageCollection.add(new String("videorecorder.video.player")); + languageCollection.add(new String("videorecorder.video.recorder")); + languageCollection.add(new String("videorecorder.web.application.not.available")); + languageCollection.add(new String("videorecorder.net.connection.not.connected")); + languageCollection.add(new String("videorecorder.net.connection.closed")); + languageCollection.add(new String("videorecorder.playing")); + languageCollection.add(new String("videorecorder.ready")); + languageCollection.add(new String("videorecorder.paused")); + languageCollection.add(new String("videorecorder.recording")); + languageCollection.add(new String("videorecorder.buffering")); + languageCollection.add(new String("videorecorder.waiting")); + languageCollection.add(new String("videorecorder.description")); + languageCollection.add(new String("videorecorder.title")); + languageCollection.add(new String("videorecorder.new.recording.details")); + languageCollection.add(new String("videorecorder.recording.complete.authoring")); + languageCollection.add(new String("videorecorder.enter.something.here")); + languageCollection.add(new String("videorecorder.recording.complete.fck")); + languageCollection.add(new String("videorecorder.tooltip.play")); + languageCollection.add(new String("videorecorder.tooltip.pause")); + languageCollection.add(new String("videorecorder.tooltip.resume")); + languageCollection.add(new String("videorecorder.tooltip.save.recording")); + languageCollection.add(new String("videorecorder.tooltip.start.recording")); + languageCollection.add(new String("videorecorder.tooltip.start.recording.again")); + languageCollection.add(new String("videorecorder.tooltip.start.recording.next")); + languageCollection.add(new String("videorecorder.tooltip.stop.recording")); + languageCollection.add(new String("videorecorder.disabled")); + languageCollection.add(new String("videorecorder.camera.not.available")); + languageCollection.add(new String("videorecorder.mic.not.available")); + + String languageOutput = ""; + + for (int i = 0; i < languageCollection.size(); i++) { + languageOutput += "" + + messageService.getMessage(languageCollection.get(i)) + ""; } - - public String getMessage(String key){ - return messageService.getMessage(key); - } + + languageOutput += ""; + + return languageOutput; + } + + public String getMessage(String key) { + return messageService.getMessage(key); + } } \ No newline at end of file Index: lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/VoteContent.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/Attic/VoteContent.hbm.xml,v diff -u -r1.9 -r1.10 --- lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/VoteContent.hbm.xml 26 Mar 2008 04:08:22 -0000 1.9 +++ lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/VoteContent.hbm.xml 2 Jul 2009 13:02:04 -0000 1.10 @@ -158,8 +158,15 @@ column="show_results" length="1" /> + + - - + Index: lams_tool_vote/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/conf/language/lams/ApplicationResources.properties,v diff -u -r1.19 -r1.20 --- lams_tool_vote/conf/language/lams/ApplicationResources.properties 11 Mar 2009 14:29:16 -0000 1.19 +++ lams_tool_vote/conf/language/lams/ApplicationResources.properties 2 Jul 2009 13:02:04 -0000 1.20 @@ -162,4 +162,8 @@ label.total.students =Total number of possible learners: msg.planner.clear.entry=Clear nomination content (will be removed from activity after save) + +label.data.flow.choose=or choose an input: +label.data.flow.none=None +msg.data.flow.clear.nominations=You have chosen to use input from an external tool. All defined nomitations will be deleted after save. Do you want to proceed? #======= End labels: Exported 154 labels for en AU ===== Index: lams_tool_vote/db/sql/create_lams_tool_vote.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/db/sql/create_lams_tool_vote.sql,v diff -u -r1.25 -r1.26 --- lams_tool_vote/db/sql/create_lams_tool_vote.sql 26 Mar 2008 04:08:39 -0000 1.25 +++ lams_tool_vote/db/sql/create_lams_tool_vote.sql 2 Jul 2009 13:02:03 -0000 1.26 @@ -18,6 +18,7 @@ , retries TINYINT(1) NOT NULL DEFAULT 0 , reflectionSubject TEXT , show_results TINYINT(1) NOT NULL DEFAULT 1 + , assigned_data_flow_object TINYINT(1) , PRIMARY KEY (uid) )TYPE=InnoDB; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java,v diff -u -r1.47 -r1.48 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java 9 Dec 2008 05:38:14 -0000 1.47 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java 2 Jul 2009 13:02:04 -0000 1.48 @@ -347,4 +347,6 @@ public static final String USER_EXCEPTION_OPTIONS_DUPLICATE = "userExceptionOptionsDuplicate"; public static final String USER_EXCEPTION_MAXNOMINATION_INVALID = "userExceptionMaxNominationInvalid"; public static final String SUCCESS = "success"; + + public static final Integer DATA_FLOW_OBJECT_ASSIGMENT_ID = 0; } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteGeneralAuthoringDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/Attic/VoteGeneralAuthoringDTO.java,v diff -u -r1.5 -r1.6 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteGeneralAuthoringDTO.java 26 Mar 2008 03:57:40 -0000 1.5 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteGeneralAuthoringDTO.java 2 Jul 2009 13:02:03 -0000 1.6 @@ -91,8 +91,14 @@ protected String isToolSessionChanged; protected String responseId; protected String currentUid; - + protected List dataFlowObjectNames; + public List getDataFlowObjectNames() { + return dataFlowObjectNames; + } + public void setDataFlowObjectNames(List dataFlowObjectNames) { + this.dataFlowObjectNames = dataFlowObjectNames; + } /** * @return Returns the httpSessionID. */ Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml,v diff -u -r1.11 -r1.12 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml 26 Mar 2009 10:00:40 -0000 1.11 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml 2 Jul 2009 13:02:04 -0000 1.12 @@ -69,6 +69,7 @@ + Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.java,v diff -u -r1.12 -r1.13 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.java 26 Mar 2008 03:57:40 -0000 1.12 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.java 2 Jul 2009 13:02:04 -0000 1.13 @@ -35,22 +35,22 @@ import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; /** - *

Persistent object/bean that defines the content for the Voting tool. - * Provides accessors and mutators to get/set attributes - * It maps to database table: tl_lavote11_content + *

+ * Persistent object/bean that defines the content for the Voting tool. Provides accessors and mutators to get/set + * attributes It maps to database table: tl_lavote11_content *

* * @author Ozgur Demirtas */ public class VoteContent implements Serializable { - static Logger logger = Logger.getLogger(VoteContent.class.getName()); + static Logger logger = Logger.getLogger(VoteContent.class.getName()); /** identifier field */ private Long uid; /** persistent field */ private Long voteContentId; - + /** persistent field, used for export portfolio */ private String content; @@ -59,9 +59,9 @@ /** nullable persistent field */ private String reflectionSubject; - + private String instructions; - + /** nullable persistent field */ private boolean defineLater; @@ -74,14 +74,13 @@ /** nullable persistent field */ private Date updateDate; - /** nullable persistent field */ private long createdBy; - + private boolean reflect; - + private boolean allowText; - + private String maxNominationCount; /** nullable persistent field */ @@ -97,43 +96,48 @@ private String onlineInstructions; private boolean showResults; - + /** persistent field */ private Set voteQueContents; /** persistent field */ private Set voteSessions; - + /** persistent field */ private Set voteAttachments; + /** + * persistent field This field can be calculated, but introducing it reduces number of DB calls. + */ + private Boolean assignedDataFlowObject; + /** full constructor */ - public VoteContent(Long voteContentId, String content, String title, String instructions, boolean defineLater, boolean runOffline, - Date creationDate, Date updateDate, boolean allowText,boolean reflect, String reflectionSubject, - String maxNominationCount, long createdBy, boolean lockOnFinish, boolean contentInUse, String offlineInstructions, - String onlineInstructions, boolean showResults, Set voteQueContents, Set voteSessions, - Set voteAttachments) { - this.voteContentId = voteContentId; - this.content=content; - this.title = title; - this.instructions = instructions; - this.defineLater = defineLater; - this.runOffline = runOffline; - this.creationDate = creationDate; - this.updateDate = updateDate; - this.maxNominationCount=maxNominationCount; - this.allowText=allowText; - this.reflect=reflect; - this.reflectionSubject=reflectionSubject; - this.createdBy = createdBy; - this.lockOnFinish = lockOnFinish; - this.contentInUse = contentInUse; - this.offlineInstructions = offlineInstructions; - this.onlineInstructions = onlineInstructions; - this.showResults = showResults; - this.voteQueContents = voteQueContents; - this.voteSessions = voteSessions; - this.voteAttachments = voteAttachments; + public VoteContent(Long voteContentId, String content, String title, String instructions, boolean defineLater, + boolean runOffline, Date creationDate, Date updateDate, boolean allowText, boolean reflect, + String reflectionSubject, String maxNominationCount, long createdBy, boolean lockOnFinish, + boolean contentInUse, String offlineInstructions, String onlineInstructions, boolean showResults, + Set voteQueContents, Set voteSessions, Set voteAttachments) { + this.voteContentId = voteContentId; + this.content = content; + this.title = title; + this.instructions = instructions; + this.defineLater = defineLater; + this.runOffline = runOffline; + this.creationDate = creationDate; + this.updateDate = updateDate; + this.maxNominationCount = maxNominationCount; + this.allowText = allowText; + this.reflect = reflect; + this.reflectionSubject = reflectionSubject; + this.createdBy = createdBy; + this.lockOnFinish = lockOnFinish; + this.contentInUse = contentInUse; + this.offlineInstructions = offlineInstructions; + this.onlineInstructions = onlineInstructions; + this.showResults = showResults; + this.voteQueContents = voteQueContents; + this.voteSessions = voteSessions; + this.voteAttachments = voteAttachments; } /** default constructor */ @@ -142,348 +146,352 @@ /** minimal constructor */ public VoteContent(Long voteContentId, Set voteQueContents, Set voteSessions) { - this.voteContentId = voteContentId; - this.voteQueContents = voteQueContents; - this.voteSessions = voteSessions; + this.voteContentId = voteContentId; + this.voteQueContents = voteQueContents; + this.voteSessions = voteSessions; } - - + /** - * gets called as part of the copyToolContent - * - * Copy Construtor to create a new mc content instance. Note that we - * don't copy the mc session data here because the mc session - * will be created after we copied tool content. - * @param mc the original mc content. - * @param newContentId the new mc content id. + * gets called as part of the copyToolContent + * + * Copy Construtor to create a new mc content instance. Note that we don't copy the mc session data here because the + * mc session will be created after we copied tool content. + * + * @param mc + * the original mc content. + * @param newContentId + * the new mc content id. * @return the new mc content object. */ - public static VoteContent newInstance(IToolContentHandler toolContentHandler, VoteContent vote, - Long newContentId) - throws ItemNotFoundException, RepositoryCheckedException - { - VoteContent newContent = new VoteContent( - newContentId, - vote.getContent(), - vote.getTitle(), - vote.getInstructions(), - vote.isDefineLater(), - vote.isRunOffline(), - vote.getCreationDate(), - vote.getUpdateDate(), - vote.isAllowText(), - vote.isReflect(), - vote.getReflectionSubject(), - vote.getMaxNominationCount(), - vote.getCreatedBy(), - vote.isLockOnFinish(), - vote.isContentInUse(), - vote.getOfflineInstructions(), - vote.getOnlineInstructions(), - vote.isShowResults(), - new TreeSet(), - new TreeSet(), - new TreeSet() - ); - newContent.setVoteQueContents(vote.deepCopyMcQueContent(newContent)); - newContent.setVoteAttachments(vote.deepCopyMcAttachments(toolContentHandler, newContent)); - - return newContent; - } - + public static VoteContent newInstance(IToolContentHandler toolContentHandler, VoteContent vote, Long newContentId) + throws ItemNotFoundException, RepositoryCheckedException { + VoteContent newContent = new VoteContent(newContentId, vote.getContent(), vote.getTitle(), vote + .getInstructions(), vote.isDefineLater(), vote.isRunOffline(), vote.getCreationDate(), vote + .getUpdateDate(), vote.isAllowText(), vote.isReflect(), vote.getReflectionSubject(), vote + .getMaxNominationCount(), vote.getCreatedBy(), vote.isLockOnFinish(), vote.isContentInUse(), vote + .getOfflineInstructions(), vote.getOnlineInstructions(), vote.isShowResults(), new TreeSet(), + new TreeSet(), new TreeSet()); + newContent.setVoteQueContents(vote.deepCopyMcQueContent(newContent)); + newContent.setVoteAttachments(vote.deepCopyMcAttachments(toolContentHandler, newContent)); + newContent.setAssignedDataFlowObject(vote.getAssignedDataFlowObject()); + + return newContent; + } + /** * gets called as part of the copyToolContent * * @param newQaContent * @return Set */ - public Set deepCopyMcQueContent(VoteContent newMcContent) - { - - Set newMcQueContent = new TreeSet(); - for (Iterator i = this.getVoteQueContents().iterator(); i.hasNext();) - { - VoteQueContent queContent = (VoteQueContent) i.next(); - if (queContent.getMcContent() != null) - { - int displayOrder=queContent.getDisplayOrder(); - VoteQueContent mcQueContent=VoteQueContent.newInstance(queContent,displayOrder, - newMcContent); - newMcQueContent.add(mcQueContent); - } - } - return newMcQueContent; + public Set deepCopyMcQueContent(VoteContent newMcContent) { + + Set newMcQueContent = new TreeSet(); + for (Iterator i = this.getVoteQueContents().iterator(); i.hasNext();) { + VoteQueContent queContent = (VoteQueContent) i.next(); + if (queContent.getMcContent() != null) { + int displayOrder = queContent.getDisplayOrder(); + VoteQueContent mcQueContent = VoteQueContent.newInstance(queContent, displayOrder, newMcContent); + newMcQueContent.add(mcQueContent); + } + } + return newMcQueContent; } - + /** * gets called as part of the copyToolContent * * @param newMcContent * @return Set */ - public Set deepCopyMcAttachments(IToolContentHandler toolContentHandler,VoteContent newMcContent) - throws ItemNotFoundException, RepositoryCheckedException - { - Set newMcQueContent = new TreeSet(); - for (Iterator i = this.getVoteAttachments().iterator(); i.hasNext();) - { - VoteUploadedFile mcUploadedFile = (VoteUploadedFile) i.next(); - if (mcUploadedFile.getVoteContent() != null) - { - VoteUploadedFile newMcUploadedFile=VoteUploadedFile.newInstance(toolContentHandler, mcUploadedFile, - newMcContent); - newMcQueContent.add(newMcUploadedFile); - } - } - return newMcQueContent; + public Set deepCopyMcAttachments(IToolContentHandler toolContentHandler, VoteContent newMcContent) + throws ItemNotFoundException, RepositoryCheckedException { + Set newMcQueContent = new TreeSet(); + for (Iterator i = this.getVoteAttachments().iterator(); i.hasNext();) { + VoteUploadedFile mcUploadedFile = (VoteUploadedFile) i.next(); + if (mcUploadedFile.getVoteContent() != null) { + VoteUploadedFile newMcUploadedFile = VoteUploadedFile.newInstance(toolContentHandler, mcUploadedFile, + newMcContent); + newMcQueContent.add(newMcUploadedFile); + } + } + return newMcQueContent; } - public Long getUid() { - return this.uid; + return uid; } public void setUid(Long uid) { - this.uid = uid; + this.uid = uid; } - public String getTitle() { - return this.title; + return title; } public void setTitle(String title) { - this.title = title; + this.title = title; } public String getInstructions() { - return this.instructions; + return instructions; } public void setInstructions(String instructions) { - this.instructions = instructions; + this.instructions = instructions; } public boolean isDefineLater() { - return this.defineLater; + return defineLater; } public void setDefineLater(boolean defineLater) { - this.defineLater = defineLater; + this.defineLater = defineLater; } public boolean isRunOffline() { - return this.runOffline; + return runOffline; } public void setRunOffline(boolean runOffline) { - this.runOffline = runOffline; + this.runOffline = runOffline; } public Date getUpdateDate() { - return this.updateDate; + return updateDate; } public void setUpdateDate(Date updateDate) { - this.updateDate = updateDate; + this.updateDate = updateDate; } public long getCreatedBy() { - return this.createdBy; + return createdBy; } public void setCreatedBy(long createdBy) { - this.createdBy = createdBy; + this.createdBy = createdBy; } - public boolean isContentInUse() { - return this.contentInUse; + return contentInUse; } public void setContentInUse(boolean contentInUse) { - this.contentInUse = contentInUse; + this.contentInUse = contentInUse; } public String getOfflineInstructions() { - return this.offlineInstructions; + return offlineInstructions; } public void setOfflineInstructions(String offlineInstructions) { - this.offlineInstructions = offlineInstructions; + this.offlineInstructions = offlineInstructions; } public String getOnlineInstructions() { - return this.onlineInstructions; + return onlineInstructions; } public void setOnlineInstructions(String onlineInstructions) { - this.onlineInstructions = onlineInstructions; + this.onlineInstructions = onlineInstructions; } - /** * @return Returns the voteQueContents. */ public Set getVoteQueContents() { - if (this.voteQueContents == null) - setVoteQueContents(new HashSet()); - return this.voteQueContents; - + if (voteQueContents == null) { + setVoteQueContents(new HashSet()); + } + return voteQueContents; + } + /** - * @param voteQueContents The voteQueContents to set. + * @param voteQueContents + * The voteQueContents to set. */ public void setVoteQueContents(Set voteQueContents) { - this.voteQueContents = voteQueContents; + this.voteQueContents = voteQueContents; } - - + /** * @return Returns the voteSessions. */ public Set getVoteSessions() { - if (this.voteSessions == null) - setVoteSessions(new HashSet()); - return this.voteSessions; + if (voteSessions == null) { + setVoteSessions(new HashSet()); + } + return voteSessions; } - + /** - * @param voteSessions The voteSessions to set. + * @param voteSessions + * The voteSessions to set. */ public void setVoteSessions(Set voteSessions) { - this.voteSessions = voteSessions; - } - - + this.voteSessions = voteSessions; + } + @Override public String toString() { - return new ToStringBuilder(this) - .append("uid", getUid()) - .toString(); + return new ToStringBuilder(this).append("uid", getUid()).toString(); } - - + /** * @return Returns the voteAttachments. */ public Set getVoteAttachments() { - if(voteAttachments == null) - voteAttachments = new TreeSet(); - - return voteAttachments; + if (voteAttachments == null) { + voteAttachments = new TreeSet(); + } + + return voteAttachments; } + /** - * @param voteAttachments The voteAttachments to set. + * @param voteAttachments + * The voteAttachments to set. */ public void setVoteAttachments(Set voteAttachments) { - this.voteAttachments = voteAttachments; - } - - /** - * @return Returns the creationDate. - */ - public Date getCreationDate() { - return creationDate; - } - /** - * @param creationDate The creationDate to set. - */ - public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; - } - /** - * @return Returns the content. - */ - public String getContent() { - return content; - } - /** - * @param content The content to set. - */ - public void setContent(String content) { - this.content = content; - } + this.voteAttachments = voteAttachments; + } + /** + * @return Returns the creationDate. + */ + public Date getCreationDate() { + return creationDate; + } + + /** + * @param creationDate + * The creationDate to set. + */ + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + /** + * @return Returns the content. + */ + public String getContent() { + return content; + } + + /** + * @param content + * The content to set. + */ + public void setContent(String content) { + this.content = content; + } + + /** * @return Returns the lockOnFinish. */ public boolean isLockOnFinish() { - return lockOnFinish; + return lockOnFinish; } + /** - * @param lockOnFinish The lockOnFinish to set. + * @param lockOnFinish + * The lockOnFinish to set. */ public void setLockOnFinish(boolean lockOnFinish) { - this.lockOnFinish = lockOnFinish; + this.lockOnFinish = lockOnFinish; } + /** * @return Returns the voteContentId. */ public Long getVoteContentId() { - return voteContentId; + return voteContentId; } + /** - * @param voteContentId The voteContentId to set. + * @param voteContentId + * The voteContentId to set. */ public void setVoteContentId(Long voteContentId) { - this.voteContentId = voteContentId; + this.voteContentId = voteContentId; } - /** * @return Returns the allowText. */ public boolean isAllowText() { - return allowText; + return allowText; } + /** - * @param allowText The allowText to set. + * @param allowText + * The allowText to set. */ public void setAllowText(boolean allowText) { - this.allowText = allowText; - } + this.allowText = allowText; + } + /** * @return Returns the maxNominationCount. */ public String getMaxNominationCount() { - return maxNominationCount; + return maxNominationCount; } + /** - * @param maxNominationCount The maxNominationCount to set. + * @param maxNominationCount + * The maxNominationCount to set. */ public void setMaxNominationCount(String maxNominationCount) { - this.maxNominationCount = maxNominationCount; + this.maxNominationCount = maxNominationCount; } + /** * @return Returns the reflect. */ public boolean isReflect() { - return reflect; + return reflect; } + /** - * @param reflect The reflect to set. + * @param reflect + * The reflect to set. */ public void setReflect(boolean reflect) { - this.reflect = reflect; + this.reflect = reflect; } + /** * @return Returns the reflectionSubject. */ public String getReflectionSubject() { - return reflectionSubject; + return reflectionSubject; } + /** - * @param reflectionSubject The reflectionSubject to set. + * @param reflectionSubject + * The reflectionSubject to set. */ public void setReflectionSubject(String reflectionSubject) { - this.reflectionSubject = reflectionSubject; + this.reflectionSubject = reflectionSubject; } - public boolean isShowResults() { - return showResults; - } + public boolean isShowResults() { + return showResults; + } - public void setShowResults(boolean showResults) { - this.showResults = showResults; - } -} + public void setShowResults(boolean showResults) { + this.showResults = showResults; + } + + public Boolean getAssignedDataFlowObject() { + return assignedDataFlowObject; + } + + public void setAssignedDataFlowObject(Boolean assignedDataFlowObject) { + this.assignedDataFlowObject = assignedDataFlowObject; + } +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java,v diff -u -r1.40 -r1.41 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java 18 Feb 2009 23:06:57 -0000 1.40 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java 2 Jul 2009 13:02:03 -0000 1.41 @@ -29,9 +29,11 @@ import org.lamsfoundation.lams.contentrepository.ITicket; import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.IToolVO; +import org.lamsfoundation.lams.tool.ToolOutput; import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; @@ -188,10 +190,9 @@ public VoteSession getVoteSessionByUID(Long uid) throws VoteApplicationException; /** - * Get the count of all the potential learners for the vote session. This - * will include the people that have never logged into the lesson. Not - * great, but it is a better estimate of how many users there will be - * eventually than the number of people already known to the tool. + * Get the count of all the potential learners for the vote session. This will include the people that have never + * logged into the lesson. Not great, but it is a better estimate of how many users there will be eventually than + * the number of people already known to the tool. * * @param voteSessionId * The tool session id @@ -301,4 +302,12 @@ public List retrieveVoteUploadedFiles(VoteContent Vote) throws VoteApplicationException; public void removeNominationsFromCache(VoteContent voteContent); -} + + public ToolOutput getToolInput(Long requestingToolContentId, Integer learnerId); + + public List getDataFlowObjects(Long toolContentId); + + public void saveDataFlowObjectAssigment(DataFlowObject assignedDataFlowObject); + + public DataFlowObject getAssignedDataFlowObject(Long toolContentId); +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java,v diff -u -r1.6 -r1.7 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java 8 Apr 2008 04:44:26 -0000 1.6 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java 2 Jul 2009 13:02:03 -0000 1.7 @@ -51,7 +51,7 @@ /** * @see org.lamsfoundation.lams.tool.OutputDefinitionFactory#getToolOutputDefinitions(java.lang.Object) */ - public SortedMap getToolOutputDefinitions(Object toolContentObject) { + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) { TreeMap definitionMap = new TreeMap(); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java,v diff -u -r1.65 -r1.66 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java 16 Mar 2009 05:56:04 -0000 1.65 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java 2 Jul 2009 13:02:03 -0000 1.66 @@ -46,9 +46,10 @@ import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; -import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.learning.service.ILearnerService; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; +import org.lamsfoundation.lams.learningdesign.dao.IDataFlowDAO; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; @@ -95,9 +96,8 @@ * * @author Ozgur Demirtas * - * The POJO implementation of Voting service. All business logic of Voting tool - * is implemented in this class. It translates the request from presentation - * layer and performs appropriate database operation. + * The POJO implementation of Voting service. All business logic of Voting tool is implemented in this class. It + * translates the request from presentation layer and performs appropriate database operation. * */ public class VoteServicePOJO implements IVoteService, ToolContentManager, ToolSessionManager, @@ -129,35 +129,36 @@ private ICoreNotebookService coreNotebookService; private IToolContentHandler voteToolContentHandler = null; private VoteOutputFactory voteOutputFactory; + private IDataFlowDAO dataFlowDAO; private MessageService messageService; public VoteServicePOJO() { } public void configureContentRepository() throws VoteApplicationException { - logger.debug("retrieved repService: " + repositoryService); + VoteServicePOJO.logger.debug("retrieved repService: " + repositoryService); cred = new SimpleCredentials(repositoryUser, repositoryId); - logger.debug("retrieved cred: " + cred); + VoteServicePOJO.logger.debug("retrieved cred: " + cred); try { repositoryService.createCredentials(cred); - logger.debug("created credentails."); - repositoryService.addWorkspace(cred, repositoryWorkspaceName); - logger.debug("created workspace."); + VoteServicePOJO.logger.debug("created credentails."); + repositoryService.addWorkspace(cred, VoteServicePOJO.repositoryWorkspaceName); + VoteServicePOJO.logger.debug("created workspace."); } catch (ItemExistsException ie) { - logger.warn("Tried to configure repository but it " + VoteServicePOJO.logger.warn("Tried to configure repository but it " + " appears to be already configured. Exception thrown by repository being ignored. ", ie); } catch (RepositoryCheckedException e) { String error = "Error occured while trying to configure repository." + " Unable to recover from error: " + e.getMessage(); - logger.error(error, e); + VoteServicePOJO.logger.error(error, e); throw new VoteApplicationException(error, e); } } public void createVote(VoteContent voteContent) throws VoteApplicationException { try { - logger.debug("using voteContent defineLater:" + voteContent.isDefineLater()); + VoteServicePOJO.logger.debug("using voteContent defineLater:" + voteContent.isDefineLater()); voteContentDAO.saveVoteContent(voteContent); } catch (DataAccessException e) { throw new VoteApplicationException("Exception occured when lams is creating vote content: " @@ -379,7 +380,8 @@ Set potentialLearners = toolService.getAllPotentialLearners(session.getVoteSessionId().longValue()); return potentialLearners != null ? potentialLearners.size() : 0; } else { - logger.error("Unable to find vote session record id=" + voteSessionId + ". Returning 0 users."); + VoteServicePOJO.logger.error("Unable to find vote session record id=" + voteSessionId + + ". Returning 0 users."); return 0; } } catch (LamsToolServiceException e) { @@ -834,7 +836,7 @@ * logs hiding of a user entered vote */ public void hideOpenVote(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException { - logger.debug("hiding user entry: " + voteUsrAttempt.getUserEntry()); + VoteServicePOJO.logger.debug("hiding user entry: " + voteUsrAttempt.getUserEntry()); auditService.logHideEntry(VoteAppConstants.MY_SIGNATURE, voteUsrAttempt.getQueUsrId(), voteUsrAttempt .getVoteQueUsr().getUsername(), voteUsrAttempt.getUserEntry()); } @@ -843,7 +845,7 @@ * logs showing of a user entered vote */ public void showOpenVote(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException { - logger.debug("showing user entry: " + voteUsrAttempt.getUserEntry()); + VoteServicePOJO.logger.debug("showing user entry: " + voteUsrAttempt.getUserEntry()); auditService.logShowEntry(VoteAppConstants.MY_SIGNATURE, voteUsrAttempt.getQueUsrId(), voteUsrAttempt .getVoteQueUsr().getUsername(), voteUsrAttempt.getUserEntry()); } @@ -886,13 +888,13 @@ public User getCurrentUserData(String username) throws VoteApplicationException { try { - logger.debug("getCurrentUserData: " + username); + VoteServicePOJO.logger.debug("getCurrentUserData: " + username); /** * this will return null if the username not found */ User user = userManagementService.getUserByLogin(username); if (user == null) { - logger.error("No user with the username: " + username + " exists."); + VoteServicePOJO.logger.error("No user with the username: " + username + " exists."); throw new VoteApplicationException("No user with that username exists."); } return user; @@ -943,14 +945,14 @@ * @throws VoteApplicationException */ public boolean studentActivityOccurredGlobal(VoteContent voteContent) throws VoteApplicationException { - logger.debug("voteContent uid: " + voteContent.getUid()); + VoteServicePOJO.logger.debug("voteContent uid: " + voteContent.getUid()); Iterator questionIterator = voteContent.getVoteQueContents().iterator(); while (questionIterator.hasNext()) { VoteQueContent voteQueContent = (VoteQueContent) questionIterator.next(); Iterator attemptsIterator = voteQueContent.getVoteUsrAttempts().iterator(); while (attemptsIterator.hasNext()) { - logger.debug("there is at least one attempt for the standard nominamtions"); + VoteServicePOJO.logger.debug("there is at least one attempt for the standard nominamtions"); /** * proved the fact that there is at least one attempt for this content. */ @@ -961,18 +963,18 @@ } public boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent) throws VoteApplicationException { - logger.debug("voteContent uid: " + voteContent.getUid()); + VoteServicePOJO.logger.debug("voteContent uid: " + voteContent.getUid()); boolean studentActivityOccurredGlobal = studentActivityOccurredGlobal(voteContent); - logger.debug("studentActivityOccurredGlobal: " + studentActivityOccurredGlobal); + VoteServicePOJO.logger.debug("studentActivityOccurredGlobal: " + studentActivityOccurredGlobal); int userEnteredVotesCount = getUserEnteredVotesCountForContent(voteContent.getUid()); - logger.debug("userEnteredVotesCount: " + userEnteredVotesCount); + VoteServicePOJO.logger.debug("userEnteredVotesCount: " + userEnteredVotesCount); if (studentActivityOccurredGlobal == true || userEnteredVotesCount > 0) { return true; } - logger.debug("there is no votes/nominations for this content"); + VoteServicePOJO.logger.debug("there is no votes/nominations for this content"); return false; } @@ -1012,77 +1014,77 @@ * */ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { - logger.debug("start of copyToolContent with ids: " + fromContentId + " and " + toContentId); + VoteServicePOJO.logger.debug("start of copyToolContent with ids: " + fromContentId + " and " + toContentId); if (fromContentId == null) { - logger.error("fromContentId is null."); - logger.debug("attempt retrieving tool's default content id with signatute : " + VoteServicePOJO.logger.error("fromContentId is null."); + VoteServicePOJO.logger.debug("attempt retrieving tool's default content id with signatute : " + VoteAppConstants.MY_SIGNATURE); long defaultContentId = 0; try { defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); fromContentId = new Long(defaultContentId); } catch (Exception e) { - logger.error("default content id has not been setup for signature: " + VoteServicePOJO.logger.error("default content id has not been setup for signature: " + VoteAppConstants.MY_SIGNATURE); throw new ToolException("WARNING! default content has not been setup for signature" + VoteAppConstants.MY_SIGNATURE + " Can't continue!"); } } if (toContentId == null) { - logger.error("throwing ToolException: toContentId is null"); + VoteServicePOJO.logger.error("throwing ToolException: toContentId is null"); throw new ToolException("toContentId is missing"); } - logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId); + VoteServicePOJO.logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId); try { VoteContent fromContent = voteContentDAO.findVoteContentById(fromContentId); if (fromContent == null) { - logger.error("fromContent is null."); - logger.error("attempt retrieving tool's default content id with signatute : " + VoteServicePOJO.logger.error("fromContent is null."); + VoteServicePOJO.logger.error("attempt retrieving tool's default content id with signatute : " + VoteAppConstants.MY_SIGNATURE); long defaultContentId = 0; try { defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); fromContentId = new Long(defaultContentId); } catch (Exception e) { - logger.error("default content id has not been setup for signature: " + VoteServicePOJO.logger.error("default content id has not been setup for signature: " + VoteAppConstants.MY_SIGNATURE); throw new ToolException("WARNING! default content has not been setup for signature" + VoteAppConstants.MY_SIGNATURE + " Can't continue!"); } fromContent = voteContentDAO.findVoteContentById(fromContentId); - logger.debug("using fromContent: " + fromContent); + VoteServicePOJO.logger.debug("using fromContent: " + fromContent); } - logger.debug("final - retrieved fromContent: " + fromContent); - logger.debug("final - before new instance using " + fromContent + " and " + toContentId); - logger.debug("final - before new instance using voteToolContentHandler: " + VoteServicePOJO.logger.debug("final - retrieved fromContent: " + fromContent); + VoteServicePOJO.logger.debug("final - before new instance using " + fromContent + " and " + toContentId); + VoteServicePOJO.logger.debug("final - before new instance using voteToolContentHandler: " + voteToolContentHandler); try { VoteContent toContent = VoteContent.newInstance(voteToolContentHandler, fromContent, toContentId); if (toContent == null) { - logger.debug("throwing ToolException: WARNING!, retrieved toContent is null."); + VoteServicePOJO.logger.debug("throwing ToolException: WARNING!, retrieved toContent is null."); throw new ToolException("WARNING! Fail to create toContent. Can't continue!"); } else { - logger.debug("retrieved toContent: " + toContent); + VoteServicePOJO.logger.debug("retrieved toContent: " + toContent); voteContentDAO.saveVoteContent(toContent); - logger.debug("toContent has been saved successfully: " + toContent); + VoteServicePOJO.logger.debug("toContent has been saved successfully: " + toContent); } - logger.debug("end of copyToolContent with ids: " + fromContentId + " and " + VoteServicePOJO.logger.debug("end of copyToolContent with ids: " + fromContentId + " and " + toContentId); } catch (ItemNotFoundException e) { - logger.error("exception occurred: " + e); + VoteServicePOJO.logger.error("exception occurred: " + e); } catch (RepositoryCheckedException e) { - logger.error("exception occurred: " + e); + VoteServicePOJO.logger.error("exception occurred: " + e); } } catch (DataAccessException e) { - logger + VoteServicePOJO.logger .error("throwing ToolException: Exception occured when lams is copying content between content ids."); throw new ToolException("Exception occured when lams is copying content between content ids."); } @@ -1099,66 +1101,66 @@ */ public void removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, ToolException { - logger.debug("start of removeToolContent with toolContentID: " + toolContentID + VoteServicePOJO.logger.debug("start of removeToolContent with toolContentID: " + toolContentID + "removeSessionData: " + removeSessionData); if (toolContentID == null) { - logger.error("toolContentID is null"); + VoteServicePOJO.logger.error("toolContentID is null"); throw new ToolException("toolContentID is missing"); } VoteContent voteContent = voteContentDAO.findVoteContentById(toolContentID); - logger.debug("retrieving voteContent: " + voteContent); + VoteServicePOJO.logger.debug("retrieving voteContent: " + voteContent); if (voteContent != null) { - logger + VoteServicePOJO.logger .error("start deleting any uploaded file for this content from the content repository"); Iterator filesIterator = voteContent.getVoteAttachments().iterator(); while (filesIterator.hasNext()) { VoteUploadedFile voteUploadedFile = (VoteUploadedFile) filesIterator.next(); - logger.debug("iterated voteUploadedFile : " + voteUploadedFile); + VoteServicePOJO.logger.debug("iterated voteUploadedFile : " + voteUploadedFile); String filesUuid = voteUploadedFile.getUuid(); if (filesUuid != null && filesUuid.length() > 0) { try { voteToolContentHandler.deleteFile(new Long(filesUuid)); } catch (RepositoryCheckedException e) { - logger.error("exception occured deleting files from content repository : " + e); + VoteServicePOJO.logger.error("exception occured deleting files from content repository : " + e); throw new ToolException("undeletable file in the content repository"); } } } - logger.debug("end deleting any uploaded files for this content."); + VoteServicePOJO.logger.debug("end deleting any uploaded files for this content."); Iterator sessionIterator = voteContent.getVoteSessions().iterator(); while (sessionIterator.hasNext()) { if (removeSessionData == false) { - logger.debug("removeSessionData is false, throwing SessionDataExistsException."); + VoteServicePOJO.logger.debug("removeSessionData is false, throwing SessionDataExistsException."); throw new SessionDataExistsException(); } VoteSession voteSession = (VoteSession) sessionIterator.next(); - logger.debug("iterated voteSession : " + voteSession); + VoteServicePOJO.logger.debug("iterated voteSession : " + voteSession); Iterator sessionUsersIterator = voteSession.getVoteQueUsers().iterator(); while (sessionUsersIterator.hasNext()) { VoteQueUsr voteQueUsr = (VoteQueUsr) sessionUsersIterator.next(); - logger.debug("iterated voteQueUsr : " + voteQueUsr); + VoteServicePOJO.logger.debug("iterated voteQueUsr : " + voteQueUsr); Iterator sessionUsersAttemptsIterator = voteQueUsr.getVoteUsrAttempts().iterator(); while (sessionUsersAttemptsIterator.hasNext()) { VoteUsrAttempt voteUsrAttempt = (VoteUsrAttempt) sessionUsersAttemptsIterator.next(); - logger.debug("iterated voteUsrAttempt : " + voteUsrAttempt); + VoteServicePOJO.logger.debug("iterated voteUsrAttempt : " + voteUsrAttempt); removeAttempt(voteUsrAttempt); - logger.debug("removed voteUsrAttempt : " + voteUsrAttempt); + VoteServicePOJO.logger.debug("removed voteUsrAttempt : " + voteUsrAttempt); } } } - logger.debug("removed all existing responses of toolContent with toolContentID:" + VoteServicePOJO.logger.debug("removed all existing responses of toolContent with toolContentID:" + toolContentID); voteContentDAO.removeVoteById(toolContentID); - logger.debug("removed voteContent:" + voteContent); + VoteServicePOJO.logger.debug("removed voteContent:" + voteContent); } else { - logger.error("Warning!!!, We should have not come here. voteContent is null."); + VoteServicePOJO.logger.error("Warning!!!, We should have not come here. voteContent is null."); throw new ToolException("toolContentID is missing"); } } @@ -1247,13 +1249,13 @@ */ public void setAsDefineLater(Long toolContentID, boolean value) throws DataMissingException, ToolException { if (toolContentID == null) { - logger.error("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); + VoteServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); throw new DataMissingException("toolContentID is missing"); } VoteContent voteContent = retrieveVote(toolContentID); if (voteContent == null) { - logger.error("throwing DataMissingException: WARNING!: retrieved voteContent is null."); + VoteServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved voteContent is null."); throw new DataMissingException("voteContent is missing"); } voteContent.setDefineLater(value); @@ -1270,12 +1272,12 @@ */ public void setAsRunOffline(Long toolContentID, boolean value) throws DataMissingException, ToolException { if (toolContentID == null) { - logger.error("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); + VoteServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); throw new DataMissingException("toolContentID is missing"); } VoteContent voteContent = voteContentDAO.findVoteContentById(toolContentID); if (voteContent == null) { - logger.error("throwing DataMissingException: WARNING!: retrieved voteContent is null."); + VoteServicePOJO.logger.error("throwing DataMissingException: WARNING!: retrieved voteContent is null."); throw new DataMissingException("voteContent is missing"); } voteContent.setRunOffline(value); @@ -1293,10 +1295,10 @@ VoteSession voteSession = retrieveVoteSession(toolSessionID); if (voteSession == null) { - logger.error("voteSession does not exist yet: " + toolSessionID); + VoteServicePOJO.logger.error("voteSession does not exist yet: " + toolSessionID); return false; } else { - logger.debug("retrieving an existing voteSession: " + voteSession + " " + toolSessionID); + VoteServicePOJO.logger.debug("retrieving an existing voteSession: " + voteSession + " " + toolSessionID); } return true; } @@ -1316,55 +1318,55 @@ * */ public void createToolSession(Long toolSessionID, String toolSessionName, Long toolContentID) throws ToolException { - logger.debug("start of createToolSession with ids: " + toolSessionID + " and " + toolContentID); - logger.debug("toolSessionName: " + toolSessionName); + VoteServicePOJO.logger.debug("start of createToolSession with ids: " + toolSessionID + " and " + toolContentID); + VoteServicePOJO.logger.debug("toolSessionName: " + toolSessionName); if (toolSessionID == null) { - logger.error("toolSessionID is null"); + VoteServicePOJO.logger.error("toolSessionID is null"); throw new ToolException("toolSessionID is missing"); } long defaultContentId = 0; if (toolContentID == null) { - logger.error("toolContentID is null."); - logger.error("attempt retrieving tool's default content id with signatute : " + VoteServicePOJO.logger.error("toolContentID is null."); + VoteServicePOJO.logger.error("attempt retrieving tool's default content id with signatute : " + VoteAppConstants.MY_SIGNATURE); try { defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); toolContentID = new Long(defaultContentId); - logger.debug("updated toolContentID to: " + toolContentID); + VoteServicePOJO.logger.debug("updated toolContentID to: " + toolContentID); } catch (Exception e) { - logger.error("default content id has not been setup for signature: " + VoteServicePOJO.logger.error("default content id has not been setup for signature: " + VoteAppConstants.MY_SIGNATURE); throw new ToolException("WARNING! default content has not been setup for signature" + VoteAppConstants.MY_SIGNATURE + " Can't continue!"); } } - logger.debug("final toolSessionID and toolContentID: " + toolSessionID + " " + toolContentID); + VoteServicePOJO.logger.debug("final toolSessionID and toolContentID: " + toolSessionID + " " + toolContentID); VoteContent voteContent = voteContentDAO.findVoteContentById(toolContentID); - logger.debug("retrieved voteContent: " + voteContent); + VoteServicePOJO.logger.debug("retrieved voteContent: " + voteContent); if (voteContent == null) { - logger.error("voteContent is null."); - logger.error("attempt retrieving tool's default content id with signatute : " + VoteServicePOJO.logger.error("voteContent is null."); + VoteServicePOJO.logger.error("attempt retrieving tool's default content id with signatute : " + VoteAppConstants.MY_SIGNATURE); try { defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); toolContentID = new Long(defaultContentId); - logger.debug("updated toolContentID to: " + toolContentID); + VoteServicePOJO.logger.debug("updated toolContentID to: " + toolContentID); } catch (Exception e) { - logger.error("default content id has not been setup for signature: " + VoteServicePOJO.logger.error("default content id has not been setup for signature: " + VoteAppConstants.MY_SIGNATURE); throw new ToolException("WARNING! default content has not been setup for signature" + VoteAppConstants.MY_SIGNATURE + " Can't continue!"); } voteContent = voteContentDAO.findVoteContentById(toolContentID); } - logger.debug("final - retrieved voteContent: " + voteContent); + VoteServicePOJO.logger.debug("final - retrieved voteContent: " + voteContent); /* * create a new a new tool session if it does not already exist in the tool session table @@ -1374,12 +1376,12 @@ VoteSession voteSession = new VoteSession(toolSessionID, new Date(System.currentTimeMillis()), VoteSession.INCOMPLETE, toolSessionName, voteContent, new TreeSet()); - logger.debug("created voteSession: " + voteSession); + VoteServicePOJO.logger.debug("created voteSession: " + voteSession); voteSessionDAO.saveVoteSession(voteSession); - logger.debug("created voteSession in the db: " + voteSession); + VoteServicePOJO.logger.debug("created voteSession in the db: " + voteSession); } catch (Exception e) { - logger.error("Error creating new toolsession in the db"); + VoteServicePOJO.logger.error("Error creating new toolsession in the db"); throw new ToolException("Error creating new toolsession in the db: " + e); } } @@ -1395,30 +1397,30 @@ * @throws ToolException */ public void removeToolSession(Long toolSessionID) throws DataMissingException, ToolException { - logger.debug("start of removeToolSession with id: " + toolSessionID); + VoteServicePOJO.logger.debug("start of removeToolSession with id: " + toolSessionID); if (toolSessionID == null) { - logger.error("toolSessionID is null"); + VoteServicePOJO.logger.error("toolSessionID is null"); throw new DataMissingException("toolSessionID is missing"); } VoteSession voteSession = null; try { voteSession = retrieveVoteSession(toolSessionID); - logger.debug("retrieved voteSession: " + voteSession); + VoteServicePOJO.logger.debug("retrieved voteSession: " + voteSession); } catch (VoteApplicationException e) { throw new DataMissingException("error retrieving voteSession: " + e); } catch (Exception e) { throw new ToolException("error retrieving voteSession: " + e); } if (voteSession == null) { - logger.error("voteSession is null"); + VoteServicePOJO.logger.error("voteSession is null"); throw new DataMissingException("voteSession is missing"); } try { voteSessionDAO.removeVoteSession(voteSession); - logger.debug("voteSession " + voteSession + " has been deleted successfully."); + VoteServicePOJO.logger.debug("voteSession " + voteSession + " has been deleted successfully."); } catch (VoteApplicationException e) { throw new ToolException("error deleting voteSession:" + e); } @@ -1435,41 +1437,41 @@ * */ public String leaveToolSession(Long toolSessionID, Long learnerId) throws DataMissingException, ToolException { - logger.debug("start of leaveToolSession with toolSessionID:" + toolSessionID + VoteServicePOJO.logger.debug("start of leaveToolSession with toolSessionID:" + toolSessionID + " and learnerId:" + learnerId); - logger.debug("make sure learnerService is available. Is it?" + learnerService); + VoteServicePOJO.logger.debug("make sure learnerService is available. Is it?" + learnerService); if (learnerService == null) { return "dummyNextUrl"; } if (learnerId == null) { - logger.error("learnerId is null"); + VoteServicePOJO.logger.error("learnerId is null"); throw new DataMissingException("learnerId is missing"); } if (toolSessionID == null) { - logger.error("toolSessionID is null"); + VoteServicePOJO.logger.error("toolSessionID is null"); throw new DataMissingException("toolSessionID is missing"); } VoteSession voteSession = null; try { voteSession = retrieveVoteSession(toolSessionID); - logger.debug("retrieved voteSession: " + voteSession); + VoteServicePOJO.logger.debug("retrieved voteSession: " + voteSession); } catch (VoteApplicationException e) { throw new DataMissingException("error retrieving voteSession: " + e); } catch (Exception e) { throw new ToolException("error retrieving voteSession: " + e); } voteSession.setSessionStatus(VoteAppConstants.COMPLETED); voteSessionDAO.updateVoteSession(voteSession); - logger.debug("updated voteSession to COMPLETED" + voteSession); + VoteServicePOJO.logger.debug("updated voteSession to COMPLETED" + voteSession); String nextUrl = learnerService.completeToolSession(toolSessionID, learnerId); - logger.debug("nextUrl: " + nextUrl); + VoteServicePOJO.logger.debug("nextUrl: " + nextUrl); if (nextUrl == null) { - logger.error("nextUrl is null"); + VoteServicePOJO.logger.error("nextUrl is null"); throw new ToolException("nextUrl is null"); } return nextUrl; @@ -1500,27 +1502,27 @@ } public IToolVO getToolBySignature(String toolSignature) throws VoteApplicationException { - logger.debug("attempt retrieving tool with signature : " + toolSignature); + VoteServicePOJO.logger.debug("attempt retrieving tool with signature : " + toolSignature); IToolVO tool = toolService.getToolBySignature(toolSignature); - logger.debug("retrieved tool: " + tool); + VoteServicePOJO.logger.debug("retrieved tool: " + tool); return tool; } public long getToolDefaultContentIdBySignature(String toolSignature) throws VoteApplicationException { long contentId = 0; contentId = toolService.getToolDefaultContentIdBySignature(toolSignature); - logger.debug("tool default contentId : " + contentId); + VoteServicePOJO.logger.debug("tool default contentId : " + contentId); return contentId; } public VoteQueContent getToolDefaultQuestionContent(long contentId) throws VoteApplicationException { VoteQueContent voteQueContent = voteQueContentDAO.getToolDefaultQuestionContent(contentId); - logger.debug("retrieved voteQueContent : " + voteQueContent); + VoteServicePOJO.logger.debug("retrieved voteQueContent : " + voteQueContent); return voteQueContent; } public List getToolSessionsForContent(VoteContent vote) { - logger.debug("attempt retrieving listToolSessionIds for : " + vote); + VoteServicePOJO.logger.debug("attempt retrieving listToolSessionIds for : " + vote); List listToolSessionIds = voteSessionDAO.getSessionsFromContent(vote); return listToolSessionIds; } @@ -1560,7 +1562,7 @@ ICredentials credentials = new SimpleCredentials(repositoryUser, repositoryId); try { ITicket ticket = repositoryService.login(credentials, VoteServicePOJO.repositoryWorkspaceName); - logger.debug("retrieved ticket: " + ticket); + VoteServicePOJO.logger.debug("retrieved ticket: " + ticket); return ticket; } catch (AccessDeniedException e) { throw new VoteApplicationException("Access Denied to repository." + e.getMessage()); @@ -1583,10 +1585,10 @@ */ public void deleteFromRepository(Long uuid, Long versionID) throws VoteApplicationException { ITicket ticket = getRepositoryLoginTicket(); - logger.debug("retrieved ticket: " + ticket); + VoteServicePOJO.logger.debug("retrieved ticket: " + ticket); try { String files[] = repositoryService.deleteVersion(ticket, uuid, versionID); - logger.debug("retrieved files: " + files); + VoteServicePOJO.logger.debug("retrieved files: " + files); } catch (Exception e) { throw new VoteApplicationException("Exception occured while deleting files from" + " the repository " + e.getMessage()); @@ -1608,13 +1610,13 @@ * @throws SubmitFilesException */ public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws VoteApplicationException { - logger.debug("attempt getting the ticket"); + VoteServicePOJO.logger.debug("attempt getting the ticket"); ITicket ticket = getRepositoryLoginTicket(); - logger.debug("retrieved ticket: " + ticket); + VoteServicePOJO.logger.debug("retrieved ticket: " + ticket); try { NodeKey nodeKey = repositoryService.addFileItem(ticket, stream, fileName, null, null); - logger.debug("retrieved nodeKey from repository service: " + nodeKey); + VoteServicePOJO.logger.debug("retrieved nodeKey from repository service: " + nodeKey); return nodeKey; } catch (Exception e) { throw new VoteApplicationException("Exception occured while trying to" + " upload file into the repository" @@ -1626,7 +1628,7 @@ ITicket ticket = getRepositoryLoginTicket(); try { IVersionedNode node = repositoryService.getFileItem(ticket, uuid, null); - logger.debug("retrieved node: " + node); + VoteServicePOJO.logger.debug("retrieved node: " + node); return node.getFile(); } catch (AccessDeniedException e) { throw new VoteApplicationException("AccessDeniedException occured while trying to download file " @@ -1645,35 +1647,36 @@ public void persistFile(String uuid, boolean isOnlineFile, String fileName, VoteContent voteContent) throws VoteApplicationException { - logger.debug("attempt persisting file to the db: " + uuid + " " + isOnlineFile + " " + fileName + VoteServicePOJO.logger.debug("attempt persisting file to the db: " + uuid + " " + isOnlineFile + " " + fileName + " " + voteContent); VoteUploadedFile voteUploadedFile = new VoteUploadedFile(uuid, isOnlineFile, fileName, voteContent); - logger.debug("created voteUploadedFile: " + voteUploadedFile); + VoteServicePOJO.logger.debug("created voteUploadedFile: " + voteUploadedFile); voteUploadedFileDAO.saveUploadFile(voteUploadedFile); - logger.debug("persisted voteUploadedFile: " + voteUploadedFile); + VoteServicePOJO.logger.debug("persisted voteUploadedFile: " + voteUploadedFile); } /** * * removes all the entries in the uploaded files table */ public void cleanUploadedFilesMetaData() throws VoteApplicationException { - logger.debug("attempt cleaning up uploaded file meta data table from the db"); + VoteServicePOJO.logger.debug("attempt cleaning up uploaded file meta data table from the db"); voteUploadedFileDAO.cleanUploadedFilesMetaData(); - logger.debug("files meta data has been cleaned up"); + VoteServicePOJO.logger.debug("files meta data has been cleaned up"); } /** * Get the definitions for possible output for an activity, based on the toolContentId. Currently we have one * definition, which is whether or not the user has selected a particular answer */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { VoteContent content = retrieveVote(toolContentId); if (content == null) { long defaultToolContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); content = retrieveVote(defaultToolContentId); } - return getVoteOutputFactory().getToolOutputDefinitions(content); + return getVoteOutputFactory().getToolOutputDefinitions(content, definitionType); } /** @@ -1736,7 +1739,7 @@ toolContentObj.setMaxNominationCount(maxCount != null ? maxCount.toString() : "1"); } catch (WDDXProcessorConversionException e) { - logger.error("Unable to content for activity " + toolContentObj.getTitle() + VoteServicePOJO.logger.error("Unable to content for activity " + toolContentObj.getTitle() + "properly due to a WDDXProcessorConversionException.", e); throw new ToolException( "Invalid import data format for activity " @@ -1765,8 +1768,7 @@ } /** - * Set the description, throws away the title value as this is not supported - * in 2.0 + * Set the description, throws away the title value as this is not supported in 2.0 */ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { @@ -1785,7 +1787,7 @@ } public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { - logger.debug("coreNotebookService: " + coreNotebookService); + VoteServicePOJO.logger.debug("coreNotebookService: " + coreNotebookService); return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); } @@ -1810,15 +1812,15 @@ public void removeFile(Long submissionId) throws VoteApplicationException { voteUploadedFileDAO.removeUploadFile(submissionId); - logger.debug("removed voteUploadedFile: " + submissionId); + VoteServicePOJO.logger.debug("removed voteUploadedFile: " + submissionId); } public void persistFile(VoteContent content, VoteUploadedFile file) throws VoteApplicationException { - logger.debug("in persistFile: " + file); + VoteServicePOJO.logger.debug("in persistFile: " + file); content.getVoteAttachments().add(file); file.setVoteContent(content); voteContentDAO.saveOrUpdateVote(content); - logger.debug("persisted voteUploadedFile: " + file); + VoteServicePOJO.logger.debug("persisted voteUploadedFile: " + file); } @@ -1835,7 +1837,7 @@ * @return Returns the logger. */ public static Logger getLogger() { - return logger; + return VoteServicePOJO.logger; } /** @@ -2186,4 +2188,30 @@ public void removeNominationsFromCache(VoteContent voteContent) { voteContentDAO.removeNominationsFromCache(voteContent); } -} + + public void setDataFlowDAO(IDataFlowDAO dataFlowDAO) { + this.dataFlowDAO = dataFlowDAO; + } + + public ToolOutput getToolInput(Long requestingToolContentId, Integer learnerId) { + // just forwarding to learner service + return learnerService.getToolInput(requestingToolContentId, VoteAppConstants.DATA_FLOW_OBJECT_ASSIGMENT_ID, + learnerId); + } + + public void saveDataFlowObjectAssigment(DataFlowObject assignedDataFlowObject) { + // this also should be done in learner service, but for simplicity... + if (assignedDataFlowObject != null) { + assignedDataFlowObject.setToolAssigmentId(VoteAppConstants.DATA_FLOW_OBJECT_ASSIGMENT_ID); + dataFlowDAO.update(assignedDataFlowObject); + } + } + + public DataFlowObject getAssignedDataFlowObject(Long toolContentId) { + return dataFlowDAO.getAssignedDataFlowObject(toolContentId, VoteAppConstants.DATA_FLOW_OBJECT_ASSIGMENT_ID); + } + + public List getDataFlowObjects(Long toolContentId) { + return dataFlowDAO.getDataFlowObjectsByToolContentId(toolContentId); + } +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java,v diff -u -r1.21 -r1.22 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java 26 Mar 2008 03:57:40 -0000 1.21 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java 2 Jul 2009 13:02:04 -0000 1.22 @@ -40,6 +40,7 @@ import org.lamsfoundation.lams.contentrepository.FileException; import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteAttachmentDTO; import org.lamsfoundation.lams.tool.vote.VoteComparator; @@ -55,171 +56,149 @@ /** * - *

Keeps all operations needed for Authoring mode.

- * + *

+ * Keeps all operations needed for Authoring mode. + *

+ * * @author Ozgur Demirtas - * + * */ public class AuthoringUtil implements VoteAppConstants { - static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); + static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); - /** - * checks if there are any duplicate entries - * @param mapOptionsContent - * @returnboolean - */ - public static boolean verifyDuplicateNominations(Map mapOptionsContent) - { - Map originalMapOptionsContent=mapOptionsContent; - Map backupMapOptionsContent=mapOptionsContent; - - int optionCount=0; - for (long i=1; i <= MAX_OPTION_COUNT ; i++) - { - String currentOption=(String)originalMapOptionsContent.get(new Long(i).toString()); - logger.debug("verified currentOption " + currentOption); - - optionCount=0; - for (long j=1; j <= MAX_OPTION_COUNT ; j++) - { - String backedOption=(String)backupMapOptionsContent.get(new Long(j).toString()); - - if ((currentOption != null) && (backedOption !=null)) - { - if (currentOption.equals(backedOption)) - { - optionCount++; - logger.debug("optionCount for " + currentOption + " is: " + optionCount); - } - - if (optionCount > 1) - return true; - } - } + /** + * checks if there are any duplicate entries + * + * @param mapOptionsContent + * @returnboolean + */ + public static boolean verifyDuplicateNominations(Map mapOptionsContent) { + Map originalMapOptionsContent = mapOptionsContent; + Map backupMapOptionsContent = mapOptionsContent; + + int optionCount = 0; + for (long i = 1; i <= VoteAppConstants.MAX_OPTION_COUNT; i++) { + String currentOption = (String) originalMapOptionsContent.get(new Long(i).toString()); + AuthoringUtil.logger.debug("verified currentOption " + currentOption); + + optionCount = 0; + for (long j = 1; j <= VoteAppConstants.MAX_OPTION_COUNT; j++) { + String backedOption = (String) backupMapOptionsContent.get(new Long(j).toString()); + + if (currentOption != null && backedOption != null) { + if (currentOption.equals(backedOption)) { + optionCount++; + AuthoringUtil.logger.debug("optionCount for " + currentOption + " is: " + optionCount); + } + + if (optionCount > 1) { + return true; + } } - return false; + } } - + return false; + } + /** * checks if the map is empty or not + * * @param map * @return boolean */ - public static boolean verifyMapNoEmptyString(Map map) - { - Iterator itMap = map.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if ((pairs.getValue() != null) && (pairs.getValue().toString().length() == 0)) - return false; - - } - return true; + public static boolean verifyMapNoEmptyString(Map map) { + Iterator itMap = map.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue() != null && pairs.getValue().toString().length() == 0) { + return false; + } + } - - - public static boolean validateNominationsNotEmpty(Map mapNominationsContent) - { - Iterator itMap = mapNominationsContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if ((pairs.getValue() != null) && (pairs.getValue().toString().length() == 0)) - return false; - - } - return true; + return true; } + public static boolean validateNominationsNotEmpty(Map mapNominationsContent) { + Iterator itMap = mapNominationsContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - public static Map repopulateMap(HttpServletRequest request, String parameterType) - { - Map mapTempNominationsContent= new TreeMap(new VoteComparator()); - logger.debug("parameterType: " + parameterType); - - long mapCounter=0; - String optionContent0=request.getParameter("optionContent0"); - logger.debug("optionContent0: " + optionContent0); - mapCounter++; - mapTempNominationsContent.put(new Long(mapCounter).toString(), optionContent0); - - - for (long i=1; i <= MAX_QUESTION_COUNT ; i++) - { - String candidateEntry =request.getParameter(parameterType + i); - if ( - (candidateEntry != null) && - (candidateEntry.length() > 0) - ) - { - mapCounter++; - mapTempNominationsContent.put(new Long(mapCounter).toString(), candidateEntry); - } - } - logger.debug("return repopulated Map: " + mapTempNominationsContent); - return mapTempNominationsContent; + if (pairs.getValue() != null && pairs.getValue().toString().length() == 0) { + return false; + } + + } + return true; } - public static Map shiftMap(Map mapOptionsContent, String optIndex , String movableOptionEntry, String direction) - { - logger.debug("movableOptionEntry: " + movableOptionEntry); - Map mapTempOptionsContent= new TreeMap(new VoteComparator()); - - String shiftableEntry=null; - - int shiftableIndex=0; - if (direction.equals("down")) - { - logger.debug("moving map down"); - shiftableIndex=new Integer(optIndex).intValue() + 1; - } - else - { - logger.debug("moving map up"); - shiftableIndex=new Integer(optIndex).intValue() - 1; - } - - logger.debug("shiftableIndex: " + shiftableIndex); - shiftableEntry=(String)mapOptionsContent.get(new Integer(shiftableIndex).toString()); - logger.debug("shiftable entry: " + shiftableEntry); - - if (shiftableEntry != null) - { - Iterator itNominationsMap = mapOptionsContent.entrySet().iterator(); - long mapCounter=0; - while (itNominationsMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itNominationsMap.next(); - logger.debug("comparing the pair: " + pairs.getKey() + " = " + pairs.getValue()); - mapCounter++; - logger.debug("mapCounter: " + mapCounter); - - if (!pairs.getKey().equals(optIndex) && !pairs.getKey().equals(new Integer(shiftableIndex).toString())) - { - logger.debug("normal copy " + optIndex); - mapTempOptionsContent.put(new Long(mapCounter).toString(), pairs.getValue()); - } - else if (pairs.getKey().equals(optIndex)) - { - logger.debug("move type 1 " + optIndex); - mapTempOptionsContent.put(new Long(mapCounter).toString(), shiftableEntry); - } - else if (pairs.getKey().equals(new Integer(shiftableIndex).toString())) - { - mapTempOptionsContent.put(new Long(mapCounter).toString(), movableOptionEntry); - } - } - } - else - { - mapTempOptionsContent=mapOptionsContent; - } - return mapTempOptionsContent; + public static Map repopulateMap(HttpServletRequest request, String parameterType) { + Map mapTempNominationsContent = new TreeMap(new VoteComparator()); + AuthoringUtil.logger.debug("parameterType: " + parameterType); + + long mapCounter = 0; + String optionContent0 = request.getParameter("optionContent0"); + AuthoringUtil.logger.debug("optionContent0: " + optionContent0); + mapCounter++; + mapTempNominationsContent.put(new Long(mapCounter).toString(), optionContent0); + + for (long i = 1; i <= VoteAppConstants.MAX_QUESTION_COUNT; i++) { + String candidateEntry = request.getParameter(parameterType + i); + if (candidateEntry != null && candidateEntry.length() > 0) { + mapCounter++; + mapTempNominationsContent.put(new Long(mapCounter).toString(), candidateEntry); + } + } + AuthoringUtil.logger.debug("return repopulated Map: " + mapTempNominationsContent); + return mapTempNominationsContent; } + public static Map shiftMap(Map mapOptionsContent, String optIndex, String movableOptionEntry, String direction) { + AuthoringUtil.logger.debug("movableOptionEntry: " + movableOptionEntry); + Map mapTempOptionsContent = new TreeMap(new VoteComparator()); + String shiftableEntry = null; + + int shiftableIndex = 0; + if (direction.equals("down")) { + AuthoringUtil.logger.debug("moving map down"); + shiftableIndex = new Integer(optIndex).intValue() + 1; + } else { + AuthoringUtil.logger.debug("moving map up"); + shiftableIndex = new Integer(optIndex).intValue() - 1; + } + + AuthoringUtil.logger.debug("shiftableIndex: " + shiftableIndex); + shiftableEntry = (String) mapOptionsContent.get(new Integer(shiftableIndex).toString()); + AuthoringUtil.logger.debug("shiftable entry: " + shiftableEntry); + + if (shiftableEntry != null) { + Iterator itNominationsMap = mapOptionsContent.entrySet().iterator(); + long mapCounter = 0; + while (itNominationsMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itNominationsMap.next(); + AuthoringUtil.logger.debug("comparing the pair: " + pairs.getKey() + " = " + pairs.getValue()); + mapCounter++; + AuthoringUtil.logger.debug("mapCounter: " + mapCounter); + + if (!pairs.getKey().equals(optIndex) && !pairs.getKey().equals(new Integer(shiftableIndex).toString())) { + AuthoringUtil.logger.debug("normal copy " + optIndex); + mapTempOptionsContent.put(new Long(mapCounter).toString(), pairs.getValue()); + } else if (pairs.getKey().equals(optIndex)) { + AuthoringUtil.logger.debug("move type 1 " + optIndex); + mapTempOptionsContent.put(new Long(mapCounter).toString(), shiftableEntry); + } else if (pairs.getKey().equals(new Integer(shiftableIndex).toString())) { + mapTempOptionsContent.put(new Long(mapCounter).toString(), movableOptionEntry); + } + } + } else { + mapTempOptionsContent = mapOptionsContent; + } + return mapTempOptionsContent; + } + /** * * Used in uploading offline and online files @@ -230,472 +209,429 @@ * @return VoteAttachmentDTO * @throws RepositoryCheckedException */ - public static VoteAttachmentDTO uploadFile(HttpServletRequest request, IVoteService voteService, VoteAuthoringForm voteAuthoringForm, - boolean isOfflineFile, SessionMap sessionMap) throws RepositoryCheckedException - { - logger.debug("doing uploadFile...: " + sessionMap); - logger.debug("isOfflineFile:" + isOfflineFile); - - InputStream stream=null; - String fileName=null; - String mimeType=null; - String fileProperty=null; - - if (isOfflineFile) - { - FormFile theOfflineFile = voteAuthoringForm.getTheOfflineFile(); - logger.debug("retrieved theOfflineFile: " + theOfflineFile); - - try - { - stream = theOfflineFile.getInputStream(); - fileName=theOfflineFile.getFileName(); - if (fileName.length() == 0) - { - return null; - } - logger.debug("retrieved fileName: " + fileName); - fileProperty="OFFLINE"; - - } - catch(FileNotFoundException e) - { - logger.debug("filenotfound exception occured in accessing the repository server for the offline file : " + e.getMessage()); - } - catch(IOException e) - { - logger.debug("io exception occured in accessing the repository server for the offline file : " + e.getMessage()); - } - - if (fileName.length() > 0) - { - List listUploadedOfflineFileNames=(List)sessionMap.get(LIST_UPLOADED_OFFLINE_FILENAMES_KEY); - logger.debug("listUploadedOfflineFileNames:" + listUploadedOfflineFileNames); - int index=findFileNameIndex(listUploadedOfflineFileNames, fileName); - logger.debug("index:" + index); - if (index == 0) - { - listUploadedOfflineFileNames.add(fileName); - logger.debug("listUploadedOfflineFileNames after add :" + listUploadedOfflineFileNames); - sessionMap.put(LIST_UPLOADED_OFFLINE_FILENAMES_KEY, listUploadedOfflineFileNames); - } - } - - } - else - { - FormFile theOnlineFile = voteAuthoringForm.getTheOnlineFile(); - logger.debug("retrieved theOnlineFile: " + theOnlineFile); - - try - { - stream = theOnlineFile.getInputStream(); - fileName=theOnlineFile.getFileName(); - - if (fileName.length() == 0) - { - return null; - } - - logger.debug("retrieved fileName: " + fileName); - fileProperty="ONLINE"; - - } - catch(FileNotFoundException e) - { - logger.debug("filenotfound exception occured in accessing the repository server for the online file : " + e.getMessage()); - } - catch(IOException e) - { - logger.debug("io exception occured in accessing the repository server for the online file : " + e.getMessage()); - } + public static VoteAttachmentDTO uploadFile(HttpServletRequest request, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm, boolean isOfflineFile, SessionMap sessionMap) + throws RepositoryCheckedException { + AuthoringUtil.logger.debug("doing uploadFile...: " + sessionMap); + AuthoringUtil.logger.debug("isOfflineFile:" + isOfflineFile); - if (fileName.length() > 0) - { - List listUploadedOnlineFileNames=(List)sessionMap.get(LIST_UPLOADED_ONLINE_FILENAMES_KEY); - logger.debug("listUploadedOnlineFileNames:" + listUploadedOnlineFileNames); - int index=findFileNameIndex(listUploadedOnlineFileNames, fileName); - logger.debug("index:" + index); - if (index == 0) - { - listUploadedOnlineFileNames.add(fileName); - logger.debug("listUploadedOnlineFileNames after add :" + listUploadedOnlineFileNames); - sessionMap.put(LIST_UPLOADED_ONLINE_FILENAMES_KEY, listUploadedOnlineFileNames); - } - } - } - - logger.debug("calling uploadFile with:"); - logger.debug("istream:" + stream); - logger.debug("filename:" + fileName); - logger.debug("mimeType:" + mimeType); - logger.debug("fileProperty:" + fileProperty); - - NodeKey nodeKey=null; - try{ - nodeKey=voteService.uploadFile(stream, fileName, mimeType, fileProperty); - logger.debug("nodeKey:" + nodeKey); - logger.debug("nodeKey uuid:" + nodeKey.getUuid()); + InputStream stream = null; + String fileName = null; + String mimeType = null; + String fileProperty = null; + + if (isOfflineFile) { + FormFile theOfflineFile = voteAuthoringForm.getTheOfflineFile(); + AuthoringUtil.logger.debug("retrieved theOfflineFile: " + theOfflineFile); + + try { + stream = theOfflineFile.getInputStream(); + fileName = theOfflineFile.getFileName(); + if (fileName.length() == 0) { + return null; } - catch(FileException e) - { - logger.debug("exception writing raw data:" + e); - /* return a null dto*/ - return null; + AuthoringUtil.logger.debug("retrieved fileName: " + fileName); + fileProperty = "OFFLINE"; + + } catch (FileNotFoundException e) { + AuthoringUtil.logger + .debug("filenotfound exception occured in accessing the repository server for the offline file : " + + e.getMessage()); + } catch (IOException e) { + AuthoringUtil.logger + .debug("io exception occured in accessing the repository server for the offline file : " + + e.getMessage()); + } + + if (fileName.length() > 0) { + List listUploadedOfflineFileNames = (List) sessionMap + .get(VoteAppConstants.LIST_UPLOADED_OFFLINE_FILENAMES_KEY); + AuthoringUtil.logger.debug("listUploadedOfflineFileNames:" + listUploadedOfflineFileNames); + int index = findFileNameIndex(listUploadedOfflineFileNames, fileName); + AuthoringUtil.logger.debug("index:" + index); + if (index == 0) { + listUploadedOfflineFileNames.add(fileName); + AuthoringUtil.logger.debug("listUploadedOfflineFileNames after add :" + + listUploadedOfflineFileNames); + sessionMap.put(VoteAppConstants.LIST_UPLOADED_OFFLINE_FILENAMES_KEY, listUploadedOfflineFileNames); } - - VoteAttachmentDTO voteAttachmentDTO= new VoteAttachmentDTO(); - voteAttachmentDTO.setUid(null); - voteAttachmentDTO.setUuid(nodeKey.getUuid().toString()); - voteAttachmentDTO.setFilename(fileName); - voteAttachmentDTO.setOfflineFile(isOfflineFile); - - logger.debug("uploadFile ends with sessionMap:" + sessionMap); - return voteAttachmentDTO; + } + + } else { + FormFile theOnlineFile = voteAuthoringForm.getTheOnlineFile(); + AuthoringUtil.logger.debug("retrieved theOnlineFile: " + theOnlineFile); + + try { + stream = theOnlineFile.getInputStream(); + fileName = theOnlineFile.getFileName(); + + if (fileName.length() == 0) { + return null; + } + + AuthoringUtil.logger.debug("retrieved fileName: " + fileName); + fileProperty = "ONLINE"; + + } catch (FileNotFoundException e) { + AuthoringUtil.logger + .debug("filenotfound exception occured in accessing the repository server for the online file : " + + e.getMessage()); + } catch (IOException e) { + AuthoringUtil.logger + .debug("io exception occured in accessing the repository server for the online file : " + + e.getMessage()); + } + + if (fileName.length() > 0) { + List listUploadedOnlineFileNames = (List) sessionMap + .get(VoteAppConstants.LIST_UPLOADED_ONLINE_FILENAMES_KEY); + AuthoringUtil.logger.debug("listUploadedOnlineFileNames:" + listUploadedOnlineFileNames); + int index = findFileNameIndex(listUploadedOnlineFileNames, fileName); + AuthoringUtil.logger.debug("index:" + index); + if (index == 0) { + listUploadedOnlineFileNames.add(fileName); + AuthoringUtil.logger.debug("listUploadedOnlineFileNames after add :" + listUploadedOnlineFileNames); + sessionMap.put(VoteAppConstants.LIST_UPLOADED_ONLINE_FILENAMES_KEY, listUploadedOnlineFileNames); + } + } } - - - /** - * returns a list of Vote attachements for listing of online and offline file information - * @param listOfflineFilesMetaData - * @return - */ - public static List populateMetaDataAsAttachments(List listOfflineFilesMetaData) - { - List listAttachments=new LinkedList(); - - Iterator itList = listOfflineFilesMetaData.iterator(); - while (itList.hasNext()) - { - VoteUploadedFile voteUploadedFile=(VoteUploadedFile)itList.next(); - logger.debug("voteUploadedFile:" + voteUploadedFile); - logger.debug("voteUploadedFile details, uid" + voteUploadedFile.getSubmissionId().toString()); - logger.debug("voteUploadedFile details, uuid" + voteUploadedFile.getUuid()); - logger.debug("voteUploadedFile details, filename" + voteUploadedFile.getFileName()); - logger.debug("voteUploadedFile details, isOfflineFile" + !voteUploadedFile.isFileOnline()); - - VoteAttachmentDTO voteAttachmentDTO= new VoteAttachmentDTO(); - voteAttachmentDTO.setUid(voteUploadedFile.getSubmissionId().toString()); - voteAttachmentDTO.setUuid(voteUploadedFile.getUuid()); - voteAttachmentDTO.setFilename(voteUploadedFile.getFileName()); - voteAttachmentDTO.setOfflineFile(!voteUploadedFile.isFileOnline()); - - listAttachments.add(voteAttachmentDTO); - logger.debug("listAttachments after add" + listAttachments); - } - logger.debug("final listAttachments after populating all: " + listAttachments); - return listAttachments; + + AuthoringUtil.logger.debug("calling uploadFile with:"); + AuthoringUtil.logger.debug("istream:" + stream); + AuthoringUtil.logger.debug("filename:" + fileName); + AuthoringUtil.logger.debug("mimeType:" + mimeType); + AuthoringUtil.logger.debug("fileProperty:" + fileProperty); + + NodeKey nodeKey = null; + try { + nodeKey = voteService.uploadFile(stream, fileName, mimeType, fileProperty); + AuthoringUtil.logger.debug("nodeKey:" + nodeKey); + AuthoringUtil.logger.debug("nodeKey uuid:" + nodeKey.getUuid()); + } catch (FileException e) { + AuthoringUtil.logger.debug("exception writing raw data:" + e); + /* return a null dto */ + return null; + } + + VoteAttachmentDTO voteAttachmentDTO = new VoteAttachmentDTO(); + voteAttachmentDTO.setUid(null); + voteAttachmentDTO.setUuid(nodeKey.getUuid().toString()); + voteAttachmentDTO.setFilename(fileName); + voteAttachmentDTO.setOfflineFile(isOfflineFile); + + AuthoringUtil.logger.debug("uploadFile ends with sessionMap:" + sessionMap); + return voteAttachmentDTO; } - + /** + * returns a list of Vote attachements for listing of online and offline file information + * + * @param listOfflineFilesMetaData + * @return + */ + public static List populateMetaDataAsAttachments(List listOfflineFilesMetaData) { + List listAttachments = new LinkedList(); + + Iterator itList = listOfflineFilesMetaData.iterator(); + while (itList.hasNext()) { + VoteUploadedFile voteUploadedFile = (VoteUploadedFile) itList.next(); + AuthoringUtil.logger.debug("voteUploadedFile:" + voteUploadedFile); + AuthoringUtil.logger.debug("voteUploadedFile details, uid" + voteUploadedFile.getSubmissionId().toString()); + AuthoringUtil.logger.debug("voteUploadedFile details, uuid" + voteUploadedFile.getUuid()); + AuthoringUtil.logger.debug("voteUploadedFile details, filename" + voteUploadedFile.getFileName()); + AuthoringUtil.logger.debug("voteUploadedFile details, isOfflineFile" + !voteUploadedFile.isFileOnline()); + + VoteAttachmentDTO voteAttachmentDTO = new VoteAttachmentDTO(); + voteAttachmentDTO.setUid(voteUploadedFile.getSubmissionId().toString()); + voteAttachmentDTO.setUuid(voteUploadedFile.getUuid()); + voteAttachmentDTO.setFilename(voteUploadedFile.getFileName()); + voteAttachmentDTO.setOfflineFile(!voteUploadedFile.isFileOnline()); + + listAttachments.add(voteAttachmentDTO); + AuthoringUtil.logger.debug("listAttachments after add" + listAttachments); + } + AuthoringUtil.logger.debug("final listAttachments after populating all: " + listAttachments); + return listAttachments; + } + + /** * @param listFilesMetaData * @return */ - public static List populateMetaDataAsFilenames(List listFilesMetaData) - { - List listFilenames=new LinkedList(); - - Iterator itList = listFilesMetaData.iterator(); - while (itList.hasNext()) - { - VoteAttachmentDTO voteAttachmentDTO=(VoteAttachmentDTO)itList.next(); - logger.debug("current filename" + voteAttachmentDTO.getFilename()); - listFilenames.add(voteAttachmentDTO.getFilename()); - logger.debug("listFilenames after add" + listFilenames); - } - logger.debug("final listFilenames after populating all: " + listFilenames); - return listFilenames; + public static List populateMetaDataAsFilenames(List listFilesMetaData) { + List listFilenames = new LinkedList(); + + Iterator itList = listFilesMetaData.iterator(); + while (itList.hasNext()) { + VoteAttachmentDTO voteAttachmentDTO = (VoteAttachmentDTO) itList.next(); + AuthoringUtil.logger.debug("current filename" + voteAttachmentDTO.getFilename()); + listFilenames.add(voteAttachmentDTO.getFilename()); + AuthoringUtil.logger.debug("listFilenames after add" + listFilenames); + } + AuthoringUtil.logger.debug("final listFilenames after populating all: " + listFilenames); + return listFilenames; } - /** * used in removing a file item listed in the jsp + * * @param request * @param filename * @param offlineFile */ - public static void removeFileItem(HttpServletRequest request, String filename, String offlineFile, SessionMap sessionMap) - { - logger.debug("starting removeFileItem, sessionMap:" + sessionMap); - logger.debug("offlineFile:" + offlineFile); - if (offlineFile.equals("1")) - { - logger.debug("will remove an offline file"); - List listUploadedOfflineFileNames=(List)sessionMap.get(LIST_UPLOADED_OFFLINE_FILENAMES_KEY); - logger.debug("listUploadedOfflineFileNames:" + listUploadedOfflineFileNames); - - listUploadedOfflineFileNames.remove(filename); - logger.debug("removed offline filename:" + filename); - - logger.debug("listUploadedOfflineFileNames after remove :" + listUploadedOfflineFileNames); - sessionMap.put(LIST_UPLOADED_OFFLINE_FILENAMES_KEY, listUploadedOfflineFileNames); - } - else - { - logger.debug("will remove an online file"); - List listUploadedOnlineFileNames=(List)sessionMap.get(LIST_UPLOADED_ONLINE_FILENAMES_KEY); - logger.debug("listUploadedOnlineFileNames:" + listUploadedOnlineFileNames); - - listUploadedOnlineFileNames.remove(filename); - logger.debug("removed online filename:" + filename); - - logger.debug("listUploadedOnlineFileNames after remove :" + listUploadedOnlineFileNames); - sessionMap.put(LIST_UPLOADED_ONLINE_FILENAMES_KEY, listUploadedOnlineFileNames); - } + public static void removeFileItem(HttpServletRequest request, String filename, String offlineFile, + SessionMap sessionMap) { + AuthoringUtil.logger.debug("starting removeFileItem, sessionMap:" + sessionMap); + AuthoringUtil.logger.debug("offlineFile:" + offlineFile); + if (offlineFile.equals("1")) { + AuthoringUtil.logger.debug("will remove an offline file"); + List listUploadedOfflineFileNames = (List) sessionMap + .get(VoteAppConstants.LIST_UPLOADED_OFFLINE_FILENAMES_KEY); + AuthoringUtil.logger.debug("listUploadedOfflineFileNames:" + listUploadedOfflineFileNames); + + listUploadedOfflineFileNames.remove(filename); + AuthoringUtil.logger.debug("removed offline filename:" + filename); + + AuthoringUtil.logger.debug("listUploadedOfflineFileNames after remove :" + listUploadedOfflineFileNames); + sessionMap.put(VoteAppConstants.LIST_UPLOADED_OFFLINE_FILENAMES_KEY, listUploadedOfflineFileNames); + } else { + AuthoringUtil.logger.debug("will remove an online file"); + List listUploadedOnlineFileNames = (List) sessionMap + .get(VoteAppConstants.LIST_UPLOADED_ONLINE_FILENAMES_KEY); + AuthoringUtil.logger.debug("listUploadedOnlineFileNames:" + listUploadedOnlineFileNames); + + listUploadedOnlineFileNames.remove(filename); + AuthoringUtil.logger.debug("removed online filename:" + filename); + + AuthoringUtil.logger.debug("listUploadedOnlineFileNames after remove :" + listUploadedOnlineFileNames); + sessionMap.put(VoteAppConstants.LIST_UPLOADED_ONLINE_FILENAMES_KEY, listUploadedOnlineFileNames); } - - + } + /** * @param listUploadedFileNames * @param filename * @return int */ - public static int findFileNameIndex(List listUploadedFileNames, String filename) - { - Iterator itListUploadedFileNames = listUploadedFileNames.iterator(); - int mainIndex=0; - while (itListUploadedFileNames.hasNext()) - { - mainIndex++; - String currentFilename=(String) itListUploadedFileNames.next(); - logger.debug("currentFilename :" + currentFilename); - if (currentFilename.equals(filename)) - { - logger.debug("currentFilename found in the list at mainIndex :" + mainIndex); - return mainIndex; - } - } - return 0; + public static int findFileNameIndex(List listUploadedFileNames, String filename) { + Iterator itListUploadedFileNames = listUploadedFileNames.iterator(); + int mainIndex = 0; + while (itListUploadedFileNames.hasNext()) { + mainIndex++; + String currentFilename = (String) itListUploadedFileNames.next(); + AuthoringUtil.logger.debug("currentFilename :" + currentFilename); + if (currentFilename.equals(filename)) { + AuthoringUtil.logger.debug("currentFilename found in the list at mainIndex :" + mainIndex); + return mainIndex; + } + } + return 0; } - - - public static List removeFileItem(List listFilesMetaData, String uuid) - { - VoteAttachmentDTO deletableAttachmentDTO=null; - - Iterator itList = listFilesMetaData.iterator(); - int mainIndex=0; - while (itList.hasNext()) - { - mainIndex++; - VoteAttachmentDTO currentAttachmentDTO=(VoteAttachmentDTO) itList.next(); - logger.debug("currentAttachmentDTO :" + currentAttachmentDTO); - logger.debug("currentAttachmentDTO uuid :" + currentAttachmentDTO.getUuid()); - - if (currentAttachmentDTO.getUuid().equals(uuid)) - { - logger.debug("equal uuid found uuid :" + uuid); - deletableAttachmentDTO=currentAttachmentDTO; - break; - } - } - - logger.debug("equal uuid found at index :" + mainIndex); - logger.debug("deletable attachment is:" + deletableAttachmentDTO); - - listFilesMetaData.remove(deletableAttachmentDTO); - logger.debug("listOfflineFilesMetaData after remove:" + listFilesMetaData); - - return listFilesMetaData; + + public static List removeFileItem(List listFilesMetaData, String uuid) { + VoteAttachmentDTO deletableAttachmentDTO = null; + + Iterator itList = listFilesMetaData.iterator(); + int mainIndex = 0; + while (itList.hasNext()) { + mainIndex++; + VoteAttachmentDTO currentAttachmentDTO = (VoteAttachmentDTO) itList.next(); + AuthoringUtil.logger.debug("currentAttachmentDTO :" + currentAttachmentDTO); + AuthoringUtil.logger.debug("currentAttachmentDTO uuid :" + currentAttachmentDTO.getUuid()); + + if (currentAttachmentDTO.getUuid().equals(uuid)) { + AuthoringUtil.logger.debug("equal uuid found uuid :" + uuid); + deletableAttachmentDTO = currentAttachmentDTO; + break; + } + } + + AuthoringUtil.logger.debug("equal uuid found at index :" + mainIndex); + AuthoringUtil.logger.debug("deletable attachment is:" + deletableAttachmentDTO); + + listFilesMetaData.remove(deletableAttachmentDTO); + AuthoringUtil.logger.debug("listOfflineFilesMetaData after remove:" + listFilesMetaData); + + return listFilesMetaData; } - - public static List extractFileNames(List listFilesMetaData) - { - Iterator itList = listFilesMetaData.iterator(); - LinkedList listFilenames= new LinkedList(); - - while (itList.hasNext()) - { - VoteAttachmentDTO voteAttachmentDTO=(VoteAttachmentDTO)itList.next(); - String filename=voteAttachmentDTO.getFilename(); - logger.debug("extracted filename: " + filename); - listFilenames.add(filename); - } - logger.debug("final extracted listFilenames: " + listFilenames); - return listFilenames; + public static List extractFileNames(List listFilesMetaData) { + Iterator itList = listFilesMetaData.iterator(); + LinkedList listFilenames = new LinkedList(); + + while (itList.hasNext()) { + VoteAttachmentDTO voteAttachmentDTO = (VoteAttachmentDTO) itList.next(); + String filename = voteAttachmentDTO.getFilename(); + AuthoringUtil.logger.debug("extracted filename: " + filename); + listFilenames.add(filename); + } + AuthoringUtil.logger.debug("final extracted listFilenames: " + listFilenames); + return listFilenames; } - - - protected Map reconstructOptionContentMapForAdd(Map mapOptionsContent, HttpServletRequest request) - { - logger.debug("doing reconstructOptionContentMapForAdd."); - logger.debug("pre-add Map content: " + mapOptionsContent); - logger.debug("pre-add Map size: " + mapOptionsContent.size()); - - mapOptionsContent=repopulateMap(mapOptionsContent, request); - logger.debug("mapOptionsContent: " + mapOptionsContent); - mapOptionsContent.put(new Long(mapOptionsContent.size()+1).toString(), ""); - - logger.debug("post-add Map is: " + mapOptionsContent); - logger.debug("post-add count " + mapOptionsContent.size()); - - return mapOptionsContent; + + protected Map reconstructOptionContentMapForAdd(Map mapOptionsContent, HttpServletRequest request) { + AuthoringUtil.logger.debug("doing reconstructOptionContentMapForAdd."); + AuthoringUtil.logger.debug("pre-add Map content: " + mapOptionsContent); + AuthoringUtil.logger.debug("pre-add Map size: " + mapOptionsContent.size()); + + mapOptionsContent = repopulateMap(mapOptionsContent, request); + AuthoringUtil.logger.debug("mapOptionsContent: " + mapOptionsContent); + mapOptionsContent.put(new Long(mapOptionsContent.size() + 1).toString(), ""); + + AuthoringUtil.logger.debug("post-add Map is: " + mapOptionsContent); + AuthoringUtil.logger.debug("post-add count " + mapOptionsContent.size()); + + return mapOptionsContent; } - - - - protected void reconstructOptionContentMapForRemove(Map mapOptionsContent, HttpServletRequest request, VoteAuthoringForm voteAuthoringForm) - { - logger.debug("doing reconstructOptionContentMapForRemove."); - String optIndex =voteAuthoringForm.getOptIndex(); - logger.debug("pre-delete map content: " + mapOptionsContent); - logger.debug("optIndex: " + optIndex); - - String defLater=voteAuthoringForm.getActiveModule(); - logger.debug("defLater: " + defLater); - - String removableOptIndex=null; - if ((defLater != null) && (defLater.equals(MONITORING))) - { - removableOptIndex=(String)request.getSession().getAttribute(REMOVABLE_QUESTION_INDEX); - logger.debug("removableOptIndex: " + removableOptIndex); - optIndex=removableOptIndex; - } - logger.debug("final removableOptIndex: " + optIndex); - - - long longOptIndex= new Long(optIndex).longValue(); - logger.debug("pre-delete count: " + mapOptionsContent.size()); - - repopulateMap(mapOptionsContent, request); - logger.debug("post-repopulateMap optIndex: " + optIndex); - - mapOptionsContent.remove(new Long(longOptIndex).toString()); - logger.debug("removed the question content with index: " + longOptIndex); - logger.debug("post-delete count " + mapOptionsContent.size()); - logger.debug("post-delete map content: " + mapOptionsContent); + + protected void reconstructOptionContentMapForRemove(Map mapOptionsContent, HttpServletRequest request, + VoteAuthoringForm voteAuthoringForm) { + AuthoringUtil.logger.debug("doing reconstructOptionContentMapForRemove."); + String optIndex = voteAuthoringForm.getOptIndex(); + AuthoringUtil.logger.debug("pre-delete map content: " + mapOptionsContent); + AuthoringUtil.logger.debug("optIndex: " + optIndex); + + String defLater = voteAuthoringForm.getActiveModule(); + AuthoringUtil.logger.debug("defLater: " + defLater); + + String removableOptIndex = null; + if (defLater != null && defLater.equals(VoteAppConstants.MONITORING)) { + removableOptIndex = (String) request.getSession().getAttribute(VoteAppConstants.REMOVABLE_QUESTION_INDEX); + AuthoringUtil.logger.debug("removableOptIndex: " + removableOptIndex); + optIndex = removableOptIndex; + } + AuthoringUtil.logger.debug("final removableOptIndex: " + optIndex); + + long longOptIndex = new Long(optIndex).longValue(); + AuthoringUtil.logger.debug("pre-delete count: " + mapOptionsContent.size()); + + repopulateMap(mapOptionsContent, request); + AuthoringUtil.logger.debug("post-repopulateMap optIndex: " + optIndex); + + mapOptionsContent.remove(new Long(longOptIndex).toString()); + AuthoringUtil.logger.debug("removed the question content with index: " + longOptIndex); + AuthoringUtil.logger.debug("post-delete count " + mapOptionsContent.size()); + AuthoringUtil.logger.debug("post-delete map content: " + mapOptionsContent); } + protected Map repopulateMap(Map mapOptionsContent, HttpServletRequest request) { + AuthoringUtil.logger.debug("starting repopulateMap"); + int intOptionIndex = mapOptionsContent.size(); + AuthoringUtil.logger.debug("intOptionIndex: " + intOptionIndex); - protected Map repopulateMap(Map mapOptionsContent, HttpServletRequest request) - { - logger.debug("starting repopulateMap"); - int intOptionIndex= mapOptionsContent.size(); - logger.debug("intOptionIndex: " + intOptionIndex); + /* if there is data in the Map remaining from previous session remove those */ + mapOptionsContent.clear(); + AuthoringUtil.logger.debug("Map got initialized: " + mapOptionsContent); - /* if there is data in the Map remaining from previous session remove those */ - mapOptionsContent.clear(); - logger.debug("Map got initialized: " + mapOptionsContent); - - for (long i=0; i < intOptionIndex ; i++) - { - String candidateOptionEntry =request.getParameter("optionContent" + i); - if (i==0) - { - request.getSession().setAttribute("defaultOptionContent", candidateOptionEntry); - logger.debug("defaultNominationContent set to: " + candidateOptionEntry); - } - if ((candidateOptionEntry != null) && (candidateOptionEntry.length() > 0)) - { - logger.debug("using key: " + i); - mapOptionsContent.put(new Long(i+1).toString(), candidateOptionEntry); - logger.debug("added new entry."); - } - } - return mapOptionsContent; + for (long i = 0; i < intOptionIndex; i++) { + String candidateOptionEntry = request.getParameter("optionContent" + i); + if (i == 0) { + request.getSession().setAttribute("defaultOptionContent", candidateOptionEntry); + AuthoringUtil.logger.debug("defaultNominationContent set to: " + candidateOptionEntry); + } + if (candidateOptionEntry != null && candidateOptionEntry.length() > 0) { + AuthoringUtil.logger.debug("using key: " + i); + mapOptionsContent.put(new Long(i + 1).toString(), candidateOptionEntry); + AuthoringUtil.logger.debug("added new entry."); + } + } + return mapOptionsContent; } /** * * @param mapOptionsContent * @param request */ - protected Map reconstructOptionsContentMapForSubmit(Map mapOptionsContent, HttpServletRequest request) - { - logger.debug("pre-submit Map:" + mapOptionsContent); - logger.debug("pre-submit Map size :" + mapOptionsContent.size()); - - repopulateMap(mapOptionsContent, request); - Map mapFinalOptionsContent = new TreeMap(new VoteComparator()); - - Iterator itMap = mapOptionsContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - if ((pairs.getValue() != null) && (!pairs.getValue().equals(""))) - { - mapFinalOptionsContent.put(pairs.getKey(), pairs.getValue()); - logger.debug("adding the pair: " + pairs.getKey() + " = " + pairs.getValue()); - } + protected Map reconstructOptionsContentMapForSubmit(Map mapOptionsContent, HttpServletRequest request) { + AuthoringUtil.logger.debug("pre-submit Map:" + mapOptionsContent); + AuthoringUtil.logger.debug("pre-submit Map size :" + mapOptionsContent.size()); + + repopulateMap(mapOptionsContent, request); + Map mapFinalOptionsContent = new TreeMap(new VoteComparator()); + + Iterator itMap = mapOptionsContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + if (pairs.getValue() != null && !pairs.getValue().equals("")) { + mapFinalOptionsContent.put(pairs.getKey(), pairs.getValue()); + AuthoringUtil.logger.debug("adding the pair: " + pairs.getKey() + " = " + pairs.getValue()); } - - mapOptionsContent=(TreeMap)mapFinalOptionsContent; - logger.debug("final mapOptionsContent:" + mapOptionsContent); - return mapOptionsContent; + } + + mapOptionsContent = mapFinalOptionsContent; + AuthoringUtil.logger.debug("final mapOptionsContent:" + mapOptionsContent); + return mapOptionsContent; } - - public void removeRedundantOptions (Map mapOptionsContent, IVoteService voteService, VoteAuthoringForm voteAuthoringForm, HttpServletRequest request) - { - logger.debug("removing unused entries... "); - logger.debug("mapOptionsContent: " + mapOptionsContent); - - String toolContentID=voteAuthoringForm.getToolContentID(); - logger.debug("toolContentID: " + toolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("voteContent: " + voteContent); - - if (voteContent != null) - { - logger.debug("voteContent uid: " + voteContent.getUid()); - List allNominations=voteService.getAllQuestionEntries(voteContent.getUid()); - logger.debug("allNominations: " + allNominations); - - Iterator listIterator=allNominations.iterator(); - Long mapIndex=new Long(1); - boolean entryUsed=false; - while (listIterator.hasNext()) - { - VoteQueContent queContent=(VoteQueContent)listIterator.next(); - logger.debug("queContent data: " + queContent); - - entryUsed=false; - Iterator itMap = mapOptionsContent.entrySet().iterator(); - while (itMap.hasNext()) - { - entryUsed=false; - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - if (pairs.getValue().toString().length() != 0) - { - logger.debug("text from map:" + pairs.getValue().toString()); - logger.debug("text from db:" + queContent.getQuestion()); - if (pairs.getValue().toString().equals(queContent.getQuestion())) - { - logger.debug("used entry in db:" + queContent.getQuestion()); - entryUsed=true; - break; - } - } - } - - if (entryUsed == false) - { - logger.debug("removing unused entry in db:" + queContent.getQuestion()); - - VoteQueContent removeableVoteQueContent=voteService.getQuestionContentByQuestionText(queContent.getQuestion(), voteContent.getUid()); - logger.debug("removeableVoteQueContent" + removeableVoteQueContent); - - - if (removeableVoteQueContent != null) - { - logger.debug("doing association removal for nomination: " + removeableVoteQueContent); - logger.debug("doing association removal, for question: " + removeableVoteQueContent.getQuestion()); - logger.debug("doing association removal for nomination list: " + voteContent.getVoteQueContents()); - voteContent.getVoteQueContents().remove(removeableVoteQueContent); - - voteService.removeVoteQueContent(removeableVoteQueContent); - - logger.debug("removed removeableVoteQueContent from the db: " + removeableVoteQueContent); - } - - } - } - } - + public void removeRedundantOptions(Map mapOptionsContent, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm, HttpServletRequest request) { + AuthoringUtil.logger.debug("removing unused entries... "); + AuthoringUtil.logger.debug("mapOptionsContent: " + mapOptionsContent); + + String toolContentID = voteAuthoringForm.getToolContentID(); + AuthoringUtil.logger.debug("toolContentID: " + toolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + AuthoringUtil.logger.debug("voteContent: " + voteContent); + + if (voteContent != null) { + AuthoringUtil.logger.debug("voteContent uid: " + voteContent.getUid()); + List allNominations = voteService.getAllQuestionEntries(voteContent.getUid()); + AuthoringUtil.logger.debug("allNominations: " + allNominations); + + Iterator listIterator = allNominations.iterator(); + Long mapIndex = new Long(1); + boolean entryUsed = false; + while (listIterator.hasNext()) { + VoteQueContent queContent = (VoteQueContent) listIterator.next(); + AuthoringUtil.logger.debug("queContent data: " + queContent); + + entryUsed = false; + Iterator itMap = mapOptionsContent.entrySet().iterator(); + while (itMap.hasNext()) { + entryUsed = false; + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + if (pairs.getValue().toString().length() != 0) { + AuthoringUtil.logger.debug("text from map:" + pairs.getValue().toString()); + AuthoringUtil.logger.debug("text from db:" + queContent.getQuestion()); + if (pairs.getValue().toString().equals(queContent.getQuestion())) { + AuthoringUtil.logger.debug("used entry in db:" + queContent.getQuestion()); + entryUsed = true; + break; + } + } + } + + if (entryUsed == false) { + AuthoringUtil.logger.debug("removing unused entry in db:" + queContent.getQuestion()); + + VoteQueContent removeableVoteQueContent = voteService.getQuestionContentByQuestionText(queContent + .getQuestion(), voteContent.getUid()); + AuthoringUtil.logger.debug("removeableVoteQueContent" + removeableVoteQueContent); + + if (removeableVoteQueContent != null) { + AuthoringUtil.logger.debug("doing association removal for nomination: " + + removeableVoteQueContent); + AuthoringUtil.logger.debug("doing association removal, for question: " + + removeableVoteQueContent.getQuestion()); + AuthoringUtil.logger.debug("doing association removal for nomination list: " + + voteContent.getVoteQueContents()); + voteContent.getVoteQueContents().remove(removeableVoteQueContent); + + voteService.removeVoteQueContent(removeableVoteQueContent); + + AuthoringUtil.logger.debug("removed removeableVoteQueContent from the db: " + + removeableVoteQueContent); + } + + } + } } + } + /** * persists the vote content * @@ -705,150 +641,145 @@ * @param request * @return */ - public VoteContent saveOrUpdateVoteContent(Map mapOptionsContent, IVoteService voteService, VoteAuthoringForm voteAuthoringForm, - HttpServletRequest request, SessionMap sessionMap) - { - UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - logger.debug("toolUser: " + toolUser); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - - String lockOnFinish = request.getParameter("lockOnFinish"); - logger.debug("lockOnFinish: " + lockOnFinish); + public VoteContent saveOrUpdateVoteContent(Map mapOptionsContent, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm, HttpServletRequest request, SessionMap sessionMap, + DataFlowObject assignedDataFlowObject) { + UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + AuthoringUtil.logger.debug("toolUser: " + toolUser); - String allowTextEntry = request.getParameter("allowText"); - logger.debug("allowTextEntry: " + allowTextEntry); + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); - String showResults = request.getParameter("showResults"); + AuthoringUtil.logger.debug("richTextTitle: " + richTextTitle); + AuthoringUtil.logger.debug("richTextInstructions: " + richTextInstructions); - String reflect=request.getParameter(REFLECT); - logger.debug("reflect: " + reflect); + String lockOnFinish = request.getParameter("lockOnFinish"); + AuthoringUtil.logger.debug("lockOnFinish: " + lockOnFinish); - String reflectionSubject=voteAuthoringForm.getReflectionSubject(); - logger.debug("reflectionSubject: " + reflectionSubject); - - String maxNomcount= voteAuthoringForm.getMaxNominationCount(); - logger.debug("maxNomcount: " + maxNomcount); + String allowTextEntry = request.getParameter("allowText"); + AuthoringUtil.logger.debug("allowTextEntry: " + allowTextEntry); - String richTextOfflineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("richTextOfflineInstructions: " + richTextOfflineInstructions); - - String richTextOnlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("richTextOnlineInstructions: " + richTextOnlineInstructions); + String showResults = request.getParameter("showResults"); - boolean setCommonContent=true; - if (lockOnFinish == null) - { - setCommonContent=false; - } - logger.debug("setCommonContent: " + setCommonContent); - - String activeModule=voteAuthoringForm.getActiveModule(); - logger.debug("activeModule: " + activeModule); + String reflect = request.getParameter(VoteAppConstants.REFLECT); + AuthoringUtil.logger.debug("reflect: " + reflect); - boolean lockedOnFinishBoolean=false; - boolean allowTextBoolean=false; - boolean reflectBoolean=false; - boolean showResultsBoolean=false; - - if ((lockOnFinish != null) && (lockOnFinish.equalsIgnoreCase("1"))) - lockedOnFinishBoolean=true; - - if ((allowTextEntry != null) && (allowTextEntry.equalsIgnoreCase("1"))) - allowTextBoolean=true; - - if ((reflect != null) && (reflect.equalsIgnoreCase("1"))) - reflectBoolean=true; + String reflectionSubject = voteAuthoringForm.getReflectionSubject(); + AuthoringUtil.logger.debug("reflectionSubject: " + reflectionSubject); - if ( showResults != null && showResults.equalsIgnoreCase("1")) - showResultsBoolean=true; - - long userId=0; - if (toolUser != null) - { - userId = toolUser.getUserID().longValue(); - } - else - { - HttpSession ss = SessionManager.getSession(); - logger.debug("ss: " + ss); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - logger.debug("user" + user); - if (user != null) - { - userId = user.getUserID().longValue(); - } - else - { - logger.debug("should not reach here"); - userId=0; - } - } - logger.debug("userId: " + userId); - - - String toolContentID =voteAuthoringForm.getToolContentID(); - logger.debug("toolContentID: " + toolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("voteContent: " + voteContent); - - boolean newContent=false; - if(voteContent == null) - { - voteContent = new VoteContent(); - newContent=true; - } + String maxNomcount = voteAuthoringForm.getMaxNominationCount(); + AuthoringUtil.logger.debug("maxNomcount: " + maxNomcount); + String richTextOfflineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + AuthoringUtil.logger.debug("richTextOfflineInstructions: " + richTextOfflineInstructions); - logger.debug("setting common content values..." + richTextTitle + " " + richTextInstructions); - voteContent.setVoteContentId(new Long(toolContentID)); - voteContent.setTitle(richTextTitle); - voteContent.setInstructions(richTextInstructions); - voteContent.setUpdateDate(new Date(System.currentTimeMillis())); /**keep updating this one*/ - logger.debug("userId: " + userId); - voteContent.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/ - logger.debug("end of setting common content values..."); + String richTextOnlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + AuthoringUtil.logger.debug("richTextOnlineInstructions: " + richTextOnlineInstructions); - logger.debug("activeModule: " + activeModule); - - if (activeModule.equals(AUTHORING)) - { - logger.debug("setting other content values..."); - voteContent.setLockOnFinish(lockedOnFinishBoolean); - voteContent.setAllowText(allowTextBoolean); - voteContent.setShowResults(showResultsBoolean); - voteContent.setReflect(reflectBoolean); - voteContent.setReflectionSubject(reflectionSubject); - voteContent.setMaxNominationCount(maxNomcount); - voteContent.setOnlineInstructions(richTextOnlineInstructions); - voteContent.setOfflineInstructions(richTextOfflineInstructions); - } - - - if (newContent) - { - logger.debug("will create: " + voteContent); - voteService.createVote(voteContent); - } - else - { - logger.debug("will update: " + voteContent); - voteService.updateVote(voteContent); - } - - voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("voteContent: " + voteContent); - - voteContent=createOptionsContent(mapOptionsContent, voteService, voteContent); - - return voteContent; + boolean setCommonContent = true; + if (lockOnFinish == null) { + setCommonContent = false; + } + AuthoringUtil.logger.debug("setCommonContent: " + setCommonContent); + + String activeModule = voteAuthoringForm.getActiveModule(); + AuthoringUtil.logger.debug("activeModule: " + activeModule); + + boolean lockedOnFinishBoolean = false; + boolean allowTextBoolean = false; + boolean reflectBoolean = false; + boolean showResultsBoolean = false; + + if (lockOnFinish != null && lockOnFinish.equalsIgnoreCase("1")) { + lockedOnFinishBoolean = true; + } + + if (allowTextEntry != null && allowTextEntry.equalsIgnoreCase("1")) { + allowTextBoolean = true; + } + + if (reflect != null && reflect.equalsIgnoreCase("1")) { + reflectBoolean = true; + } + + if (showResults != null && showResults.equalsIgnoreCase("1")) { + showResultsBoolean = true; + } + + long userId = 0; + if (toolUser != null) { + userId = toolUser.getUserID().longValue(); + } else { + HttpSession ss = SessionManager.getSession(); + AuthoringUtil.logger.debug("ss: " + ss); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + AuthoringUtil.logger.debug("user" + user); + if (user != null) { + userId = user.getUserID().longValue(); + } else { + AuthoringUtil.logger.debug("should not reach here"); + userId = 0; + } + } + AuthoringUtil.logger.debug("userId: " + userId); + + String toolContentID = voteAuthoringForm.getToolContentID(); + AuthoringUtil.logger.debug("toolContentID: " + toolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + AuthoringUtil.logger.debug("voteContent: " + voteContent); + + boolean newContent = false; + if (voteContent == null) { + voteContent = new VoteContent(); + newContent = true; + } + + AuthoringUtil.logger.debug("setting common content values..." + richTextTitle + " " + richTextInstructions); + voteContent.setVoteContentId(new Long(toolContentID)); + voteContent.setTitle(richTextTitle); + voteContent.setInstructions(richTextInstructions); + voteContent.setUpdateDate(new Date(System.currentTimeMillis())); + /** keep updating this one */ + AuthoringUtil.logger.debug("userId: " + userId); + voteContent.setCreatedBy(userId); + /** make sure we are setting the userId from the User object above */ + AuthoringUtil.logger.debug("end of setting common content values..."); + + AuthoringUtil.logger.debug("activeModule: " + activeModule); + + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + AuthoringUtil.logger.debug("setting other content values..."); + voteContent.setLockOnFinish(lockedOnFinishBoolean); + voteContent.setAllowText(allowTextBoolean); + voteContent.setShowResults(showResultsBoolean); + voteContent.setReflect(reflectBoolean); + voteContent.setReflectionSubject(reflectionSubject); + voteContent.setMaxNominationCount(maxNomcount); + voteContent.setOnlineInstructions(richTextOnlineInstructions); + voteContent.setOfflineInstructions(richTextOfflineInstructions); + } + + voteContent.setAssignedDataFlowObject(assignedDataFlowObject != null); + + if (newContent) { + AuthoringUtil.logger.debug("will create: " + voteContent); + voteService.createVote(voteContent); + } else { + AuthoringUtil.logger.debug("will update: " + voteContent); + voteService.updateVote(voteContent); + } + + voteContent = voteService.retrieveVote(new Long(toolContentID)); + AuthoringUtil.logger.debug("voteContent: " + voteContent); + + voteContent = createOptionsContent(mapOptionsContent, voteService, voteContent); + + voteService.saveDataFlowObjectAssigment(assignedDataFlowObject); + + return voteContent; } - + /** * creates a new vote content * @@ -857,742 +788,672 @@ * @param voteContent * @return */ - protected VoteContent createOptionsContent(Map mapOptionsContent, IVoteService voteService, VoteContent voteContent) - { - logger.debug("starting createOptiosContent: " + voteContent); - logger.debug("content uid is: " + voteContent.getUid()); - List questions=voteService.retrieveVoteQueContentsByToolContentId(voteContent.getUid().longValue()); - logger.debug("questions: " + questions); + protected VoteContent createOptionsContent(Map mapOptionsContent, IVoteService voteService, VoteContent voteContent) { + AuthoringUtil.logger.debug("starting createOptiosContent: " + voteContent); + AuthoringUtil.logger.debug("content uid is: " + voteContent.getUid()); + List questions = voteService.retrieveVoteQueContentsByToolContentId(voteContent.getUid().longValue()); + AuthoringUtil.logger.debug("questions: " + questions); - - Iterator itMap = mapOptionsContent.entrySet().iterator(); - int diplayOrder=0; - while (itMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().toString().length() != 0) - { - logger.debug("starting createNominationContent: pairs.getValue().toString():" + pairs.getValue().toString()); - logger.debug("starting createNominationContent: voteContent: " + voteContent); - logger.debug("starting createNominationContent: diplayOrder: " + diplayOrder); - diplayOrder=new Integer(pairs.getKey().toString()).intValue(); - logger.debug("int diplayOrder: " + diplayOrder); - - - VoteQueContent queContent= new VoteQueContent(pairs.getValue().toString(), - diplayOrder, - voteContent, - null); - - - /* checks if the question is already recorded*/ - logger.debug("question text is: " + pairs.getValue().toString()); - logger.debug("content uid is: " + voteContent.getUid()); - logger.debug("question display order is: " + diplayOrder); - - VoteQueContent existingVoteQueContent=voteService.getQuestionContentByQuestionText(pairs.getValue().toString(), voteContent.getUid()); - logger.debug("existingVoteQueContent: " + existingVoteQueContent); - if (existingVoteQueContent == null) - { - /*make sure a question with the same question text is not already saved*/ - VoteQueContent duplicateVoteQueContent=voteService.getQuestionContentByQuestionText(pairs.getValue().toString(), voteContent.getUid()); - logger.debug("duplicateVoteQueContent: " + duplicateVoteQueContent); - if (duplicateVoteQueContent == null) - { - logger.debug("adding a new question to content: " + queContent); - voteContent.getVoteQueContents().add(queContent); - queContent.setVoteContent(voteContent); - - voteService.createVoteQue(queContent); - } - } - else - { - existingVoteQueContent.setQuestion(pairs.getValue().toString()); - existingVoteQueContent.setDisplayOrder(diplayOrder); - logger.debug("updating the existing question content: " + existingVoteQueContent); - voteService.updateVoteQueContent(existingVoteQueContent); - } - } + Iterator itMap = mapOptionsContent.entrySet().iterator(); + int diplayOrder = 0; + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue().toString().length() != 0) { + AuthoringUtil.logger.debug("starting createNominationContent: pairs.getValue().toString():" + + pairs.getValue().toString()); + AuthoringUtil.logger.debug("starting createNominationContent: voteContent: " + voteContent); + AuthoringUtil.logger.debug("starting createNominationContent: diplayOrder: " + diplayOrder); + diplayOrder = new Integer(pairs.getKey().toString()).intValue(); + AuthoringUtil.logger.debug("int diplayOrder: " + diplayOrder); + + VoteQueContent queContent = new VoteQueContent(pairs.getValue().toString(), diplayOrder, voteContent, + null); + + /* checks if the question is already recorded */ + AuthoringUtil.logger.debug("question text is: " + pairs.getValue().toString()); + AuthoringUtil.logger.debug("content uid is: " + voteContent.getUid()); + AuthoringUtil.logger.debug("question display order is: " + diplayOrder); + + VoteQueContent existingVoteQueContent = voteService.getQuestionContentByQuestionText(pairs.getValue() + .toString(), voteContent.getUid()); + AuthoringUtil.logger.debug("existingVoteQueContent: " + existingVoteQueContent); + if (existingVoteQueContent == null) { + /* make sure a question with the same question text is not already saved */ + VoteQueContent duplicateVoteQueContent = voteService.getQuestionContentByQuestionText(pairs + .getValue().toString(), voteContent.getUid()); + AuthoringUtil.logger.debug("duplicateVoteQueContent: " + duplicateVoteQueContent); + if (duplicateVoteQueContent == null) { + AuthoringUtil.logger.debug("adding a new question to content: " + queContent); + voteContent.getVoteQueContents().add(queContent); + queContent.setVoteContent(voteContent); + + voteService.createVoteQue(queContent); + } + } else { + existingVoteQueContent.setQuestion(pairs.getValue().toString()); + existingVoteQueContent.setDisplayOrder(diplayOrder); + AuthoringUtil.logger.debug("updating the existing question content: " + existingVoteQueContent); + voteService.updateVoteQueContent(existingVoteQueContent); + } } - return voteContent; + } + return voteContent; } - - - protected static List swapNodes(List listNominationContentDTO, String questionIndex, String direction) - { - logger.debug("swapNodes:"); - logger.debug("listNominationContentDTO:" + listNominationContentDTO); - logger.debug("questionIndex:" + questionIndex); - logger.debug("direction:" + direction); - int intNominationIndex=new Integer(questionIndex).intValue(); - int intOriginalNominationIndex=intNominationIndex; - logger.debug("intNominationIndex:" + intNominationIndex); - - int replacedNodeIndex=0; - if (direction.equals("down")) - { - logger.debug("direction down:"); - replacedNodeIndex=++intNominationIndex; - } - else - { - logger.debug("direction up:"); - replacedNodeIndex=--intNominationIndex; - - } - logger.debug("replacedNodeIndex:" + replacedNodeIndex); - logger.debug("replacing nodes:" + intOriginalNominationIndex + " and " + replacedNodeIndex); - - VoteNominationContentDTO mainNode=extractNodeAtDisplayOrder(listNominationContentDTO, intOriginalNominationIndex); - logger.debug("mainNode:" + mainNode); - + protected static List swapNodes(List listNominationContentDTO, String questionIndex, String direction) { + AuthoringUtil.logger.debug("swapNodes:"); + AuthoringUtil.logger.debug("listNominationContentDTO:" + listNominationContentDTO); + AuthoringUtil.logger.debug("questionIndex:" + questionIndex); + AuthoringUtil.logger.debug("direction:" + direction); - VoteNominationContentDTO replacedNode=extractNodeAtDisplayOrder(listNominationContentDTO, replacedNodeIndex); - logger.debug("replacedNode:" + replacedNode); + int intNominationIndex = new Integer(questionIndex).intValue(); + int intOriginalNominationIndex = intNominationIndex; + AuthoringUtil.logger.debug("intNominationIndex:" + intNominationIndex); - List listFinalNominationContentDTO=new LinkedList(); - - listFinalNominationContentDTO=reorderSwappedListNominationContentDTO(listNominationContentDTO, intOriginalNominationIndex, - replacedNodeIndex, mainNode, replacedNode); - - - logger.debug("listFinalNominationContentDTO:" + listFinalNominationContentDTO); - return listFinalNominationContentDTO; + int replacedNodeIndex = 0; + if (direction.equals("down")) { + AuthoringUtil.logger.debug("direction down:"); + replacedNodeIndex = ++intNominationIndex; + } else { + AuthoringUtil.logger.debug("direction up:"); + replacedNodeIndex = --intNominationIndex; + + } + AuthoringUtil.logger.debug("replacedNodeIndex:" + replacedNodeIndex); + AuthoringUtil.logger.debug("replacing nodes:" + intOriginalNominationIndex + " and " + replacedNodeIndex); + + VoteNominationContentDTO mainNode = extractNodeAtDisplayOrder(listNominationContentDTO, + intOriginalNominationIndex); + AuthoringUtil.logger.debug("mainNode:" + mainNode); + + VoteNominationContentDTO replacedNode = extractNodeAtDisplayOrder(listNominationContentDTO, replacedNodeIndex); + AuthoringUtil.logger.debug("replacedNode:" + replacedNode); + + List listFinalNominationContentDTO = new LinkedList(); + + listFinalNominationContentDTO = reorderSwappedListNominationContentDTO(listNominationContentDTO, + intOriginalNominationIndex, replacedNodeIndex, mainNode, replacedNode); + + AuthoringUtil.logger.debug("listFinalNominationContentDTO:" + listFinalNominationContentDTO); + return listFinalNominationContentDTO; } - - protected static VoteNominationContentDTO extractNodeAtDisplayOrder(List listNominationContentDTO, int intOriginalNominationIndex) - { - logger.debug("listNominationContentDTO:" + listNominationContentDTO); - logger.debug("intOriginalNominationIndex:" + intOriginalNominationIndex); - - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO=(VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - logger.debug("intOriginalNominationIndex versus displayOrder:" + new Integer(intOriginalNominationIndex).toString() + " versus " + - voteNominationContentDTO.getDisplayOrder()); - if (new Integer(intOriginalNominationIndex).toString().equals(voteNominationContentDTO.getDisplayOrder())) - { - logger.debug("node found:" + voteNominationContentDTO); - return voteNominationContentDTO; - } - } - return null; + + protected static VoteNominationContentDTO extractNodeAtDisplayOrder(List listNominationContentDTO, + int intOriginalNominationIndex) { + AuthoringUtil.logger.debug("listNominationContentDTO:" + listNominationContentDTO); + AuthoringUtil.logger.debug("intOriginalNominationIndex:" + intOriginalNominationIndex); + + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + + AuthoringUtil.logger.debug("intOriginalNominationIndex versus displayOrder:" + + new Integer(intOriginalNominationIndex).toString() + " versus " + + voteNominationContentDTO.getDisplayOrder()); + if (new Integer(intOriginalNominationIndex).toString().equals(voteNominationContentDTO.getDisplayOrder())) { + AuthoringUtil.logger.debug("node found:" + voteNominationContentDTO); + return voteNominationContentDTO; + } + } + return null; } - - protected static List reorderSwappedListNominationContentDTO(List listNominationContentDTO, int intOriginalNominationIndex, - int replacedNodeIndex, VoteNominationContentDTO mainNode, VoteNominationContentDTO replacedNode) - { - logger.debug("reorderSwappedListNominationContentDTO: intOriginalNominationIndex:" + intOriginalNominationIndex); - logger.debug("reorderSwappedListNominationContentDTO: replacedNodeIndex:" + replacedNodeIndex); - logger.debug("mainNode: " + mainNode); - logger.debug("replacedNode: " + replacedNode); - - - List listFinalNominationContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - queIndex++; - VoteNominationContentDTO tempNode=new VoteNominationContentDTO(); - - if ((!voteNominationContentDTO.getDisplayOrder().equals(new Integer(intOriginalNominationIndex).toString())) && - !voteNominationContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) - { - logger.debug("normal copy "); - tempNode.setNomination(voteNominationContentDTO.getNomination()); - tempNode.setDisplayOrder(voteNominationContentDTO.getDisplayOrder()); - tempNode.setFeedback(voteNominationContentDTO.getFeedback()); - } - else if (voteNominationContentDTO.getDisplayOrder().equals(new Integer(intOriginalNominationIndex).toString())) - { - logger.debug("move type 1 "); - tempNode.setNomination(replacedNode.getNomination()); - tempNode.setDisplayOrder(replacedNode.getDisplayOrder()); - tempNode.setFeedback(replacedNode.getFeedback()); - } - else if (voteNominationContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) - { - logger.debug("move type 1 "); - tempNode.setNomination(mainNode.getNomination()); - tempNode.setDisplayOrder(mainNode.getDisplayOrder()); - tempNode.setFeedback(mainNode.getFeedback()); - } - - - listFinalNominationContentDTO.add(tempNode); + protected static List reorderSwappedListNominationContentDTO(List listNominationContentDTO, + int intOriginalNominationIndex, int replacedNodeIndex, VoteNominationContentDTO mainNode, + VoteNominationContentDTO replacedNode) { + AuthoringUtil.logger.debug("reorderSwappedListNominationContentDTO: intOriginalNominationIndex:" + + intOriginalNominationIndex); + AuthoringUtil.logger.debug("reorderSwappedListNominationContentDTO: replacedNodeIndex:" + replacedNodeIndex); + AuthoringUtil.logger.debug("mainNode: " + mainNode); + AuthoringUtil.logger.debug("replacedNode: " + replacedNode); + + List listFinalNominationContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + queIndex++; + VoteNominationContentDTO tempNode = new VoteNominationContentDTO(); + + if (!voteNominationContentDTO.getDisplayOrder().equals(new Integer(intOriginalNominationIndex).toString()) + && !voteNominationContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) { + AuthoringUtil.logger.debug("normal copy "); + tempNode.setNomination(voteNominationContentDTO.getNomination()); + tempNode.setDisplayOrder(voteNominationContentDTO.getDisplayOrder()); + tempNode.setFeedback(voteNominationContentDTO.getFeedback()); + } else if (voteNominationContentDTO.getDisplayOrder().equals( + new Integer(intOriginalNominationIndex).toString())) { + AuthoringUtil.logger.debug("move type 1 "); + tempNode.setNomination(replacedNode.getNomination()); + tempNode.setDisplayOrder(replacedNode.getDisplayOrder()); + tempNode.setFeedback(replacedNode.getFeedback()); + } else if (voteNominationContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) { + AuthoringUtil.logger.debug("move type 1 "); + tempNode.setNomination(mainNode.getNomination()); + tempNode.setDisplayOrder(mainNode.getDisplayOrder()); + tempNode.setFeedback(mainNode.getFeedback()); } - logger.debug("final listFinalNominationContentDTO:" + listFinalNominationContentDTO); - return listFinalNominationContentDTO; + listFinalNominationContentDTO.add(tempNode); + } + + AuthoringUtil.logger.debug("final listFinalNominationContentDTO:" + listFinalNominationContentDTO); + return listFinalNominationContentDTO; } - - protected static List reorderSimpleListNominationContentDTO(List listNominationContentDTO) - { - logger.debug("reorderListNominationContentDTO"); - logger.debug("listNominationContentDTO:" + listNominationContentDTO); - List listFinalNominationContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - String question=voteNominationContentDTO.getNomination(); - logger.debug("question:" + question); - - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - String feedback=voteNominationContentDTO.getFeedback(); - logger.debug("feedback:" + feedback); - - if ((question != null) && (!question.equals(""))) - { - ++queIndex; - logger.debug("using queIndex:" + queIndex); - - voteNominationContentDTO.setNomination(question); - voteNominationContentDTO.setDisplayOrder(new Integer(queIndex).toString()); - voteNominationContentDTO.setFeedback(feedback); - - listFinalNominationContentDTO.add(voteNominationContentDTO); - } + protected static List reorderSimpleListNominationContentDTO(List listNominationContentDTO) { + AuthoringUtil.logger.debug("reorderListNominationContentDTO"); + AuthoringUtil.logger.debug("listNominationContentDTO:" + listNominationContentDTO); + List listFinalNominationContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + + String question = voteNominationContentDTO.getNomination(); + AuthoringUtil.logger.debug("question:" + question); + + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + AuthoringUtil.logger.debug("displayOrder:" + displayOrder); + + String feedback = voteNominationContentDTO.getFeedback(); + AuthoringUtil.logger.debug("feedback:" + feedback); + + if (question != null && !question.equals("")) { + ++queIndex; + AuthoringUtil.logger.debug("using queIndex:" + queIndex); + + voteNominationContentDTO.setNomination(question); + voteNominationContentDTO.setDisplayOrder(new Integer(queIndex).toString()); + voteNominationContentDTO.setFeedback(feedback); + + listFinalNominationContentDTO.add(voteNominationContentDTO); } - - - logger.debug("final listFinalNominationContentDTO:" + listFinalNominationContentDTO); - return listFinalNominationContentDTO; + } + + AuthoringUtil.logger.debug("final listFinalNominationContentDTO:" + listFinalNominationContentDTO); + return listFinalNominationContentDTO; } - - protected static List reorderListNominationContentDTO(List listNominationContentDTO, String excludeNominationIndex) - { - logger.debug("reorderListNominationContentDTO"); - logger.debug("listNominationContentDTO:" + listNominationContentDTO); - logger.debug("excludeNominationIndex:" + excludeNominationIndex); - - List listFinalNominationContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - String question=voteNominationContentDTO.getNomination(); - logger.debug("question:" + question); - - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - String feedback=voteNominationContentDTO.getFeedback(); - logger.debug("feedback:" + feedback); - - logger.debug("displayOrder versus excludeNominationIndex :" + displayOrder + " versus " + excludeNominationIndex); - - if ((question != null) && (!question.equals(""))) - { - if (!displayOrder.equals(excludeNominationIndex)) - { - ++queIndex; - logger.debug("using queIndex:" + queIndex); - - voteNominationContentDTO.setNomination(question); - voteNominationContentDTO.setDisplayOrder(new Integer(queIndex).toString()); - voteNominationContentDTO.setFeedback(feedback); - - listFinalNominationContentDTO.add(voteNominationContentDTO); - } - } + protected static List reorderListNominationContentDTO(List listNominationContentDTO, String excludeNominationIndex) { + AuthoringUtil.logger.debug("reorderListNominationContentDTO"); + AuthoringUtil.logger.debug("listNominationContentDTO:" + listNominationContentDTO); + AuthoringUtil.logger.debug("excludeNominationIndex:" + excludeNominationIndex); + + List listFinalNominationContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + + String question = voteNominationContentDTO.getNomination(); + AuthoringUtil.logger.debug("question:" + question); + + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + AuthoringUtil.logger.debug("displayOrder:" + displayOrder); + + String feedback = voteNominationContentDTO.getFeedback(); + AuthoringUtil.logger.debug("feedback:" + feedback); + + AuthoringUtil.logger.debug("displayOrder versus excludeNominationIndex :" + displayOrder + " versus " + + excludeNominationIndex); + + if (question != null && !question.equals("")) { + if (!displayOrder.equals(excludeNominationIndex)) { + ++queIndex; + AuthoringUtil.logger.debug("using queIndex:" + queIndex); + + voteNominationContentDTO.setNomination(question); + voteNominationContentDTO.setDisplayOrder(new Integer(queIndex).toString()); + voteNominationContentDTO.setFeedback(feedback); + + listFinalNominationContentDTO.add(voteNominationContentDTO); + } } - - - logger.debug("final listFinalNominationContentDTO:" + listFinalNominationContentDTO); - return listFinalNominationContentDTO; + } + + AuthoringUtil.logger.debug("final listFinalNominationContentDTO:" + listFinalNominationContentDTO); + return listFinalNominationContentDTO; } - - - public static boolean checkDuplicateNominations(List listNominationContentDTO, String newNomination) - { - logger.debug("checkDuplicateNominations: " + listNominationContentDTO); - logger.debug("newNomination: " + newNomination); - - Map mapNominationContent=extractMapNominationContent(listNominationContentDTO); - logger.debug("mapNominationContent: " + mapNominationContent); - - Iterator itMap = mapNominationContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - if ((pairs.getValue() != null) && (!pairs.getValue().equals(""))) - { - logger.debug("checking the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().equals(newNomination)) - { - logger.debug("entry found: " + newNomination); - return true; - } - } + public static boolean checkDuplicateNominations(List listNominationContentDTO, String newNomination) { + AuthoringUtil.logger.debug("checkDuplicateNominations: " + listNominationContentDTO); + AuthoringUtil.logger.debug("newNomination: " + newNomination); + + Map mapNominationContent = extractMapNominationContent(listNominationContentDTO); + AuthoringUtil.logger.debug("mapNominationContent: " + mapNominationContent); + + Iterator itMap = mapNominationContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + if (pairs.getValue() != null && !pairs.getValue().equals("")) { + AuthoringUtil.logger.debug("checking the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue().equals(newNomination)) { + AuthoringUtil.logger.debug("entry found: " + newNomination); + return true; + } } - return false; + } + return false; } - - - protected static Map extractMapNominationContent(List listNominationContentDTO) - { - logger.debug("listNominationContentDTO:" + listNominationContentDTO); - Map mapNominationContent= new TreeMap(new VoteComparator()); - - Iterator listIterator=listNominationContentDTO.iterator(); - int queIndex=0; - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO=(VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - queIndex++; - logger.debug("queIndex:" + queIndex); - mapNominationContent.put(new Integer(queIndex).toString(), voteNominationContentDTO.getNomination()); - } - logger.debug("mapNominationContent:" + mapNominationContent); - return mapNominationContent; + + protected static Map extractMapNominationContent(List listNominationContentDTO) { + AuthoringUtil.logger.debug("listNominationContentDTO:" + listNominationContentDTO); + Map mapNominationContent = new TreeMap(new VoteComparator()); + + Iterator listIterator = listNominationContentDTO.iterator(); + int queIndex = 0; + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + + queIndex++; + AuthoringUtil.logger.debug("queIndex:" + queIndex); + mapNominationContent.put(new Integer(queIndex).toString(), voteNominationContentDTO.getNomination()); + } + AuthoringUtil.logger.debug("mapNominationContent:" + mapNominationContent); + return mapNominationContent; } - - protected static List reorderUpdateListNominationContentDTO(List listNominationContentDTO, - VoteNominationContentDTO voteNominationContentDTONew, - String editableNominationIndex) - { - logger.debug("reorderUpdateListNominationContentDTO"); - logger.debug("listNominationContentDTO:" + listNominationContentDTO); - logger.debug("voteNominationContentDTONew:" + voteNominationContentDTONew); - logger.debug("editableNominationIndex:" + editableNominationIndex); - - - List listFinalNominationContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - ++queIndex; - logger.debug("using queIndex:" + queIndex); - String question=voteNominationContentDTO.getNomination(); - logger.debug("question:" + question); - - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - String feedback=voteNominationContentDTO.getFeedback(); - logger.debug("feedback:" + feedback); - - if (displayOrder.equals(editableNominationIndex)) - { - logger.debug("displayOrder equals editableNominationIndex:" + editableNominationIndex); - voteNominationContentDTO.setNomination(voteNominationContentDTONew.getNomination()); - voteNominationContentDTO.setDisplayOrder(voteNominationContentDTONew.getDisplayOrder()); - voteNominationContentDTO.setFeedback(voteNominationContentDTONew.getFeedback()); - - listFinalNominationContentDTO.add(voteNominationContentDTO); - } - else - { - logger.debug("displayOrder does not equal editableNominationIndex:" + editableNominationIndex); - voteNominationContentDTO.setNomination(question); - voteNominationContentDTO.setDisplayOrder(displayOrder); - voteNominationContentDTO.setFeedback(feedback); - - listFinalNominationContentDTO.add(voteNominationContentDTO); - } + protected static List reorderUpdateListNominationContentDTO(List listNominationContentDTO, + VoteNominationContentDTO voteNominationContentDTONew, String editableNominationIndex) { + AuthoringUtil.logger.debug("reorderUpdateListNominationContentDTO"); + AuthoringUtil.logger.debug("listNominationContentDTO:" + listNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTONew:" + voteNominationContentDTONew); + AuthoringUtil.logger.debug("editableNominationIndex:" + editableNominationIndex); + + List listFinalNominationContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + + ++queIndex; + AuthoringUtil.logger.debug("using queIndex:" + queIndex); + String question = voteNominationContentDTO.getNomination(); + AuthoringUtil.logger.debug("question:" + question); + + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + AuthoringUtil.logger.debug("displayOrder:" + displayOrder); + + String feedback = voteNominationContentDTO.getFeedback(); + AuthoringUtil.logger.debug("feedback:" + feedback); + + if (displayOrder.equals(editableNominationIndex)) { + AuthoringUtil.logger.debug("displayOrder equals editableNominationIndex:" + editableNominationIndex); + voteNominationContentDTO.setNomination(voteNominationContentDTONew.getNomination()); + voteNominationContentDTO.setDisplayOrder(voteNominationContentDTONew.getDisplayOrder()); + voteNominationContentDTO.setFeedback(voteNominationContentDTONew.getFeedback()); + + listFinalNominationContentDTO.add(voteNominationContentDTO); + } else { + AuthoringUtil.logger.debug("displayOrder does not equal editableNominationIndex:" + + editableNominationIndex); + voteNominationContentDTO.setNomination(question); + voteNominationContentDTO.setDisplayOrder(displayOrder); + voteNominationContentDTO.setFeedback(feedback); + + listFinalNominationContentDTO.add(voteNominationContentDTO); + } } - - logger.debug("listFinalNominationContentDTO:" + listFinalNominationContentDTO); + + AuthoringUtil.logger.debug("listFinalNominationContentDTO:" + listFinalNominationContentDTO); return listFinalNominationContentDTO; + } + + protected static Map extractMapFeedback(List listNominationContentDTO) { + AuthoringUtil.logger.debug("listNominationContentDTO:" + listNominationContentDTO); + Map mapFeedbackContent = new TreeMap(new VoteComparator()); + + Iterator listIterator = listNominationContentDTO.iterator(); + int queIndex = 0; + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + AuthoringUtil.logger.debug("voteNominationContentDTO feedback:" + voteNominationContentDTO.getFeedback()); + + queIndex++; + AuthoringUtil.logger.debug("queIndex:" + queIndex); + mapFeedbackContent.put(new Integer(queIndex).toString(), voteNominationContentDTO.getFeedback()); } + AuthoringUtil.logger.debug("mapFeedbackContent:" + mapFeedbackContent); + return mapFeedbackContent; + } - - protected static Map extractMapFeedback(List listNominationContentDTO) - { - logger.debug("listNominationContentDTO:" + listNominationContentDTO); - Map mapFeedbackContent= new TreeMap(new VoteComparator()); - - Iterator listIterator=listNominationContentDTO.iterator(); - int queIndex=0; - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO=(VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO feedback:" + voteNominationContentDTO.getFeedback()); - - queIndex++; - logger.debug("queIndex:" + queIndex); - mapFeedbackContent.put(new Integer(queIndex).toString(), voteNominationContentDTO.getFeedback()); - } - logger.debug("mapFeedbackContent:" + mapFeedbackContent); - return mapFeedbackContent; + public void removeRedundantNominations(Map mapNominationContent, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm, HttpServletRequest request, String toolContentID) { + AuthoringUtil.logger.debug("removing unused entries... "); + AuthoringUtil.logger.debug("mapNominationContent: " + mapNominationContent); + AuthoringUtil.logger.debug("toolContentID: " + toolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + AuthoringUtil.logger.debug("voteContent: " + voteContent); + + if (voteContent != null) { + AuthoringUtil.logger.debug("voteContent uid: " + voteContent.getUid()); + List allNominations = voteService.getAllQuestionEntries(voteContent.getUid()); + AuthoringUtil.logger.debug("allNominations: " + allNominations); + + Iterator listIterator = allNominations.iterator(); + int mapIndex = 0; + boolean entryUsed = false; + while (listIterator.hasNext()) { + ++mapIndex; + AuthoringUtil.logger.debug("current mapIndex: " + mapIndex); + + VoteQueContent queContent = (VoteQueContent) listIterator.next(); + AuthoringUtil.logger.debug("queContent data: " + queContent); + AuthoringUtil.logger.debug("queContent: " + queContent.getQuestion() + " " + + queContent.getDisplayOrder()); + + entryUsed = false; + Iterator itMap = mapNominationContent.entrySet().iterator(); + int displayOrder = 0; + while (itMap.hasNext()) { + ++displayOrder; + AuthoringUtil.logger.debug("current displayOrder: " + displayOrder); + entryUsed = false; + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue().toString().length() != 0) { + AuthoringUtil.logger.debug("text from map:" + pairs.getValue().toString()); + AuthoringUtil.logger.debug("text from db:" + queContent.getQuestion()); + + AuthoringUtil.logger.debug("mapIndex versus displayOrder:" + mapIndex + " versus " + + displayOrder); + if (mapIndex == displayOrder) { + AuthoringUtil.logger.debug("used displayOrder position:" + displayOrder); + entryUsed = true; + break; + } + + } + } + + if (entryUsed == false) { + AuthoringUtil.logger.debug("removing unused entry in db:" + queContent.getQuestion()); + + VoteQueContent removeableVoteQueContent = voteService.getQuestionContentByQuestionText(queContent + .getQuestion(), voteContent.getUid()); + AuthoringUtil.logger.debug("removeableVoteQueContent" + removeableVoteQueContent); + if (removeableVoteQueContent != null) { + voteService.removeVoteQueContent(removeableVoteQueContent); + AuthoringUtil.logger.debug("removed removeableVoteQueContent from the db: " + + removeableVoteQueContent); + } + + } + } + } + } - - public void removeRedundantNominations (Map mapNominationContent, IVoteService voteService, VoteAuthoringForm voteAuthoringForm, - HttpServletRequest request, String toolContentID) + public VoteContent saveOrUpdateVoteContent(Map mapQuestionContent, Map mapFeedback, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm, HttpServletRequest request, VoteContent voteContent, + String strToolContentID, DataFlowObject assignedDataFlowObject) { + UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + boolean isLockOnFinish = false; + boolean isAllowTextEntry = false; + boolean isReflect = false; + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + + AuthoringUtil.logger.debug("richTextTitle: " + richTextTitle); + AuthoringUtil.logger.debug("richTextInstructions: " + richTextInstructions); + + String lockOnFinish = request.getParameter("lockOnFinish"); + AuthoringUtil.logger.debug("lockOnFinish: " + lockOnFinish); + + String allowTextEntry = request.getParameter("allowText"); + AuthoringUtil.logger.debug("allowTextEntry: " + allowTextEntry); + + String showResults = request.getParameter("showResults"); + + String reflect = request.getParameter(VoteAppConstants.REFLECT); + AuthoringUtil.logger.debug("reflect: " + reflect); + + String reflectionSubject = voteAuthoringForm.getReflectionSubject(); + AuthoringUtil.logger.debug("reflectionSubject: " + reflectionSubject); + + String maxNomcount = voteAuthoringForm.getMaxNominationCount(); + AuthoringUtil.logger.debug("maxNomcount: " + maxNomcount); + + String richTextOfflineInstructions = request.getParameter(VoteAppConstants.OFFLINE_INSTRUCTIONS); + String richTextOnlineInstructions = request.getParameter(VoteAppConstants.ONLINE_INSTRUCTIONS); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + AuthoringUtil.logger.debug("activeModule: " + activeModule); + + boolean setCommonContent = true; + if (lockOnFinish == null || allowTextEntry == null || showResults == null || reflect == null + || reflectionSubject == null || maxNomcount == null) + { - logger.debug("removing unused entries... "); - logger.debug("mapNominationContent: " + mapNominationContent); - logger.debug("toolContentID: " + toolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("voteContent: " + voteContent); - - if (voteContent != null) - { - logger.debug("voteContent uid: " + voteContent.getUid()); - List allNominations=voteService.getAllQuestionEntries(voteContent.getUid()); - logger.debug("allNominations: " + allNominations); - - Iterator listIterator=allNominations.iterator(); - int mapIndex=0; - boolean entryUsed=false; - while (listIterator.hasNext()) - { - ++mapIndex; - logger.debug("current mapIndex: " + mapIndex); + setCommonContent = false; + } + AuthoringUtil.logger.debug("setCommonContent: " + setCommonContent); - VoteQueContent queContent=(VoteQueContent)listIterator.next(); - logger.debug("queContent data: " + queContent); - logger.debug("queContent: " + queContent.getQuestion() + " " + queContent.getDisplayOrder()); - - entryUsed=false; - Iterator itMap = mapNominationContent.entrySet().iterator(); - int displayOrder=0; - while (itMap.hasNext()) - { - ++displayOrder; - logger.debug("current displayOrder: " + displayOrder); - entryUsed=false; - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().toString().length() != 0) - { - logger.debug("text from map:" + pairs.getValue().toString()); - logger.debug("text from db:" + queContent.getQuestion()); + boolean lockOnFinishBoolean = false; + boolean allowTextEntryBoolean = false; + boolean reflectBoolean = false; + boolean showResultsBoolean = false; - logger.debug("mapIndex versus displayOrder:" + mapIndex + " versus " + displayOrder); - if (mapIndex == displayOrder) - { - logger.debug("used displayOrder position:" + displayOrder); - entryUsed=true; - break; - } - - } - } - - if (entryUsed == false) - { - logger.debug("removing unused entry in db:" + queContent.getQuestion()); - - VoteQueContent removeableVoteQueContent=voteService.getQuestionContentByQuestionText(queContent.getQuestion(), voteContent.getUid()); - logger.debug("removeableVoteQueContent" + removeableVoteQueContent); - if (removeableVoteQueContent != null) - { - voteService.removeVoteQueContent(removeableVoteQueContent); - logger.debug("removed removeableVoteQueContent from the db: " + removeableVoteQueContent); - } - - } - } - } - + if (lockOnFinish != null && lockOnFinish.equalsIgnoreCase("1")) { + lockOnFinishBoolean = true; } - - - public VoteContent saveOrUpdateVoteContent(Map mapQuestionContent, Map mapFeedback, IVoteService voteService, VoteAuthoringForm voteAuthoringForm, - HttpServletRequest request, VoteContent voteContent, String strToolContentID) - { - UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - - boolean isLockOnFinish=false; - boolean isAllowTextEntry=false; - boolean isReflect=false; + if (allowTextEntry != null && allowTextEntry.equalsIgnoreCase("1")) { + allowTextEntryBoolean = true; + } - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); + if (reflect != null && reflect.equalsIgnoreCase("1")) { + reflectBoolean = true; + } - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - + if (showResults != null && showResults.equalsIgnoreCase("1")) { + showResultsBoolean = true; + } - String lockOnFinish = request.getParameter("lockOnFinish"); - logger.debug("lockOnFinish: " + lockOnFinish); + AuthoringUtil.logger.debug("lockOnFinishBoolean: " + lockOnFinishBoolean); + AuthoringUtil.logger.debug("allowTextEntryBoolean: " + allowTextEntryBoolean); + AuthoringUtil.logger.debug("reflectBoolean: " + reflectBoolean); - String allowTextEntry = request.getParameter("allowText"); - logger.debug("allowTextEntry: " + allowTextEntry); + long userId = 0; + if (toolUser != null) { + userId = toolUser.getUserID().longValue(); + } else { + HttpSession ss = SessionManager.getSession(); + AuthoringUtil.logger.debug("ss: " + ss); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + AuthoringUtil.logger.debug("user" + user); + if (user != null) { + userId = user.getUserID().longValue(); + } else { + AuthoringUtil.logger.debug("should not reach here"); + userId = 0; + } + } + AuthoringUtil.logger.debug("userId: " + userId); + AuthoringUtil.logger.debug("voteContent: " + voteContent); - String showResults = request.getParameter("showResults"); + boolean newContent = false; + if (voteContent == null) { + voteContent = new VoteContent(); + newContent = true; + } - String reflect=request.getParameter(REFLECT); - logger.debug("reflect: " + reflect); + AuthoringUtil.logger.debug("setting common content values..." + richTextTitle + " " + richTextInstructions); + voteContent.setVoteContentId(new Long(strToolContentID)); + voteContent.setTitle(richTextTitle); + voteContent.setInstructions(richTextInstructions); + voteContent.setUpdateDate(new Date(System.currentTimeMillis())); + /** keep updating this one */ + AuthoringUtil.logger.debug("userId: " + userId); + voteContent.setCreatedBy(userId); + /** make sure we are setting the userId from the User object above */ + AuthoringUtil.logger.debug("end of setting common content values..."); - String reflectionSubject=voteAuthoringForm.getReflectionSubject(); - logger.debug("reflectionSubject: " + reflectionSubject); - - String maxNomcount= voteAuthoringForm.getMaxNominationCount(); - logger.debug("maxNomcount: " + maxNomcount); + AuthoringUtil.logger.debug("activeModule:" + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + AuthoringUtil.logger.debug("setting other content values..."); + voteContent.setLockOnFinish(lockOnFinishBoolean); + voteContent.setAllowText(allowTextEntryBoolean); + voteContent.setShowResults(showResultsBoolean); + voteContent.setReflect(reflectBoolean); + voteContent.setMaxNominationCount(maxNomcount); - String richTextOfflineInstructions=request.getParameter(OFFLINE_INSTRUCTIONS); - String richTextOnlineInstructions=request.getParameter(ONLINE_INSTRUCTIONS); + voteContent.setOnlineInstructions(richTextOnlineInstructions); + voteContent.setOfflineInstructions(richTextOfflineInstructions); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - - boolean setCommonContent=true; - if ( (lockOnFinish == null) || - (allowTextEntry == null) || (showResults == null) || (reflect == null) || - (reflectionSubject == null) || (maxNomcount == null)) - - { - setCommonContent=false; - } - logger.debug("setCommonContent: " + setCommonContent); - - boolean lockOnFinishBoolean=false; - boolean allowTextEntryBoolean=false; - boolean reflectBoolean=false; - boolean showResultsBoolean=false; - - if ((lockOnFinish != null) && (lockOnFinish.equalsIgnoreCase("1"))) - lockOnFinishBoolean=true; - - if ((allowTextEntry != null) && (allowTextEntry.equalsIgnoreCase("1"))) - allowTextEntryBoolean=true; + voteContent.setReflectionSubject(reflectionSubject); + } - if ((reflect != null) && (reflect.equalsIgnoreCase("1"))) - reflectBoolean=true; - - if ( showResults != null && showResults.equalsIgnoreCase("1")) - showResultsBoolean=true; - - logger.debug("lockOnFinishBoolean: " + lockOnFinishBoolean); - logger.debug("allowTextEntryBoolean: " + allowTextEntryBoolean); - logger.debug("reflectBoolean: " + reflectBoolean); - - long userId=0; - if (toolUser != null) - { - userId = toolUser.getUserID().longValue(); - } - else - { - HttpSession ss = SessionManager.getSession(); - logger.debug("ss: " + ss); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - logger.debug("user" + user); - if (user != null) - { - userId = user.getUserID().longValue(); - } - else - { - logger.debug("should not reach here"); - userId=0; - } - } - logger.debug("userId: " + userId); - logger.debug("voteContent: " + voteContent); - - boolean newContent=false; - if(voteContent == null) - { - voteContent = new VoteContent(); - newContent=true; - } + // If we use tool input, we clear any existing user created nominations + if (assignedDataFlowObject == null) { + voteContent.setAssignedDataFlowObject(true); + voteContent.setVoteQueContents(null); + } else { + voteContent.setAssignedDataFlowObject(false); + } + if (newContent) { + AuthoringUtil.logger.debug("will create: " + voteContent); + voteService.createVote(voteContent); + } else { + AuthoringUtil.logger.debug("will update: " + voteContent); + voteService.updateVote(voteContent); + } - logger.debug("setting common content values..." + richTextTitle + " " + richTextInstructions); - voteContent.setVoteContentId(new Long(strToolContentID)); - voteContent.setTitle(richTextTitle); - voteContent.setInstructions(richTextInstructions); - voteContent.setUpdateDate(new Date(System.currentTimeMillis())); /**keep updating this one*/ - logger.debug("userId: " + userId); - voteContent.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/ - logger.debug("end of setting common content values..."); + voteContent = voteService.retrieveVote(new Long(strToolContentID)); - + AuthoringUtil.logger.debug("voteContent: " + voteContent); - logger.debug("activeModule:" + activeModule); - if (activeModule.equals(AUTHORING)) - { - logger.debug("setting other content values..."); - voteContent.setLockOnFinish(lockOnFinishBoolean); - voteContent.setAllowText(allowTextEntryBoolean); - voteContent.setShowResults(showResultsBoolean); - voteContent.setReflect(reflectBoolean); - voteContent.setMaxNominationCount(maxNomcount); - - voteContent.setOnlineInstructions(richTextOnlineInstructions); - voteContent.setOfflineInstructions(richTextOfflineInstructions); - - voteContent.setReflectionSubject(reflectionSubject); - } - - - if (newContent) - { - logger.debug("will create: " + voteContent); - voteService.createVote(voteContent); - } - else - { - logger.debug("will update: " + voteContent); - voteService.updateVote(voteContent); - } - - voteContent=voteService.retrieveVote(new Long(strToolContentID)); - - - logger.debug("voteContent: " + voteContent); - - voteContent=createQuestionContent(mapQuestionContent, mapFeedback, voteService, voteContent); - - return voteContent; + if (!voteContent.getAssignedDataFlowObject()) { + voteContent = createQuestionContent(mapQuestionContent, mapFeedback, voteService, voteContent); + } + + voteService.saveDataFlowObjectAssigment(assignedDataFlowObject); + + return voteContent; } - - - protected VoteContent createQuestionContent(Map mapQuestionContent, Map mapFeedback, IVoteService voteService, VoteContent voteContent) - { - logger.debug("createQuestionContent: "); - logger.debug("content uid is: " + voteContent.getUid()); - List questions=voteService.retrieveVoteQueContentsByToolContentId(voteContent.getUid().longValue()); - logger.debug("questions: " + questions); - - logger.debug("mapQuestionContent: " + mapQuestionContent); - logger.debug("mapFeedback: " + mapFeedback); + protected VoteContent createQuestionContent(Map mapQuestionContent, Map mapFeedback, IVoteService voteService, + VoteContent voteContent) { + AuthoringUtil.logger.debug("createQuestionContent: "); + AuthoringUtil.logger.debug("content uid is: " + voteContent.getUid()); + List questions = voteService.retrieveVoteQueContentsByToolContentId(voteContent.getUid().longValue()); + AuthoringUtil.logger.debug("questions: " + questions); - - Iterator itMap = mapQuestionContent.entrySet().iterator(); - int displayOrder=0; - while (itMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().toString().length() != 0) - { - logger.debug("starting createQuestionContent: pairs.getValue().toString():" + pairs.getValue().toString()); - logger.debug("starting createQuestionContent: voteContent: " + voteContent); - - ++displayOrder; - logger.debug("starting createQuestionContent: displayOrder: " + displayOrder); - String currentFeedback=(String)mapFeedback.get(new Integer(displayOrder).toString()); - logger.debug("currentFeedback: " + currentFeedback); - - VoteQueContent queContent= new VoteQueContent(pairs.getValue().toString(), - displayOrder, - voteContent, - null); - - - logger.debug("queContent: " + queContent); - - /* checks if the question is already recorded*/ - logger.debug("question text is: " + pairs.getValue().toString()); - logger.debug("content uid is: " + voteContent.getUid()); - logger.debug("question display order is: " + displayOrder); - VoteQueContent existingVoteQueContent=voteService.getQuestionContentByDisplayOrder(new Long(displayOrder), voteContent.getUid()); - logger.debug("existingVoteQueContent: " + existingVoteQueContent); - - if (existingVoteQueContent == null) - { - /*make sure a question with the same question text is not already saved*/ - VoteQueContent duplicateVoteQueContent=voteService.getQuestionContentByQuestionText(pairs.getValue().toString(), voteContent.getUid()); - logger.debug("duplicateVoteQueContent: " + duplicateVoteQueContent); - logger.debug("adding a new question to content: " + queContent); - voteContent.getVoteQueContents().add(queContent); - queContent.setVoteContent(voteContent); - - voteService.createVoteQue(queContent); - } - else - { + AuthoringUtil.logger.debug("mapQuestionContent: " + mapQuestionContent); + AuthoringUtil.logger.debug("mapFeedback: " + mapFeedback); - String existingQuestion=existingVoteQueContent.getQuestion(); - logger.debug("existingQuestion: " + existingQuestion); - - logger.debug("map question versus existingQuestion: " + pairs.getValue().toString() + - " versus db question value: " + existingQuestion); + Iterator itMap = mapQuestionContent.entrySet().iterator(); + int displayOrder = 0; + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - existingVoteQueContent.setQuestion(pairs.getValue().toString()); - //existingVoteQueContent.setFeedback(currentFeedback); - existingVoteQueContent.setDisplayOrder(displayOrder); - - logger.debug("updating the existing question content: " + existingVoteQueContent); - voteService.updateVoteQueContent(existingVoteQueContent); - } - } + if (pairs.getValue().toString().length() != 0) { + AuthoringUtil.logger.debug("starting createQuestionContent: pairs.getValue().toString():" + + pairs.getValue().toString()); + AuthoringUtil.logger.debug("starting createQuestionContent: voteContent: " + voteContent); + + ++displayOrder; + AuthoringUtil.logger.debug("starting createQuestionContent: displayOrder: " + displayOrder); + String currentFeedback = (String) mapFeedback.get(new Integer(displayOrder).toString()); + AuthoringUtil.logger.debug("currentFeedback: " + currentFeedback); + + VoteQueContent queContent = new VoteQueContent(pairs.getValue().toString(), displayOrder, voteContent, + null); + + AuthoringUtil.logger.debug("queContent: " + queContent); + + /* checks if the question is already recorded */ + AuthoringUtil.logger.debug("question text is: " + pairs.getValue().toString()); + AuthoringUtil.logger.debug("content uid is: " + voteContent.getUid()); + AuthoringUtil.logger.debug("question display order is: " + displayOrder); + VoteQueContent existingVoteQueContent = voteService.getQuestionContentByDisplayOrder(new Long( + displayOrder), voteContent.getUid()); + AuthoringUtil.logger.debug("existingVoteQueContent: " + existingVoteQueContent); + + if (existingVoteQueContent == null) { + /* make sure a question with the same question text is not already saved */ + VoteQueContent duplicateVoteQueContent = voteService.getQuestionContentByQuestionText(pairs + .getValue().toString(), voteContent.getUid()); + AuthoringUtil.logger.debug("duplicateVoteQueContent: " + duplicateVoteQueContent); + AuthoringUtil.logger.debug("adding a new question to content: " + queContent); + voteContent.getVoteQueContents().add(queContent); + queContent.setVoteContent(voteContent); + + voteService.createVoteQue(queContent); + } else { + + String existingQuestion = existingVoteQueContent.getQuestion(); + AuthoringUtil.logger.debug("existingQuestion: " + existingQuestion); + + AuthoringUtil.logger.debug("map question versus existingQuestion: " + pairs.getValue().toString() + + " versus db question value: " + existingQuestion); + + existingVoteQueContent.setQuestion(pairs.getValue().toString()); + // existingVoteQueContent.setFeedback(currentFeedback); + existingVoteQueContent.setDisplayOrder(displayOrder); + + AuthoringUtil.logger.debug("updating the existing question content: " + existingVoteQueContent); + voteService.updateVoteQueContent(existingVoteQueContent); + } } - return voteContent; + } + return voteContent; } - - - public void reOrganizeDisplayOrder(Map mapQuestionContent, IVoteService voteService, VoteAuthoringForm voteAuthoringForm, VoteContent voteContent) - { - logger.debug("voteContent: " + voteContent); - if (voteContent != null) - { - logger.debug("content uid: " + voteContent.getUid()); - List sortedQuestions=voteService.getAllQuestionEntriesSorted(voteContent.getUid().longValue()); - logger.debug("sortedQuestions: " + sortedQuestions); - - Iterator listIterator=sortedQuestions.iterator(); - int displayOrder=1; - while (listIterator.hasNext()) - { - VoteQueContent queContent=(VoteQueContent)listIterator.next(); - logger.debug("queContent data: " + queContent); - logger.debug("queContent: " + queContent.getQuestion() + " " + queContent.getDisplayOrder()); - - VoteQueContent existingVoteQueContent=voteService.getQuestionContentByQuestionText(queContent.getQuestion(), voteContent.getUid()); - logger.debug("existingVoteQueContent: " + existingVoteQueContent); - existingVoteQueContent.setDisplayOrder(displayOrder); - logger.debug("updating the existing question content for displayOrder: " + existingVoteQueContent); - voteService.updateVoteQueContent(existingVoteQueContent); - displayOrder++; - } - } - logger.debug("done with reOrganizeDisplayOrder..."); + public void reOrganizeDisplayOrder(Map mapQuestionContent, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm, VoteContent voteContent) { + AuthoringUtil.logger.debug("voteContent: " + voteContent); + if (voteContent != null) { + AuthoringUtil.logger.debug("content uid: " + voteContent.getUid()); + List sortedQuestions = voteService.getAllQuestionEntriesSorted(voteContent.getUid().longValue()); + AuthoringUtil.logger.debug("sortedQuestions: " + sortedQuestions); + + Iterator listIterator = sortedQuestions.iterator(); + int displayOrder = 1; + while (listIterator.hasNext()) { + VoteQueContent queContent = (VoteQueContent) listIterator.next(); + AuthoringUtil.logger.debug("queContent data: " + queContent); + AuthoringUtil.logger.debug("queContent: " + queContent.getQuestion() + " " + + queContent.getDisplayOrder()); + + VoteQueContent existingVoteQueContent = voteService.getQuestionContentByQuestionText(queContent + .getQuestion(), voteContent.getUid()); + AuthoringUtil.logger.debug("existingVoteQueContent: " + existingVoteQueContent); + existingVoteQueContent.setDisplayOrder(displayOrder); + AuthoringUtil.logger.debug("updating the existing question content for displayOrder: " + + existingVoteQueContent); + voteService.updateVoteQueContent(existingVoteQueContent); + displayOrder++; + } + } + AuthoringUtil.logger.debug("done with reOrganizeDisplayOrder..."); } } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/Attic/LearningUtil.java,v diff -u -r1.20 -r1.21 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java 17 Sep 2006 06:29:22 -0000 1.20 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java 2 Jul 2009 13:02:04 -0000 1.21 @@ -25,12 +25,15 @@ import java.util.Date; import java.util.Iterator; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; +import org.lamsfoundation.lams.tool.ToolOutput; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteComparator; import org.lamsfoundation.lams.tool.vote.VoteUtils; @@ -43,94 +46,97 @@ /** * - *

Keeps all operations needed for Learning mode.

- * + *

+ * Keeps all operations needed for Learning mode. + *

+ * * @author Ozgur Demirtas - * + * */ public class LearningUtil implements VoteAppConstants { - static Logger logger = Logger.getLogger(LearningUtil.class.getName()); - - /** Build a map of the display ids -> nomination text. If checkedOptions != null then - * only include the display ids in the checkedOptions list. - * - * @param request - * @param voteContent the content of the vote from the database - * @param checkedOptions collection of String display IDs to which to restrict the map (optional) - * @return Map of display id -> nomination text. - */ - public static Map buildQuestionContentMap(HttpServletRequest request, IVoteService voteService, - VoteContent voteContent, Collection checkedOptions) - { - Map mapQuestionsContent= new TreeMap(new VoteComparator()); - - Iterator contentIterator=voteContent.getVoteQueContents().iterator(); - while (contentIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent)contentIterator.next(); - if (voteQueContent != null) - { - String displayOrder = (new Integer(voteQueContent.getDisplayOrder())).toString(); - if ( (checkedOptions==null || checkedOptions.contains(displayOrder)) && ! displayOrder.equals("0")) - { - /* add the question to the questions Map in the displayOrder*/ - mapQuestionsContent.put(displayOrder.toString(),voteQueContent.getQuestion()); - } - } - } - return mapQuestionsContent; + static Logger logger = Logger.getLogger(LearningUtil.class.getName()); + + /** + * Build a map of the display ids -> nomination text. If checkedOptions != null then only include the display ids in + * the checkedOptions list. + * + * @param request + * @param voteContent + * the content of the vote from the database + * @param checkedOptions + * collection of String display IDs to which to restrict the map (optional) + * @return Map of display id -> nomination text. + */ + public static Map buildQuestionContentMap(HttpServletRequest request, IVoteService voteService, + VoteContent voteContent, Collection checkedOptions) { + Map mapQuestionsContent = new TreeMap(new VoteComparator()); + Set nominations = voteContent.getVoteQueContents(); + if (Boolean.TRUE.equals(voteContent.getAssignedDataFlowObject()) + && (nominations == null || nominations.isEmpty())) { + // If we are using tool input rather that previously defined nominations, we need to get this input now and + // create questions. Once they are created, they will be not altered, no matter if another learner gets to + // this point and the tool input changed + createQuestionsFromToolInput(voteContent, voteService); + nominations = voteContent.getVoteQueContents(); + } + + Iterator contentIterator = nominations.iterator(); + while (contentIterator.hasNext()) { + VoteQueContent voteQueContent = contentIterator.next(); + if (voteQueContent != null) { + String displayOrder = (new Integer(voteQueContent.getDisplayOrder())).toString(); + if ((checkedOptions == null || checkedOptions.contains(displayOrder)) && !displayOrder.equals("0")) { + /* add the question to the questions Map in the displayOrder */ + mapQuestionsContent.put(displayOrder.toString(), voteQueContent.getQuestion()); + } + } + } + + return mapQuestionsContent; } - /** * determines if a user is already in the tool's tables + * * @param request * @return */ - public static boolean doesUserExists(HttpServletRequest request, IVoteService voteService) - { - Long queUsrId=VoteUtils.getUserId(); - VoteQueUsr voteQueUsr=voteService.retrieveVoteQueUsr(queUsrId); - - if (voteQueUsr != null) - return true; - - return false; + public static boolean doesUserExists(HttpServletRequest request, IVoteService voteService) { + Long queUsrId = VoteUtils.getUserId(); + VoteQueUsr voteQueUsr = voteService.retrieveVoteQueUsr(queUsrId); + + if (voteQueUsr != null) { + return true; } + return false; + } /** * creates a new user for the tool * * @param request * @return */ - public static VoteQueUsr createUser(HttpServletRequest request, IVoteService voteService, Long toolSessionID) - { - logger.debug("createUser: " + toolSessionID); - - Long queUsrId=VoteUtils.getUserId(); - String username=VoteUtils.getUserName(); - String fullname=VoteUtils.getUserFullName(); - VoteSession voteSession=voteService.retrieveVoteSession(toolSessionID); - VoteQueUsr voteQueUsr= new VoteQueUsr(queUsrId, - username, - fullname, - voteSession, - new TreeSet()); - voteService.createVoteQueUsr(voteQueUsr); - logger.debug("created voteQueUsr in the db: " + voteQueUsr); - return voteQueUsr; - } + public static VoteQueUsr createUser(HttpServletRequest request, IVoteService voteService, Long toolSessionID) { + LearningUtil.logger.debug("createUser: " + toolSessionID); - - public static VoteQueUsr getUser(HttpServletRequest request, IVoteService voteService) - { - Long queUsrId=VoteUtils.getUserId(); - VoteQueUsr voteQueUsr=voteService.retrieveVoteQueUsr(queUsrId); - return voteQueUsr; - } - + Long queUsrId = VoteUtils.getUserId(); + String username = VoteUtils.getUserName(); + String fullname = VoteUtils.getUserFullName(); + VoteSession voteSession = voteService.retrieveVoteSession(toolSessionID); + VoteQueUsr voteQueUsr = new VoteQueUsr(queUsrId, username, fullname, voteSession, new TreeSet()); + voteService.createVoteQueUsr(voteQueUsr); + LearningUtil.logger.debug("created voteQueUsr in the db: " + voteQueUsr); + return voteQueUsr; + } + + public static VoteQueUsr getUser(HttpServletRequest request, IVoteService voteService) { + Long queUsrId = VoteUtils.getUserId(); + VoteQueUsr voteQueUsr = voteService.retrieveVoteQueUsr(queUsrId); + return voteQueUsr; + } + /** * creates a new vote record in the database * @@ -141,197 +147,196 @@ * @param singleUserEntry * @param voteSession */ - public static void createAttempt(HttpServletRequest request, IVoteService voteService, - VoteQueUsr voteQueUsr, Map mapGeneralCheckedOptionsContent, String userEntry, - boolean singleUserEntry, VoteSession voteSession, Long toolContentUID) - { - logger.debug("doing voteSession: " + voteSession); - logger.debug("doing createAttempt: " + mapGeneralCheckedOptionsContent); - logger.debug("userEntry: " + userEntry); - logger.debug("singleUserEntry: " + singleUserEntry); - - Date attempTime=VoteUtils.getGMTDateTime(); - String timeZone= VoteUtils.getCurrentTimeZone(); - logger.debug("timeZone: " + timeZone); - - logger.debug("toolContentUID: " + toolContentUID); - - - if ((mapGeneralCheckedOptionsContent.size() == 0)) - { - logger.debug("mapGeneralCheckedOptionsContent is empty"); - VoteQueContent localVoteQueContent=voteService.getToolDefaultQuestionContent(1); - logger.debug("localVoteQueContent: " + localVoteQueContent); - createIndividualOptions(request, voteService, localVoteQueContent, voteQueUsr, attempTime, - timeZone, userEntry, singleUserEntry, voteSession); - + public static void createAttempt(HttpServletRequest request, IVoteService voteService, VoteQueUsr voteQueUsr, + Map mapGeneralCheckedOptionsContent, String userEntry, boolean singleUserEntry, VoteSession voteSession, + Long toolContentUID) { + LearningUtil.logger.debug("doing voteSession: " + voteSession); + LearningUtil.logger.debug("doing createAttempt: " + mapGeneralCheckedOptionsContent); + LearningUtil.logger.debug("userEntry: " + userEntry); + LearningUtil.logger.debug("singleUserEntry: " + singleUserEntry); + + Date attempTime = VoteUtils.getGMTDateTime(); + String timeZone = VoteUtils.getCurrentTimeZone(); + LearningUtil.logger.debug("timeZone: " + timeZone); + + LearningUtil.logger.debug("toolContentUID: " + toolContentUID); + + if (mapGeneralCheckedOptionsContent.size() == 0) { + LearningUtil.logger.debug("mapGeneralCheckedOptionsContent is empty"); + VoteQueContent localVoteQueContent = voteService.getToolDefaultQuestionContent(1); + LearningUtil.logger.debug("localVoteQueContent: " + localVoteQueContent); + createIndividualOptions(request, voteService, localVoteQueContent, voteQueUsr, attempTime, timeZone, + userEntry, singleUserEntry, voteSession); + + } else { + LearningUtil.logger.debug("mapGeneralCheckedOptionsContent is not empty"); + if (toolContentUID != null) { + Iterator itCheckedMap = mapGeneralCheckedOptionsContent.entrySet().iterator(); + LearningUtil.logger.debug("iterating mapGeneralCheckedOptionsContent"); + while (itCheckedMap.hasNext()) { + Map.Entry checkedPairs = (Map.Entry) itCheckedMap.next(); + Long questionDisplayOrder = new Long(checkedPairs.getKey().toString()); + + LearningUtil.logger.debug("questionDisplayOrder: " + questionDisplayOrder); + + VoteQueContent voteQueContent = voteService.getQuestionContentByDisplayOrder(questionDisplayOrder, + toolContentUID); + LearningUtil.logger.debug("voteQueContent: " + voteQueContent); + if (voteQueContent != null) { + createIndividualOptions(request, voteService, voteQueContent, voteQueUsr, attempTime, timeZone, + userEntry, false, voteSession); + } } - else - { - logger.debug("mapGeneralCheckedOptionsContent is not empty"); - if (toolContentUID != null) - { - Iterator itCheckedMap = mapGeneralCheckedOptionsContent.entrySet().iterator(); - logger.debug("iterating mapGeneralCheckedOptionsContent"); - while (itCheckedMap.hasNext()) - { - Map.Entry checkedPairs = (Map.Entry)itCheckedMap.next(); - Long questionDisplayOrder=new Long(checkedPairs.getKey().toString()); - - logger.debug("questionDisplayOrder: " + questionDisplayOrder); - - VoteQueContent voteQueContent=voteService.getQuestionContentByDisplayOrder(questionDisplayOrder, toolContentUID); - logger.debug("voteQueContent: " + voteQueContent); - if (voteQueContent != null) - { - createIndividualOptions(request, voteService, voteQueContent, voteQueUsr, attempTime, timeZone, userEntry, false, voteSession); - } - } - } - } + } + } - } + } - - public static void createIndividualOptions(HttpServletRequest request, IVoteService voteService, VoteQueContent voteQueContent, - VoteQueUsr voteQueUsr, Date attempTime, String timeZone, String userEntry, boolean singleUserEntry, VoteSession voteSession) - { - logger.debug("doing voteSession: " + voteSession); - logger.debug("userEntry: " + userEntry); - logger.debug("singleUserEntry: " + singleUserEntry); + public static void createIndividualOptions(HttpServletRequest request, IVoteService voteService, + VoteQueContent voteQueContent, VoteQueUsr voteQueUsr, Date attempTime, String timeZone, String userEntry, + boolean singleUserEntry, VoteSession voteSession) { + LearningUtil.logger.debug("doing voteSession: " + voteSession); + LearningUtil.logger.debug("userEntry: " + userEntry); + LearningUtil.logger.debug("singleUserEntry: " + singleUserEntry); - logger.debug("voteQueContent: " + voteQueContent); - logger.debug("user " + voteQueUsr.getQueUsrId()); - logger.debug("voteQueContent.getVoteContentId() " +voteQueContent.getVoteContentId()); - - if (voteQueContent != null) - { - VoteUsrAttempt existingVoteUsrAttempt=voteService.getAttemptsForUserAndQuestionContentAndSession(voteQueUsr.getQueUsrId(),voteQueContent.getVoteContentId(), voteSession.getUid()); - logger.debug("existingVoteUsrAttempt: " + existingVoteUsrAttempt); - - if (existingVoteUsrAttempt != null) - { - logger.debug("update existingVoteUsrAttempt: " + existingVoteUsrAttempt); - existingVoteUsrAttempt.setUserEntry(userEntry); - existingVoteUsrAttempt.setAttemptTime(attempTime); - existingVoteUsrAttempt.setTimeZone(timeZone); - voteService.updateVoteUsrAttempt(existingVoteUsrAttempt); - logger.debug("done updating existingVoteUsrAttempt: " + existingVoteUsrAttempt); - } - else - { - logger.debug("create new attempt"); - VoteUsrAttempt voteUsrAttempt=new VoteUsrAttempt(attempTime, timeZone, voteQueContent, voteQueUsr, userEntry, singleUserEntry, true); - logger.debug("voteUsrAttempt: " + voteUsrAttempt); - voteService.createVoteUsrAttempt(voteUsrAttempt); - logger.debug("created voteUsrAttempt in the db :" + voteUsrAttempt); - } - } + LearningUtil.logger.debug("voteQueContent: " + voteQueContent); + LearningUtil.logger.debug("user " + voteQueUsr.getQueUsrId()); + LearningUtil.logger.debug("voteQueContent.getVoteContentId() " + voteQueContent.getVoteContentId()); + + if (voteQueContent != null) { + VoteUsrAttempt existingVoteUsrAttempt = voteService.getAttemptsForUserAndQuestionContentAndSession( + voteQueUsr.getQueUsrId(), voteQueContent.getVoteContentId(), voteSession.getUid()); + LearningUtil.logger.debug("existingVoteUsrAttempt: " + existingVoteUsrAttempt); + + if (existingVoteUsrAttempt != null) { + LearningUtil.logger.debug("update existingVoteUsrAttempt: " + existingVoteUsrAttempt); + existingVoteUsrAttempt.setUserEntry(userEntry); + existingVoteUsrAttempt.setAttemptTime(attempTime); + existingVoteUsrAttempt.setTimeZone(timeZone); + voteService.updateVoteUsrAttempt(existingVoteUsrAttempt); + LearningUtil.logger.debug("done updating existingVoteUsrAttempt: " + existingVoteUsrAttempt); + } else { + LearningUtil.logger.debug("create new attempt"); + VoteUsrAttempt voteUsrAttempt = new VoteUsrAttempt(attempTime, timeZone, voteQueContent, voteQueUsr, + userEntry, singleUserEntry, true); + LearningUtil.logger.debug("voteUsrAttempt: " + voteUsrAttempt); + voteService.createVoteUsrAttempt(voteUsrAttempt); + LearningUtil.logger.debug("created voteUsrAttempt in the db :" + voteUsrAttempt); + } + } } - - public static void readParameters(HttpServletRequest request, VoteLearningForm voteLearningForm) - { - String optionCheckBoxSelected=request.getParameter("optionCheckBoxSelected"); - logger.debug("parameter optionCheckBoxSelected: " + optionCheckBoxSelected); - if ((optionCheckBoxSelected != null) && optionCheckBoxSelected.equals("1")) - { - logger.debug("parameter optionCheckBoxSelected is selected " + optionCheckBoxSelected); - voteLearningForm.setOptionCheckBoxSelected("1"); - } - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("parameter questionIndex: " + questionIndex); - if ((questionIndex != null)) - { - logger.debug("parameter questionIndex is selected " + questionIndex); - voteLearningForm.setQuestionIndex(questionIndex); - } - - String optionIndex=request.getParameter("optionIndex"); - logger.debug("parameter optionIndex: " + optionIndex); - if (optionIndex != null) - { - logger.debug("parameter optionIndex is selected " + optionIndex); - voteLearningForm.setOptionIndex(optionIndex); - } - - String optionValue=request.getParameter("optionValue"); - logger.debug("parameter optionValue: " + optionValue); - if (optionValue != null) - { - voteLearningForm.setOptionValue(optionValue); - } - - String checked=request.getParameter("checked"); - logger.debug("parameter checked: " + checked); - if (checked != null) - { - logger.debug("parameter checked is selected " + checked); - voteLearningForm.setChecked(checked); - } + public static void readParameters(HttpServletRequest request, VoteLearningForm voteLearningForm) { + String optionCheckBoxSelected = request.getParameter("optionCheckBoxSelected"); + LearningUtil.logger.debug("parameter optionCheckBoxSelected: " + optionCheckBoxSelected); + if (optionCheckBoxSelected != null && optionCheckBoxSelected.equals("1")) { + LearningUtil.logger.debug("parameter optionCheckBoxSelected is selected " + optionCheckBoxSelected); + voteLearningForm.setOptionCheckBoxSelected("1"); + } + + String questionIndex = request.getParameter("questionIndex"); + LearningUtil.logger.debug("parameter questionIndex: " + questionIndex); + if (questionIndex != null) { + LearningUtil.logger.debug("parameter questionIndex is selected " + questionIndex); + voteLearningForm.setQuestionIndex(questionIndex); + } + + String optionIndex = request.getParameter("optionIndex"); + LearningUtil.logger.debug("parameter optionIndex: " + optionIndex); + if (optionIndex != null) { + LearningUtil.logger.debug("parameter optionIndex is selected " + optionIndex); + voteLearningForm.setOptionIndex(optionIndex); + } + + String optionValue = request.getParameter("optionValue"); + LearningUtil.logger.debug("parameter optionValue: " + optionValue); + if (optionValue != null) { + voteLearningForm.setOptionValue(optionValue); + } + + String checked = request.getParameter("checked"); + LearningUtil.logger.debug("parameter checked: " + checked); + if (checked != null) { + LearningUtil.logger.debug("parameter checked is selected " + checked); + voteLearningForm.setChecked(checked); + } } - - public static Map selectOptionsCheckBox(HttpServletRequest request,VoteLearningForm voteLearningForm, String questionIndex, - Map mapGeneralCheckedOptionsContent, Map mapQuestionContentLearner) - { - logger.debug("requested optionCheckBoxSelected..."); - logger.debug("questionIndex: " + voteLearningForm.getQuestionIndex()); - logger.debug("optionValue: " + voteLearningForm.getOptionValue()); - logger.debug("checked: " + voteLearningForm.getChecked()); - logger.debug("mapQuestionContentLearner: " + mapQuestionContentLearner); - - String selectedNomination=(String)mapQuestionContentLearner.get(voteLearningForm.getQuestionIndex()); - logger.debug("selectedNomination: " + selectedNomination); + public static Map selectOptionsCheckBox(HttpServletRequest request, VoteLearningForm voteLearningForm, + String questionIndex, Map mapGeneralCheckedOptionsContent, Map mapQuestionContentLearner) { + LearningUtil.logger.debug("requested optionCheckBoxSelected..."); + LearningUtil.logger.debug("questionIndex: " + voteLearningForm.getQuestionIndex()); + LearningUtil.logger.debug("optionValue: " + voteLearningForm.getOptionValue()); + LearningUtil.logger.debug("checked: " + voteLearningForm.getChecked()); + LearningUtil.logger.debug("mapQuestionContentLearner: " + mapQuestionContentLearner); - Map mapFinal= new TreeMap(new VoteComparator()); - - if (mapGeneralCheckedOptionsContent.size() == 0) - { - logger.debug("mapGeneralCheckedOptionsContent size is 0"); - Map mapLeanerCheckedOptionsContent= new TreeMap(new VoteComparator()); - - if (voteLearningForm.getChecked().equals("true")) - mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), selectedNomination); - else - mapLeanerCheckedOptionsContent.remove(voteLearningForm.getQuestionIndex()); - - - mapFinal=mapLeanerCheckedOptionsContent; - } - else - { - Map mapCurrentOptions= mapGeneralCheckedOptionsContent; - - logger.debug("mapCurrentOptions: " + mapCurrentOptions); - if (mapCurrentOptions != null) - { - if (voteLearningForm.getChecked().equals("true")) - mapCurrentOptions.put(voteLearningForm.getQuestionIndex(), selectedNomination); - else - mapCurrentOptions.remove(voteLearningForm.getQuestionIndex()); - - logger.debug("updated mapCurrentOptions: " + mapCurrentOptions); - - mapFinal=mapCurrentOptions; - } - else - { - logger.debug("no options for this questions has been selected yet"); - Map mapLeanerCheckedOptionsContent= new TreeMap(new VoteComparator()); - - if (voteLearningForm.getChecked().equals("true")) - mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), selectedNomination); - else - mapLeanerCheckedOptionsContent.remove(voteLearningForm.getOptionIndex()); - - mapFinal=mapLeanerCheckedOptionsContent; - } - } - - logger.debug("mapFinal: " + mapFinal); - return mapFinal; + String selectedNomination = (String) mapQuestionContentLearner.get(voteLearningForm.getQuestionIndex()); + LearningUtil.logger.debug("selectedNomination: " + selectedNomination); + + Map mapFinal = new TreeMap(new VoteComparator()); + + if (mapGeneralCheckedOptionsContent.size() == 0) { + LearningUtil.logger.debug("mapGeneralCheckedOptionsContent size is 0"); + Map mapLeanerCheckedOptionsContent = new TreeMap(new VoteComparator()); + + if (voteLearningForm.getChecked().equals("true")) { + mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), selectedNomination); + } else { + mapLeanerCheckedOptionsContent.remove(voteLearningForm.getQuestionIndex()); + } + + mapFinal = mapLeanerCheckedOptionsContent; + } else { + Map mapCurrentOptions = mapGeneralCheckedOptionsContent; + + LearningUtil.logger.debug("mapCurrentOptions: " + mapCurrentOptions); + if (mapCurrentOptions != null) { + if (voteLearningForm.getChecked().equals("true")) { + mapCurrentOptions.put(voteLearningForm.getQuestionIndex(), selectedNomination); + } else { + mapCurrentOptions.remove(voteLearningForm.getQuestionIndex()); + } + + LearningUtil.logger.debug("updated mapCurrentOptions: " + mapCurrentOptions); + + mapFinal = mapCurrentOptions; + } else { + LearningUtil.logger.debug("no options for this questions has been selected yet"); + Map mapLeanerCheckedOptionsContent = new TreeMap(new VoteComparator()); + + if (voteLearningForm.getChecked().equals("true")) { + mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), selectedNomination); + } else { + mapLeanerCheckedOptionsContent.remove(voteLearningForm.getOptionIndex()); + } + + mapFinal = mapLeanerCheckedOptionsContent; + } + } + + LearningUtil.logger.debug("mapFinal: " + mapFinal); + return mapFinal; } -} + private static void createQuestionsFromToolInput(VoteContent voteContent, IVoteService voteService) { + // We get whatever the source tool provides us with and try to create questions out of it + DataFlowObject dataFlowObject = voteService.getAssignedDataFlowObject(voteContent.getVoteContentId()); + ToolOutput toolInput = voteService.getToolInput(voteContent.getVoteContentId(), VoteUtils.getUserId() + .intValue()); + Object value = toolInput.getValue().getComplex(); + // If the input is array of strings, it's pretty straightforward + if (value instanceof String[]) { + String[] stringList = (String[]) value; + voteContent.getVoteQueContents().clear(); + for (int nominationIndex = 1; nominationIndex <= stringList.length; nominationIndex++) { + VoteQueContent nomination = new VoteQueContent(); + nomination.setDisplayOrder(nominationIndex); + nomination.setMcContent(voteContent); + nomination.setQuestion(stringList[nominationIndex - 1]); + voteService.saveOrUpdateVoteQueContent(nomination); + voteContent.getVoteQueContents().add(nomination); + } + } + } + +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java,v diff -u -r1.38 -r1.39 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java 26 Mar 2008 03:57:40 -0000 1.38 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java 2 Jul 2009 13:02:04 -0000 1.39 @@ -46,6 +46,7 @@ import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteApplicationException; @@ -68,128 +69,131 @@ import org.springframework.web.context.support.WebApplicationContextUtils; /** - * * @author Ozgur Demirtas + * * * - *

Action class that controls the logic of tool behavior.

+ * @author Ozgur Demirtas * - *

Note that Struts action class only has the responsibility to navigate - * page flow. All database operation should go to service layer and data - * transformation from domain model to struts form bean should go to form - * bean class. This ensure clean and maintainable code. + *

+ * Action class that controls the logic of tool behavior. *

* - * SystemException is thrown whenever an known error condition is - * identified. No system exception error handling code should appear in the - * Struts action class as all of them are handled in + *

+ * Note that Struts action class only has the responsibility to navigate page flow. All database operation should go to + * service layer and data transformation from domain model to struts form bean should go to form bean class. This ensure + * clean and maintainable code. + *

+ * + * SystemException is thrown whenever an known error condition is identified. No system exception error + * handling code should appear in the Struts action class as all of them are handled in * CustomStrutsExceptionHandler. * * - - + + - - - - - - - - - + - - - - + - * -*/ -public class VoteAction extends LamsDispatchAction implements VoteAppConstants -{ - static Logger logger = Logger.getLogger(VoteAction.class.getName()); - - private VoteToolContentHandler toolContentHandler; - - /** - *

Default struts dispatch method.

+ + + + + + + + + +
+ + * + */ +public class VoteAction extends LamsDispatchAction implements VoteAppConstants { + static Logger logger = Logger.getLogger(VoteAction.class.getName()); + + private VoteToolContentHandler toolContentHandler; + + /** + *

+ * Default struts dispatch method. + *

* - *

It is assuming that progress engine should pass in the tool access - * mode and the tool session id as http parameters.

+ *

+ * It is assuming that progress engine should pass in the tool access mode and the tool session id as http + * parameters. + *

* - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. - * - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. + * + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. * @throws IOException * @throws ServletException - * @throws VoteApplicationException the known runtime exception + * @throws VoteApplicationException + * the known runtime exception * - * unspecified(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - - * main content/question content management and workflow logic - * - * if the passed toolContentID exists in the db, we need to get the relevant data into the Map - * if not, create the default Map - */ - public ActionForward unspecified(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - VoteUtils.cleanUpUserExceptions(request); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - SessionMap sessionMap= new SessionMap(); - VoteUtils.saveRichText(request, voteGeneralAuthoringDTO,sessionMap); - voteAuthoringForm.resetUserAction(); - return null; + * unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * throws IOException, ServletException + * + * main content/question content management and workflow logic + * + * if the passed toolContentID exists in the db, we need to get the relevant data into the Map if not, create the + * default Map + */ + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteUtils.cleanUpUserExceptions(request); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + SessionMap sessionMap = new SessionMap(); + VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); + voteAuthoringForm.resetUserAction(); + return null; } - /** * persists offline files * @@ -202,114 +206,104 @@ * @throws ServletException * @throws RepositoryCheckedException */ - public ActionForward submitOfflineFiles(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - RepositoryCheckedException - { - VoteUtils.cleanUpUserExceptions(request); - logger.debug("dispatching submitOfflineFile..."); - - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); + public ActionForward submitOfflineFiles(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, RepositoryCheckedException { + VoteUtils.cleanUpUserExceptions(request); + VoteAction.logger.debug("dispatching submitOfflineFile..."); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - logger.debug("voteAuthoringForm :" +voteAuthoringForm); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - Map mapOptionsContent=(Map)sessionMap.get(MAP_OPTIONS_CONTENT_KEY); - logger.debug("mapOptionsContent: " + mapOptionsContent); - voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - - int maxIndex=mapOptionsContent.size(); - logger.debug("maxIndex: " + maxIndex); - voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - - String firstEntry=(String)mapOptionsContent.get("1"); - logger.debug("firstEntry: " + firstEntry); - voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + VoteAction.logger.debug("voteAuthoringForm :" + voteAuthoringForm); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); - voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); - + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceVoteStarter = (String) request.getAttribute(SOURCE_VOTE_STARTER); - logger.debug("sourceVoteStarter: " + sourceVoteStarter); - String destination=VoteUtils.getDestination(sourceVoteStarter); - logger.debug("destination: " + destination); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); - - logger.debug("will uploadFile for offline file:"); - VoteAttachmentDTO voteAttachmentDTO=AuthoringUtil.uploadFile(request, voteService, voteAuthoringForm, true, sessionMap); - logger.debug("returned voteAttachmentDTO:" + voteAttachmentDTO); - logger.debug("returned sessionMap:" + sessionMap); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - List listOfflineFilesMetaData =(List)sessionMap.get(LIST_OFFLINEFILES_METADATA_KEY); - logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); - - if (voteAttachmentDTO != null) - { - listOfflineFilesMetaData.add(voteAttachmentDTO); - } - - logger.debug("listOfflineFilesMetaData after add:" + listOfflineFilesMetaData); - sessionMap.put(LIST_OFFLINEFILES_METADATA_KEY, listOfflineFilesMetaData); - voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); - - logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); - - - List listOnlineFilesMetaData =(List)sessionMap.get(LIST_ONLINEFILES_METADATA_KEY); - logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); - voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - if (voteAttachmentDTO == null) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - voteGeneralAuthoringDTO.setUserExceptionFilenameEmpty(new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.fileName.empty")); - saveErrors(request,errors); - voteAuthoringForm.resetUserAction(); - persistInRequestError(request,"error.fileName.empty"); + Map mapOptionsContent = (Map) sessionMap.get(VoteAppConstants.MAP_OPTIONS_CONTENT_KEY); + VoteAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + int maxIndex = mapOptionsContent.size(); + VoteAction.logger.debug("maxIndex: " + maxIndex); + voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - return (mapping.findForward(destination)); - } - - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("persisting sessionMap into session: " + sessionMap); - request.getSession().setAttribute(httpSessionID, sessionMap); + String firstEntry = (String) mapOptionsContent.get("1"); + VoteAction.logger.debug("firstEntry: " + firstEntry); + voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); - - voteAuthoringForm.resetUserAction(); - return (mapping.findForward(destination)); + voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); + voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); + + /* determine whether the request is from Monitoring url Edit Activity */ + String sourceVoteStarter = (String) request.getAttribute(VoteAppConstants.SOURCE_VOTE_STARTER); + VoteAction.logger.debug("sourceVoteStarter: " + sourceVoteStarter); + String destination = VoteUtils.getDestination(sourceVoteStarter); + VoteAction.logger.debug("destination: " + destination); + + VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); + + VoteAction.logger.debug("will uploadFile for offline file:"); + VoteAttachmentDTO voteAttachmentDTO = AuthoringUtil.uploadFile(request, voteService, voteAuthoringForm, true, + sessionMap); + VoteAction.logger.debug("returned voteAttachmentDTO:" + voteAttachmentDTO); + VoteAction.logger.debug("returned sessionMap:" + sessionMap); + + List listOfflineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_OFFLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); + + if (voteAttachmentDTO != null) { + listOfflineFilesMetaData.add(voteAttachmentDTO); + } + + VoteAction.logger.debug("listOfflineFilesMetaData after add:" + listOfflineFilesMetaData); + sessionMap.put(VoteAppConstants.LIST_OFFLINEFILES_METADATA_KEY, listOfflineFilesMetaData); + voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + + VoteAction.logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); + + List listOnlineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_ONLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); + voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + + if (voteAttachmentDTO == null) { + ActionMessages errors = new ActionMessages(); + errors = new ActionMessages(); + voteGeneralAuthoringDTO.setUserExceptionFilenameEmpty(new Boolean(true).toString()); + errors.add(Globals.ERROR_KEY, new ActionMessage("error.fileName.empty")); + saveErrors(request, errors); + voteAuthoringForm.resetUserAction(); + persistInRequestError(request, "error.fileName.empty"); + + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + return mapping.findForward(destination); + } + + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("persisting sessionMap into session: " + sessionMap); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteAuthoringForm.resetUserAction(); + return mapping.findForward(destination); } - /** * persists online files + * * @param mapping * @param form * @param request @@ -319,112 +313,101 @@ * @throws ServletException * @throws RepositoryCheckedException */ - public ActionForward submitOnlineFiles(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - RepositoryCheckedException - { - VoteUtils.cleanUpUserExceptions(request); - logger.debug("dispatching submitOnlineFiles..."); - - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); + public ActionForward submitOnlineFiles(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, RepositoryCheckedException { + VoteUtils.cleanUpUserExceptions(request); + VoteAction.logger.debug("dispatching submitOnlineFiles..."); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - logger.debug("voteAuthoringForm :" +voteAuthoringForm); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - Map mapOptionsContent=(Map)sessionMap.get(MAP_OPTIONS_CONTENT_KEY); - logger.debug("mapOptionsContent: " + mapOptionsContent); - voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + VoteAction.logger.debug("voteAuthoringForm :" + voteAuthoringForm); - int maxIndex=mapOptionsContent.size(); - logger.debug("maxIndex: " + maxIndex); - voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - - String firstEntry=(String)mapOptionsContent.get("1"); - logger.debug("firstEntry: " + firstEntry); - voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); - voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); - + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceVoteStarter = (String) request.getAttribute(SOURCE_VOTE_STARTER); - logger.debug("sourceVoteStarter: " + sourceVoteStarter); - String destination=VoteUtils.getDestination(sourceVoteStarter); - logger.debug("destination: " + destination); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); - - logger.debug("will uploadFile for online file:"); - VoteAttachmentDTO voteAttachmentDTO=AuthoringUtil.uploadFile(request, voteService, voteAuthoringForm, false, sessionMap); - logger.debug("returned voteAttachmentDTO:" + voteAttachmentDTO); - logger.debug("returned sessionMap:" + sessionMap); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - List listOnlineFilesMetaData =(List)sessionMap.get(LIST_ONLINEFILES_METADATA_KEY); - logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); - - if (voteAttachmentDTO != null) - { - listOnlineFilesMetaData.add(voteAttachmentDTO); - } - logger.debug("listOnlineFilesMetaData after add:" + listOnlineFilesMetaData); - - sessionMap.put(LIST_ONLINEFILES_METADATA_KEY, listOnlineFilesMetaData); - voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); - - logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); - - List listOfflineFilesMetaData =(List)sessionMap.get(LIST_OFFLINEFILES_METADATA_KEY); - logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); - voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + Map mapOptionsContent = (Map) sessionMap.get(VoteAppConstants.MAP_OPTIONS_CONTENT_KEY); + VoteAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - if (voteAttachmentDTO == null) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - voteGeneralAuthoringDTO.setUserExceptionFilenameEmpty(new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.fileName.empty")); - saveErrors(request,errors); - voteAuthoringForm.resetUserAction(); - persistInRequestError(request,"error.fileName.empty"); + int maxIndex = mapOptionsContent.size(); + VoteAction.logger.debug("maxIndex: " + maxIndex); + voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + String firstEntry = (String) mapOptionsContent.get("1"); + VoteAction.logger.debug("firstEntry: " + firstEntry); + voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); - return (mapping.findForward(destination)); - } + voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); + voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); - - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("persisting sessionMap into session: " + sessionMap); - request.getSession().setAttribute(httpSessionID, sessionMap); + /* determine whether the request is from Monitoring url Edit Activity */ + String sourceVoteStarter = (String) request.getAttribute(VoteAppConstants.SOURCE_VOTE_STARTER); + VoteAction.logger.debug("sourceVoteStarter: " + sourceVoteStarter); + String destination = VoteUtils.getDestination(sourceVoteStarter); + VoteAction.logger.debug("destination: " + destination); - voteAuthoringForm.resetUserAction(); - return (mapping.findForward(destination)); - } + VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); + VoteAction.logger.debug("will uploadFile for online file:"); + VoteAttachmentDTO voteAttachmentDTO = AuthoringUtil.uploadFile(request, voteService, voteAuthoringForm, false, + sessionMap); + VoteAction.logger.debug("returned voteAttachmentDTO:" + voteAttachmentDTO); + VoteAction.logger.debug("returned sessionMap:" + sessionMap); + List listOnlineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_ONLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); + + if (voteAttachmentDTO != null) { + listOnlineFilesMetaData.add(voteAttachmentDTO); + } + VoteAction.logger.debug("listOnlineFilesMetaData after add:" + listOnlineFilesMetaData); + + sessionMap.put(VoteAppConstants.LIST_ONLINEFILES_METADATA_KEY, listOnlineFilesMetaData); + voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + + VoteAction.logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); + + List listOfflineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_OFFLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); + voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + + if (voteAttachmentDTO == null) { + ActionMessages errors = new ActionMessages(); + errors = new ActionMessages(); + voteGeneralAuthoringDTO.setUserExceptionFilenameEmpty(new Boolean(true).toString()); + errors.add(Globals.ERROR_KEY, new ActionMessage("error.fileName.empty")); + saveErrors(request, errors); + voteAuthoringForm.resetUserAction(); + persistInRequestError(request, "error.fileName.empty"); + + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + return mapping.findForward(destination); + } + + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("persisting sessionMap into session: " + sessionMap); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteAuthoringForm.resetUserAction(); + return mapping.findForward(destination); + } + /** * removes an offline file from the jsp * @@ -436,179 +419,169 @@ * @throws IOException * @throws ServletException */ - public ActionForward deleteOfflineFile(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + public ActionForward deleteOfflineFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - VoteUtils.cleanUpUserExceptions(request); - logger.debug("dispatching deleteOfflineFile..."); - - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); + VoteUtils.cleanUpUserExceptions(request); + VoteAction.logger.debug("dispatching deleteOfflineFile..."); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - logger.debug("voteAuthoringForm :" +voteAuthoringForm); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + VoteAction.logger.debug("voteAuthoringForm :" + voteAuthoringForm); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - Map mapOptionsContent=(Map)sessionMap.get(MAP_OPTIONS_CONTENT_KEY); - logger.debug("mapOptionsContent: " + mapOptionsContent); - voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - - int maxIndex=mapOptionsContent.size(); - logger.debug("maxIndex: " + maxIndex); - voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - - String firstEntry=(String)mapOptionsContent.get("1"); - logger.debug("firstEntry: " + firstEntry); - voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); - - - voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); - voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceVoteStarter = (String) request.getAttribute(SOURCE_VOTE_STARTER); - logger.debug("sourceVoteStarter: " + sourceVoteStarter); - String destination=VoteUtils.getDestination(sourceVoteStarter); - logger.debug("destination: " + destination); - - VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); - - String uuid =voteAuthoringForm.getUuid(); - logger.debug("uuid:" + uuid); - - List listOfflineFilesMetaData =(List)sessionMap.get(LIST_OFFLINEFILES_METADATA_KEY); - logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); - listOfflineFilesMetaData=AuthoringUtil.removeFileItem(listOfflineFilesMetaData, uuid); - logger.debug("listOfflineFilesMetaData after remove:" + listOfflineFilesMetaData); - sessionMap.put(LIST_OFFLINEFILES_METADATA_KEY, listOfflineFilesMetaData); - - voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); - - List listOnlineFilesMetaData =(List)sessionMap.get(LIST_ONLINEFILES_METADATA_KEY); - logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); - voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("persisting sessionMap into session: " + sessionMap); - request.getSession().setAttribute(httpSessionID, sessionMap); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - - voteAuthoringForm.resetUserAction(); - - return (mapping.findForward(destination)); + Map mapOptionsContent = (Map) sessionMap.get(VoteAppConstants.MAP_OPTIONS_CONTENT_KEY); + VoteAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); + + int maxIndex = mapOptionsContent.size(); + VoteAction.logger.debug("maxIndex: " + maxIndex); + voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); + + String firstEntry = (String) mapOptionsContent.get("1"); + VoteAction.logger.debug("firstEntry: " + firstEntry); + voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); + + voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); + voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); + + /* determine whether the request is from Monitoring url Edit Activity */ + String sourceVoteStarter = (String) request.getAttribute(VoteAppConstants.SOURCE_VOTE_STARTER); + VoteAction.logger.debug("sourceVoteStarter: " + sourceVoteStarter); + String destination = VoteUtils.getDestination(sourceVoteStarter); + VoteAction.logger.debug("destination: " + destination); + + VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); + + String uuid = voteAuthoringForm.getUuid(); + VoteAction.logger.debug("uuid:" + uuid); + + List listOfflineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_OFFLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); + listOfflineFilesMetaData = AuthoringUtil.removeFileItem(listOfflineFilesMetaData, uuid); + VoteAction.logger.debug("listOfflineFilesMetaData after remove:" + listOfflineFilesMetaData); + sessionMap.put(VoteAppConstants.LIST_OFFLINEFILES_METADATA_KEY, listOfflineFilesMetaData); + + voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + + VoteAction.logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); + + List listOnlineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_ONLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); + voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("persisting sessionMap into session: " + sessionMap); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteAuthoringForm.resetUserAction(); + + return mapping.findForward(destination); } - /** - * deletes an online file from the jsp - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward deleteOnlineFile(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + /** + * deletes an online file from the jsp + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward deleteOnlineFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - VoteUtils.cleanUpUserExceptions(request); - logger.debug("dispatching deleteOnlineFile..."); - - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); + VoteUtils.cleanUpUserExceptions(request); + VoteAction.logger.debug("dispatching deleteOnlineFile..."); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - logger.debug("voteAuthoringForm :" +voteAuthoringForm); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - Map mapOptionsContent=(Map)sessionMap.get(MAP_OPTIONS_CONTENT_KEY); - logger.debug("mapOptionsContent: " + mapOptionsContent); - voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - - int maxIndex=mapOptionsContent.size(); - logger.debug("maxIndex: " + maxIndex); - voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - - String firstEntry=(String)mapOptionsContent.get("1"); - logger.debug("firstEntry: " + firstEntry); - voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); - + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + VoteAction.logger.debug("voteAuthoringForm :" + voteAuthoringForm); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); - voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceVoteStarter = (String) request.getAttribute(SOURCE_VOTE_STARTER); - logger.debug("sourceVoteStarter: " + sourceVoteStarter); - String destination=VoteUtils.getDestination(sourceVoteStarter); - logger.debug("destination: " + destination); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); - - String uuid =voteAuthoringForm.getUuid(); - logger.debug("uuid:" + uuid); - - List listOnlineFilesMetaData =(List)sessionMap.get(LIST_ONLINEFILES_METADATA_KEY); - logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); - listOnlineFilesMetaData=AuthoringUtil.removeFileItem(listOnlineFilesMetaData, uuid); - logger.debug("listOnlineFilesMetaData after remove:" + listOnlineFilesMetaData); - sessionMap.put(LIST_ONLINEFILES_METADATA_KEY, listOnlineFilesMetaData); - - voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); - - List listOfflineFilesMetaData =(List)sessionMap.get(LIST_OFFLINEFILES_METADATA_KEY); - logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); - voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("persisting sessionMap into session: " + sessionMap); - request.getSession().setAttribute(httpSessionID, sessionMap); - - voteAuthoringForm.resetUserAction(); - - return (mapping.findForward(destination)); + Map mapOptionsContent = (Map) sessionMap.get(VoteAppConstants.MAP_OPTIONS_CONTENT_KEY); + VoteAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); + + int maxIndex = mapOptionsContent.size(); + VoteAction.logger.debug("maxIndex: " + maxIndex); + voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); + + String firstEntry = (String) mapOptionsContent.get("1"); + VoteAction.logger.debug("firstEntry: " + firstEntry); + voteGeneralAuthoringDTO.setDefaultOptionContent(firstEntry); + + voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); + voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); + + /* determine whether the request is from Monitoring url Edit Activity */ + String sourceVoteStarter = (String) request.getAttribute(VoteAppConstants.SOURCE_VOTE_STARTER); + VoteAction.logger.debug("sourceVoteStarter: " + sourceVoteStarter); + String destination = VoteUtils.getDestination(sourceVoteStarter); + VoteAction.logger.debug("destination: " + destination); + + VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap); + + String uuid = voteAuthoringForm.getUuid(); + VoteAction.logger.debug("uuid:" + uuid); + + List listOnlineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_ONLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); + listOnlineFilesMetaData = AuthoringUtil.removeFileItem(listOnlineFilesMetaData, uuid); + VoteAction.logger.debug("listOnlineFilesMetaData after remove:" + listOnlineFilesMetaData); + sessionMap.put(VoteAppConstants.LIST_ONLINEFILES_METADATA_KEY, listOnlineFilesMetaData); + + voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + + VoteAction.logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); + + List listOfflineFilesMetaData = (List) sessionMap.get(VoteAppConstants.LIST_OFFLINEFILES_METADATA_KEY); + VoteAction.logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); + voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("persisting sessionMap into session: " + sessionMap); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteAuthoringForm.resetUserAction(); + + return mapping.findForward(destination); } /** @@ -623,201 +596,187 @@ * @throws ServletException * @throws ToolException */ - public ActionForward editActivityQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - ToolException - { - logger.debug("dispatching editActivityQuestions..."); - - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - logger.debug("voteAuthoringForm: " + voteAuthoringForm); - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); + public ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteAction.logger.debug("dispatching editActivityQuestions..."); - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + VoteAction.logger.debug("voteAuthoringForm: " + voteAuthoringForm); - String activeModule=DEFINE_LATER; - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - - logger.debug("title: " + voteContent.getTitle()); - logger.debug("instructions: " + voteContent.getInstructions()); - - voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); - voteAuthoringForm.setTitle(voteContent.getTitle()); - - voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); - - sessionMap.put(ACTIVITY_TITLE_KEY, voteContent.getTitle()); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, voteContent.getInstructions()); - - voteAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + voteAuthoringForm.setHttpSessionID(httpSessionID); - VoteUtils.setDefineLater(request, true, strToolContentID, voteService); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("1"); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - List listNominationContentDTO= new LinkedList(); + String activeModule = VoteAppConstants.DEFINE_LATER; - Iterator queIterator=voteContent.getVoteQueContents().iterator(); - while (queIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO=new VoteNominationContentDTO(); - - VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); - if (voteQueContent != null) - { - logger.debug("question: " + voteQueContent.getQuestion()); - logger.debug("displayorder: " + new Integer(voteQueContent.getDisplayOrder()).toString()); - - voteNominationContentDTO.setQuestion(voteQueContent.getQuestion()); - voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); - //voteNominationContentDTO.setFeedback(voteQueContent.getFeedback()); - listNominationContentDTO.add(voteNominationContentDTO); - } - } - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - request.getSession().setAttribute(httpSessionID, sessionMap); - - logger.debug("before fwding to jsp, voteAuthoringForm: " + voteAuthoringForm); - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); - logger.debug("forwarding to : " + LOAD_QUESTIONS); - return mapping.findForward(LOAD_QUESTIONS); - } + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + VoteAction.logger.debug("title: " + voteContent.getTitle()); + VoteAction.logger.debug("instructions: " + voteContent.getInstructions()); + + voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); + voteAuthoringForm.setTitle(voteContent.getTitle()); + + voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, voteContent.getTitle()); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, voteContent.getInstructions()); + + voteAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteAction.logger.debug("isContentInUse:" + isContentInUse); + + VoteUtils.setDefineLater(request, true, strToolContentID, voteService); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("1"); + + List listNominationContentDTO = new LinkedList(); + + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + while (queIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO(); + + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + VoteAction.logger.debug("question: " + voteQueContent.getQuestion()); + VoteAction.logger.debug("displayorder: " + new Integer(voteQueContent.getDisplayOrder()).toString()); + + voteNominationContentDTO.setQuestion(voteQueContent.getQuestion()); + voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); + // voteNominationContentDTO.setFeedback(voteQueContent.getFeedback()); + listNominationContentDTO.add(voteNominationContentDTO); + } + } + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + request.getSession().setAttribute(httpSessionID, sessionMap); + + VoteAction.logger.debug("before fwding to jsp, voteAuthoringForm: " + voteAuthoringForm); + VoteAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("forwarding to : " + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); + } + /** - * repopulateRequestParameters - * reads and saves request parameters + * repopulateRequestParameters reads and saves request parameters * * @param request * @param voteAuthoringForm * @param voteGeneralAuthoringDTO */ - protected void repopulateRequestParameters(HttpServletRequest request, VoteAuthoringForm voteAuthoringForm, - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) - { - logger.debug("starting repopulateRequestParameters"); - - String toolContentID=request.getParameter(TOOL_CONTENT_ID); - logger.debug("toolContentID: " + toolContentID); - voteAuthoringForm.setToolContentID(toolContentID); - voteGeneralAuthoringDTO.setToolContentID(toolContentID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - voteAuthoringForm.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - - String httpSessionID=request.getParameter(HTTP_SESSION_ID); - logger.debug("httpSessionID: " + httpSessionID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + protected void repopulateRequestParameters(HttpServletRequest request, VoteAuthoringForm voteAuthoringForm, + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) { + VoteAction.logger.debug("starting repopulateRequestParameters"); - String defineLaterInEditMode=request.getParameter(DEFINE_LATER_IN_EDIT_MODE); - logger.debug("defineLaterInEditMode: " + defineLaterInEditMode); - voteAuthoringForm.setDefineLaterInEditMode(defineLaterInEditMode); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(defineLaterInEditMode); - - String lockOnFinish=request.getParameter(LOCK_ON_FINISH); - logger.debug("lockOnFinish: " + lockOnFinish); - voteAuthoringForm.setLockOnFinish(lockOnFinish); - voteGeneralAuthoringDTO.setLockOnFinish(lockOnFinish); - - String allowText=request.getParameter(ALLOW_TEXT); - logger.debug("allowText: " + allowText); - voteAuthoringForm.setAllowText(allowText); - voteGeneralAuthoringDTO.setAllowText(allowText); - - String showResults=request.getParameter(SHOW_RESULTS); - logger.debug("showResults: " + showResults); - voteAuthoringForm.setShowResults(showResults); - voteGeneralAuthoringDTO.setShowResults(showResults); + String toolContentID = request.getParameter(VoteAppConstants.TOOL_CONTENT_ID); + VoteAction.logger.debug("toolContentID: " + toolContentID); + voteAuthoringForm.setToolContentID(toolContentID); + voteGeneralAuthoringDTO.setToolContentID(toolContentID); - String maxNominationCount=request.getParameter(MAX_NOMINATION_COUNT); - logger.debug("maxNominationCount: " + maxNominationCount); - voteAuthoringForm.setMaxNominationCount(maxNominationCount); - voteGeneralAuthoringDTO.setMaxNominationCount(maxNominationCount); - - String reflect=request.getParameter("reflect"); - logger.debug("reflect: " + reflect); - voteAuthoringForm.setReflect(reflect); - voteGeneralAuthoringDTO.setReflect(reflect); + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + voteAuthoringForm.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setActiveModule(activeModule); - String reflectionSubject=request.getParameter("reflectionSubject"); - logger.debug("reflectionSubject: " + reflectionSubject); - voteAuthoringForm.setReflectionSubject(reflectionSubject); - voteGeneralAuthoringDTO.setReflectionSubject(reflectionSubject); + String httpSessionID = request.getParameter(VoteAppConstants.HTTP_SESSION_ID); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + String defineLaterInEditMode = request.getParameter(VoteAppConstants.DEFINE_LATER_IN_EDIT_MODE); + VoteAction.logger.debug("defineLaterInEditMode: " + defineLaterInEditMode); + voteAuthoringForm.setDefineLaterInEditMode(defineLaterInEditMode); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(defineLaterInEditMode); - String offlineInstructions=request.getParameter(OFFLINE_INSTRUCTIONS); - logger.debug("offlineInstructions: " + offlineInstructions); - voteAuthoringForm.setOfflineInstructions(offlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + String lockOnFinish = request.getParameter(VoteAppConstants.LOCK_ON_FINISH); + VoteAction.logger.debug("lockOnFinish: " + lockOnFinish); + voteAuthoringForm.setLockOnFinish(lockOnFinish); + voteGeneralAuthoringDTO.setLockOnFinish(lockOnFinish); - String onlineInstructions=request.getParameter(ONLINE_INSTRUCTIONS); - logger.debug("onlineInstructions: " + onlineInstructions); - voteAuthoringForm.setOnlineInstructions(onlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - } - - + String allowText = request.getParameter(VoteAppConstants.ALLOW_TEXT); + VoteAction.logger.debug("allowText: " + allowText); + voteAuthoringForm.setAllowText(allowText); + voteGeneralAuthoringDTO.setAllowText(allowText); + + String showResults = request.getParameter(VoteAppConstants.SHOW_RESULTS); + VoteAction.logger.debug("showResults: " + showResults); + voteAuthoringForm.setShowResults(showResults); + voteGeneralAuthoringDTO.setShowResults(showResults); + + String maxNominationCount = request.getParameter(VoteAppConstants.MAX_NOMINATION_COUNT); + VoteAction.logger.debug("maxNominationCount: " + maxNominationCount); + voteAuthoringForm.setMaxNominationCount(maxNominationCount); + voteGeneralAuthoringDTO.setMaxNominationCount(maxNominationCount); + + String reflect = request.getParameter("reflect"); + VoteAction.logger.debug("reflect: " + reflect); + voteAuthoringForm.setReflect(reflect); + voteGeneralAuthoringDTO.setReflect(reflect); + + String reflectionSubject = request.getParameter("reflectionSubject"); + VoteAction.logger.debug("reflectionSubject: " + reflectionSubject); + voteAuthoringForm.setReflectionSubject(reflectionSubject); + voteGeneralAuthoringDTO.setReflectionSubject(reflectionSubject); + + String offlineInstructions = request.getParameter(VoteAppConstants.OFFLINE_INSTRUCTIONS); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteAuthoringForm.setOfflineInstructions(offlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + String onlineInstructions = request.getParameter(VoteAppConstants.ONLINE_INSTRUCTIONS); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + voteAuthoringForm.setOnlineInstructions(onlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + } + /** * persists error messages to request scope + * * @param request * @param message */ - public void persistInRequestError(HttpServletRequest request, String message) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY, new ActionMessage(message)); - logger.debug("add " + message +" to ActionMessages:"); - saveErrors(request,errors); - } - - + public void persistInRequestError(HttpServletRequest request, String message) { + ActionMessages errors = new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + VoteAction.logger.debug("add " + message + " to ActionMessages:"); + saveErrors(request, errors); + } + /** * moveNominationDown * * moves a nomination down in the authoring list + * * @param mapping * @param form * @param request @@ -826,133 +785,125 @@ * @throws IOException * @throws ServletException */ - public ActionForward moveNominationDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching moveNominationDown"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); + public ActionForward moveNominationDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispatching moveNominationDown"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "down"); - logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); - logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("1"); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - + String questionIndex = request.getParameter("questionIndex"); + VoteAction.logger.debug("questionIndex: " + questionIndex); - logger.debug("fwd ing to LOAD_NOMINATIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); - } + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "down"); + VoteAction.logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); + listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); + VoteAction.logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); + + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("1"); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + VoteAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + VoteAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("fwd ing to LOAD_NOMINATIONS: " + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); + } + /** * moveNominationUp * * moves a nomination up in the authoring list + * * @param mapping * @param form * @param request @@ -961,132 +912,125 @@ * @throws IOException * @throws ServletException */ - public ActionForward moveNominationUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching moveNominationUp"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "up"); - logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); - logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); + public ActionForward moveNominationUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispatching moveNominationUp"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("1"); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - logger.debug("fwd ing to LOAD_NOMINATIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + String questionIndex = request.getParameter("questionIndex"); + VoteAction.logger.debug("questionIndex: " + questionIndex); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "up"); + VoteAction.logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); + + listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); + VoteAction.logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); + + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("1"); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + VoteAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + VoteAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("fwd ing to LOAD_NOMINATIONS: " + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); } - - + /** * removeNomination * * removes a nomination from the authoring list + * * @param mapping * @param form * @param request @@ -1095,154 +1039,144 @@ * @throws IOException * @throws ServletException */ - public ActionForward removeNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching removeNomination"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - VoteNominationContentDTO voteNominationContentDTO= null; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - String question=voteNominationContentDTO.getNomination(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - break; - } - - } - } - - logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - voteNominationContentDTO.setNomination(""); - logger.debug("listNominationContentDTO after remove:" + listNominationContentDTO); - - - listNominationContentDTO=AuthoringUtil.reorderListNominationContentDTO(listNominationContentDTO, questionIndex ); - logger.debug("listNominationContentDTO reordered:" + listNominationContentDTO); - - - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + public ActionForward removeNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispatching removeNomination"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + + String questionIndex = request.getParameter("questionIndex"); + VoteAction.logger.debug("questionIndex: " + questionIndex); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + VoteNominationContentDTO voteNominationContentDTO = null; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteAction.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + + String question = voteNominationContentDTO.getNomination(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + VoteAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + break; } - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("1"); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - logger.debug("voteNominationContentDTO now: " + voteNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + + } + } + + VoteAction.logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); + voteNominationContentDTO.setNomination(""); + VoteAction.logger.debug("listNominationContentDTO after remove:" + listNominationContentDTO); + + listNominationContentDTO = AuthoringUtil.reorderListNominationContentDTO(listNominationContentDTO, + questionIndex); + VoteAction.logger.debug("listNominationContentDTO reordered:" + listNominationContentDTO); + + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("1"); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + VoteAction.logger.debug("voteNominationContentDTO now: " + voteNominationContentDTO); + VoteAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + VoteAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); } - + /** * newEditableNominationBox * * enables editing a nomination + * * @param mapping * @param form * @param request @@ -1251,119 +1185,109 @@ * @throws IOException * @throws ServletException */ - public ActionForward newEditableNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing newEditableNominationBox"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + public ActionForward newEditableNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispathcing newEditableNominationBox"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - voteAuthoringForm.setEditableNominationIndex(questionIndex); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - String editableNomination=""; - String editableFeedback=""; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - String question=voteNominationContentDTO.getNomination(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - editableFeedback=voteNominationContentDTO.getFeedback(); - editableNomination=voteNominationContentDTO.getNomination(); - logger.debug("editableFeedback found :" + editableFeedback); - break; - } - - } - } - logger.debug("editableFeedback found :" + editableFeedback); - logger.debug("editableNomination found :" + editableNomination); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + String questionIndex = request.getParameter("questionIndex"); + VoteAction.logger.debug("questionIndex: " + questionIndex); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + voteAuthoringForm.setEditableNominationIndex(questionIndex); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + String editableNomination = ""; + String editableFeedback = ""; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteAction.logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); + String question = voteNominationContentDTO.getNomination(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - - voteGeneralAuthoringDTO.setEditableNominationText(editableNomination); - voteGeneralAuthoringDTO.setEditableNominationFeedback (editableFeedback); - voteAuthoringForm.setFeedback(editableFeedback); + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + editableFeedback = voteNominationContentDTO.getFeedback(); + editableNomination = voteNominationContentDTO.getNomination(); + VoteAction.logger.debug("editableFeedback found :" + editableFeedback); + break; + } - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); } - - logger.debug("fwd ing to editNominationBox: "); - return (mapping.findForward("editNominationBox")); - } + } + VoteAction.logger.debug("editableFeedback found :" + editableFeedback); + VoteAction.logger.debug("editableNomination found :" + editableNomination); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + voteGeneralAuthoringDTO.setEditableNominationText(editableNomination); + voteGeneralAuthoringDTO.setEditableNominationFeedback(editableFeedback); + voteAuthoringForm.setFeedback(editableFeedback); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + VoteAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + VoteAction.logger.debug("fwd ing to editNominationBox: "); + return mapping.findForward("editNominationBox"); + } + /** * newNominationBox * * enables adding a new nomination + * * @param mapping * @param form * @param request @@ -1372,82 +1296,78 @@ * @throws IOException * @throws ServletException */ - public ActionForward newNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing newNominationBox"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + public ActionForward newNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispathcing newNominationBox"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - logger.debug("fwd ing to newNominationBox: "); - return (mapping.findForward("newNominationBox")); + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + VoteAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("fwd ing to newNominationBox: "); + return mapping.findForward("newNominationBox"); } /** * addSingleNomination * * enables adding a new nomination to the authoring nominations list + * * @param mapping * @param form * @param request @@ -1456,684 +1376,628 @@ * @throws IOException * @throws ServletException */ - public ActionForward addSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispathcing addSingleNomination"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - String newNomination=request.getParameter("newNomination"); - logger.debug("newNomination: " + newNomination); - - String feedback=request.getParameter("feedback"); - logger.debug("feedback: " + feedback); - - - int listSize=listNominationContentDTO.size(); - logger.debug("listSize: " + listSize); - - if ((newNomination != null) && (newNomination.length() > 0)) - { - boolean duplicates=AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - VoteNominationContentDTO voteNominationContentDTO=new VoteNominationContentDTO(); - voteNominationContentDTO.setDisplayOrder(new Long(listSize+1).toString()); - voteNominationContentDTO.setFeedback(feedback); - voteNominationContentDTO.setNomination(newNomination); - - listNominationContentDTO.add(voteNominationContentDTO); - logger.debug("updated listNominationContentDTO: " + listNominationContentDTO); - } - else - { - logger.debug("entry duplicate, not adding"); + public ActionForward addSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispathcing addSingleNomination"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - } - } - else - { - logger.debug("entry blank, not adding"); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - } - - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - - String richTextTitle=(String)sessionMap.get(ACTIVITY_TITLE_KEY); - logger.debug("richTextTitle: " + richTextTitle); - String richTextInstructions=(String)sessionMap.get(ACTIVITY_INSTRUCTIONS_KEY); - logger.debug("richTextInstructions: " + richTextInstructions); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOfflineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + String newNomination = request.getParameter("newNomination"); + VoteAction.logger.debug("newNomination: " + newNomination); + + String feedback = request.getParameter("feedback"); + VoteAction.logger.debug("feedback: " + feedback); + + int listSize = listNominationContentDTO.size(); + VoteAction.logger.debug("listSize: " + listSize); + + if (newNomination != null && newNomination.length() > 0) { + boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); + VoteAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO(); + voteNominationContentDTO.setDisplayOrder(new Long(listSize + 1).toString()); + voteNominationContentDTO.setFeedback(feedback); + voteNominationContentDTO.setNomination(newNomination); + + listNominationContentDTO.add(voteNominationContentDTO); + VoteAction.logger.debug("updated listNominationContentDTO: " + listNominationContentDTO); + } else { + VoteAction.logger.debug("entry duplicate, not adding"); + } - - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("1"); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + voteGeneralAuthoringDTO.getMapNominationContent()); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + } else { + VoteAction.logger.debug("entry blank, not adding"); + } - - - /** - * saveSingleNomination - * saves a new or updated nomination in the authoring nominations list - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward saveSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing saveSingleNomination"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - - String editNominationBoxRequest=request.getParameter("editNominationBoxRequest"); - logger.debug("editNominationBoxRequest: " + editNominationBoxRequest); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - - String newNomination=request.getParameter("newNomination"); - logger.debug("newNomination: " + newNomination); - - String feedback=request.getParameter("feedback"); - logger.debug("feedback: " + feedback); - - String editableNominationIndex=request.getParameter("editableNominationIndex"); - logger.debug("editableNominationIndex: " + editableNominationIndex); - + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - if ((newNomination != null) && (newNomination.length() > 0)) - { - if ((editNominationBoxRequest != null) && (editNominationBoxRequest.equals("false"))) - { - logger.debug("request for add and save"); - boolean duplicates=AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - VoteNominationContentDTO voteNominationContentDTO= null; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getQuestion()); - - String question=voteNominationContentDTO.getNomination(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableNominationIndex)) - { - break; - } - - } - } - logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - - voteNominationContentDTO.setQuestion(newNomination); - voteNominationContentDTO.setFeedback(feedback); - voteNominationContentDTO.setDisplayOrder(editableNominationIndex); - - listNominationContentDTO=AuthoringUtil.reorderUpdateListNominationContentDTO(listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); - logger.debug("post reorderUpdateListNominationContentDTO listNominationContentDTO: " + listNominationContentDTO); - } - else - { - logger.debug("duplicate question entry, not adding"); - } - } - else - { - logger.debug("request for edit and save."); - VoteNominationContentDTO voteNominationContentDTO= null; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - String question=voteNominationContentDTO.getNomination(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableNominationIndex)) - { - break; - } - - } - } - logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - - voteNominationContentDTO.setNomination(newNomination); - voteNominationContentDTO.setFeedback(feedback); - voteNominationContentDTO.setDisplayOrder(editableNominationIndex); - - listNominationContentDTO=AuthoringUtil.reorderUpdateListNominationContentDTO(listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); - logger.debug("post reorderUpdateListNominationContentDTO listNominationContentDTO: " + listNominationContentDTO); - } - } - else - { - logger.debug("entry blank, not adding"); - } - + String richTextTitle = (String) sessionMap.get(VoteAppConstants.ACTIVITY_TITLE_KEY); + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + String richTextInstructions = (String) sessionMap.get(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - - String richTextTitle=(String)sessionMap.get(ACTIVITY_TITLE_KEY); - logger.debug("richTextTitle: " + richTextTitle); - String richTextInstructions=(String)sessionMap.get(ACTIVITY_INSTRUCTIONS_KEY); - logger.debug("richTextInstructions: " + richTextInstructions); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOfflineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOfflineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("1"); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + VoteAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + VoteAction.logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + + voteGeneralAuthoringDTO.getMapNominationContent()); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); + } + + /** + * saveSingleNomination saves a new or updated nomination in the authoring nominations list + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward saveSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + VoteAction.logger.debug("dispathcing saveSingleNomination"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); + + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + String editNominationBoxRequest = request.getParameter("editNominationBoxRequest"); + VoteAction.logger.debug("editNominationBoxRequest: " + editNominationBoxRequest); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + String newNomination = request.getParameter("newNomination"); + VoteAction.logger.debug("newNomination: " + newNomination); + + String feedback = request.getParameter("feedback"); + VoteAction.logger.debug("feedback: " + feedback); + + String editableNominationIndex = request.getParameter("editableNominationIndex"); + VoteAction.logger.debug("editableNominationIndex: " + editableNominationIndex); + + if (newNomination != null && newNomination.length() > 0) { + if (editNominationBoxRequest != null && editNominationBoxRequest.equals("false")) { + VoteAction.logger.debug("request for add and save"); + boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); + VoteAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + VoteNominationContentDTO voteNominationContentDTO = null; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteAction.logger.debug("voteNominationContentDTO question:" + + voteNominationContentDTO.getQuestion()); + + String question = voteNominationContentDTO.getNomination(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + VoteAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableNominationIndex)) { + break; + } + + } + } + VoteAction.logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); + + voteNominationContentDTO.setQuestion(newNomination); + voteNominationContentDTO.setFeedback(feedback); + voteNominationContentDTO.setDisplayOrder(editableNominationIndex); + + listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO( + listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); + VoteAction.logger.debug("post reorderUpdateListNominationContentDTO listNominationContentDTO: " + + listNominationContentDTO); + } else { + VoteAction.logger.debug("duplicate question entry, not adding"); + } + } else { + VoteAction.logger.debug("request for edit and save."); + VoteNominationContentDTO voteNominationContentDTO = null; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteAction.logger.debug("voteNominationContentDTO question:" + + voteNominationContentDTO.getNomination()); + + String question = voteNominationContentDTO.getNomination(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + VoteAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableNominationIndex)) { + break; + } + + } + } + VoteAction.logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); + + voteNominationContentDTO.setNomination(newNomination); + voteNominationContentDTO.setFeedback(feedback); + voteNominationContentDTO.setDisplayOrder(editableNominationIndex); + + listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO( + listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); + VoteAction.logger.debug("post reorderUpdateListNominationContentDTO listNominationContentDTO: " + + listNominationContentDTO); } - - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("1"); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); - logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + voteGeneralAuthoringDTO.getMapNominationContent()); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + } else { + VoteAction.logger.debug("entry blank, not adding"); } - /** - * submitAllContent - * - * persists the nominations list and other user selections in the db. - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispathcing submitAllContent :" +form); - - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - Map mapNominationContent=AuthoringUtil.extractMapNominationContent(listNominationContentDTO); - logger.debug("extracted mapNominationContent: " + mapNominationContent); - - - Map mapFeedback=AuthoringUtil.extractMapFeedback(listNominationContentDTO); - logger.debug("extracted mapFeedback: " + mapFeedback); - - ActionMessages errors = new ActionMessages(); - logger.debug("mapNominationContent size: " + mapNominationContent.size()); - - if (mapNominationContent.size() == 0) - { - ActionMessage error = new ActionMessage("nominations.none.submitted"); + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + VoteAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + String richTextTitle = (String) sessionMap.get(VoteAppConstants.ACTIVITY_TITLE_KEY); + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + String richTextInstructions = (String) sessionMap.get(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOfflineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + + } + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("1"); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + VoteAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + VoteAction.logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + + voteGeneralAuthoringDTO.getMapNominationContent()); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); + } + + /** + * submitAllContent + * + * persists the nominations list and other user selections in the db. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispathcing submitAllContent :" + form); + + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); + + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + Map mapNominationContent = AuthoringUtil.extractMapNominationContent(listNominationContentDTO); + VoteAction.logger.debug("extracted mapNominationContent: " + mapNominationContent); + + Map mapFeedback = AuthoringUtil.extractMapFeedback(listNominationContentDTO); + VoteAction.logger.debug("extracted mapFeedback: " + mapFeedback); + + ActionMessages errors = new ActionMessages(); + VoteAction.logger.debug("mapNominationContent size: " + mapNominationContent.size()); + + if (mapNominationContent.size() == 0) { + ActionMessage error = new ActionMessage("nominations.none.submitted"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + String maxNomCount = voteAuthoringForm.getMaxNominationCount(); + VoteAction.logger.debug("maxNomCount:" + maxNomCount); + + if (activeModule != null) { + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + if (maxNomCount != null) { + if (maxNomCount.equals("0") || maxNomCount.contains("-")) { + ActionMessage error = new ActionMessage("maxNomination.invalid"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - - - String maxNomCount=voteAuthoringForm.getMaxNominationCount(); - logger.debug("maxNomCount:" + maxNomCount); - - if (activeModule != null) - { - if (activeModule.equals(AUTHORING)) - { - if (maxNomCount != null) - { - if (maxNomCount.equals("0") || maxNomCount.contains("-")) - { - ActionMessage error = new ActionMessage("maxNomination.invalid"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - - try - { - int intMaxNomCount=new Integer(maxNomCount).intValue(); - logger.debug("intMaxNomCount : " +intMaxNomCount); - } - catch(NumberFormatException e) - { - ActionMessage error = new ActionMessage("maxNomination.invalid"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - } } + + try { + int intMaxNomCount = new Integer(maxNomCount).intValue(); + VoteAction.logger.debug("intMaxNomCount : " + intMaxNomCount); + } catch (NumberFormatException e) { + ActionMessage error = new ActionMessage("maxNomination.invalid"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + } } - - boolean nominationsDuplicate=AuthoringUtil.verifyDuplicateNominations(mapNominationContent); - logger.debug("nominationsDuplicate :" +nominationsDuplicate); - - if (nominationsDuplicate == true) - { - ActionMessage error = new ActionMessage("nominations.duplicate"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + boolean nominationsDuplicate = AuthoringUtil.verifyDuplicateNominations(mapNominationContent); + VoteAction.logger.debug("nominationsDuplicate :" + nominationsDuplicate); + + if (nominationsDuplicate == true) { + ActionMessage error = new ActionMessage("nominations.duplicate"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + VoteAction.logger.debug("errors: " + errors); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + List attachmentListBackup = new ArrayList(); + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + attachmentListBackup = attachmentList; + + List deletedAttachmentListBackup = new ArrayList(); + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + deletedAttachmentListBackup = deletedAttachmentList; + + String onlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOfflineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + + } + + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + + VoteAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteAction.logger.debug("there are no issues with input, continue and submit data"); + + VoteContent voteContentTest = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContentTest: " + voteContentTest); + + VoteAction.logger.debug("errors: " + errors); + if (!errors.isEmpty()) { + saveErrors(request, errors); + VoteAction.logger.debug("errors saved: " + errors); + } + + VoteContent voteContent = voteContentTest; + if (errors.isEmpty()) { + VoteAction.logger.debug("errors is empty: " + errors); + /* to remove deleted entries in the questions table based on mapNominationContent */ + authoringUtil.removeRedundantNominations(mapNominationContent, voteService, voteAuthoringForm, request, + strToolContentID); + VoteAction.logger.debug("end of removing unused entries... "); + DataFlowObject assignedDataFlowObject = null; + if (voteAuthoringForm.getAssignedDataFlowObject() != null + && voteAuthoringForm.getAssignedDataFlowObject() != 0) { + List dataFlowObjects = voteService.getDataFlowObjects(new Long(strToolContentID)); + assignedDataFlowObject = dataFlowObjects.get(voteAuthoringForm.getAssignedDataFlowObject() - 1); } - - logger.debug("errors: " + errors); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - List attachmentListBackup= new ArrayList(); - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - attachmentListBackup=attachmentList; - - List deletedAttachmentListBackup= new ArrayList(); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - deletedAttachmentListBackup=deletedAttachmentList; - - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - voteGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOfflineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - + + voteContent = authoringUtil.saveOrUpdateVoteContent(mapNominationContent, mapFeedback, voteService, + voteAuthoringForm, request, voteContentTest, strToolContentID, assignedDataFlowObject); + VoteAction.logger.debug("voteContent: " + voteContent); + + long defaultContentID = 0; + VoteAction.logger.debug("attempt retrieving tool with signatute : " + VoteAppConstants.MY_SIGNATURE); + defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); + VoteAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (voteContent != null) { + voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); } - - - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("there are no issues with input, continue and submit data"); - - VoteContent voteContentTest=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContentTest: " + voteContentTest); - - logger.debug("errors: " + errors); - if(!errors.isEmpty()){ - saveErrors(request, errors); - logger.debug("errors saved: " + errors); + VoteAction.logger.debug("updated voteGeneralAuthoringDTO to: " + voteGeneralAuthoringDTO); + + authoringUtil.reOrganizeDisplayOrder(mapNominationContent, voteService, voteAuthoringForm, voteContent); + + VoteAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + VoteAction.logger.debug("since it is authoring save the attachments: "); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + + List attachments = saveAttachments(voteContent, attachmentList, deletedAttachmentList, mapping, request); + VoteAction.logger.debug("attachments: " + attachments); + } + + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + VoteUtils.setDefineLater(request, false, strToolContentID, voteService); + VoteAction.logger.debug("define later set to false"); + + if (activeModule.equals(VoteAppConstants.AUTHORING)) { + VoteAction.logger.debug("standard authoring close"); + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + } else { + VoteAction.logger.debug("go back to view only screen"); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + } + + } else { + VoteAction.logger.debug("errors is not empty: " + errors); + + if (voteContent != null) { + long defaultContentID = 0; + VoteAction.logger.debug("attempt retrieving tool with signatute : " + VoteAppConstants.MY_SIGNATURE); + defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); + VoteAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (voteContent != null) { + voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); } - - - VoteContent voteContent=voteContentTest; - if(errors.isEmpty()){ - logger.debug("errors is empty: " + errors); - /*to remove deleted entries in the questions table based on mapNominationContent */ - authoringUtil.removeRedundantNominations(mapNominationContent, voteService, voteAuthoringForm, request, strToolContentID); - logger.debug("end of removing unused entries... "); - - voteContent=authoringUtil.saveOrUpdateVoteContent(mapNominationContent, mapFeedback, voteService, voteAuthoringForm, request, voteContentTest, strToolContentID); - logger.debug("voteContent: " + voteContent); - - - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=voteService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (voteContent != null) - { - voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } - logger.debug("updated voteGeneralAuthoringDTO to: " + voteGeneralAuthoringDTO); - - authoringUtil.reOrganizeDisplayOrder(mapNominationContent, voteService, voteAuthoringForm, voteContent); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - logger.debug("since it is authoring save the attachments: "); - - List attachmentList= (List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - - List attachments=saveAttachments(voteContent,attachmentList, deletedAttachmentList, mapping, request); - logger.debug("attachments: " + attachments); - } - - logger.debug("strToolContentID: " + strToolContentID); - VoteUtils.setDefineLater(request, false, strToolContentID, voteService); - logger.debug("define later set to false"); - - if (activeModule.equals(AUTHORING)) - { - logger.debug("standard authoring close"); - request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG,Boolean.TRUE); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - } - else - { - logger.debug("go back to view only screen"); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); - } - - } - else - { - logger.debug("errors is not empty: " + errors); - - if (voteContent != null) - { - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=voteService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (voteContent != null) - { - voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } - - } - } - - - voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); - - voteAuthoringForm.resetUserAction(); - voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); - - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - request.getSession().setAttribute(httpSessionID, sessionMap); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("1"); - - logger.debug("forwarding to :" + LOAD_QUESTIONS); - return mapping.findForward(LOAD_QUESTIONS); + + } + } + + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); + + voteAuthoringForm.resetUserAction(); + voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); + + VoteAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + request.getSession().setAttribute(httpSessionID, sessionMap); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("1"); + + VoteAction.logger.debug("forwarding to :" + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); } - - - private VoteToolContentHandler getToolContentHandler() - { - if ( toolContentHandler == null ) { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); - toolContentHandler = (VoteToolContentHandler) wac.getBean("voteToolContentHandler"); - } - return toolContentHandler; + private VoteToolContentHandler getToolContentHandler() { + if (toolContentHandler == null) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + toolContentHandler = (VoteToolContentHandler) wac.getBean("voteToolContentHandler"); + } + return toolContentHandler; } - + /** * saveAttachments * @@ -2146,56 +2010,53 @@ * @param request * @return */ - private List saveAttachments (VoteContent voteContent, - List attachmentList, List deletedAttachmentList, - ActionMapping mapping, HttpServletRequest request) { + private List saveAttachments(VoteContent voteContent, List attachmentList, List deletedAttachmentList, + ActionMapping mapping, HttpServletRequest request) { - logger.debug("start saveAttachments, attachmentList " + attachmentList); - logger.debug("start deletedAttachmentList, deletedAttachmentList " + deletedAttachmentList); - - if(attachmentList==null || deletedAttachmentList==null) - return null; - - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - if ( deletedAttachmentList != null ) { - logger.debug("deletedAttachmentList is iterated..."); - Iterator iter = deletedAttachmentList.iterator(); - while (iter.hasNext()) { - VoteUploadedFile attachment = (VoteUploadedFile) iter.next(); - logger.debug("attachment: " + attachment); - - if ( attachment.getSubmissionId() != null ) { - voteService.removeFile(attachment.getSubmissionId()); - } - } - deletedAttachmentList.clear(); - logger.error("cleared attachment list."); - } - - - if ( attachmentList != null ) - { - logger.debug("attachmentList is iterated..."); - Iterator iter = attachmentList.iterator(); - while (iter.hasNext()) { - VoteUploadedFile attachment = (VoteUploadedFile) iter.next(); - logger.debug("attachment: " + attachment); - logger.debug("attachment submission id: " + attachment.getSubmissionId()); + VoteAction.logger.debug("start saveAttachments, attachmentList " + attachmentList); + VoteAction.logger.debug("start deletedAttachmentList, deletedAttachmentList " + deletedAttachmentList); - if ( attachment.getSubmissionId() == null ) { - /* add entry to tool table - file already in content repository */ - logger.debug("calling persistFile with attachment: " + attachment); - voteService.persistFile(voteContent, attachment); - } - } - } - - return deletedAttachmentList; + if (attachmentList == null || deletedAttachmentList == null) { + return null; + } + + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); + + if (deletedAttachmentList != null) { + VoteAction.logger.debug("deletedAttachmentList is iterated..."); + Iterator iter = deletedAttachmentList.iterator(); + while (iter.hasNext()) { + VoteUploadedFile attachment = (VoteUploadedFile) iter.next(); + VoteAction.logger.debug("attachment: " + attachment); + + if (attachment.getSubmissionId() != null) { + voteService.removeFile(attachment.getSubmissionId()); + } + } + deletedAttachmentList.clear(); + VoteAction.logger.error("cleared attachment list."); + } + + if (attachmentList != null) { + VoteAction.logger.debug("attachmentList is iterated..."); + Iterator iter = attachmentList.iterator(); + while (iter.hasNext()) { + VoteUploadedFile attachment = (VoteUploadedFile) iter.next(); + VoteAction.logger.debug("attachment: " + attachment); + VoteAction.logger.debug("attachment submission id: " + attachment.getSubmissionId()); + + if (attachment.getSubmissionId() == null) { + /* add entry to tool table - file already in content repository */ + VoteAction.logger.debug("calling persistFile with attachment: " + attachment); + voteService.persistFile(voteContent, attachment); + } + } + } + + return deletedAttachmentList; } - - + /** * deleteFile * @@ -2209,136 +2070,125 @@ * @throws IOException * @throws ServletException */ - public ActionForward deleteFile(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching deleteFile"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); + public ActionForward deleteFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispatching deleteFile"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - String httpSessionID=request.getParameter(HTTP_SESSION_ID); - logger.debug("httpSessionID: " + httpSessionID); - voteAuthoringForm.setHttpSessionID(httpSessionID); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + String httpSessionID = request.getParameter(VoteAppConstants.HTTP_SESSION_ID); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listQuestionContentDTO); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteGeneralAuthoringDTO.setSbmtSuccess( new Integer(0).toString()); - + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); - String onlineInstructions=(String) sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); - String offlineInstructions=(String) sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - - - logger.debug("onlineInstructions: " + onlineInstructions); - logger.debug("offlineInstructions: " + offlineInstructions); - voteAuthoringForm.setOnlineInstructions(onlineInstructions); - voteAuthoringForm.setOfflineInstructions(offlineInstructions); - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + List listQuestionContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listQuestionContentDTO); - String richTextTitle=(String)sessionMap.get(ACTIVITY_TITLE_KEY); - String richTextInstructions=(String)sessionMap.get(ACTIVITY_INSTRUCTIONS_KEY); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - long uuid = WebUtil.readLongParam(request, UUID); + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - - if(attachmentList == null) - attachmentList = new ArrayList(); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - if(deletedAttachmentList == null) - deletedAttachmentList = new ArrayList(); - - /* move the file's details from the attachment collection to the deleted attachments collection - the attachment will be delete on saving. */ - - deletedAttachmentList = VoteUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList ); - logger.debug("post moveToDelete, attachmentList: " + attachmentList); - logger.debug("post moveToDelete, deletedAttachmentList: " + deletedAttachmentList); - + String onlineInstructions = (String) sessionMap.get(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); - sessionMap.put(ATTACHMENT_LIST_KEY,attachmentList); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY,deletedAttachmentList); - - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - - request.getSession().setAttribute(httpSessionID, sessionMap); + String offlineInstructions = (String) sessionMap.get(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("3"); - + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + voteAuthoringForm.setOnlineInstructions(onlineInstructions); + voteAuthoringForm.setOfflineInstructions(offlineInstructions); + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + String richTextTitle = (String) sessionMap.get(VoteAppConstants.ACTIVITY_TITLE_KEY); + String richTextInstructions = (String) sessionMap.get(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listQuestionContentDTO.size())); - - voteAuthoringForm.resetUserAction(); - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - - return (mapping.findForward(LOAD_QUESTIONS)); + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + long uuid = WebUtil.readLongParam(request, VoteAppConstants.UUID); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + + if (attachmentList == null) { + attachmentList = new ArrayList(); + } + + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + if (deletedAttachmentList == null) { + deletedAttachmentList = new ArrayList(); + } + + /* + * move the file's details from the attachment collection to the deleted attachments collection the attachment + * will be delete on saving. + */ + + deletedAttachmentList = VoteUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList); + VoteAction.logger.debug("post moveToDelete, attachmentList: " + attachmentList); + VoteAction.logger.debug("post moveToDelete, deletedAttachmentList: " + deletedAttachmentList); + + sessionMap.put(VoteAppConstants.ATTACHMENT_LIST_KEY, attachmentList); + sessionMap.put(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY, deletedAttachmentList); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("3"); + + VoteAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listQuestionContentDTO.size())); + + voteAuthoringForm.resetUserAction(); + VoteAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + VoteAppConstants.LOAD_QUESTIONS); + + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); } - /** * addNewFile * @@ -2352,118 +2202,115 @@ * @throws IOException * @throws ServletException */ - public ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispathching addNewFile"); - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String onlineInstructions=request.getParameter(ONLINE_INSTRUCTIONS); - logger.debug("onlineInstructions: " + onlineInstructions); - - String offlineInstructions=request.getParameter(OFFLINE_INSTRUCTIONS); - logger.debug("offlineInstructions: " + offlineInstructions); - - sessionMap.put(ONLINE_INSTRUCTIONS_KEY, onlineInstructions); - sessionMap.put(OFFLINE_INSTRUCTIONS, offlineInstructions); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - addFileToContentRepository(request, voteAuthoringForm, attachmentList, deletedAttachmentList, sessionMap, voteGeneralAuthoringDTO); - logger.debug("post addFileToContentRepository, attachmentList: " + attachmentList); - logger.debug("post addFileToContentRepository, deletedAttachmentList: " + deletedAttachmentList); - - sessionMap.put(ATTACHMENT_LIST_KEY,attachmentList); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY,deletedAttachmentList); - - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setCurrentTab("3"); - - - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - voteAuthoringForm.resetUserAction(); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); - voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + public ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteAction.logger.debug("dispathching addNewFile"); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); + + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteAction.logger.debug("activeModule: " + activeModule); + + String onlineInstructions = request.getParameter(VoteAppConstants.ONLINE_INSTRUCTIONS); + VoteAction.logger.debug("onlineInstructions: " + onlineInstructions); + + String offlineInstructions = request.getParameter(VoteAppConstants.OFFLINE_INSTRUCTIONS); + VoteAction.logger.debug("offlineInstructions: " + offlineInstructions); + + sessionMap.put(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY, onlineInstructions); + sessionMap.put(VoteAppConstants.OFFLINE_INSTRUCTIONS, offlineInstructions); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteAction.logger.debug("strToolContentID: " + strToolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + voteGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + voteGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + + VoteAction.logger.debug("richTextTitle: " + richTextTitle); + VoteAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + List attachmentList = (List) sessionMap.get(VoteAppConstants.ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + addFileToContentRepository(request, voteAuthoringForm, attachmentList, deletedAttachmentList, sessionMap, + voteGeneralAuthoringDTO); + VoteAction.logger.debug("post addFileToContentRepository, attachmentList: " + attachmentList); + VoteAction.logger.debug("post addFileToContentRepository, deletedAttachmentList: " + deletedAttachmentList); + + sessionMap.put(VoteAppConstants.ATTACHMENT_LIST_KEY, attachmentList); + sessionMap.put(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY, deletedAttachmentList); + + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setCurrentTab("3"); + + VoteAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + voteAuthoringForm.resetUserAction(); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + VoteAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + VoteAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + voteAuthoringForm.setOnlineInstructions(strOnlineInstructions); + voteAuthoringForm.setOfflineInstructions(strOfflineInstructions); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + VoteAppConstants.LOAD_QUESTIONS); + return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS); } - /** * addFileToContentRepository * @@ -2476,96 +2323,95 @@ * @param sessionMap * @param voteGeneralAuthoringDTO */ - public void addFileToContentRepository(HttpServletRequest request, VoteAuthoringForm voteAuthoringForm, - List attachmentList, List deletedAttachmentList, SessionMap sessionMap, - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) - { - logger.debug("attempt addFileToContentRepository"); - logger.debug("attachmentList: " + attachmentList); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - if(attachmentList == null) - attachmentList = new ArrayList(); - - if(deletedAttachmentList == null) - deletedAttachmentList = new ArrayList(); - - FormFile uploadedFile = null; - boolean isOnlineFile = false; - String fileType = null; - if(voteAuthoringForm.getTheOfflineFile() != null && voteAuthoringForm.getTheOfflineFile().getFileSize() > 0 ){ - logger.debug("theOfflineFile is available: "); - uploadedFile = voteAuthoringForm.getTheOfflineFile(); - logger.debug("uploadedFile: " + uploadedFile); - fileType = IToolContentHandler.TYPE_OFFLINE; - } - else if(voteAuthoringForm.getTheOnlineFile() != null && voteAuthoringForm.getTheOnlineFile().getFileSize() > 0 ){ - logger.debug("theOnlineFile is available: "); - uploadedFile = voteAuthoringForm.getTheOnlineFile(); - logger.debug("uploadedFile: " + uploadedFile); - isOnlineFile = true; - fileType = IToolContentHandler.TYPE_ONLINE; - } - else - /*no file uploaded*/ - return; - - //validate upload file size. - ActionMessages errors = new ActionMessages(); - FileValidatorUtil.validateFileSize(uploadedFile, true, errors ); - if(!errors.isEmpty()){ - this.saveErrors(request, errors); - return; - } - - logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName()); - - /* if a file with the same name already exists then move the old one to deleted */ - deletedAttachmentList = VoteUtils.moveToDelete(uploadedFile.getFileName(), isOnlineFile, attachmentList, deletedAttachmentList ); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); + public void addFileToContentRepository(HttpServletRequest request, VoteAuthoringForm voteAuthoringForm, + List attachmentList, List deletedAttachmentList, SessionMap sessionMap, + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) { + VoteAction.logger.debug("attempt addFileToContentRepository"); + VoteAction.logger.debug("attachmentList: " + attachmentList); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteAction.logger.debug("voteService: " + voteService); - try - { - /* This is a new file and so is saved to the content repository. Add it to the - attachments collection, but don't add it to the tool's tables yet. - */ - NodeKey node = getToolContentHandler().uploadFile(uploadedFile.getInputStream(), uploadedFile.getFileName(), - uploadedFile.getContentType(), fileType); - VoteUploadedFile file = new VoteUploadedFile(); - String fileName=uploadedFile.getFileName(); - logger.debug("fileName: " + fileName); - logger.debug("fileName length: " + fileName.length()); - - if ((fileName != null) && (fileName.length() > 30)) - { - fileName=fileName.substring(0, 31); - logger.debug("shortened fileName: " + fileName); - } - - file.setFileName(fileName); - file.setFileOnline(isOnlineFile); - file.setUuid(node.getUuid().toString()); - /* file.setVersionId(node.getVersion()); */ - - /* add the files to the attachment collection - if one existed, it should have already been removed. */ - attachmentList.add(file); - - /* reset the fields so that more files can be uploaded */ - voteAuthoringForm.setTheOfflineFile(null); - voteAuthoringForm.setTheOnlineFile(null); - } - catch (FileNotFoundException e) { - logger.error("Unable to uploadfile",e); - throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); - } catch (IOException e) { - logger.error("Unable to uploadfile",e); - throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); - } catch (RepositoryCheckedException e) { - logger.error("Unable to uploadfile",e); - throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); - } + if (attachmentList == null) { + attachmentList = new ArrayList(); + } + + if (deletedAttachmentList == null) { + deletedAttachmentList = new ArrayList(); + } + + FormFile uploadedFile = null; + boolean isOnlineFile = false; + String fileType = null; + if (voteAuthoringForm.getTheOfflineFile() != null && voteAuthoringForm.getTheOfflineFile().getFileSize() > 0) { + VoteAction.logger.debug("theOfflineFile is available: "); + uploadedFile = voteAuthoringForm.getTheOfflineFile(); + VoteAction.logger.debug("uploadedFile: " + uploadedFile); + fileType = IToolContentHandler.TYPE_OFFLINE; + } else if (voteAuthoringForm.getTheOnlineFile() != null + && voteAuthoringForm.getTheOnlineFile().getFileSize() > 0) { + VoteAction.logger.debug("theOnlineFile is available: "); + uploadedFile = voteAuthoringForm.getTheOnlineFile(); + VoteAction.logger.debug("uploadedFile: " + uploadedFile); + isOnlineFile = true; + fileType = IToolContentHandler.TYPE_ONLINE; + } else { + /* no file uploaded */ + return; + } + + // validate upload file size. + ActionMessages errors = new ActionMessages(); + FileValidatorUtil.validateFileSize(uploadedFile, true, errors); + if (!errors.isEmpty()) { + this.saveErrors(request, errors); + return; + } + + VoteAction.logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName()); + + /* if a file with the same name already exists then move the old one to deleted */ + deletedAttachmentList = VoteUtils.moveToDelete(uploadedFile.getFileName(), isOnlineFile, attachmentList, + deletedAttachmentList); + VoteAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + try { + /* + * This is a new file and so is saved to the content repository. Add it to the attachments collection, but + * don't add it to the tool's tables yet. + */ + NodeKey node = getToolContentHandler().uploadFile(uploadedFile.getInputStream(), + uploadedFile.getFileName(), uploadedFile.getContentType(), fileType); + VoteUploadedFile file = new VoteUploadedFile(); + String fileName = uploadedFile.getFileName(); + VoteAction.logger.debug("fileName: " + fileName); + VoteAction.logger.debug("fileName length: " + fileName.length()); + + if (fileName != null && fileName.length() > 30) { + fileName = fileName.substring(0, 31); + VoteAction.logger.debug("shortened fileName: " + fileName); + } + + file.setFileName(fileName); + file.setFileOnline(isOnlineFile); + file.setUuid(node.getUuid().toString()); + /* file.setVersionId(node.getVersion()); */ + + /* add the files to the attachment collection - if one existed, it should have already been removed. */ + attachmentList.add(file); + + /* reset the fields so that more files can be uploaded */ + voteAuthoringForm.setTheOfflineFile(null); + voteAuthoringForm.setTheOnlineFile(null); + } catch (FileNotFoundException e) { + VoteAction.logger.error("Unable to uploadfile", e); + throw new RuntimeException("Unable to upload file, exception was " + e.getMessage()); + } catch (IOException e) { + VoteAction.logger.error("Unable to uploadfile", e); + throw new RuntimeException("Unable to upload file, exception was " + e.getMessage()); + } catch (RepositoryCheckedException e) { + VoteAction.logger.error("Unable to uploadfile", e); + throw new RuntimeException("Unable to upload file, exception was " + e.getMessage()); + } } } - Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAuthoringForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/Attic/VoteAuthoringForm.java,v diff -u -r1.20 -r1.21 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAuthoringForm.java 26 Mar 2008 03:57:40 -0000 1.20 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAuthoringForm.java 2 Jul 2009 13:02:04 -0000 1.21 @@ -28,987 +28,1146 @@ import org.lamsfoundation.lams.tool.vote.service.IVoteService; /** - *

ActionForm for the Authoring environment

+ *

+ * ActionForm for the Authoring environment + *

* * @author Ozgur Demirtas * */ public class VoteAuthoringForm extends VoteLearningForm implements VoteAppConstants { - /* form controllers */ - protected String addOptionContent; - protected String currentTab; - - protected String questionIndex; - protected String optIndex; - protected String optionIndex; - protected String selectedIndex; - protected String deletableOptionIndex; - - protected String editDefaultQuestion; - protected String removeOptionContent; - - protected String lockOnFinish; - protected String allowText; - protected String showResults; - - protected String reflect; - protected String reflectionSubject; - - protected String activeModule; - - protected String maxNominationCount; - - protected String fileItem; - protected String uuid; - - protected FormFile receivedFile; - protected String offlineFile; - - protected String addContent; - protected String removeContent; - protected String removeAllContent; - protected String submitAllContent; - protected String submitTabDone; - protected String submitOfflineFile; - protected String submitOnlineFile; - - /* tab controller, these may go away once the Flash wraps the jsp */ - protected String choice; - protected String choiceBasic; - protected String choiceAdvanced; - protected String choiceInstructions; - - protected String submit; - - /* basic content */ - protected String title; - protected String instructions; - - protected String isRemoveContent; - protected String toolContentID; - protected String editableNominationIndex; - - - /* instructions content */ - protected String onlineInstructions; - protected String offlineInstructions; - protected FormFile theOfflineFile; - protected FormFile theOnlineFile; - - protected String richTextOfflineInstructions; - protected String richTextOnlineInstructions; - - protected String defineLaterInEditMode; - - - /* proxy controllers for Monitoring tabs */ - protected String summaryMonitoring; - protected String instructionsMonitoring; - protected String editActivityMonitoring; - protected String statsMonitoring; + /* form controllers */ + protected String addOptionContent; + protected String currentTab; - protected String edit; - protected String exceptionMaxNominationInvalid; - protected String defaultContentIdStr; - protected String defaultContentId; - protected String isDefineLater; - protected String submissionAttempt; - protected String defaultOptionContent; - protected String httpSessionID; - protected IVoteService voteService; - - - private String contentFolderID; - private String addSingleQuestion; - private String editableQuestionIndex; - private String feedback; - private String editQuestionBoxRequest; - - public void resetUserAction() - { - this.editDefaultQuestion=null; - this.addOptionContent=null; - this.removeOptionContent=null; - - this.fileItem=null; - - this.addContent=null; - this.removeContent=null; - this.removeAllContent=null; - this.submitAllContent=null; - this.submitTabDone=null; - this.submitOfflineFile=null; - this.submitOnlineFile=null; - - - this.summaryMonitoring=null; - this.instructionsMonitoring=null; - this.editActivityMonitoring=null; - this.statsMonitoring=null; - this.edit=null; - this.submit=null; + protected String questionIndex; + protected String optIndex; + protected String optionIndex; + protected String selectedIndex; + protected String deletableOptionIndex; + + protected String editDefaultQuestion; + protected String removeOptionContent; + + protected String lockOnFinish; + protected String allowText; + protected String showResults; + + protected String reflect; + protected String reflectionSubject; + + protected String activeModule; + + protected String maxNominationCount; + + protected String fileItem; + protected String uuid; + + protected FormFile receivedFile; + protected String offlineFile; + + protected String addContent; + protected String removeContent; + protected String removeAllContent; + protected String submitAllContent; + protected String submitTabDone; + protected String submitOfflineFile; + protected String submitOnlineFile; + + /* tab controller, these may go away once the Flash wraps the jsp */ + protected String choice; + protected String choiceBasic; + protected String choiceAdvanced; + protected String choiceInstructions; + + protected String submit; + + /* basic content */ + protected String title; + protected String instructions; + + protected String isRemoveContent; + protected String toolContentID; + protected String editableNominationIndex; + + /* instructions content */ + protected String onlineInstructions; + protected String offlineInstructions; + protected FormFile theOfflineFile; + protected FormFile theOnlineFile; + + protected String richTextOfflineInstructions; + protected String richTextOnlineInstructions; + + protected String defineLaterInEditMode; + + /* proxy controllers for Monitoring tabs */ + protected String summaryMonitoring; + protected String instructionsMonitoring; + protected String editActivityMonitoring; + protected String statsMonitoring; + + protected String edit; + protected String exceptionMaxNominationInvalid; + protected String defaultContentIdStr; + protected String defaultContentId; + protected String isDefineLater; + protected String submissionAttempt; + protected String defaultOptionContent; + protected String httpSessionID; + protected IVoteService voteService; + + private String contentFolderID; + private String addSingleQuestion; + private String editableQuestionIndex; + private String feedback; + private String editQuestionBoxRequest; + + protected Integer assignedDataFlowObject; + + public Integer getAssignedDataFlowObject() { + return assignedDataFlowObject; } - - public void reset() - { - this.editDefaultQuestion=null; - this.addOptionContent=null; - this.removeOptionContent=null; - - this.fileItem=null; - this.uuid=null; - this.receivedFile=null; - - this.addContent=null; - this.removeContent=null; - this.removeAllContent=null; - this.submitAllContent=null; - this.submitTabDone=null; - this.submitOfflineFile=null; - this.submitOnlineFile=null; - this.offlineFile=null; - this.choice=null; - this.choiceBasic=null; - this.choiceAdvanced=null; - this.choiceInstructions=null; - - this.title=null; - this.instructions=null; - this.questionIndex=null; - this.optIndex=null; - this.optionIndex=null; - this.selectedIndex=null; - this.deletableOptionIndex=null; - this.isRemoveContent=null; - this.toolContentID=null; - - this.onlineInstructions=null; - this.offlineInstructions=null; - - this.richTextOfflineInstructions=null; - this.richTextOnlineInstructions=null; - - this.reflect=null; - this.lockOnFinish=null; - this.allowText=null; - this.showResults=null; - this.maxNominationCount=null; - - this.summaryMonitoring=null; - this.instructionsMonitoring=null; - this.editActivityMonitoring=null; - this.statsMonitoring=null; - this.edit=null; - this.submit=null; - this.submissionAttempt=null; - this.sbmtSuccess=null; - } - - public void resetRadioBoxes() - { - this.lockOnFinish ="0"; - this.allowText ="0"; - this.showResults ="0"; - this.reflect ="0"; - } + public void setAssignedDataFlowObject(Integer assignedDataFlowObject) { + this.assignedDataFlowObject = assignedDataFlowObject; + } - + public void resetUserAction() { + editDefaultQuestion = null; + addOptionContent = null; + removeOptionContent = null; + + fileItem = null; + + addContent = null; + removeContent = null; + removeAllContent = null; + submitAllContent = null; + submitTabDone = null; + submitOfflineFile = null; + submitOnlineFile = null; + + summaryMonitoring = null; + instructionsMonitoring = null; + editActivityMonitoring = null; + statsMonitoring = null; + edit = null; + submit = null; + } + + public void reset() { + editDefaultQuestion = null; + addOptionContent = null; + removeOptionContent = null; + + fileItem = null; + uuid = null; + receivedFile = null; + + addContent = null; + removeContent = null; + removeAllContent = null; + submitAllContent = null; + submitTabDone = null; + submitOfflineFile = null; + submitOnlineFile = null; + offlineFile = null; + + choice = null; + choiceBasic = null; + choiceAdvanced = null; + choiceInstructions = null; + + title = null; + instructions = null; + questionIndex = null; + optIndex = null; + optionIndex = null; + selectedIndex = null; + deletableOptionIndex = null; + isRemoveContent = null; + toolContentID = null; + + onlineInstructions = null; + offlineInstructions = null; + + richTextOfflineInstructions = null; + richTextOnlineInstructions = null; + + reflect = null; + lockOnFinish = null; + allowText = null; + showResults = null; + maxNominationCount = null; + + summaryMonitoring = null; + instructionsMonitoring = null; + editActivityMonitoring = null; + statsMonitoring = null; + edit = null; + submit = null; + submissionAttempt = null; + sbmtSuccess = null; + } + + public void resetRadioBoxes() { + lockOnFinish = "0"; + allowText = "0"; + showResults = "0"; + reflect = "0"; + } + /** * @return Returns the defaultContentId. */ public String getDefaultContentId() { - return defaultContentId; + return defaultContentId; } + /** - * @param defaultContentId The defaultContentId to set. + * @param defaultContentId + * The defaultContentId to set. */ public void setDefaultContentId(String defaultContentId) { - this.defaultContentId = defaultContentId; + this.defaultContentId = defaultContentId; } + /** * @return Returns the defaultContentIdStr. */ public String getDefaultContentIdStr() { - return defaultContentIdStr; + return defaultContentIdStr; } + /** - * @param defaultContentIdStr The defaultContentIdStr to set. + * @param defaultContentIdStr + * The defaultContentIdStr to set. */ public void setDefaultContentIdStr(String defaultContentIdStr) { - this.defaultContentIdStr = defaultContentIdStr; + this.defaultContentIdStr = defaultContentIdStr; } - /** - * @return Returns the isRemoveContent. - */ - public String getIsRemoveContent() { - return isRemoveContent; - } - /** - * @param isRemoveContent The isRemoveContent to set. - */ - public void setIsRemoveContent(String isRemoveContent) { - this.isRemoveContent = isRemoveContent; - } - /** - * @return Returns the questionIndex. - */ - public String getQuestionIndex() { - return questionIndex; - } - /** - * @param questionIndex The questionIndex to set. - */ - public void setQuestionIndex(String questionIndex) { - this.questionIndex = questionIndex; - } - - /** - * @return Returns the addContent. - */ - public String getAddContent() { - return addContent; - } - /** - * @param addContent The addContent to set. - */ - public void setAddContent(String addContent) { - this.addContent = addContent; - } - /** - * @return Returns the removeContent. - */ - public String getRemoveContent() { - return removeContent; - } - /** - * @param removeContent The removeContent to set. - */ - public void setRemoveContent(String removeContent) { - this.removeContent = removeContent; - } - /** - * @return Returns the removeAllContent. - */ - public String getRemoveAllContent() { - return removeAllContent; - } - /** - * @param removeAllContent The removeAllContent to set. - */ - public void setRemoveAllContent(String removeAllContent) { - this.removeAllContent = removeAllContent; - } - /** - * @return Returns the submitAllContent. - */ - public String getSubmitAllContent() { - return submitAllContent; - } - /** - * @param submitAllContent The submitAllContent to set. - */ - public void setSubmitAllContent(String submitAllContent) { - this.submitAllContent = submitAllContent; - } - /** - * @return Returns the instructions. - */ - public String getInstructions() { - return instructions; - } - /** - * @param instructions The instructions to set. - */ - public void setInstructions(String instructions) { - this.instructions = instructions; - } - /** - * @return Returns the title. - */ - public String getTitle() { - return title; - } - /** - * @param title The title to set. - */ - public void setTitle(String title) { - this.title = title; - } - /** - * @return Returns the offlineInstructions. - */ - public String getOfflineInstructions() { - return offlineInstructions; - } - /** - * @param offlineInstructions The offlineInstructions to set. - */ - public void setOfflineInstructions(String offlineInstructions) { - this.offlineInstructions = offlineInstructions; - } - /** - * @return Returns the onlineInstructions. - */ - public String getOnlineInstructions() { - return onlineInstructions; - } - /** - * @param onlineInstructions The onlineInstructions to set. - */ - public void setOnlineInstructions(String onlineInstructions) { - this.onlineInstructions = onlineInstructions; - } - - - /** - * @return Returns the choiceAdvanced. - */ - public String getChoiceAdvanced() { - return choiceAdvanced; - } - /** - * @param choiceAdvanced The choiceAdvanced to set. - */ - public void setChoiceAdvanced(String choiceAdvanced) { - this.choiceAdvanced = choiceAdvanced; - } - /** - * @return Returns the choiceBasic. - */ - public String getChoiceBasic() { - return choiceBasic; - } - /** - * @param choiceBasic The choiceBasic to set. - */ - public void setChoiceBasic(String choiceBasic) { - this.choiceBasic = choiceBasic; - } - /** - * @return Returns the choiceInstructions. - */ - public String getChoiceInstructions() { - return choiceInstructions; - } - /** - * @param choiceInstructions The choiceInstructions to set. - */ - public void setChoiceInstructions(String choiceInstructions) { - this.choiceInstructions = choiceInstructions; - } - /** - * @return Returns the choice. - */ - public String getChoice() { - return choice; - } - /** - * @param choice The choice to set. - */ - public void setChoice(String choice) { - this.choice = choice; - } + /** + * @return Returns the isRemoveContent. + */ + public String getIsRemoveContent() { + return isRemoveContent; + } - /** - * @return Returns the submitTabDone. - */ - public String getSubmitTabDone() { - return submitTabDone; - } - /** - * @param submitTabDone The submitTabDone to set. - */ - public void setSubmitTabDone(String submitTabDone) { - this.submitTabDone = submitTabDone; - } - - /** - * @return Returns the editActivityMonitoring. - */ - public String getEditActivityMonitoring() { - return editActivityMonitoring; - } - /** - * @param editActivityMonitoring The editActivityMonitoring to set. - */ - public void setEditActivityMonitoring(String editActivityMonitoring) { - this.editActivityMonitoring = editActivityMonitoring; - } - /** - * @return Returns the instructionsMonitoring. - */ - public String getInstructionsMonitoring() { - return instructionsMonitoring; - } - /** - * @param instructionsMonitoring The instructionsMonitoring to set. - */ - public void setInstructionsMonitoring(String instructionsMonitoring) { - this.instructionsMonitoring = instructionsMonitoring; - } - /** - * @return Returns the statsMonitoring. - */ - public String getStatsMonitoring() { - return statsMonitoring; - } - /** - * @param statsMonitoring The statsMonitoring to set. - */ - public void setStatsMonitoring(String statsMonitoring) { - this.statsMonitoring = statsMonitoring; - } - /** - * @return Returns the summaryMonitoring. - */ - public String getSummaryMonitoring() { - return summaryMonitoring; - } - /** - * @param summaryMonitoring The summaryMonitoring to set. - */ - public void setSummaryMonitoring(String summaryMonitoring) { - this.summaryMonitoring = summaryMonitoring; - } - /** - * @return Returns the edit. - */ - public String getEdit() { - return edit; - } - /** - * @param edit The edit to set. - */ - public void setEdit(String edit) { - this.edit = edit; - } - - /** - * @return Returns the submitOfflineFile. - */ - public String getSubmitOfflineFile() { - return submitOfflineFile; - } - /** - * @param submitOfflineFile The submitOfflineFile to set. - */ - public void setSubmitOfflineFile(String submitOfflineFile) { - this.submitOfflineFile = submitOfflineFile; - } - /** - * @param theOfflineFile The theOfflineFile to set. - */ - public void setTheOfflineFile(FormFile theOfflineFile) { - this.theOfflineFile = theOfflineFile; - } - /** - * @param theOnlineFile The theOnlineFile to set. - */ - public void setTheOnlineFile(FormFile theOnlineFile) { - this.theOnlineFile = theOnlineFile; - } - /** - * @return Returns the theOfflineFile. - */ - public FormFile getTheOfflineFile() { - return theOfflineFile; - } - /** - * @return Returns the theOnlineFile. - */ - public FormFile getTheOnlineFile() { - return theOnlineFile; - } - /** - * @return Returns the submitOnlineFile. - */ - public String getSubmitOnlineFile() { - return submitOnlineFile; - } - /** - * @param submitOnlineFile The submitOnlineFile to set. - */ - public void setSubmitOnlineFile(String submitOnlineFile) { - this.submitOnlineFile = submitOnlineFile; - } - /** - * @return Returns the richTextOfflineInstructions. - */ - public String getRichTextOfflineInstructions() { - return richTextOfflineInstructions; - } - /** - * @param richTextOfflineInstructions The richTextOfflineInstructions to set. - */ - public void setRichTextOfflineInstructions( - String richTextOfflineInstructions) { - this.richTextOfflineInstructions = richTextOfflineInstructions; - } - /** - * @return Returns the richTextOnlineInstructions. - */ - public String getRichTextOnlineInstructions() { - return richTextOnlineInstructions; - } - /** - * @param richTextOnlineInstructions The richTextOnlineInstructions to set. - */ - public void setRichTextOnlineInstructions(String richTextOnlineInstructions) { - this.richTextOnlineInstructions = richTextOnlineInstructions; - } - /** - * @return Returns the editDefaultQuestion. - */ - public String getEditDefaultQuestion() { - return editDefaultQuestion; - } - /** - * @param editDefaultQuestion The editDefaultQuestion to set. - */ - public void setEditDefaultQuestion(String editDefaultQuestion) { - this.editDefaultQuestion = editDefaultQuestion; - } - /** - * @return Returns the addOptionContent. - */ - public String getAddOptionContent() { - return addOptionContent; - } - /** - * @param addOptionContent The addOptionContent to set. - */ - public void setAddOptionContent(String addOptionContent) { - this.addOptionContent = addOptionContent; - } - /** - * @return Returns the removeOptionContent. - */ - public String getRemoveOptionContent() { - return removeOptionContent; - } - /** - * @param removeOptionContent The removeOptionContent to set. - */ - public void setRemoveOptionContent(String removeOptionContent) { - this.removeOptionContent = removeOptionContent; - } - /** - * @return Returns the optionIndex. - */ - public String getOptionIndex() { - return optionIndex; - } - /** - * @param optionIndex The optionIndex to set. - */ - public void setOptionIndex(String optionIndex) { - this.optionIndex = optionIndex; - } + /** + * @param isRemoveContent + * The isRemoveContent to set. + */ + public void setIsRemoveContent(String isRemoveContent) { + this.isRemoveContent = isRemoveContent; + } - /** - * @return Returns the selectedIndex. - */ - public String getSelectedIndex() { - return selectedIndex; - } - /** - * @param selectedIndex The selectedIndex to set. - */ - public void setSelectedIndex(String selectedIndex) { - this.selectedIndex = selectedIndex; - } - /** - * @return Returns the deletableOptionIndex. - */ - public String getDeletableOptionIndex() { - return deletableOptionIndex; - } - /** - * @param deletableOptionIndex The deletableOptionIndex to set. - */ - public void setDeletableOptionIndex(String deletableOptionIndex) { - this.deletableOptionIndex = deletableOptionIndex; - } + /** + * @return Returns the questionIndex. + */ + @Override + public String getQuestionIndex() { + return questionIndex; + } - /** - * @return Returns the fileItem. - */ - public String getFileItem() { - return fileItem; - } - /** - * @param fileItem The fileItem to set. - */ - public void setFileItem(String fileItem) { - this.fileItem = fileItem; - } - /** - * @return Returns the receivedFile. - */ - public FormFile getReceivedFile() { - return receivedFile; - } - /** - * @param receivedFile The receivedFile to set. - */ - public void setReceivedFile(FormFile receivedFile) { - this.receivedFile = receivedFile; - } + /** + * @param questionIndex + * The questionIndex to set. + */ + @Override + public void setQuestionIndex(String questionIndex) { + this.questionIndex = questionIndex; + } - - /** - * @return Returns the offlineFile. - */ - public String getOfflineFile() { - return offlineFile; - } - /** - * @param offlineFile The offlineFile to set. - */ - public void setOfflineFile(String offlineFile) { - this.offlineFile = offlineFile; - } - /** - * @return Returns the uuid. - */ - public String getUuid() { - return uuid; - } - /** - * @param uuid The uuid to set. - */ - public void setUuid(String uuid) { - this.uuid = uuid; - } - /** - * @return Returns the currentTab. - */ - public String getCurrentTab() { - return currentTab; - } - /** - * @param currentTab The currentTab to set. - */ - public void setCurrentTab(String currentTab) { - this.currentTab = currentTab; - } + /** + * @return Returns the addContent. + */ + public String getAddContent() { + return addContent; + } - /** - * @return Returns the submit. - */ - public String getSubmit() { - return submit; - } - /** - * @param submit The submit to set. - */ - public void setSubmit(String submit) { - this.submit = submit; - } + /** + * @param addContent + * The addContent to set. + */ + public void setAddContent(String addContent) { + this.addContent = addContent; + } /** + * @return Returns the removeContent. + */ + public String getRemoveContent() { + return removeContent; + } + + /** + * @param removeContent + * The removeContent to set. + */ + public void setRemoveContent(String removeContent) { + this.removeContent = removeContent; + } + + /** + * @return Returns the removeAllContent. + */ + public String getRemoveAllContent() { + return removeAllContent; + } + + /** + * @param removeAllContent + * The removeAllContent to set. + */ + public void setRemoveAllContent(String removeAllContent) { + this.removeAllContent = removeAllContent; + } + + /** + * @return Returns the submitAllContent. + */ + public String getSubmitAllContent() { + return submitAllContent; + } + + /** + * @param submitAllContent + * The submitAllContent to set. + */ + public void setSubmitAllContent(String submitAllContent) { + this.submitAllContent = submitAllContent; + } + + /** + * @return Returns the instructions. + */ + public String getInstructions() { + return instructions; + } + + /** + * @param instructions + * The instructions to set. + */ + public void setInstructions(String instructions) { + this.instructions = instructions; + } + + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + } + + /** + * @param title + * The title to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return Returns the offlineInstructions. + */ + public String getOfflineInstructions() { + return offlineInstructions; + } + + /** + * @param offlineInstructions + * The offlineInstructions to set. + */ + public void setOfflineInstructions(String offlineInstructions) { + this.offlineInstructions = offlineInstructions; + } + + /** + * @return Returns the onlineInstructions. + */ + public String getOnlineInstructions() { + return onlineInstructions; + } + + /** + * @param onlineInstructions + * The onlineInstructions to set. + */ + public void setOnlineInstructions(String onlineInstructions) { + this.onlineInstructions = onlineInstructions; + } + + /** + * @return Returns the choiceAdvanced. + */ + public String getChoiceAdvanced() { + return choiceAdvanced; + } + + /** + * @param choiceAdvanced + * The choiceAdvanced to set. + */ + public void setChoiceAdvanced(String choiceAdvanced) { + this.choiceAdvanced = choiceAdvanced; + } + + /** + * @return Returns the choiceBasic. + */ + public String getChoiceBasic() { + return choiceBasic; + } + + /** + * @param choiceBasic + * The choiceBasic to set. + */ + public void setChoiceBasic(String choiceBasic) { + this.choiceBasic = choiceBasic; + } + + /** + * @return Returns the choiceInstructions. + */ + public String getChoiceInstructions() { + return choiceInstructions; + } + + /** + * @param choiceInstructions + * The choiceInstructions to set. + */ + public void setChoiceInstructions(String choiceInstructions) { + this.choiceInstructions = choiceInstructions; + } + + /** + * @return Returns the choice. + */ + public String getChoice() { + return choice; + } + + /** + * @param choice + * The choice to set. + */ + public void setChoice(String choice) { + this.choice = choice; + } + + /** + * @return Returns the submitTabDone. + */ + public String getSubmitTabDone() { + return submitTabDone; + } + + /** + * @param submitTabDone + * The submitTabDone to set. + */ + public void setSubmitTabDone(String submitTabDone) { + this.submitTabDone = submitTabDone; + } + + /** + * @return Returns the editActivityMonitoring. + */ + public String getEditActivityMonitoring() { + return editActivityMonitoring; + } + + /** + * @param editActivityMonitoring + * The editActivityMonitoring to set. + */ + public void setEditActivityMonitoring(String editActivityMonitoring) { + this.editActivityMonitoring = editActivityMonitoring; + } + + /** + * @return Returns the instructionsMonitoring. + */ + public String getInstructionsMonitoring() { + return instructionsMonitoring; + } + + /** + * @param instructionsMonitoring + * The instructionsMonitoring to set. + */ + public void setInstructionsMonitoring(String instructionsMonitoring) { + this.instructionsMonitoring = instructionsMonitoring; + } + + /** + * @return Returns the statsMonitoring. + */ + public String getStatsMonitoring() { + return statsMonitoring; + } + + /** + * @param statsMonitoring + * The statsMonitoring to set. + */ + public void setStatsMonitoring(String statsMonitoring) { + this.statsMonitoring = statsMonitoring; + } + + /** + * @return Returns the summaryMonitoring. + */ + public String getSummaryMonitoring() { + return summaryMonitoring; + } + + /** + * @param summaryMonitoring + * The summaryMonitoring to set. + */ + public void setSummaryMonitoring(String summaryMonitoring) { + this.summaryMonitoring = summaryMonitoring; + } + + /** + * @return Returns the edit. + */ + public String getEdit() { + return edit; + } + + /** + * @param edit + * The edit to set. + */ + public void setEdit(String edit) { + this.edit = edit; + } + + /** + * @return Returns the submitOfflineFile. + */ + public String getSubmitOfflineFile() { + return submitOfflineFile; + } + + /** + * @param submitOfflineFile + * The submitOfflineFile to set. + */ + public void setSubmitOfflineFile(String submitOfflineFile) { + this.submitOfflineFile = submitOfflineFile; + } + + /** + * @param theOfflineFile + * The theOfflineFile to set. + */ + public void setTheOfflineFile(FormFile theOfflineFile) { + this.theOfflineFile = theOfflineFile; + } + + /** + * @param theOnlineFile + * The theOnlineFile to set. + */ + public void setTheOnlineFile(FormFile theOnlineFile) { + this.theOnlineFile = theOnlineFile; + } + + /** + * @return Returns the theOfflineFile. + */ + public FormFile getTheOfflineFile() { + return theOfflineFile; + } + + /** + * @return Returns the theOnlineFile. + */ + public FormFile getTheOnlineFile() { + return theOnlineFile; + } + + /** + * @return Returns the submitOnlineFile. + */ + public String getSubmitOnlineFile() { + return submitOnlineFile; + } + + /** + * @param submitOnlineFile + * The submitOnlineFile to set. + */ + public void setSubmitOnlineFile(String submitOnlineFile) { + this.submitOnlineFile = submitOnlineFile; + } + + /** + * @return Returns the richTextOfflineInstructions. + */ + public String getRichTextOfflineInstructions() { + return richTextOfflineInstructions; + } + + /** + * @param richTextOfflineInstructions + * The richTextOfflineInstructions to set. + */ + public void setRichTextOfflineInstructions(String richTextOfflineInstructions) { + this.richTextOfflineInstructions = richTextOfflineInstructions; + } + + /** + * @return Returns the richTextOnlineInstructions. + */ + public String getRichTextOnlineInstructions() { + return richTextOnlineInstructions; + } + + /** + * @param richTextOnlineInstructions + * The richTextOnlineInstructions to set. + */ + public void setRichTextOnlineInstructions(String richTextOnlineInstructions) { + this.richTextOnlineInstructions = richTextOnlineInstructions; + } + + /** + * @return Returns the editDefaultQuestion. + */ + public String getEditDefaultQuestion() { + return editDefaultQuestion; + } + + /** + * @param editDefaultQuestion + * The editDefaultQuestion to set. + */ + public void setEditDefaultQuestion(String editDefaultQuestion) { + this.editDefaultQuestion = editDefaultQuestion; + } + + /** + * @return Returns the addOptionContent. + */ + public String getAddOptionContent() { + return addOptionContent; + } + + /** + * @param addOptionContent + * The addOptionContent to set. + */ + public void setAddOptionContent(String addOptionContent) { + this.addOptionContent = addOptionContent; + } + + /** + * @return Returns the removeOptionContent. + */ + public String getRemoveOptionContent() { + return removeOptionContent; + } + + /** + * @param removeOptionContent + * The removeOptionContent to set. + */ + public void setRemoveOptionContent(String removeOptionContent) { + this.removeOptionContent = removeOptionContent; + } + + /** + * @return Returns the optionIndex. + */ + @Override + public String getOptionIndex() { + return optionIndex; + } + + /** + * @param optionIndex + * The optionIndex to set. + */ + @Override + public void setOptionIndex(String optionIndex) { + this.optionIndex = optionIndex; + } + + /** + * @return Returns the selectedIndex. + */ + public String getSelectedIndex() { + return selectedIndex; + } + + /** + * @param selectedIndex + * The selectedIndex to set. + */ + public void setSelectedIndex(String selectedIndex) { + this.selectedIndex = selectedIndex; + } + + /** + * @return Returns the deletableOptionIndex. + */ + public String getDeletableOptionIndex() { + return deletableOptionIndex; + } + + /** + * @param deletableOptionIndex + * The deletableOptionIndex to set. + */ + public void setDeletableOptionIndex(String deletableOptionIndex) { + this.deletableOptionIndex = deletableOptionIndex; + } + + /** + * @return Returns the fileItem. + */ + public String getFileItem() { + return fileItem; + } + + /** + * @param fileItem + * The fileItem to set. + */ + public void setFileItem(String fileItem) { + this.fileItem = fileItem; + } + + /** + * @return Returns the receivedFile. + */ + public FormFile getReceivedFile() { + return receivedFile; + } + + /** + * @param receivedFile + * The receivedFile to set. + */ + public void setReceivedFile(FormFile receivedFile) { + this.receivedFile = receivedFile; + } + + /** + * @return Returns the offlineFile. + */ + public String getOfflineFile() { + return offlineFile; + } + + /** + * @param offlineFile + * The offlineFile to set. + */ + public void setOfflineFile(String offlineFile) { + this.offlineFile = offlineFile; + } + + /** + * @return Returns the uuid. + */ + public String getUuid() { + return uuid; + } + + /** + * @param uuid + * The uuid to set. + */ + public void setUuid(String uuid) { + this.uuid = uuid; + } + + /** + * @return Returns the currentTab. + */ + public String getCurrentTab() { + return currentTab; + } + + /** + * @param currentTab + * The currentTab to set. + */ + public void setCurrentTab(String currentTab) { + this.currentTab = currentTab; + } + + /** + * @return Returns the submit. + */ + public String getSubmit() { + return submit; + } + + /** + * @param submit + * The submit to set. + */ + public void setSubmit(String submit) { + this.submit = submit; + } + + /** * @return Returns the optIndex. */ public String getOptIndex() { - return optIndex; + return optIndex; } + /** - * @param optIndex The optIndex to set. + * @param optIndex + * The optIndex to set. */ public void setOptIndex(String optIndex) { - this.optIndex = optIndex; + this.optIndex = optIndex; } - - + /** * @return Returns the lockOnFinish. */ + @Override public String getLockOnFinish() { - return lockOnFinish; + return lockOnFinish; } + /** - * @param lockOnFinish The lockOnFinish to set. + * @param lockOnFinish + * The lockOnFinish to set. */ + @Override public void setLockOnFinish(String lockOnFinish) { - this.lockOnFinish = lockOnFinish; + this.lockOnFinish = lockOnFinish; } + /** * @return Returns the allowText. */ public String getAllowText() { - return allowText; + return allowText; } + /** - * @param allowText The allowText to set. + * @param allowText + * The allowText to set. */ public void setAllowText(String allowText) { - this.allowText = allowText; + this.allowText = allowText; } + /** * @return Returns the maxNominationCount. */ + @Override public String getMaxNominationCount() { - return maxNominationCount; + return maxNominationCount; } + /** - * @param maxNominationCount The maxNominationCount to set. + * @param maxNominationCount + * The maxNominationCount to set. */ + @Override public void setMaxNominationCount(String maxNominationCount) { - this.maxNominationCount = maxNominationCount; + this.maxNominationCount = maxNominationCount; } + /** * @return Returns the exceptionMaxNominationInvalid. */ public String getExceptionMaxNominationInvalid() { - return exceptionMaxNominationInvalid; + return exceptionMaxNominationInvalid; } + /** - * @param exceptionMaxNominationInvalid The exceptionMaxNominationInvalid to set. + * @param exceptionMaxNominationInvalid + * The exceptionMaxNominationInvalid to set. */ - public void setExceptionMaxNominationInvalid( - String exceptionMaxNominationInvalid) { - this.exceptionMaxNominationInvalid = exceptionMaxNominationInvalid; + public void setExceptionMaxNominationInvalid(String exceptionMaxNominationInvalid) { + this.exceptionMaxNominationInvalid = exceptionMaxNominationInvalid; } + /** * @return Returns the activeModule. */ public String getActiveModule() { - return activeModule; + return activeModule; } + /** - * @param activeModule The activeModule to set. + * @param activeModule + * The activeModule to set. */ public void setActiveModule(String activeModule) { - this.activeModule = activeModule; + this.activeModule = activeModule; } + /** * @return Returns the submissionAttempt. */ public String getSubmissionAttempt() { - return submissionAttempt; + return submissionAttempt; } + /** - * @param submissionAttempt The submissionAttempt to set. + * @param submissionAttempt + * The submissionAttempt to set. */ public void setSubmissionAttempt(String submissionAttempt) { - this.submissionAttempt = submissionAttempt; + this.submissionAttempt = submissionAttempt; } /** * @return Returns the defineLaterInEditMode. */ public String getDefineLaterInEditMode() { - return defineLaterInEditMode; + return defineLaterInEditMode; } + /** - * @param defineLaterInEditMode The defineLaterInEditMode to set. + * @param defineLaterInEditMode + * The defineLaterInEditMode to set. */ public void setDefineLaterInEditMode(String defineLaterInEditMode) { - this.defineLaterInEditMode = defineLaterInEditMode; + this.defineLaterInEditMode = defineLaterInEditMode; } + /** * @return Returns the toolContentID. */ + @Override public String getToolContentID() { - return toolContentID; + return toolContentID; } + /** - * @param toolContentID The toolContentID to set. + * @param toolContentID + * The toolContentID to set. */ + @Override public void setToolContentID(String toolContentID) { - this.toolContentID = toolContentID; + this.toolContentID = toolContentID; } - + /** * @return Returns the isDefineLater. */ public String getIsDefineLater() { - return isDefineLater; + return isDefineLater; } + /** - * @param isDefineLater The isDefineLater to set. + * @param isDefineLater + * The isDefineLater to set. */ public void setIsDefineLater(String isDefineLater) { - this.isDefineLater = isDefineLater; + this.isDefineLater = isDefineLater; } /** * @return Returns the defaultOptionContent. */ public String getDefaultOptionContent() { - return defaultOptionContent; + return defaultOptionContent; } + /** - * @param defaultOptionContent The defaultOptionContent to set. + * @param defaultOptionContent + * The defaultOptionContent to set. */ public void setDefaultOptionContent(String defaultOptionContent) { - this.defaultOptionContent = defaultOptionContent; + this.defaultOptionContent = defaultOptionContent; } /** * @return Returns the voteService. */ public IVoteService getVoteService() { - return voteService; + return voteService; } + /** - * @param voteService The voteService to set. + * @param voteService + * The voteService to set. */ public void setVoteService(IVoteService voteService) { - this.voteService = voteService; + this.voteService = voteService; } - + /** * @return Returns the httpSessionID. */ public String getHttpSessionID() { - return httpSessionID; + return httpSessionID; } + /** - * @param httpSessionID The httpSessionID to set. + * @param httpSessionID + * The httpSessionID to set. */ public void setHttpSessionID(String httpSessionID) { - this.httpSessionID = httpSessionID; + this.httpSessionID = httpSessionID; } - - public String toString() { - return new ToStringBuilder(this) - .append("activeModule: ", activeModule) - .append("contentFolderID: ", contentFolderID) - .append("addSingleQuestion: ", addSingleQuestion) - .append("editableQuestionIndex: ", editableQuestionIndex) - .append("feedback: ", feedback) - .append("editQuestionBoxRequest: ", editQuestionBoxRequest) - .append("defineLaterInEditMode: ", defineLaterInEditMode) - .append("submissionAttempt: ", submissionAttempt) - .append("sbmtSuccess: ", sbmtSuccess) - .append("exceptionMaxNominationInvalid: ", exceptionMaxNominationInvalid) - .append("isDefineLater: ", isDefineLater) - .append("toolContentID: ", toolContentID) - .append("allowText: ", allowText) - .append("showResults: ", showResults) - .append("lockOnFinish: ", lockOnFinish) - .append("reflect: ", reflect) - .append("defaultContentId: ", defaultContentId) - .append("defaultContentIdStr: ", defaultContentIdStr) - .append("maxNominationCount: ", maxNominationCount) - .append("defaultOptionContent: ", defaultOptionContent) - .append("activityTitle: ", activityTitle) - .append("activityInstructions: ", activityInstructions) - .append("richTextOfflineInstructions: ", richTextOfflineInstructions) - .append("richTextOnlineInstructions: ", richTextOnlineInstructions) - .append("onlineInstructions: ", onlineInstructions) - .append("offlineInstructions: ", offlineInstructions) - .toString(); + + @Override + public String toString() { + return new ToStringBuilder(this).append("activeModule: ", activeModule).append("contentFolderID: ", + contentFolderID).append("addSingleQuestion: ", addSingleQuestion).append("editableQuestionIndex: ", + editableQuestionIndex).append("feedback: ", feedback).append("editQuestionBoxRequest: ", + editQuestionBoxRequest).append("defineLaterInEditMode: ", defineLaterInEditMode).append( + "submissionAttempt: ", submissionAttempt).append("sbmtSuccess: ", sbmtSuccess).append( + "exceptionMaxNominationInvalid: ", exceptionMaxNominationInvalid).append("isDefineLater: ", + isDefineLater).append("toolContentID: ", toolContentID).append("allowText: ", allowText).append( + "showResults: ", showResults).append("lockOnFinish: ", lockOnFinish).append("reflect: ", reflect) + .append("defaultContentId: ", defaultContentId).append("defaultContentIdStr: ", defaultContentIdStr) + .append("maxNominationCount: ", maxNominationCount).append("defaultOptionContent: ", + defaultOptionContent).append("activityTitle: ", activityTitle).append("activityInstructions: ", + activityInstructions).append("richTextOfflineInstructions: ", richTextOfflineInstructions) + .append("richTextOnlineInstructions: ", richTextOnlineInstructions).append("onlineInstructions: ", + onlineInstructions).append("offlineInstructions: ", offlineInstructions).toString(); } /** * @return Returns the reflect. */ public String getReflect() { - return reflect; + return reflect; } + /** - * @param reflect The reflect to set. + * @param reflect + * The reflect to set. */ public void setReflect(String reflect) { - this.reflect = reflect; + this.reflect = reflect; } + /** * @return Returns the reflectionSubject. */ public String getReflectionSubject() { - return reflectionSubject; + return reflectionSubject; } + /** - * @param reflectionSubject The reflectionSubject to set. + * @param reflectionSubject + * The reflectionSubject to set. */ public void setReflectionSubject(String reflectionSubject) { - this.reflectionSubject = reflectionSubject; + this.reflectionSubject = reflectionSubject; } - + /** * @return Returns the addSingleQuestion. */ public String getAddSingleQuestion() { - return addSingleQuestion; + return addSingleQuestion; } + /** - * @param addSingleQuestion The addSingleQuestion to set. + * @param addSingleQuestion + * The addSingleQuestion to set. */ public void setAddSingleQuestion(String addSingleQuestion) { - this.addSingleQuestion = addSingleQuestion; + this.addSingleQuestion = addSingleQuestion; } + /** * @return Returns the contentFolderID. */ public String getContentFolderID() { - return contentFolderID; + return contentFolderID; } + /** - * @param contentFolderID The contentFolderID to set. + * @param contentFolderID + * The contentFolderID to set. */ public void setContentFolderID(String contentFolderID) { - this.contentFolderID = contentFolderID; + this.contentFolderID = contentFolderID; } + /** * @return Returns the editableQuestionIndex. */ public String getEditableQuestionIndex() { - return editableQuestionIndex; + return editableQuestionIndex; } + /** - * @param editableQuestionIndex The editableQuestionIndex to set. + * @param editableQuestionIndex + * The editableQuestionIndex to set. */ public void setEditableQuestionIndex(String editableQuestionIndex) { - this.editableQuestionIndex = editableQuestionIndex; + this.editableQuestionIndex = editableQuestionIndex; } + /** * @return Returns the editQuestionBoxRequest. */ public String getEditQuestionBoxRequest() { - return editQuestionBoxRequest; + return editQuestionBoxRequest; } + /** - * @param editQuestionBoxRequest The editQuestionBoxRequest to set. + * @param editQuestionBoxRequest + * The editQuestionBoxRequest to set. */ public void setEditQuestionBoxRequest(String editQuestionBoxRequest) { - this.editQuestionBoxRequest = editQuestionBoxRequest; + this.editQuestionBoxRequest = editQuestionBoxRequest; } + /** * @return Returns the feedback. */ public String getFeedback() { - return feedback; + return feedback; } + /** - * @param feedback The feedback to set. + * @param feedback + * The feedback to set. */ public void setFeedback(String feedback) { - this.feedback = feedback; + this.feedback = feedback; } - - + /** * @return Returns the editableNominationIndex. */ public String getEditableNominationIndex() { - return editableNominationIndex; + return editableNominationIndex; } + /** - * @param editableNominationIndex The editableNominationIndex to set. + * @param editableNominationIndex + * The editableNominationIndex to set. */ public void setEditableNominationIndex(String editableNominationIndex) { - this.editableNominationIndex = editableNominationIndex; + this.editableNominationIndex = editableNominationIndex; } - public String getShowResults() { - return showResults; - } + @Override + public String getShowResults() { + return showResults; + } - public void setShowResults(String showResults) { - this.showResults = showResults; - } + @Override + public void setShowResults(String showResults) { + this.showResults = showResults; + } } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java,v diff -u -r1.46 -r1.47 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java 13 May 2008 03:44:34 -0000 1.46 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java 2 Jul 2009 13:02:04 -0000 1.47 @@ -58,90 +58,90 @@ * If they return to the activity (e.g. via the progress bar) then the entries should be read only. * - - + + - - - - - + - + - + - - - - - + - - + - - - + - - - + + + + + + + + + + + + + + * */ @@ -194,569 +194,551 @@ import org.lamsfoundation.lams.web.util.AttributeNames; public class VoteLearningStarterAction extends Action implements VoteAppConstants { - static Logger logger = Logger.getLogger(VoteLearningStarterAction.class.getName()); + static Logger logger = Logger.getLogger(VoteLearningStarterAction.class.getName()); /* - * By now, the passed tool session id MUST exist in the db through the calling of: - * public void createToolSession(Long toolSessionID, Long toolContentId) by the container. - * + * By now, the passed tool session id MUST exist in the db through the calling of: public void + * createToolSession(Long toolSessionID, Long toolContentId) by the container. * + * * make sure this session exists in tool's session table by now. */ - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, VoteApplicationException { + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, VoteApplicationException { - VoteUtils.cleanUpSessionAbsolute(request); - - Map mapQuestionsContent= new TreeMap(new VoteComparator()); - Map mapAnswers= new TreeMap(new VoteComparator()); + Map mapQuestionsContent = new TreeMap(new VoteComparator()); + Map mapAnswers = new TreeMap(new VoteComparator()); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("retrieving voteService from session: " + voteService); + VoteLearningStarterAction.logger.debug("retrieving voteService from session: " + voteService); - VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO(); + VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO(); VoteLearningForm voteLearningForm = (VoteLearningForm) form; - + voteLearningForm.setRevisitingUser(new Boolean(false).toString()); voteLearningForm.setUserEntry(""); voteLearningForm.setCastVoteCount(0); voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString()); voteLearningForm.setActivityRunOffline(new Boolean(false).toString()); - + voteGeneralLearnerFlowDTO.setRevisitingUser(new Boolean(false).toString()); voteGeneralLearnerFlowDTO.setUserEntry(""); voteGeneralLearnerFlowDTO.setCastVoteCount("0"); voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString()); voteGeneralLearnerFlowDTO.setActivityRunOffline(new Boolean(false).toString()); - - - /* - * save time zone information to session scope. - */ - VoteUtils.saveTimeZone(request); - ActionForward validateParameters=validateParameters(request, mapping, voteLearningForm); - logger.debug("validateParameters: " + validateParameters); - if (validateParameters != null) - { - return validateParameters; - } - String toolSessionID=voteLearningForm.getToolSessionID(); - logger.debug("retrieved toolSessionID: " + toolSessionID); - /* - * by now, we made sure that the passed tool session id exists in the db as a new record - * Make sure we can retrieve it and the relavent content + * save time zone information to session scope. */ - - VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID)); - logger.debug("retrieving voteSession: " + voteSession); - - if (voteSession == null) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("error: The tool expects voteSession."); - return (mapping.findForward(ERROR_LIST)); - } + VoteUtils.saveTimeZone(request); + ActionForward validateParameters = validateParameters(request, mapping, voteLearningForm); + VoteLearningStarterAction.logger.debug("validateParameters: " + validateParameters); + if (validateParameters != null) { + return validateParameters; + } - /* - * find out what content this tool session is referring to - * get the content for this tool session - * Each passed tool session id points to a particular content. Many to one mapping. - */ - VoteContent voteContent=voteSession.getVoteContent(); - logger.debug("using voteContent: " + voteContent); - - if (voteContent == null) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("error: The tool expects voteContent."); - persistInRequestError(request,"error.content.doesNotExist"); - return (mapping.findForward(ERROR_LIST)); - } + String toolSessionID = voteLearningForm.getToolSessionID(); + VoteLearningStarterAction.logger.debug("retrieved toolSessionID: " + toolSessionID); - - /* - * The content we retrieved above must have been created before in Authoring time. - * And the passed tool session id already refers to it. - */ - setupAttributes(request, voteContent, voteLearningForm, voteGeneralLearnerFlowDTO); - - logger.debug("using TOOL_CONTENT_ID: " + voteContent.getVoteContentId()); - voteLearningForm.setToolContentID(voteContent.getVoteContentId().toString()); - voteGeneralLearnerFlowDTO.setToolContentID(voteContent.getVoteContentId().toString()); - - logger.debug("using TOOL_CONTENT_UID: " + voteContent.getUid()); - voteLearningForm.setToolContentUID(voteContent.getUid().toString()); - voteGeneralLearnerFlowDTO.setToolContentUID(voteContent.getUid().toString()); - - - String userID=voteLearningForm.getUserID(); - logger.debug("userID: " + userID); + /* + * by now, we made sure that the passed tool session id exists in the db as a new record Make sure we can + * retrieve it and the relavent content + */ - logger.debug("is tool reflective: " + voteContent.isReflect()); + VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID)); + VoteLearningStarterAction.logger.debug("retrieving voteSession: " + voteSession); + + if (voteSession == null) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteLearningStarterAction.logger.debug("error: The tool expects voteSession."); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + + /* + * find out what content this tool session is referring to get the content for this tool session Each passed + * tool session id points to a particular content. Many to one mapping. + */ + VoteContent voteContent = voteSession.getVoteContent(); + VoteLearningStarterAction.logger.debug("using voteContent: " + voteContent); + + if (voteContent == null) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteLearningStarterAction.logger.debug("error: The tool expects voteContent."); + persistInRequestError(request, "error.content.doesNotExist"); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + + /* + * The content we retrieved above must have been created before in Authoring time. And the passed tool session + * id already refers to it. + */ + setupAttributes(request, voteContent, voteLearningForm, voteGeneralLearnerFlowDTO); + + VoteLearningStarterAction.logger.debug("using TOOL_CONTENT_ID: " + voteContent.getVoteContentId()); + voteLearningForm.setToolContentID(voteContent.getVoteContentId().toString()); + voteGeneralLearnerFlowDTO.setToolContentID(voteContent.getVoteContentId().toString()); + + VoteLearningStarterAction.logger.debug("using TOOL_CONTENT_UID: " + voteContent.getUid()); + voteLearningForm.setToolContentUID(voteContent.getUid().toString()); + voteGeneralLearnerFlowDTO.setToolContentUID(voteContent.getUid().toString()); + + String userID = voteLearningForm.getUserID(); + VoteLearningStarterAction.logger.debug("userID: " + userID); + + VoteLearningStarterAction.logger.debug("is tool reflective: " + voteContent.isReflect()); voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString()); - logger.debug("reflection subject: " + voteContent.getReflectionSubject()); - String reflectionSubject=VoteUtils.replaceNewLines(voteContent.getReflectionSubject()); + VoteLearningStarterAction.logger.debug("reflection subject: " + voteContent.getReflectionSubject()); + String reflectionSubject = VoteUtils.replaceNewLines(voteContent.getReflectionSubject()); voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject); - - logger.debug("is vote lockOnFinish: " + voteContent.isLockOnFinish()); - - - /* Is the request for a preview by the author? - Preview The tool must be able to show the specified content as if it was running in a lesson. - It will be the learner url with tool access mode set to ToolAccessMode.AUTHOR - 3 modes are: - author - teacher - learner - */ - /* ? CHECK THIS: how do we determine whether preview is requested? Mode is not enough on its own.*/ - - - logger.debug("before checking for preview voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO); - /*handle PREVIEW mode*/ - String mode=voteLearningForm.getLearningMode(); - logger.debug("mode: " + mode); - if ((mode != null) && (mode.equals("author"))) - { - logger.debug("Author requests for a preview of the content."); - logger.debug("existing voteContent:" + voteContent); - - commonContentSetup(request, voteService, voteContent, voteGeneralLearnerFlowDTO); - - logger.debug("preview voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO); + VoteLearningStarterAction.logger.debug("is vote lockOnFinish: " + voteContent.isLockOnFinish()); + + /* + * Is the request for a preview by the author? Preview The tool must be able to show the specified content as if + * it was running in a lesson. It will be the learner url with tool access mode set to ToolAccessMode.AUTHOR 3 + * modes are: author teacher learner + */ + /* ? CHECK THIS: how do we determine whether preview is requested? Mode is not enough on its own. */ + + VoteLearningStarterAction.logger.debug("before checking for preview voteGeneralLearnerFlowDTO: " + + voteGeneralLearnerFlowDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); + + /* handle PREVIEW mode */ + String mode = voteLearningForm.getLearningMode(); + VoteLearningStarterAction.logger.debug("mode: " + mode); + if (mode != null && mode.equals("author")) { + VoteLearningStarterAction.logger.debug("Author requests for a preview of the content."); + VoteLearningStarterAction.logger.debug("existing voteContent:" + voteContent); + + commonContentSetup(request, voteService, voteContent, voteGeneralLearnerFlowDTO); + + VoteLearningStarterAction.logger.debug("preview voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); } - - /* by now, we know that the mode is either teacher or learner - * check if the mode is teacher and request is for Learner Progress + + /* + * by now, we know that the mode is either teacher or learner check if the mode is teacher and request is for + * Learner Progress */ - - String learnerProgressUserId=request.getParameter(USER_ID); - logger.debug("learnerProgressUserId: " + learnerProgressUserId); - - if ((learnerProgressUserId != null) && (mode.equals("teacher"))) - { - VoteQueUsr voteQueUsr=voteService.getVoteUserBySession(new Long(learnerProgressUserId), voteSession.getUid()); - if ( voteQueUsr != null ) { + String learnerProgressUserId = request.getParameter(VoteAppConstants.USER_ID); + VoteLearningStarterAction.logger.debug("learnerProgressUserId: " + learnerProgressUserId); - Long sessionUid=voteQueUsr.getVoteSessionId(); - - logger.debug("start building MAP_GENERAL_CHECKED_OPTIONS_CONTENT"); - String toolContentId=voteLearningForm.getToolContentID(); - logger.debug("toolContentId: " + toolContentId); + if (learnerProgressUserId != null && mode.equals("teacher")) { + VoteQueUsr voteQueUsr = voteService.getVoteUserBySession(new Long(learnerProgressUserId), voteSession + .getUid()); - putMapQuestionsContentIntoRequest(request, voteService, voteQueUsr); - - logger.debug("geting user answers for user uid and sessionUid" + voteQueUsr.getUid() + " " + sessionUid); - Set userAttempts=voteService.getAttemptsForUserAndSessionUseOpenAnswer(voteQueUsr.getUid(), sessionUid); - logger.debug("userAttempts: "+ userAttempts); - request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts); - - } else { - request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, new TreeMap(new VoteComparator())); - request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, new HashSet()); - } - - logger.debug("since this is progress view, present a screen which can not be edited"); - voteLearningForm.setReportViewOnly(new Boolean(true).toString()); - voteGeneralLearnerFlowDTO.setReportViewOnly(new Boolean(true).toString()); - voteGeneralLearnerFlowDTO.setLearningMode(mode); - putNotebookEntryIntoVoteGeneralLearnerFlowDTO(voteService, voteGeneralLearnerFlowDTO, toolSessionID, learnerProgressUserId); - - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO=new VoteGeneralMonitoringDTO(); - MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(), - voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, getMessageService()); + if (voteQueUsr != null) { - logger.debug("fwd'ing to: " + EXIT_PAGE); - return (mapping.findForward(EXIT_PAGE)); + Long sessionUid = voteQueUsr.getVoteSessionId(); + + VoteLearningStarterAction.logger.debug("start building MAP_GENERAL_CHECKED_OPTIONS_CONTENT"); + String toolContentId = voteLearningForm.getToolContentID(); + VoteLearningStarterAction.logger.debug("toolContentId: " + toolContentId); + + putMapQuestionsContentIntoRequest(request, voteService, voteQueUsr); + + VoteLearningStarterAction.logger.debug("geting user answers for user uid and sessionUid" + + voteQueUsr.getUid() + " " + sessionUid); + Set userAttempts = voteService.getAttemptsForUserAndSessionUseOpenAnswer(voteQueUsr.getUid(), + sessionUid); + VoteLearningStarterAction.logger.debug("userAttempts: " + userAttempts); + request.setAttribute(VoteAppConstants.LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts); + + } else { + request.setAttribute(VoteAppConstants.MAP_GENERAL_CHECKED_OPTIONS_CONTENT, new TreeMap( + new VoteComparator())); + request.setAttribute(VoteAppConstants.LIST_GENERAL_CHECKED_OPTIONS_CONTENT, new HashSet()); + } + + VoteLearningStarterAction.logger + .debug("since this is progress view, present a screen which can not be edited"); + voteLearningForm.setReportViewOnly(new Boolean(true).toString()); + voteGeneralLearnerFlowDTO.setReportViewOnly(new Boolean(true).toString()); + voteGeneralLearnerFlowDTO.setLearningMode(mode); + putNotebookEntryIntoVoteGeneralLearnerFlowDTO(voteService, voteGeneralLearnerFlowDTO, toolSessionID, + learnerProgressUserId); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(), + voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, + getMessageService()); + + VoteLearningStarterAction.logger.debug("fwd'ing to: " + VoteAppConstants.EXIT_PAGE); + return mapping.findForward(VoteAppConstants.EXIT_PAGE); } - - /* by now, we know that the mode is learner*/ + + /* by now, we know that the mode is learner */ putNotebookEntryIntoVoteGeneralLearnerFlowDTO(voteService, voteGeneralLearnerFlowDTO, toolSessionID, userID); - - /* find out if the content is set to run offline or online. If it is set to run offline , the learners are informed about that. */ - boolean isRunOffline=VoteUtils.isRunOffline(voteContent); - logger.debug("isRunOffline: " + isRunOffline); - if (isRunOffline == true) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("warning to learner: the activity is offline."); - voteLearningForm.setActivityRunOffline(new Boolean(true).toString()); - voteGeneralLearnerFlowDTO.setActivityRunOffline(new Boolean(true).toString()); - - logger.debug("runOffline voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO); - //return (mapping.findForward(ERROR_LIST)); - logger.debug("fwding to :" + RUN_OFFLINE); - return (mapping.findForward(RUN_OFFLINE)); - } - /* find out if the content is being modified at the moment. */ - boolean isDefineLater=VoteUtils.isDefineLater(voteContent); - logger.debug("isDefineLater: " + isDefineLater); - if (isDefineLater == true) - { - VoteUtils.cleanUpSessionAbsolute(request); - return (mapping.findForward(DEFINE_LATER)); - } + /* + * find out if the content is set to run offline or online. If it is set to run offline , the learners are + * informed about that. + */ + boolean isRunOffline = VoteUtils.isRunOffline(voteContent); + VoteLearningStarterAction.logger.debug("isRunOffline: " + isRunOffline); + if (isRunOffline == true) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteLearningStarterAction.logger.debug("warning to learner: the activity is offline."); + voteLearningForm.setActivityRunOffline(new Boolean(true).toString()); + voteGeneralLearnerFlowDTO.setActivityRunOffline(new Boolean(true).toString()); - /* + VoteLearningStarterAction.logger + .debug("runOffline voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); + // return (mapping.findForward(ERROR_LIST)); + VoteLearningStarterAction.logger.debug("fwding to :" + VoteAppConstants.RUN_OFFLINE); + return mapping.findForward(VoteAppConstants.RUN_OFFLINE); + } + + /* find out if the content is being modified at the moment. */ + boolean isDefineLater = VoteUtils.isDefineLater(voteContent); + VoteLearningStarterAction.logger.debug("isDefineLater: " + isDefineLater); + if (isDefineLater == true) { + VoteUtils.cleanUpSessionAbsolute(request); + return mapping.findForward(VoteAppConstants.DEFINE_LATER); + } + + /* * fetch question content from content */ - mapQuestionsContent=LearningUtil.buildQuestionContentMap(request, voteService, voteContent,null); - logger.debug("mapQuestionsContent: " + mapQuestionsContent); - - request.setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent); - logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getAttribute(MAP_QUESTION_CONTENT_LEARNER)); - request.setAttribute(MAP_OPTIONS_CONTENT, mapQuestionsContent); - - + mapQuestionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent, null); + VoteLearningStarterAction.logger.debug("mapQuestionsContent: " + mapQuestionsContent); + + request.setAttribute(VoteAppConstants.MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent); + VoteLearningStarterAction.logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + + request.getAttribute(VoteAppConstants.MAP_QUESTION_CONTENT_LEARNER)); + request.setAttribute(VoteAppConstants.MAP_OPTIONS_CONTENT, mapQuestionsContent); + /* - * verify that userId does not already exist in the db. - * If it does exist, that means, that user already responded to the content and - * his answers must be displayed read-only - * - */ - - logger.debug("userID:" + userID); - - logger.debug("voteSession uid :" + voteSession.getUid()); - VoteQueUsr voteQueUsr=voteService.getVoteUserBySession(new Long(userID), voteSession.getUid()); - logger.debug("voteQueUsr:" + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("voteQueUsr is available in the db:" + voteQueUsr); - Long queUsrId=voteQueUsr.getUid(); - logger.debug("queUsrId: " + queUsrId); - } - else - { - logger.debug("voteQueUsr is not available in the db:" + voteQueUsr); - } - - String learningMode=voteLearningForm.getLearningMode(); - logger.debug("users learning mode is: " + learningMode); - - /*the user's session id AND user id exists in the tool tables - *goto this screen if the OverAll Results scren has been already called up by this user*/ - if (voteQueUsr != null && voteQueUsr.isFinalScreenRequested()) - { - Long sessionUid=voteQueUsr.getVoteSessionId(); - logger.debug("users sessionUid: " + sessionUid); - VoteSession voteUserSession= voteService.getVoteSessionByUID(sessionUid); - logger.debug("voteUserSession: " + voteUserSession); - String userSessionId=voteUserSession.getVoteSessionId().toString(); - logger.debug("userSessionId: " + userSessionId); - logger.debug("current toolSessionID: " + toolSessionID); + * verify that userId does not already exist in the db. If it does exist, that means, that user already + * responded to the content and his answers must be displayed read-only + * + */ - if (toolSessionID.toString().equals(userSessionId)) - { - logger.debug("the learner has already responsed to this content, just generate a read-only report. Use redo questions for this."); - - logger.debug("start building MAP_GENERAL_CHECKED_OPTIONS_CONTENT"); - String toolContentId=voteLearningForm.getToolContentID(); - logger.debug("toolContentId: " + toolContentId); + VoteLearningStarterAction.logger.debug("userID:" + userID); - putMapQuestionsContentIntoRequest(request, voteService, voteQueUsr); - - boolean isResponseFinalised=voteQueUsr.isResponseFinalised(); - logger.debug("isResponseFinalised: " + isResponseFinalised); - if (isResponseFinalised) - { - logger.debug("since the response is finalised present a screen which can not be edited"); - voteLearningForm.setReportViewOnly(new Boolean(true).toString()); - voteGeneralLearnerFlowDTO.setReportViewOnly(new Boolean(true).toString()); - } - - logger.debug("geting user answers for user uid and sessionUid" + voteQueUsr.getUid() + " " + sessionUid); - Set userAttempts=voteService.getAttemptsForUserAndSessionUseOpenAnswer(voteQueUsr.getUid(), sessionUid); - logger.debug("userAttempts: "+ userAttempts); - request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts); + VoteLearningStarterAction.logger.debug("voteSession uid :" + voteSession.getUid()); + VoteQueUsr voteQueUsr = voteService.getVoteUserBySession(new Long(userID), voteSession.getUid()); + VoteLearningStarterAction.logger.debug("voteQueUsr:" + voteQueUsr); - - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO=new VoteGeneralMonitoringDTO(); - MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(), - voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, getMessageService()); + if (voteQueUsr != null) { + VoteLearningStarterAction.logger.debug("voteQueUsr is available in the db:" + voteQueUsr); + Long queUsrId = voteQueUsr.getUid(); + VoteLearningStarterAction.logger.debug("queUsrId: " + queUsrId); + } else { + VoteLearningStarterAction.logger.debug("voteQueUsr is not available in the db:" + voteQueUsr); + } - - String isContentLockOnFinish=voteLearningForm.getLockOnFinish(); - logger.debug("isContentLockOnFinish: " + isContentLockOnFinish); - if ((isContentLockOnFinish.equals(new Boolean(true).toString()) && (isResponseFinalised == true))) - { - logger.debug("user with session id: " + userSessionId + " should not redo votes. session is locked."); - logger.debug("fwd'ing to: " + EXIT_PAGE); - return (mapping.findForward(EXIT_PAGE)); - } - - logger.debug("the user's session id AND user id exists in the tool tables go to redo questions. " + toolSessionID + " voteQueUsr: " + - voteQueUsr + " user id: " + voteQueUsr.getQueUsrId()); - voteLearningForm.setRevisitingUser(new Boolean(true).toString()); - voteGeneralLearnerFlowDTO.setRevisitingUser(new Boolean(true).toString()); - logger.debug("preparing chart data for readonly mode"); + String learningMode = voteLearningForm.getLearningMode(); + VoteLearningStarterAction.logger.debug("users learning mode is: " + learningMode); - - logger.debug("view-only voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO); - - if ((isContentLockOnFinish.equals(new Boolean(false).toString()) && (isResponseFinalised == true))) - { - logger.debug("isContentLockOnFinish is false, enable redo of votes : "); - logger.debug("fwd'ing to: " + REVISITED_ALL_NOMINATIONS); - return (mapping.findForward(REVISITED_ALL_NOMINATIONS)); - } + /* + * the user's session id AND user id exists in the tool tables goto this screen if the OverAll Results scren has + * been already called up by this user + */ + if (voteQueUsr != null && voteQueUsr.isFinalScreenRequested()) { + Long sessionUid = voteQueUsr.getVoteSessionId(); + VoteLearningStarterAction.logger.debug("users sessionUid: " + sessionUid); + VoteSession voteUserSession = voteService.getVoteSessionByUID(sessionUid); + VoteLearningStarterAction.logger.debug("voteUserSession: " + voteUserSession); + String userSessionId = voteUserSession.getVoteSessionId().toString(); + VoteLearningStarterAction.logger.debug("userSessionId: " + userSessionId); + VoteLearningStarterAction.logger.debug("current toolSessionID: " + toolSessionID); - - logger.debug("fwd'ing to: " + ALL_NOMINATIONS); - return (mapping.findForward(ALL_NOMINATIONS)); - } - } - logger.debug("presenting standard learner screen.."); - return (mapping.findForward(LOAD_LEARNER)); -} + if (toolSessionID.toString().equals(userSessionId)) { + VoteLearningStarterAction.logger + .debug("the learner has already responsed to this content, just generate a read-only report. Use redo questions for this."); - private void putNotebookEntryIntoVoteGeneralLearnerFlowDTO(IVoteService voteService, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO, String toolSessionID, String userID) { - logger.debug("attempt getting notebookEntry: "); - NotebookEntry notebookEntry = voteService.getEntry(new Long(toolSessionID), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(userID)); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - String notebookEntryPresentable=VoteUtils.replaceNewLines(notebookEntry.getEntry()); - voteGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable); + VoteLearningStarterAction.logger.debug("start building MAP_GENERAL_CHECKED_OPTIONS_CONTENT"); + String toolContentId = voteLearningForm.getToolContentID(); + VoteLearningStarterAction.logger.debug("toolContentId: " + toolContentId); + + putMapQuestionsContentIntoRequest(request, voteService, voteQueUsr); + + boolean isResponseFinalised = voteQueUsr.isResponseFinalised(); + VoteLearningStarterAction.logger.debug("isResponseFinalised: " + isResponseFinalised); + if (isResponseFinalised) { + VoteLearningStarterAction.logger + .debug("since the response is finalised present a screen which can not be edited"); + voteLearningForm.setReportViewOnly(new Boolean(true).toString()); + voteGeneralLearnerFlowDTO.setReportViewOnly(new Boolean(true).toString()); } + + VoteLearningStarterAction.logger.debug("geting user answers for user uid and sessionUid" + + voteQueUsr.getUid() + " " + sessionUid); + Set userAttempts = voteService.getAttemptsForUserAndSessionUseOpenAnswer(voteQueUsr.getUid(), + sessionUid); + VoteLearningStarterAction.logger.debug("userAttempts: " + userAttempts); + request.setAttribute(VoteAppConstants.LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(), + voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, + getMessageService()); + + String isContentLockOnFinish = voteLearningForm.getLockOnFinish(); + VoteLearningStarterAction.logger.debug("isContentLockOnFinish: " + isContentLockOnFinish); + if (isContentLockOnFinish.equals(new Boolean(true).toString()) && isResponseFinalised == true) { + VoteLearningStarterAction.logger.debug("user with session id: " + userSessionId + + " should not redo votes. session is locked."); + VoteLearningStarterAction.logger.debug("fwd'ing to: " + VoteAppConstants.EXIT_PAGE); + return mapping.findForward(VoteAppConstants.EXIT_PAGE); + } + + VoteLearningStarterAction.logger + .debug("the user's session id AND user id exists in the tool tables go to redo questions. " + + toolSessionID + " voteQueUsr: " + voteQueUsr + " user id: " + + voteQueUsr.getQueUsrId()); + voteLearningForm.setRevisitingUser(new Boolean(true).toString()); + voteGeneralLearnerFlowDTO.setRevisitingUser(new Boolean(true).toString()); + VoteLearningStarterAction.logger.debug("preparing chart data for readonly mode"); + + VoteLearningStarterAction.logger.debug("view-only voteGeneralLearnerFlowDTO: " + + voteGeneralLearnerFlowDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); + + if (isContentLockOnFinish.equals(new Boolean(false).toString()) && isResponseFinalised == true) { + VoteLearningStarterAction.logger.debug("isContentLockOnFinish is false, enable redo of votes : "); + VoteLearningStarterAction.logger.debug("fwd'ing to: " + VoteAppConstants.REVISITED_ALL_NOMINATIONS); + return mapping.findForward(VoteAppConstants.REVISITED_ALL_NOMINATIONS); + } + + VoteLearningStarterAction.logger.debug("fwd'ing to: " + VoteAppConstants.ALL_NOMINATIONS); + return mapping.findForward(VoteAppConstants.ALL_NOMINATIONS); + } } + VoteLearningStarterAction.logger.debug("presenting standard learner screen.."); + return mapping.findForward(VoteAppConstants.LOAD_LEARNER); + } - /** Build the attempts map and put it in the request, based on the supplied user. - * If the user is null then the map will be set but it will be empty - * TODO This shouldn't go in the request, it should go in our special session map. */ - private void putMapQuestionsContentIntoRequest(HttpServletRequest request, IVoteService voteService, VoteQueUsr voteQueUsr) { - List attempts=null; - if ( voteQueUsr != null ) { - attempts = voteService.getAttemptsForUser(voteQueUsr.getUid()); - } - logger.debug("attempts: " + attempts); + private void putNotebookEntryIntoVoteGeneralLearnerFlowDTO(IVoteService voteService, + VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO, String toolSessionID, String userID) { + VoteLearningStarterAction.logger.debug("attempt getting notebookEntry: "); + NotebookEntry notebookEntry = voteService.getEntry(new Long(toolSessionID), + CoreNotebookConstants.NOTEBOOK_TOOL, VoteAppConstants.MY_SIGNATURE, new Integer(userID)); - Map localMapQuestionsContent= new TreeMap(new VoteComparator()); + VoteLearningStarterAction.logger.debug("notebookEntry: " + notebookEntry); - if ( attempts != null ) { - - Iterator listIterator=attempts.iterator(); - int order=0; - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - logger.debug("attempt: " + attempt); - VoteQueContent voteQueContent=attempt.getVoteQueContent(); - logger.debug("voteQueContent: " + voteQueContent); - order++; - if (voteQueContent != null) - { - String entry=voteQueContent.getQuestion(); - logger.debug("entry: " + entry); - - String voteQueContentId=attempt.getVoteQueContentId().toString(); - logger.debug("voteQueContentId: " + voteQueContentId); - if (entry != null) - { - if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) - { - logger.debug("this nomination entry points to a user entered nomination: " + attempt.getUserEntry()); - localMapQuestionsContent.put(new Integer(order).toString(), attempt.getUserEntry()); - } - else - { - logger.debug("this nomination entry points to a standard nomination: " + voteQueContent.getQuestion()); - localMapQuestionsContent.put(new Integer(order).toString(),voteQueContent.getQuestion()); - } - } - } + if (notebookEntry != null) { + String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry()); + voteGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable); + } + } + + /** + * Build the attempts map and put it in the request, based on the supplied user. If the user is null then the map + * will be set but it will be empty TODO This shouldn't go in the request, it should go in our special session map. + */ + private void putMapQuestionsContentIntoRequest(HttpServletRequest request, IVoteService voteService, + VoteQueUsr voteQueUsr) { + List attempts = null; + if (voteQueUsr != null) { + attempts = voteService.getAttemptsForUser(voteQueUsr.getUid()); + } + VoteLearningStarterAction.logger.debug("attempts: " + attempts); + + Map localMapQuestionsContent = new TreeMap(new VoteComparator()); + + if (attempts != null) { + + Iterator listIterator = attempts.iterator(); + int order = 0; + while (listIterator.hasNext()) { + VoteUsrAttempt attempt = (VoteUsrAttempt) listIterator.next(); + VoteLearningStarterAction.logger.debug("attempt: " + attempt); + VoteQueContent voteQueContent = attempt.getVoteQueContent(); + VoteLearningStarterAction.logger.debug("voteQueContent: " + voteQueContent); + order++; + if (voteQueContent != null) { + String entry = voteQueContent.getQuestion(); + VoteLearningStarterAction.logger.debug("entry: " + entry); + + String voteQueContentId = attempt.getVoteQueContentId().toString(); + VoteLearningStarterAction.logger.debug("voteQueContentId: " + voteQueContentId); + if (entry != null) { + if (entry.equals("sample nomination") && voteQueContentId.equals("1")) { + VoteLearningStarterAction.logger + .debug("this nomination entry points to a user entered nomination: " + + attempt.getUserEntry()); + localMapQuestionsContent.put(new Integer(order).toString(), attempt.getUserEntry()); + } else { + VoteLearningStarterAction.logger + .debug("this nomination entry points to a standard nomination: " + + voteQueContent.getQuestion()); + localMapQuestionsContent.put(new Integer(order).toString(), voteQueContent.getQuestion()); } + } } - - request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, localMapQuestionsContent); - logger.debug("end building MAP_GENERAL_CHECKED_OPTIONS_CONTENT: " + localMapQuestionsContent); + } } + request.setAttribute(VoteAppConstants.MAP_GENERAL_CHECKED_OPTIONS_CONTENT, localMapQuestionsContent); + VoteLearningStarterAction.logger.debug("end building MAP_GENERAL_CHECKED_OPTIONS_CONTENT: " + + localMapQuestionsContent); + } - /** - * sets up question and candidate answers maps - * commonContentSetup(HttpServletRequest request, VoteContent voteContent) - * - * @param request - * @param voteContent + /** + * sets up question and candidate answers maps commonContentSetup(HttpServletRequest request, VoteContent + * voteContent) + * + * @param request + * @param voteContent + */ + protected void commonContentSetup(HttpServletRequest request, IVoteService voteService, VoteContent voteContent, + VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO) { + Map mapQuestionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent, null); + VoteLearningStarterAction.logger.debug("mapQuestionsContent: " + mapQuestionsContent); + + request.setAttribute(VoteAppConstants.MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent); + VoteLearningStarterAction.logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + + request.getAttribute(VoteAppConstants.MAP_QUESTION_CONTENT_LEARNER)); + VoteLearningStarterAction.logger.debug("voteContent has : " + mapQuestionsContent.size() + " entries."); + voteGeneralLearnerFlowDTO.setTotalQuestionCount(new Long(mapQuestionsContent.size()).toString()); + } + + /** + * sets up session scope attributes based on content linked to the passed tool session id + * setupAttributes(HttpServletRequest request, VoteContent voteContent) + * + * @param request + * @param voteContent + */ + protected void setupAttributes(HttpServletRequest request, VoteContent voteContent, + VoteLearningForm voteLearningForm, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO) { + + VoteLearningStarterAction.logger.debug("IS_CONTENT_IN_USE: " + voteContent.isContentInUse()); + + Map mapGeneralCheckedOptionsContent = new TreeMap(new VoteComparator()); + request.setAttribute(VoteAppConstants.MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); + /* + * Is the tool activity been checked as Run Offline in the property inspector? */ - protected void commonContentSetup(HttpServletRequest request, IVoteService voteService, VoteContent voteContent, - VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO) - { - Map mapQuestionsContent=LearningUtil.buildQuestionContentMap(request,voteService, voteContent,null); - logger.debug("mapQuestionsContent: " + mapQuestionsContent); - - request.setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent); - logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getAttribute(MAP_QUESTION_CONTENT_LEARNER)); - logger.debug("voteContent has : " + mapQuestionsContent.size() + " entries."); - voteGeneralLearnerFlowDTO.setTotalQuestionCount(new Long(mapQuestionsContent.size()).toString()); - } + VoteLearningStarterAction.logger.debug("IS_TOOL_ACTIVITY_OFFLINE: " + voteContent.isRunOffline()); + VoteLearningStarterAction.logger.debug("advanced properties maxNominationCount: " + + voteContent.getMaxNominationCount()); + VoteLearningStarterAction.logger.debug("advanced properties isAllowText(): " + + new Boolean(voteContent.isAllowText()).toString()); + VoteLearningStarterAction.logger.debug("advanced properties isRunOffline(): " + + new Boolean(voteContent.isRunOffline()).toString()); + VoteLearningStarterAction.logger.debug("advanced properties isLockOnFinish(): " + + new Boolean(voteContent.isLockOnFinish()).toString()); - /** - * sets up session scope attributes based on content linked to the passed tool session id - * setupAttributes(HttpServletRequest request, VoteContent voteContent) - * - * @param request - * @param voteContent + voteLearningForm.setActivityTitle(voteContent.getTitle()); + voteLearningForm.setActivityInstructions(voteContent.getInstructions()); + voteLearningForm.setActivityRunOffline(new Boolean(voteContent.isRunOffline()).toString()); + voteLearningForm.setMaxNominationCount(voteContent.getMaxNominationCount()); + voteLearningForm.setAllowTextEntry(new Boolean(voteContent.isAllowText()).toString()); + voteLearningForm.setShowResults(new Boolean(voteContent.isShowResults()).toString()); + voteLearningForm.setLockOnFinish(new Boolean(voteContent.isLockOnFinish()).toString()); + + voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle()); + voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions()); + voteGeneralLearnerFlowDTO.setActivityRunOffline(new Boolean(voteContent.isRunOffline()).toString()); + voteGeneralLearnerFlowDTO.setMaxNominationCount(voteContent.getMaxNominationCount()); + voteGeneralLearnerFlowDTO.setAllowTextEntry(new Boolean(voteContent.isAllowText()).toString()); + voteGeneralLearnerFlowDTO.setLockOnFinish(new Boolean(voteContent.isLockOnFinish()).toString()); + voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle()); + voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions()); + } + + protected ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping, + VoteLearningForm voteLearningForm) { + /* + * obtain and setup the current user's data */ - protected void setupAttributes(HttpServletRequest request, VoteContent voteContent, - VoteLearningForm voteLearningForm, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO) - { - - logger.debug("IS_CONTENT_IN_USE: " + voteContent.isContentInUse()); - - Map mapGeneralCheckedOptionsContent= new TreeMap(new VoteComparator()); - request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); - /* - * Is the tool activity been checked as Run Offline in the property inspector? - */ - logger.debug("IS_TOOL_ACTIVITY_OFFLINE: " + voteContent.isRunOffline()); - logger.debug("advanced properties maxNominationCount: " + voteContent.getMaxNominationCount()); - logger.debug("advanced properties isAllowText(): " + new Boolean(voteContent.isAllowText()).toString()); - logger.debug("advanced properties isRunOffline(): " + new Boolean(voteContent.isRunOffline()).toString()); - logger.debug("advanced properties isLockOnFinish(): " + new Boolean(voteContent.isLockOnFinish()).toString()); - - - voteLearningForm.setActivityTitle(voteContent.getTitle()); - voteLearningForm.setActivityInstructions(voteContent.getInstructions()); - voteLearningForm.setActivityRunOffline(new Boolean(voteContent.isRunOffline()).toString()); - voteLearningForm.setMaxNominationCount(voteContent.getMaxNominationCount()); - voteLearningForm.setAllowTextEntry(new Boolean(voteContent.isAllowText()).toString()); - voteLearningForm.setShowResults(new Boolean(voteContent.isShowResults()).toString()); - voteLearningForm.setLockOnFinish(new Boolean(voteContent.isLockOnFinish()).toString()); - - voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle()); - voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions()); - voteGeneralLearnerFlowDTO.setActivityRunOffline(new Boolean(voteContent.isRunOffline()).toString()); - voteGeneralLearnerFlowDTO.setMaxNominationCount(voteContent.getMaxNominationCount()); - voteGeneralLearnerFlowDTO.setAllowTextEntry(new Boolean(voteContent.isAllowText()).toString()); - voteGeneralLearnerFlowDTO.setLockOnFinish(new Boolean(voteContent.isLockOnFinish()).toString()); - voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle()); - voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions()); - } - - - protected ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping, VoteLearningForm voteLearningForm) - { - /* - * obtain and setup the current user's data - */ - - String userID = ""; - HttpSession ss = SessionManager.getSession(); - logger.debug("ss: " + ss); - - if (ss != null) - { - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if ((user != null) && (user.getUserID() != null)) - { - userID = user.getUserID().toString(); - logger.debug("retrieved userId: " + userID); - voteLearningForm.setUserID(userID); - } + String userID = ""; + HttpSession ss = SessionManager.getSession(); + VoteLearningStarterAction.logger.debug("ss: " + ss); + + if (ss != null) { + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (user != null && user.getUserID() != null) { + userID = user.getUserID().toString(); + VoteLearningStarterAction.logger.debug("retrieved userId: " + userID); + voteLearningForm.setUserID(userID); } - - - /* - * process incoming tool session id and later derive toolContentId from it. - */ - String strToolSessionId=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); - long toolSessionID=0; - if ((strToolSessionId == null) || (strToolSessionId.length() == 0)) - { - VoteUtils.cleanUpSessionAbsolute(request); - //persistInRequestError(request, "error.toolSessionId.required"); - return (mapping.findForward(ERROR_LIST)); - } - else - { - try - { - toolSessionID=new Long(strToolSessionId).longValue(); - logger.debug("passed TOOL_SESSION_ID : " + new Long(toolSessionID)); - voteLearningForm.setToolSessionID(new Long(toolSessionID).toString()); - } - catch(NumberFormatException e) - { - VoteUtils.cleanUpSessionAbsolute(request); - //persistInRequestError(request, "error.sessionId.numberFormatException"); - logger.debug("add error.sessionId.numberFormatException to ActionMessages."); - return (mapping.findForward(ERROR_LIST)); - } - } - - /*mode can be learner, teacher or author */ - String mode=request.getParameter(MODE); - logger.debug("mode: " + mode); - - if ((mode == null) || (mode.length() == 0)) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.error("mode missing: "); - return (mapping.findForward(ERROR_LIST)); - } - - if ((!mode.equals("learner")) && (!mode.equals("teacher")) && (!mode.equals("author"))) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.error("mode invalid: "); - return (mapping.findForward(ERROR_LIST)); - } - logger.debug("session LEARNING_MODE set to:" + mode); - voteLearningForm.setLearningMode(mode); - - return null; } - - boolean isSessionCompleted(String userSessionId, IVoteService voteService) - { - logger.debug("userSessionId:" + userSessionId); - VoteSession voteSession=voteService.retrieveVoteSession(new Long(userSessionId)); - logger.debug("retrieving voteSession: " + voteSession); - logger.debug("voteSession status : " + voteSession.getSessionStatus()); - if ((voteSession.getSessionStatus() != null) && (voteSession.getSessionStatus().equals(VoteAppConstants.COMPLETED))) - { - logger.debug("this session is COMPLETED voteSession status : " + userSessionId + "->" + voteSession.getSessionStatus()); - return true; + /* + * process incoming tool session id and later derive toolContentId from it. + */ + String strToolSessionId = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); + long toolSessionID = 0; + if (strToolSessionId == null || strToolSessionId.length() == 0) { + VoteUtils.cleanUpSessionAbsolute(request); + // persistInRequestError(request, "error.toolSessionId.required"); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } else { + try { + toolSessionID = new Long(strToolSessionId).longValue(); + VoteLearningStarterAction.logger.debug("passed TOOL_SESSION_ID : " + new Long(toolSessionID)); + voteLearningForm.setToolSessionID(new Long(toolSessionID).toString()); + } catch (NumberFormatException e) { + VoteUtils.cleanUpSessionAbsolute(request); + // persistInRequestError(request, "error.sessionId.numberFormatException"); + VoteLearningStarterAction.logger.debug("add error.sessionId.numberFormatException to ActionMessages."); + return mapping.findForward(VoteAppConstants.ERROR_LIST); } - return false; } - - /** + + /* mode can be learner, teacher or author */ + String mode = request.getParameter(VoteAppConstants.MODE); + VoteLearningStarterAction.logger.debug("mode: " + mode); + + if (mode == null || mode.length() == 0) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteLearningStarterAction.logger.error("mode missing: "); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + + if (!mode.equals("learner") && !mode.equals("teacher") && !mode.equals("author")) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteLearningStarterAction.logger.error("mode invalid: "); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + VoteLearningStarterAction.logger.debug("session LEARNING_MODE set to:" + mode); + voteLearningForm.setLearningMode(mode); + + return null; + } + + boolean isSessionCompleted(String userSessionId, IVoteService voteService) { + VoteLearningStarterAction.logger.debug("userSessionId:" + userSessionId); + VoteSession voteSession = voteService.retrieveVoteSession(new Long(userSessionId)); + VoteLearningStarterAction.logger.debug("retrieving voteSession: " + voteSession); + VoteLearningStarterAction.logger.debug("voteSession status : " + voteSession.getSessionStatus()); + if (voteSession.getSessionStatus() != null && voteSession.getSessionStatus().equals(VoteAppConstants.COMPLETED)) { + VoteLearningStarterAction.logger.debug("this session is COMPLETED voteSession status : " + userSessionId + + "->" + voteSession.getSessionStatus()); + return true; + } + return false; + } + + /** * persists error messages to request scope + * * @param request * @param message */ - public void persistInRequestError(HttpServletRequest request, String message) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY, new ActionMessage(message)); - logger.debug("add " + message +" to ActionMessages:"); - saveErrors(request,errors); - } - - /** - * Return ResourceService bean. - */ - private MessageService getMessageService() { - return (MessageService) VoteServiceProxy.getMessageService(getServlet().getServletContext()); - } -} + public void persistInRequestError(HttpServletRequest request, String message) { + ActionMessages errors = new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + VoteLearningStarterAction.logger.debug("add " + message + " to ActionMessages:"); + saveErrors(request, errors); + } + + /** + * Return ResourceService bean. + */ + private MessageService getMessageService() { + return VoteServiceProxy.getMessageService(getServlet().getServletContext()); + } +} Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java,v diff -u -r1.44 -r1.45 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java 23 May 2008 06:05:24 -0000 1.44 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java 2 Jul 2009 13:02:04 -0000 1.45 @@ -71,909 +71,831 @@ import org.lamsfoundation.lams.web.util.SessionMap; /** - *

Action class that controls the logic of tool behavior.

+ *

+ * Action class that controls the logic of tool behavior. + *

* - *

Note that Struts action class only has the responsibility to navigate - * page flow. All database operation should go to service layer and data - * transformation from domain model to struts form bean should go to form - * bean class. This ensure clean and maintainable code. + *

+ * Note that Struts action class only has the responsibility to navigate page flow. All database operation should go to + * service layer and data transformation from domain model to struts form bean should go to form bean class. This ensure + * clean and maintainable code. *

* - * SystemException is thrown whenever an known error condition is - * identified. No system exception error handling code should appear in the - * Struts action class as all of them are handled in + * SystemException is thrown whenever an known error condition is identified. No system exception error + * handling code should appear in the Struts action class as all of them are handled in * CustomStrutsExceptionHandler. * * @author Ozgur Demirtas * * - - - + - - - + - + - + + - + - + - - + - * -*/ -public class VoteMonitoringAction extends LamsDispatchAction implements VoteAppConstants -{ - static Logger logger = Logger.getLogger(VoteMonitoringAction.class.getName()); - - /** - *

Default struts dispatch method.

+ + +
+ + * + */ +public class VoteMonitoringAction extends LamsDispatchAction implements VoteAppConstants { + static Logger logger = Logger.getLogger(VoteMonitoringAction.class.getName()); + + /** + *

+ * Default struts dispatch method. + *

* - *

It is assuming that progress engine should pass in the tool access - * mode and the tool session id as http parameters.

+ *

+ * It is assuming that progress engine should pass in the tool access mode and the tool session id as http + * parameters. + *

* - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. - * - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. + * + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. * @throws IOException * @throws ServletException - * @throws VoteApplicationException the known runtime exception + * @throws VoteApplicationException + * the known runtime exception * - * unspecified(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - - * main content/question content management and workflow logic - * - */ - public ActionForward unspecified(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - VoteUtils.cleanUpUserExceptions(request); - logger.debug("dispatching unspecified..."); - return null; + * unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * throws IOException, ServletException + * + * main content/question content management and workflow logic + * + */ + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteUtils.cleanUpUserExceptions(request); + VoteMonitoringAction.logger.debug("dispatching unspecified..."); + return null; } - - public ActionForward submitSession(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response, - IVoteService voteService, - MessageService messageService, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO - ) throws IOException, - ServletException - { - logger.debug("calling submitSession...voteGeneralMonitoringDTO:" + voteGeneralMonitoringDTO); - commonSubmitSessionCode(form, request, voteService, messageService, voteGeneralMonitoringDTO); - logger.debug("post commonSubmitSessionCode: " +voteGeneralMonitoringDTO); - return (mapping.findForward(LOAD_MONITORING)); + public ActionForward submitSession(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response, IVoteService voteService, MessageService messageService, + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("calling submitSession...voteGeneralMonitoringDTO:" + + voteGeneralMonitoringDTO); + commonSubmitSessionCode(form, request, voteService, messageService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post commonSubmitSessionCode: " + voteGeneralMonitoringDTO); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); + } + + protected void commonSubmitSessionCode(ActionForm form, HttpServletRequest request, IVoteService voteService, + MessageService messageService, VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, + ServletException { + VoteMonitoringAction.logger.debug("starting commonSubmitSessionCode...voteGeneralMonitoringDTO:" + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("voteService:" + voteService); + VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + + repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("done repopulateRequestParameters"); + + String currentMonitoredToolSession = voteMonitoringForm.getSelectedToolSessionId(); + VoteMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + + String toolContentID = voteMonitoringForm.getToolContentID(); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); + + if (currentMonitoredToolSession.equals("All")) { + voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(2)); + + VoteMonitoringAction.logger.debug("generate DTO for All sessions: "); + List listVoteAllSessionsDTO = MonitoringUtil.prepareChartDTO(request, voteService, voteMonitoringForm, + voteContent.getVoteContentId(), messageService); + VoteMonitoringAction.logger.debug("listVoteAllSessionsDTO: " + listVoteAllSessionsDTO); + voteGeneralMonitoringDTO.setListVoteAllSessionsDTO(listVoteAllSessionsDTO); + } else { + VoteMonitoringAction.logger.debug("preparing chart data for content id: " + voteContent.getVoteContentId()); + VoteMonitoringAction.logger.debug("preparing chart data for currentMonitoredToolSession: " + + currentMonitoredToolSession); + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(1)); + + VoteSession voteSession = voteService.retrieveVoteSession(new Long(currentMonitoredToolSession)); + VoteMonitoringAction.logger.debug("voteSession uid:" + voteSession.getUid()); + MonitoringUtil.prepareChartData(request, voteService, voteMonitoringForm, voteContent.getVoteContentId() + .toString(), voteSession.getUid().toString(), null, voteGeneralMonitoringDTO, getMessageService()); + + VoteMonitoringAction.logger.debug("post prepareChartData, voteGeneralMonitoringDTO:" + + voteGeneralMonitoringDTO); + + refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, null, true, + null, voteGeneralMonitoringDTO, null); + VoteMonitoringAction.logger.debug("session_name: " + voteSession.getSession_name()); + voteGeneralMonitoringDTO.setGroupName(voteSession.getSession_name()); + VoteMonitoringAction.logger.debug("post refreshSummaryData, voteGeneralMonitoringDTO:" + + voteGeneralMonitoringDTO); + voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); } - + VoteMonitoringAction.logger.debug("SELECTION_CASE: " + voteGeneralMonitoringDTO.getSelectionCase()); - protected void commonSubmitSessionCode(ActionForm form, HttpServletRequest request,IVoteService voteService, MessageService messageService, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, ServletException - { - logger.debug("starting commonSubmitSessionCode...voteGeneralMonitoringDTO:" + voteGeneralMonitoringDTO); - - logger.debug("voteService:" + voteService); - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - - repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - logger.debug("done repopulateRequestParameters"); + VoteMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(VoteAppConstants.SELECTION_CASE)); + request.setAttribute(VoteAppConstants.CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); - String currentMonitoredToolSession=voteMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); + voteMonitoringForm.setSbmtSuccess(new Boolean(false).toString()); + voteGeneralMonitoringDTO.setSbmtSuccess(new Boolean(false).toString()); + voteGeneralMonitoringDTO.setRequestLearningReport(new Boolean(false).toString()); - String toolContentID =voteMonitoringForm.getToolContentID(); - logger.debug("toolContentID: " + toolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("existing voteContent:" + voteContent); - - - if (currentMonitoredToolSession.equals("All")) - { - voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); - request.setAttribute(SELECTION_CASE, new Long(2)); - - logger.debug("generate DTO for All sessions: "); - List listVoteAllSessionsDTO=MonitoringUtil.prepareChartDTO(request, voteService, voteMonitoringForm, voteContent.getVoteContentId(), messageService); - logger.debug("listVoteAllSessionsDTO: " + listVoteAllSessionsDTO); - voteGeneralMonitoringDTO.setListVoteAllSessionsDTO(listVoteAllSessionsDTO); - } - else - { - logger.debug("preparing chart data for content id: " + voteContent.getVoteContentId()); - logger.debug("preparing chart data for currentMonitoredToolSession: " + currentMonitoredToolSession); - request.setAttribute(SELECTION_CASE, new Long(1)); - - VoteSession voteSession=voteService.retrieveVoteSession(new Long(currentMonitoredToolSession)); - logger.debug("voteSession uid:" + voteSession.getUid()); - MonitoringUtil.prepareChartData(request, voteService, voteMonitoringForm, voteContent.getVoteContentId().toString(), - voteSession.getUid().toString(), null, voteGeneralMonitoringDTO, getMessageService()); - - logger.debug("post prepareChartData, voteGeneralMonitoringDTO:" + voteGeneralMonitoringDTO); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, voteContent, voteService); + VoteMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + voteGeneralMonitoringDTO.setSummaryToolSessions(summaryToolSessions); - refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, null, true, null, - voteGeneralMonitoringDTO, null); - logger.debug("session_name: " + voteSession.getSession_name()); - voteGeneralMonitoringDTO.setGroupName(voteSession.getSession_name()); - logger.debug("post refreshSummaryData, voteGeneralMonitoringDTO:" + voteGeneralMonitoringDTO); - voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, voteContent, voteService); + VoteMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + voteGeneralMonitoringDTO.setSummaryToolSessionsId(summaryToolSessionsId); + + VoteMonitoringAction.logger.debug("calling initInstructionsContent."); + // initInstructionsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initStatsContent."); + initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + /* setting editable screen properties */ + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); + voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); + + Map mapOptionsContent = new TreeMap(new VoteComparator()); + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + Long mapIndex = new Long(1); + VoteMonitoringAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + while (queIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + VoteMonitoringAction.logger.debug("question: " + voteQueContent.getQuestion()); + mapOptionsContent.put(mapIndex.toString(), voteQueContent.getQuestion()); + /** + * make the first entry the default(first) one for jsp + */ + if (mapIndex.longValue() == 1) { + voteGeneralAuthoringDTO.setDefaultOptionContent(voteQueContent.getQuestion()); + } + + mapIndex = new Long(mapIndex.longValue() + 1); } - logger.debug("SELECTION_CASE: " + voteGeneralMonitoringDTO.getSelectionCase()); - - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - request.setAttribute(CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); + } - - voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); - voteMonitoringForm.setSbmtSuccess(new Boolean(false).toString()); - voteGeneralMonitoringDTO.setSbmtSuccess(new Boolean(false).toString()); - voteGeneralMonitoringDTO.setRequestLearningReport(new Boolean(false).toString()); - - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, voteContent, voteService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - voteGeneralMonitoringDTO.setSummaryToolSessions(summaryToolSessions); + VoteMonitoringAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + int maxIndex = mapOptionsContent.size(); + VoteMonitoringAction.logger.debug("maxIndex: " + maxIndex); + voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, voteContent, voteService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - voteGeneralMonitoringDTO.setSummaryToolSessionsId(summaryToolSessionsId); + voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - logger.debug("calling initInstructionsContent."); - //initInstructionsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initStatsContent."); - initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(false).toString()); + if (isContentInUse == true) { + VoteMonitoringAction.logger + .debug("monitoring url does not allow editActivity since the content is in use."); + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); + } - - /*setting editable screen properties*/ - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); - voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - Map mapOptionsContent= new TreeMap(new VoteComparator()); - Iterator queIterator=voteContent.getVoteQueContents().iterator(); - Long mapIndex=new Long(1); - logger.debug("mapOptionsContent: " + mapOptionsContent); - while (queIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); - if (voteQueContent != null) - { - logger.debug("question: " + voteQueContent.getQuestion()); - mapOptionsContent.put(mapIndex.toString(),voteQueContent.getQuestion()); - /** - * make the first entry the default(first) one for jsp - */ - if (mapIndex.longValue() == 1) - { - voteGeneralAuthoringDTO.setDefaultOptionContent(voteQueContent.getQuestion()); - } - - mapIndex=new Long(mapIndex.longValue()+1); - } - } - - logger.debug("mapOptionsContent: " + mapOptionsContent); - int maxIndex=mapOptionsContent.size(); - logger.debug("maxIndex: " + maxIndex); - voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); - voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(false).toString()); - if (isContentInUse == true) - { - logger.debug("monitoring url does not allow editActivity since the content is in use."); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); - } + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + VoteMonitoringAction.logger.debug("end of commonSubmitSessionCode, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - - logger.debug("end of commonSubmitSessionCode, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); + EditActivityDTO editActivityDTO = new EditActivityDTO(); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + } - - - public ActionForward submitSession(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response, - MessageService messageService) - throws IOException,ServletException - { - logger.debug("dispathcing submitSession.."); - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " +voteService); - - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - - commonSubmitSessionCode(form, request, voteService, messageService, voteGeneralMonitoringDTO); - logger.debug("post commonSubmitSessionCode: " +voteGeneralMonitoringDTO); - - return (mapping.findForward(LOAD_MONITORING)); + public ActionForward submitSession(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response, MessageService messageService) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("dispathcing submitSession.."); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + + commonSubmitSessionCode(form, request, voteService, messageService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post commonSubmitSessionCode: " + voteGeneralMonitoringDTO); + + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); + } + + public void refreshSummaryData(HttpServletRequest request, VoteContent voteContent, IVoteService voteService, + boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId, + boolean showUserEntriesBySession, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO, + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO, ExportPortfolioDTO exportPortfolioDTO) { + VoteMonitoringAction.logger.debug("doing refreshSummaryData." + voteGeneralLearnerFlowDTO); + VoteMonitoringAction.logger.debug("voteGeneralMonitoringDTO:" + voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("exportPortfolioDTO:" + exportPortfolioDTO); + + if (voteService == null) { + VoteMonitoringAction.logger.debug("will retrieve voteService"); + voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("retrieving voteService from session: " + voteService); } + VoteMonitoringAction.logger.debug("voteService: " + voteService); - - public void refreshSummaryData(HttpServletRequest request, VoteContent voteContent, IVoteService voteService, - boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId, - boolean showUserEntriesBySession, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO, ExportPortfolioDTO exportPortfolioDTO) - { - logger.debug("doing refreshSummaryData." + voteGeneralLearnerFlowDTO); - logger.debug("voteGeneralMonitoringDTO:" + voteGeneralMonitoringDTO); - logger.debug("exportPortfolioDTO:" + exportPortfolioDTO); - - if (voteService == null) - { - logger.debug("will retrieve voteService"); - voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("retrieving voteService from session: " + voteService); - } - logger.debug("voteService: " + voteService); - - logger.debug("isUserNamesVisible: " + isUserNamesVisible); - logger.debug("isLearnerRequest: " + isLearnerRequest); - - /* this section is related to summary tab. Starts here. */ - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, voteContent, voteService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - - if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) - { - if (voteGeneralMonitoringDTO != null) - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - } - else - { - if (voteGeneralMonitoringDTO != null) - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - } - - String userExceptionNoToolSessions=voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions: " + userExceptionNoToolSessions); - if (exportPortfolioDTO != null) - { - exportPortfolioDTO.setUserExceptionNoToolSessions(userExceptionNoToolSessions); - } - - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, voteContent, voteService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - logger.debug("currentSessionId: " + currentSessionId); - - if ((currentSessionId != null) && (!currentSessionId.equals("All"))) - { - VoteSession voteSession= voteService.retrieveVoteSession(new Long(currentSessionId)); - logger.debug("voteSession:" + voteSession); - if (voteGeneralMonitoringDTO != null) - voteGeneralMonitoringDTO.setGroupName(voteSession.getSession_name()); + VoteMonitoringAction.logger.debug("isUserNamesVisible: " + isUserNamesVisible); + VoteMonitoringAction.logger.debug("isLearnerRequest: " + isLearnerRequest); + + /* this section is related to summary tab. Starts here. */ + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, voteContent, voteService); + VoteMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + + if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) { + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); } - else - { - voteGeneralMonitoringDTO.setGroupName("All Groups"); + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + } else { + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); } - - logger.debug("using allUsersData to retrieve data: " + isUserNamesVisible); - List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, voteContent, - isUserNamesVisible, isLearnerRequest, currentSessionId, userId, voteService); - logger.debug("listMonitoredAnswersContainerDTO: " + listMonitoredAnswersContainerDTO); - /* ends here. */ - - logger.debug("decide processing user entered values based on isLearnerRequest: " + isLearnerRequest); + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + } - List listUserEntries=processUserEnteredNominations(voteService, voteContent, currentSessionId, showUserEntriesBySession, userId, isLearnerRequest); - logger.debug("listUserEntries: " + listUserEntries); - - if (voteGeneralLearnerFlowDTO != null) - { - logger.debug("placing dtos within the voteGeneralLearnerFlowDTO: "); - voteGeneralLearnerFlowDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); - voteGeneralLearnerFlowDTO.setListUserEntries(listUserEntries);; + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions: " + userExceptionNoToolSessions); + if (exportPortfolioDTO != null) { + exportPortfolioDTO.setUserExceptionNoToolSessions(userExceptionNoToolSessions); + } + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, voteContent, voteService); + VoteMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + VoteMonitoringAction.logger.debug("currentSessionId: " + currentSessionId); + + if (currentSessionId != null && !currentSessionId.equals("All")) { + VoteSession voteSession = voteService.retrieveVoteSession(new Long(currentSessionId)); + VoteMonitoringAction.logger.debug("voteSession:" + voteSession); + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO.setGroupName(voteSession.getSession_name()); } + } else { + voteGeneralMonitoringDTO.setGroupName("All Groups"); + } - - if (exportPortfolioDTO != null) - { - logger.debug("placing dtos within the exportPortfolioDTO: "); - exportPortfolioDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); - exportPortfolioDTO.setListUserEntries(listUserEntries);; + VoteMonitoringAction.logger.debug("using allUsersData to retrieve data: " + isUserNamesVisible); + List listMonitoredAnswersContainerDTO = MonitoringUtil.buildGroupsQuestionData(request, voteContent, + isUserNamesVisible, isLearnerRequest, currentSessionId, userId, voteService); + VoteMonitoringAction.logger.debug("listMonitoredAnswersContainerDTO: " + listMonitoredAnswersContainerDTO); + /* ends here. */ + + VoteMonitoringAction.logger.debug("decide processing user entered values based on isLearnerRequest: " + + isLearnerRequest); + + List listUserEntries = processUserEnteredNominations(voteService, voteContent, currentSessionId, + showUserEntriesBySession, userId, isLearnerRequest); + VoteMonitoringAction.logger.debug("listUserEntries: " + listUserEntries); + + if (voteGeneralLearnerFlowDTO != null) { + VoteMonitoringAction.logger.debug("placing dtos within the voteGeneralLearnerFlowDTO: "); + voteGeneralLearnerFlowDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); + voteGeneralLearnerFlowDTO.setListUserEntries(listUserEntries); + ; + } + + if (exportPortfolioDTO != null) { + VoteMonitoringAction.logger.debug("placing dtos within the exportPortfolioDTO: "); + exportPortfolioDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); + exportPortfolioDTO.setListUserEntries(listUserEntries); + ; + } + + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO.setSummaryToolSessions(summaryToolSessions); + voteGeneralMonitoringDTO.setSummaryToolSessionsId(summaryToolSessionsId); + voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); + voteGeneralMonitoringDTO.setCurrentMonitoredToolSession("All"); + voteGeneralMonitoringDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); + voteGeneralMonitoringDTO.setListUserEntries(listUserEntries); + + voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(false).toString()); + if (listUserEntries.size() > 0) { + voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(true).toString()); } - - - if (voteGeneralMonitoringDTO != null) - { - voteGeneralMonitoringDTO.setSummaryToolSessions(summaryToolSessions); - voteGeneralMonitoringDTO.setSummaryToolSessionsId(summaryToolSessionsId); - voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); - voteGeneralMonitoringDTO.setCurrentMonitoredToolSession("All"); - voteGeneralMonitoringDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); - voteGeneralMonitoringDTO.setListUserEntries(listUserEntries); - - voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(false).toString()); - if (listUserEntries.size() > 0) - { - voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(true).toString()); - } + } + + VoteMonitoringAction.logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); + VoteMonitoringAction.logger.debug("final voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(false).toString()); + if (isContentInUse == true) { + VoteMonitoringAction.logger + .debug("monitoring url does not allow editActivity since the content is in use."); + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); + } + + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } - - logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - logger.debug("final voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(false).toString()); - if (isContentInUse == true) - { - logger.debug("monitoring url does not allow editActivity since the content is in use."); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); - } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + } - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + public List processUserEnteredNominations(IVoteService voteService, VoteContent voteContent, + String currentSessionId, boolean showUserEntriesBySession, String userId, boolean showUserEntriesByUserId) { + VoteMonitoringAction.logger.debug("start getting user entries, showUserEntriesBySession: " + + showUserEntriesBySession); + VoteMonitoringAction.logger.debug("start getting user entries, currentSessionId: " + currentSessionId); + VoteMonitoringAction.logger.debug("start getting user entries, showUserEntriesByUserId: " + + showUserEntriesByUserId); + VoteMonitoringAction.logger.debug("start getting user entries, userId: " + userId); + VoteMonitoringAction.logger.debug("start getting user entries, voteContent: " + voteContent); + VoteMonitoringAction.logger.debug("start getting user entries, voteContent id: " + + voteContent.getVoteContentId()); + + Set userEntries = voteService.getUserEntries(); + VoteMonitoringAction.logger.debug("userEntries: " + userEntries); + + List listUserEntries = new LinkedList(); + + Iterator itListNominations = userEntries.iterator(); + while (itListNominations.hasNext()) { + String userEntry = (String) itListNominations.next(); + VoteMonitoringAction.logger.debug("userEntry:..." + userEntry); + + if (userEntry != null && userEntry.length() > 0) { + VoteMonitoredAnswersDTO voteMonitoredAnswersDTO = new VoteMonitoredAnswersDTO(); + VoteMonitoringAction.logger.debug("adding user entry : " + userEntry); + voteMonitoredAnswersDTO.setQuestion(userEntry); + + List userRecords = voteService.getUserRecords(userEntry); + VoteMonitoringAction.logger.debug("userRecords: " + userRecords); + + VoteMonitoringAction.logger.debug("start processing user records: "); + + List listMonitoredUserContainerDTO = new LinkedList(); + + Iterator itUserRecords = userRecords.iterator(); + while (itUserRecords.hasNext()) { + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + VoteMonitoringAction.logger.debug("new DTO created"); + VoteUsrAttempt voteUsrAttempt = (VoteUsrAttempt) itUserRecords.next(); + VoteMonitoringAction.logger.debug("voteUsrAttempt: " + voteUsrAttempt); + + VoteSession localUserSession = voteUsrAttempt.getVoteQueUsr().getVoteSession(); + VoteMonitoringAction.logger.debug("localUserSession: " + localUserSession); + VoteMonitoringAction.logger.debug("localUserSession's content id: " + + localUserSession.getVoteContentId()); + VoteMonitoringAction.logger.debug("incoming content uid versus localUserSession's content id: " + + voteContent.getUid() + " versus " + localUserSession.getVoteContentId()); + + if (showUserEntriesBySession == false) { + VoteMonitoringAction.logger.debug("showUserEntriesBySession is false"); + VoteMonitoringAction.logger.debug("show user entries by same content only"); + if (voteContent.getUid().toString().equals(localUserSession.getVoteContentId().toString())) { + voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); + voteMonitoredUserDTO.setTimeZone(voteUsrAttempt.getTimeZone()); + voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteUsrAttempt.getVoteQueUsr().getUid().toString()); + voteMonitoredUserDTO.setUserEntry(voteUsrAttempt.getUserEntry()); + voteMonitoredUserDTO.setUid(voteUsrAttempt.getUid().toString()); + voteMonitoredUserDTO.setVisible(new Boolean(voteUsrAttempt.isVisible()).toString()); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + } + } else { + VoteMonitoringAction.logger + .debug("showUserEntriesBySession is true: the case with learner export portfolio"); + VoteMonitoringAction.logger + .debug("show user entries by same content and same session and same user"); + String userSessionId = voteUsrAttempt.getVoteQueUsr().getVoteSession().getVoteSessionId() + .toString(); + VoteMonitoringAction.logger.debug("userSessionId versus currentSessionId: " + userSessionId + + " versus " + currentSessionId); + + if (showUserEntriesByUserId == true) { + if (voteContent.getUid().toString().equals(localUserSession.getVoteContentId().toString())) { + VoteMonitoringAction.logger.debug("showUserEntriesByUserId is true"); + if (userSessionId.equals(currentSessionId)) { + String localUserId = voteUsrAttempt.getVoteQueUsr().getQueUsrId().toString(); + if (userId.equals(localUserId)) { + VoteMonitoringAction.logger.debug("this is requested by user id: " + userId); + voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); + voteMonitoredUserDTO.setTimeZone(voteUsrAttempt.getTimeZone()); + voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteUsrAttempt.getVoteQueUsr().getUid() + .toString()); + voteMonitoredUserDTO.setUserEntry(voteUsrAttempt.getUserEntry()); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + voteMonitoredUserDTO.setUid(voteUsrAttempt.getUid().toString()); + voteMonitoredUserDTO.setVisible(new Boolean(voteUsrAttempt.isVisible()) + .toString()); + VoteMonitoringAction.logger + .debug("overriding the nomination text with 'Nomination Hidden' if needed"); + VoteMonitoringAction.logger.debug("is entry visible: " + + voteUsrAttempt.isVisible()); + if (voteUsrAttempt.isVisible() == false) { + voteMonitoredAnswersDTO.setQuestion("Nomination Hidden"); + VoteMonitoringAction.logger.debug("overwrote the nomination text"); + } + + } + } + } + } else { + VoteMonitoringAction.logger.debug("showUserEntriesByUserId is false"); + VoteMonitoringAction.logger.debug("show user entries by same content and same session"); + VoteMonitoringAction.logger + .debug("voteContent.getVoteContentId() versus localUserSession.getVoteContentId().toString(): " + + voteContent.getVoteContentId() + + " versus " + + localUserSession.getVoteContentId()); + if (voteContent.getUid().toString().equals(localUserSession.getVoteContentId().toString())) { + if (userSessionId.equals(currentSessionId)) { + VoteMonitoringAction.logger.debug("this is requested by session id: " + + currentSessionId); + voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); + voteMonitoredUserDTO.setTimeZone(voteUsrAttempt.getTimeZone()); + voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); + voteMonitoredUserDTO + .setQueUsrId(voteUsrAttempt.getVoteQueUsr().getUid().toString()); + voteMonitoredUserDTO.setUserEntry(voteUsrAttempt.getUserEntry()); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + voteMonitoredUserDTO.setUid(voteUsrAttempt.getUid().toString()); + voteMonitoredUserDTO.setVisible(new Boolean(voteUsrAttempt.isVisible()).toString()); + } + } + } } + } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + + VoteMonitoringAction.logger.debug("final listMonitoredUserContainerDTO: " + + listMonitoredUserContainerDTO); + + VoteMonitoringAction.logger.debug("final listMonitoredUserContainerDTO size: " + + listMonitoredUserContainerDTO.size()); + if (listMonitoredUserContainerDTO.size() > 0) { + VoteMonitoringAction.logger.debug("adding user entry's data"); + Map mapMonitoredUserContainerDTO = MonitoringUtil + .convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO); + VoteMonitoringAction.logger.debug("final user entry mapMonitoredUserContainerDTO:..." + + mapMonitoredUserContainerDTO); + + voteMonitoredAnswersDTO.setQuestionAttempts(mapMonitoredUserContainerDTO); + listUserEntries.add(voteMonitoredAnswersDTO); } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); + } + } + VoteMonitoringAction.logger.debug("finish getting user entries: " + listUserEntries); + return listUserEntries; + } + + public void initSummaryContent(String toolContentID, HttpServletRequest request, IVoteService voteService, + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("start initSummaryContent...toolContentID: " + toolContentID); + VoteMonitoringAction.logger.debug("dispatching getSummary...voteGeneralMonitoringDTO:" + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("voteService: " + voteService); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); + + /* this section is related to summary tab. Starts here. */ + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, voteContent, voteService); + VoteMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + voteGeneralMonitoringDTO.setSummaryToolSessions(summaryToolSessions); + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, voteContent, voteService); + VoteMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + voteGeneralMonitoringDTO.setSummaryToolSessionsId(summaryToolSessionsId); + /* ends here. */ + + /* true means there is at least 1 response */ + if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) { + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + } else { + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); } + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); - public List processUserEnteredNominations(IVoteService voteService, VoteContent voteContent, String currentSessionId, boolean showUserEntriesBySession, String userId, boolean showUserEntriesByUserId) - { - logger.debug("start getting user entries, showUserEntriesBySession: " + showUserEntriesBySession); - logger.debug("start getting user entries, currentSessionId: " + currentSessionId); - logger.debug("start getting user entries, showUserEntriesByUserId: " + showUserEntriesByUserId); - logger.debug("start getting user entries, userId: " + userId); - logger.debug("start getting user entries, voteContent: " + voteContent); - logger.debug("start getting user entries, voteContent id: " + voteContent.getVoteContentId()); + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - Set userEntries=voteService.getUserEntries(); - logger.debug("userEntries: " + userEntries); - - List listUserEntries=new LinkedList(); - - Iterator itListNominations = userEntries.iterator(); - while (itListNominations.hasNext()) - { - String userEntry =(String)itListNominations.next(); - logger.debug("userEntry:..." + userEntry); - - if ((userEntry != null) && (userEntry.length() > 0)) - { - VoteMonitoredAnswersDTO voteMonitoredAnswersDTO= new VoteMonitoredAnswersDTO(); - logger.debug("adding user entry : " + userEntry); - voteMonitoredAnswersDTO.setQuestion(userEntry); - - List userRecords=voteService.getUserRecords(userEntry); - logger.debug("userRecords: " + userRecords); - - logger.debug("start processing user records: "); - - List listMonitoredUserContainerDTO= new LinkedList(); - - Iterator itUserRecords= userRecords.iterator(); - while (itUserRecords.hasNext()) - { - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - logger.debug("new DTO created"); - VoteUsrAttempt voteUsrAttempt =(VoteUsrAttempt)itUserRecords.next(); - logger.debug("voteUsrAttempt: " + voteUsrAttempt); - + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - VoteSession localUserSession=voteUsrAttempt.getVoteQueUsr().getVoteSession(); - logger.debug("localUserSession: " + localUserSession); - logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); - logger.debug("incoming content uid versus localUserSession's content id: " + voteContent.getUid() + " versus " + localUserSession.getVoteContentId()); + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ - if (showUserEntriesBySession == false) - { - logger.debug("showUserEntriesBySession is false"); - logger.debug("show user entries by same content only"); - if (voteContent.getUid().toString().equals(localUserSession.getVoteContentId().toString())) - { - voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); - voteMonitoredUserDTO.setTimeZone(voteUsrAttempt.getTimeZone()); - voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteUsrAttempt.getVoteQueUsr().getUid().toString()); - voteMonitoredUserDTO.setUserEntry(voteUsrAttempt.getUserEntry()); - voteMonitoredUserDTO.setUid(voteUsrAttempt.getUid().toString()); - voteMonitoredUserDTO.setVisible(new Boolean(voteUsrAttempt.isVisible()).toString()); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - else - { - logger.debug("showUserEntriesBySession is true: the case with learner export portfolio"); - logger.debug("show user entries by same content and same session and same user"); - String userSessionId=voteUsrAttempt.getVoteQueUsr().getVoteSession().getVoteSessionId().toString() ; - logger.debug("userSessionId versus currentSessionId: " + userSessionId + " versus " + currentSessionId); - - if (showUserEntriesByUserId == true) - { - if (voteContent.getUid().toString().equals(localUserSession.getVoteContentId().toString())) - { - logger.debug("showUserEntriesByUserId is true"); - if (userSessionId.equals(currentSessionId)) - { - String localUserId=voteUsrAttempt.getVoteQueUsr().getQueUsrId().toString(); - if (userId.equals(localUserId)) - { - logger.debug("this is requested by user id: " + userId); - voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); - voteMonitoredUserDTO.setTimeZone(voteUsrAttempt.getTimeZone()); - voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteUsrAttempt.getVoteQueUsr().getUid().toString()); - voteMonitoredUserDTO.setUserEntry(voteUsrAttempt.getUserEntry()); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - voteMonitoredUserDTO.setUid(voteUsrAttempt.getUid().toString()); - voteMonitoredUserDTO.setVisible(new Boolean(voteUsrAttempt.isVisible()).toString()); - logger.debug("overriding the nomination text with 'Nomination Hidden' if needed"); - logger.debug("is entry visible: " + voteUsrAttempt.isVisible()); - if (voteUsrAttempt.isVisible() == false) - { - voteMonitoredAnswersDTO.setQuestion("Nomination Hidden"); - logger.debug("overwrote the nomination text"); - } - - } - } - } - } - else - { - logger.debug("showUserEntriesByUserId is false"); - logger.debug("show user entries by same content and same session"); - logger.debug("voteContent.getVoteContentId() versus localUserSession.getVoteContentId().toString(): " + - voteContent.getVoteContentId() + " versus " + localUserSession.getVoteContentId()); - if (voteContent.getUid().toString().equals(localUserSession.getVoteContentId().toString())) - { - if (userSessionId.equals(currentSessionId)) - { - logger.debug("this is requested by session id: " + currentSessionId); - voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); - voteMonitoredUserDTO.setTimeZone(voteUsrAttempt.getTimeZone()); - voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteUsrAttempt.getVoteQueUsr().getUid().toString()); - voteMonitoredUserDTO.setUserEntry(voteUsrAttempt.getUserEntry()); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - voteMonitoredUserDTO.setUid(voteUsrAttempt.getUid().toString()); - voteMonitoredUserDTO.setVisible(new Boolean(voteUsrAttempt.isVisible()).toString()); - } - } - } - } - - } - - logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); - - logger.debug("final listMonitoredUserContainerDTO size: " + listMonitoredUserContainerDTO.size()); - if (listMonitoredUserContainerDTO.size() > 0) - { - logger.debug("adding user entry's data"); - Map mapMonitoredUserContainerDTO=MonitoringUtil.convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO); - logger.debug("final user entry mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); + voteGeneralMonitoringDTO.setCurrentMonitoringTab("summary"); - voteMonitoredAnswersDTO.setQuestionAttempts(mapMonitoredUserContainerDTO); - listUserEntries.add(voteMonitoredAnswersDTO); - } - } - } - - logger.debug("finish getting user entries: " + listUserEntries); - return listUserEntries; + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); } + /* ... till here */ - - public void initSummaryContent(String toolContentID, - HttpServletRequest request, - IVoteService voteService, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, - ServletException - { - logger.debug("start initSummaryContent...toolContentID: " + toolContentID); - logger.debug("dispatching getSummary...voteGeneralMonitoringDTO:" + voteGeneralMonitoringDTO); - - logger.debug("voteService: " + voteService); - logger.debug("toolContentID: " + toolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("existing voteContent:" + voteContent); - - /* this section is related to summary tab. Starts here. */ - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, voteContent, voteService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - voteGeneralMonitoringDTO.setSummaryToolSessions(summaryToolSessions); - - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, voteContent, voteService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - voteGeneralMonitoringDTO.setSummaryToolSessionsId(summaryToolSessionsId); - /* ends here. */ - - /*true means there is at least 1 response*/ - if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) - { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - } - else - { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - } + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + VoteMonitoringAction.logger.debug("end initSummaryContent..."); + } - - voteGeneralMonitoringDTO.setCurrentMonitoringTab("summary"); + public void initStatsContent(String toolContentID, HttpServletRequest request, IVoteService voteService, + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("starting initStatsContent...:" + toolContentID); + VoteMonitoringAction.logger.debug("dispatching getStats..." + request); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); + if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) { + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + } else { + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + } - logger.debug("end initSummaryContent..."); + refreshStatsData(request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post refreshStatsData, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } - - - public void initStatsContent(String toolContentID, - HttpServletRequest request, - IVoteService voteService, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) throws IOException, - ServletException - { - logger.debug("starting initStatsContent...:" + toolContentID); - logger.debug("dispatching getStats..." + request); - logger.debug("voteService: " + voteService); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("existing voteContent:" + voteContent); - - if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) - { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - } - else - { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - - refreshStatsData(request, voteService,voteGeneralMonitoringDTO); - logger.debug("post refreshStatsData, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO ); - - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + voteGeneralMonitoringDTO.setCurrentMonitoringTab("stats"); - - voteGeneralMonitoringDTO.setCurrentMonitoringTab("stats"); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("ending initStatsContent..."); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); } - - - public void refreshStatsData(HttpServletRequest request, IVoteService voteService, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) - { - logger.debug("starting refreshStatsData: " + voteService); - /* it is possible that no users has ever logged in for the activity yet*/ - if (voteService == null) - { - logger.debug("will retrieve voteService"); - voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("retrieving voteService from session: " + voteService); - } - - int countAllUsers=voteService.getTotalNumberOfUsers(); - logger.debug("countAllUsers: " + countAllUsers); - - if (countAllUsers == 0) - { - logger.debug("error: countAllUsers is 0"); - voteGeneralMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString()); - } - - voteGeneralMonitoringDTO.setCountAllUsers(new Integer(countAllUsers).toString()); - - int countSessionComplete=voteService.countSessionComplete(); - logger.debug("countSessionComplete: " + countSessionComplete); - voteGeneralMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); - + /* ... till here */ - logger.debug("end of refreshStatsData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("ending initStatsContent..."); + } + + public void refreshStatsData(HttpServletRequest request, IVoteService voteService, + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) { + VoteMonitoringAction.logger.debug("starting refreshStatsData: " + voteService); + /* it is possible that no users has ever logged in for the activity yet */ + if (voteService == null) { + VoteMonitoringAction.logger.debug("will retrieve voteService"); + voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("retrieving voteService from session: " + voteService); } - - - + + int countAllUsers = voteService.getTotalNumberOfUsers(); + VoteMonitoringAction.logger.debug("countAllUsers: " + countAllUsers); + + if (countAllUsers == 0) { + VoteMonitoringAction.logger.debug("error: countAllUsers is 0"); + voteGeneralMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString()); + } + + voteGeneralMonitoringDTO.setCountAllUsers(new Integer(countAllUsers).toString()); + + int countSessionComplete = voteService.countSessionComplete(); + VoteMonitoringAction.logger.debug("countSessionComplete: " + countSessionComplete); + voteGeneralMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); + + VoteMonitoringAction.logger.debug("end of refreshStatsData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + } + /** - * calls learning action endLearning functionality - * ActionForward endLearning(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException + * calls learning action endLearning functionality ActionForward endLearning(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, ToolException * * @param mapping * @param form @@ -984,821 +906,711 @@ * @throws ServletException * @throws ToolException */ - public ActionForward endLearning(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching proxy endLearning to learning module..."); - - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService :" +voteService); - - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - logger.debug("voteMonitoringForm :" +voteMonitoringForm); - voteMonitoringForm.setVoteService(voteService); + public ActionForward endLearning(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching proxy endLearning to learning module..."); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - - VoteLearningAction voteLearningAction= new VoteLearningAction(); - - return null; + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService :" + voteService); + + VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + VoteMonitoringAction.logger.debug("voteMonitoringForm :" + voteMonitoringForm); + voteMonitoringForm.setVoteService(voteService); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); + + VoteLearningAction voteLearningAction = new VoteLearningAction(); + + return null; } + public ActionForward viewOpenVotes(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching viewOpenVotes..."); - public ActionForward viewOpenVotes(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching viewOpenVotes..."); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService :" + voteService); - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService :" +voteService); - - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - logger.debug("voteMonitoringForm :" +voteMonitoringForm); - voteMonitoringForm.setVoteService(voteService); + VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + VoteMonitoringAction.logger.debug("voteMonitoringForm :" + voteMonitoringForm); + voteMonitoringForm.setVoteService(voteService); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO=new VoteGeneralMonitoringDTO(); + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); + repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - if (voteService == null) - { - logger.debug("will retrieve voteService"); - voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - } - logger.debug("voteService: " + voteService); + if (voteService == null) { + VoteMonitoringAction.logger.debug("will retrieve voteService"); + voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + } + VoteMonitoringAction.logger.debug("voteService: " + voteService); - voteMonitoringForm.setShowOpenVotesSection(new Boolean(true).toString()); - voteGeneralMonitoringDTO.setShowOpenVotesSection(new Boolean(true).toString()); - - logger.debug("showOpen votes set to true: "); - - String toolContentID =voteMonitoringForm.getToolContentID(); - logger.debug("toolContentID: " + toolContentID); + voteMonitoringForm.setShowOpenVotesSection(new Boolean(true).toString()); + voteGeneralMonitoringDTO.setShowOpenVotesSection(new Boolean(true).toString()); - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("existing voteContent:" + voteContent); + VoteMonitoringAction.logger.debug("showOpen votes set to true: "); - String currentMonitoredToolSession=voteMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + String toolContentID = voteMonitoringForm.getToolContentID(); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); - refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, - null, true, null,voteGeneralMonitoringDTO, null); - - - initSummaryContent(toolContentID , request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initInstructionsContent."); - logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initStatsContent."); - initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + String currentMonitoredToolSession = voteMonitoringForm.getSelectedToolSessionId(); + VoteMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - - logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, null, true, + null, voteGeneralMonitoringDTO, null); - - if (currentMonitoredToolSession.equals("All")) - { - voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); + initSummaryContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initInstructionsContent."); + VoteMonitoringAction.logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initStatsContent."); + initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + VoteMonitoringAction.logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (currentMonitoredToolSession.equals("All")) { + voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); + } else { + voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); + } + + voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("ending editActivityQuestions, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } - else - { - voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); - - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ - - - logger.debug("ending editActivityQuestions, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + VoteMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(1)); + } - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + VoteMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(VoteAppConstants.SELECTION_CASE)); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; + VoteMonitoringAction.logger + .debug("ending viewOpenVotes, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("fwd'ing to LOAD_MONITORING: " + VoteAppConstants.LOAD_MONITORING); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); + } + + public ActionForward closeOpenVotes(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching closeOpenVotes..."); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService :" + voteService); + + VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + VoteMonitoringAction.logger.debug("voteMonitoringForm :" + voteMonitoringForm); + voteMonitoringForm.setVoteService(voteService); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + + repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); + + voteMonitoringForm.setShowOpenVotesSection(new Boolean(false).toString()); + voteGeneralMonitoringDTO.setShowOpenVotesSection(new Boolean(false).toString()); + + VoteMonitoringAction.logger.debug("showOpen votes set to false: "); + + String toolContentID = voteMonitoringForm.getToolContentID(); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); + + initSummaryContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initInstructionsContent."); + VoteMonitoringAction.logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initStatsContent."); + initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); + + if (voteContent != null) { + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); } + } - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + VoteMonitoringAction.logger.debug("ending closeOpenVotes, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); - - logger.debug("ending viewOpenVotes, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - logger.debug("fwd'ing to LOAD_MONITORING: " + LOAD_MONITORING); - return (mapping.findForward(LOAD_MONITORING)); - } - + String currentMonitoredToolSession = voteMonitoringForm.getSelectedToolSessionId(); + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } - public ActionForward closeOpenVotes(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching closeOpenVotes..."); - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService :" +voteService); - - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - logger.debug("voteMonitoringForm :" +voteMonitoringForm); - voteMonitoringForm.setVoteService(voteService); + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(1)); + } - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO=new VoteGeneralMonitoringDTO(); - - repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - - voteMonitoringForm.setShowOpenVotesSection(new Boolean(false).toString()); - voteGeneralMonitoringDTO.setShowOpenVotesSection(new Boolean(false).toString()); - - logger.debug("showOpen votes set to false: "); - - String toolContentID =voteMonitoringForm.getToolContentID(); - logger.debug("toolContentID: " + toolContentID); - - initSummaryContent(toolContentID , request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initInstructionsContent."); - logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initStatsContent."); - initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(VoteAppConstants.SELECTION_CASE)); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("existing voteContent:" + voteContent); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); + } - if (voteContent != null) - { - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ - - - logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + public ActionForward hideOpenVote(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching hideOpenVote..."); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService :" + voteService); + VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + VoteMonitoringAction.logger.debug("voteMonitoringForm :" + voteMonitoringForm); + voteMonitoringForm.setVoteService(voteService); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - logger.debug("ending closeOpenVotes, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - String currentMonitoredToolSession=voteMonitoringForm.getSelectedToolSessionId(); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; + String currentUid = voteMonitoringForm.getCurrentUid(); + VoteMonitoringAction.logger.debug("currentUid: " + currentUid); + + VoteUsrAttempt voteUsrAttempt = voteService.getAttemptByUID(new Long(currentUid)); + VoteMonitoringAction.logger.debug("voteUsrAttempt: " + voteUsrAttempt); + + voteUsrAttempt.setVisible(false); + voteService.updateVoteUsrAttempt(voteUsrAttempt); + VoteMonitoringAction.logger.debug("hiding the user entry : " + voteUsrAttempt.getUserEntry()); + voteService.hideOpenVote(voteUsrAttempt); + + String toolContentID = voteMonitoringForm.getToolContentID(); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); + + initSummaryContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initInstructionsContent."); + VoteMonitoringAction.logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initStatsContent."); + initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + String currentMonitoredToolSession = voteMonitoringForm.getSelectedToolSessionId(); + VoteMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + + refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, null, true, + null, voteGeneralMonitoringDTO, null); + + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } + + if (currentMonitoredToolSession.equals("All")) { + voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(2)); + } else { + voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(1)); + } + + voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); + + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("ending editActivityQuestions, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); - - return (mapping.findForward(LOAD_MONITORING)); - } - - + VoteMonitoringAction.logger.debug("submitting session to refresh the data from the database: "); + return submitSession(mapping, form, request, response, voteService, getMessageService(), + voteGeneralMonitoringDTO); + } - public ActionForward hideOpenVote(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching hideOpenVote..."); - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService :" +voteService); - - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - logger.debug("voteMonitoringForm :" +voteMonitoringForm); - voteMonitoringForm.setVoteService(voteService); + public ActionForward showOpenVote(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching showOpenVote..."); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService :" + voteService); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - - repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - - String currentUid=voteMonitoringForm.getCurrentUid(); - logger.debug("currentUid: " + currentUid); - - VoteUsrAttempt voteUsrAttempt =voteService.getAttemptByUID(new Long(currentUid)); - logger.debug("voteUsrAttempt: " + voteUsrAttempt); - - voteUsrAttempt.setVisible(false); - voteService.updateVoteUsrAttempt(voteUsrAttempt); - logger.debug("hiding the user entry : " + voteUsrAttempt.getUserEntry()); - voteService.hideOpenVote(voteUsrAttempt); - - String toolContentID=voteMonitoringForm.getToolContentID(); - logger.debug("toolContentID: " + toolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("existing voteContent:" + voteContent); + VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + VoteMonitoringAction.logger.debug("voteMonitoringForm :" + voteMonitoringForm); + voteMonitoringForm.setVoteService(voteService); - initSummaryContent(toolContentID , request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initInstructionsContent."); - logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initStatsContent."); - initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - - String currentMonitoredToolSession=voteMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, null, true, null, - voteGeneralMonitoringDTO, null); - + String currentUid = voteMonitoringForm.getCurrentUid(); + VoteMonitoringAction.logger.debug("currentUid: " + currentUid); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; + VoteUsrAttempt voteUsrAttempt = voteService.getAttemptByUID(new Long(currentUid)); + VoteMonitoringAction.logger.debug("voteUsrAttempt: " + voteUsrAttempt); + voteUsrAttempt.setVisible(true); + + voteService.updateVoteUsrAttempt(voteUsrAttempt); + voteService.showOpenVote(voteUsrAttempt); + VoteMonitoringAction.logger.debug("voteUsrAttempt: " + voteUsrAttempt); + + String toolContentID = voteMonitoringForm.getToolContentID(); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); + + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); + + initSummaryContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initInstructionsContent."); + VoteMonitoringAction.logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + VoteMonitoringAction.logger.debug("calling initStatsContent."); + initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + + String currentMonitoredToolSession = voteMonitoringForm.getSelectedToolSessionId(); + VoteMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + + refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, null, true, + null, voteGeneralMonitoringDTO, null); + + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } + + if (currentMonitoredToolSession.equals("All")) { + voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(2)); + } else { + voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); + request.setAttribute(VoteAppConstants.SELECTION_CASE, new Long(1)); + } + + VoteMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(VoteAppConstants.SELECTION_CASE)); + + voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } - if (currentMonitoredToolSession.equals("All")) - { - voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); - request.setAttribute(SELECTION_CASE, new Long(2)); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } - else - { - voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); - request.setAttribute(SELECTION_CASE, new Long(1)); - } - + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); - - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ - - - logger.debug("ending editActivityQuestions, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); - - logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("submitting session to refresh the data from the database: "); + return submitSession(mapping, form, request, response, voteService, getMessageService(), + voteGeneralMonitoringDTO); + } - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); + public ActionForward getVoteNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching getVoteNomination..."); - - logger.debug("submitting session to refresh the data from the database: "); - return submitSession(mapping, form, request, response, voteService, getMessageService(), voteGeneralMonitoringDTO); - } + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService :" + voteService); - - public ActionForward showOpenVote(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching showOpenVote..."); - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService :" +voteService); - - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - logger.debug("voteMonitoringForm :" +voteMonitoringForm); - voteMonitoringForm.setVoteService(voteService); + VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + VoteMonitoringAction.logger.debug("voteMonitoringForm :" + voteMonitoringForm); + voteMonitoringForm.setVoteService(voteService); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - - repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - - String currentUid=voteMonitoringForm.getCurrentUid(); - logger.debug("currentUid: " + currentUid); - - VoteUsrAttempt voteUsrAttempt =voteService.getAttemptByUID(new Long(currentUid)); - logger.debug("voteUsrAttempt: " + voteUsrAttempt); - voteUsrAttempt.setVisible(true); - - voteService.updateVoteUsrAttempt(voteUsrAttempt); - voteService.showOpenVote(voteUsrAttempt); - logger.debug("voteUsrAttempt: " + voteUsrAttempt); + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - String toolContentID=voteMonitoringForm.getToolContentID(); - logger.debug("toolContentID: " + toolContentID); - - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("existing voteContent:" + voteContent); - - initSummaryContent(toolContentID , request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initSummaryContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initInstructionsContent."); - logger.debug("post initInstructionsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - - logger.debug("calling initStatsContent."); - initStatsContent(toolContentID, request, voteService, voteGeneralMonitoringDTO); - logger.debug("post initStatsContent, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + String questionUid = request.getParameter("questionUid"); + String sessionUid = request.getParameter("sessionUid"); + VoteMonitoringAction.logger.debug("questionUid: " + questionUid); + VoteMonitoringAction.logger.debug("sessionUid: " + sessionUid); - String currentMonitoredToolSession=voteMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + List userNames = voteService.getStandardAttemptUsersForQuestionContentAndSessionUid(new Long(questionUid), + new Long(sessionUid)); + VoteMonitoringAction.logger.debug("userNames: " + userNames); + List listVotedLearnersDTO = new LinkedList(); - refreshSummaryData(request, voteContent, voteService, true, false, currentMonitoredToolSession, null, - true, null, voteGeneralMonitoringDTO, null); - - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + VoteContent voteContent = null; + Iterator userIterator = userNames.iterator(); + while (userIterator.hasNext()) { + VoteUsrAttempt voteUsrAttempt = (VoteUsrAttempt) userIterator.next(); - if (currentMonitoredToolSession.equals("All")) - { - voteGeneralMonitoringDTO.setSelectionCase(new Long(2)); - request.setAttribute(SELECTION_CASE, new Long(2)); + if (voteUsrAttempt != null) { + VoteMonitoringAction.logger.debug("used voteContent is: "); + voteContent = voteUsrAttempt.getVoteQueContent().getVoteContent(); } - else - { - voteGeneralMonitoringDTO.setSelectionCase(new Long(1)); - request.setAttribute(SELECTION_CASE, new Long(1)); - } - - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - - voteGeneralMonitoringDTO.setCurrentMonitoredToolSession(currentMonitoredToolSession); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); + voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); + listVotedLearnersDTO.add(voteMonitoredUserDTO); + } + VoteMonitoringAction.logger.debug("listVoteAllSessionsDTO: " + listVotedLearnersDTO); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ - - - logger.debug("voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + voteGeneralMonitoringDTO.setMapStudentsVoted(listVotedLearnersDTO); + voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); + VoteMonitoringAction.logger.debug("ending getVoteNomination, voteGeneralMonitoringDTO: " + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("submitting session to refresh the data from the database: "); - return submitSession(mapping, form, request, response, voteService, getMessageService(), voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("fdwing to: " + VoteAppConstants.VOTE_NOMINATION_VIEWER); + return mapping.findForward(VoteAppConstants.VOTE_NOMINATION_VIEWER); } + public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching openNotebook..."); + IVoteService VoteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("VoteService: " + VoteService); - public ActionForward getVoteNomination(ActionMapping mapping, ActionForm form, - HttpServletRequest request,HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching getVoteNomination..."); - - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService :" +voteService); - - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - logger.debug("voteMonitoringForm :" +voteMonitoringForm); - voteMonitoringForm.setVoteService(voteService); + String uid = request.getParameter("uid"); + VoteMonitoringAction.logger.debug("uid: " + uid); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); + String userId = request.getParameter("userId"); + VoteMonitoringAction.logger.debug("userId: " + userId); - String questionUid=request.getParameter("questionUid"); - String sessionUid=request.getParameter("sessionUid"); - - logger.debug("questionUid: " + questionUid); - logger.debug("sessionUid: " + sessionUid); + String userName = request.getParameter("userName"); + VoteMonitoringAction.logger.debug("userName: " + userName); - List userNames=voteService.getStandardAttemptUsersForQuestionContentAndSessionUid(new Long(questionUid), new Long(sessionUid)); - logger.debug("userNames: " + userNames); - List listVotedLearnersDTO= new LinkedList(); - - VoteContent voteContent=null; - Iterator userIterator=userNames.iterator(); - while (userIterator.hasNext()) - { - VoteUsrAttempt voteUsrAttempt=(VoteUsrAttempt)userIterator.next(); - - if (voteUsrAttempt != null) - { - logger.debug("used voteContent is: "); - voteContent = voteUsrAttempt.getVoteQueContent().getVoteContent(); - } - - VoteMonitoredUserDTO voteMonitoredUserDTO= new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); - voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); - listVotedLearnersDTO.add(voteMonitoredUserDTO); - } - logger.debug("listVoteAllSessionsDTO: " + listVotedLearnersDTO); - logger.debug("voteContent: " + voteContent); - - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + String sessionId = request.getParameter("sessionId"); + VoteMonitoringAction.logger.debug("sessionId: " + sessionId); - - voteGeneralMonitoringDTO.setMapStudentsVoted(listVotedLearnersDTO); - voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString()); - logger.debug("ending getVoteNomination, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + NotebookEntry notebookEntry = VoteService.getEntry(new Long(sessionId), CoreNotebookConstants.NOTEBOOK_TOOL, + VoteAppConstants.MY_SIGNATURE, new Integer(userId)); - logger.debug("fdwing to: " + VOTE_NOMINATION_VIEWER); - return (mapping.findForward(VOTE_NOMINATION_VIEWER)); + VoteMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO(); + if (notebookEntry != null) { + String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry()); + voteGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable); + voteGeneralLearnerFlowDTO.setUserName(userName); + } + + VoteMonitoringAction.logger.debug("voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); + + VoteMonitoringAction.logger.debug("fwding to : " + VoteAppConstants.LEARNER_NOTEBOOK); + return mapping.findForward(VoteAppConstants.LEARNER_NOTEBOOK); } - - - public ActionForward openNotebook(ActionMapping mapping, - ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching openNotebook..."); - IVoteService VoteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("VoteService: " + VoteService); - - String uid=request.getParameter("uid"); - logger.debug("uid: " + uid); - - String userId=request.getParameter("userId"); - logger.debug("userId: " + userId); - - String userName=request.getParameter("userName"); - logger.debug("userName: " + userName); + protected void repopulateRequestParameters(HttpServletRequest request, VoteMonitoringForm voteMonitoringForm, + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) { + VoteMonitoringAction.logger.debug("starting repopulateRequestParameters"); - String sessionId=request.getParameter("sessionId"); - logger.debug("sessionId: " + sessionId); - - - NotebookEntry notebookEntry = VoteService.getEntry(new Long(sessionId), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(userId)); - - logger.debug("notebookEntry: " + notebookEntry); - - VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO(); - if (notebookEntry != null) { - String notebookEntryPresentable=VoteUtils.replaceNewLines(notebookEntry.getEntry()); - voteGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable); - voteGeneralLearnerFlowDTO.setUserName(userName); - } + String toolContentID = request.getParameter(VoteAppConstants.TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); + voteMonitoringForm.setToolContentID(toolContentID); + voteGeneralMonitoringDTO.setToolContentID(toolContentID); - logger.debug("voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); - - - logger.debug("fwding to : " + LEARNER_NOTEBOOK); - return mapping.findForward(LEARNER_NOTEBOOK); - } - - - protected void repopulateRequestParameters(HttpServletRequest request, VoteMonitoringForm voteMonitoringForm, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) - { - logger.debug("starting repopulateRequestParameters"); - - String toolContentID=request.getParameter(TOOL_CONTENT_ID); - logger.debug("toolContentID: " + toolContentID); - voteMonitoringForm.setToolContentID(toolContentID); - voteGeneralMonitoringDTO.setToolContentID(toolContentID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - voteMonitoringForm.setActiveModule(activeModule); - voteGeneralMonitoringDTO.setActiveModule(activeModule); - - String defineLaterInEditMode=request.getParameter(DEFINE_LATER_IN_EDIT_MODE); - logger.debug("defineLaterInEditMode: " + defineLaterInEditMode); - voteMonitoringForm.setDefineLaterInEditMode(defineLaterInEditMode); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(defineLaterInEditMode); + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + voteMonitoringForm.setActiveModule(activeModule); + voteGeneralMonitoringDTO.setActiveModule(activeModule); - - String isToolSessionChanged=request.getParameter(IS_TOOL_SESSION_CHANGED); - logger.debug("isToolSessionChanged: " + isToolSessionChanged); - voteMonitoringForm.setIsToolSessionChanged(isToolSessionChanged); - voteGeneralMonitoringDTO.setIsToolSessionChanged(isToolSessionChanged); + String defineLaterInEditMode = request.getParameter(VoteAppConstants.DEFINE_LATER_IN_EDIT_MODE); + VoteMonitoringAction.logger.debug("defineLaterInEditMode: " + defineLaterInEditMode); + voteMonitoringForm.setDefineLaterInEditMode(defineLaterInEditMode); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(defineLaterInEditMode); - String responseId=request.getParameter(RESPONSE_ID); - logger.debug("responseId: " + responseId); - voteMonitoringForm.setResponseId(responseId); - voteGeneralMonitoringDTO.setResponseId(responseId); + String isToolSessionChanged = request.getParameter(VoteAppConstants.IS_TOOL_SESSION_CHANGED); + VoteMonitoringAction.logger.debug("isToolSessionChanged: " + isToolSessionChanged); + voteMonitoringForm.setIsToolSessionChanged(isToolSessionChanged); + voteGeneralMonitoringDTO.setIsToolSessionChanged(isToolSessionChanged); - String currentUid=request.getParameter(CURRENT_UID); - logger.debug("currentUid: " + currentUid); - voteMonitoringForm.setCurrentUid(currentUid); - voteGeneralMonitoringDTO.setCurrentUid(currentUid); + String responseId = request.getParameter(VoteAppConstants.RESPONSE_ID); + VoteMonitoringAction.logger.debug("responseId: " + responseId); + voteMonitoringForm.setResponseId(responseId); + voteGeneralMonitoringDTO.setResponseId(responseId); + + String currentUid = request.getParameter(VoteAppConstants.CURRENT_UID); + VoteMonitoringAction.logger.debug("currentUid: " + currentUid); + voteMonitoringForm.setCurrentUid(currentUid); + voteGeneralMonitoringDTO.setCurrentUid(currentUid); } - - - protected void repopulateRequestParameters(HttpServletRequest request, VoteMonitoringForm voteMonitoringForm, - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) - { - logger.debug("starting repopulateRequestParameters"); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteMonitoringForm.setContentFolderID(contentFolderID); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + protected void repopulateRequestParameters(HttpServletRequest request, VoteMonitoringForm voteMonitoringForm, + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) { + VoteMonitoringAction.logger.debug("starting repopulateRequestParameters"); - - String toolContentID=request.getParameter(TOOL_CONTENT_ID); - logger.debug("toolContentID: " + toolContentID); - voteMonitoringForm.setToolContentID(toolContentID); - voteGeneralAuthoringDTO.setToolContentID(toolContentID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - voteMonitoringForm.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - - String defineLaterInEditMode=request.getParameter(DEFINE_LATER_IN_EDIT_MODE); - logger.debug("defineLaterInEditMode: " + defineLaterInEditMode); - voteMonitoringForm.setDefineLaterInEditMode(defineLaterInEditMode); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(defineLaterInEditMode); - + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteMonitoringForm.setContentFolderID(contentFolderID); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String toolContentID = request.getParameter(VoteAppConstants.TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("toolContentID: " + toolContentID); + voteMonitoringForm.setToolContentID(toolContentID); + voteGeneralAuthoringDTO.setToolContentID(toolContentID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + voteMonitoringForm.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + + String defineLaterInEditMode = request.getParameter(VoteAppConstants.DEFINE_LATER_IN_EDIT_MODE); + VoteMonitoringAction.logger.debug("defineLaterInEditMode: " + defineLaterInEditMode); + voteMonitoringForm.setDefineLaterInEditMode(defineLaterInEditMode); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(defineLaterInEditMode); + } - - + /** * used in define later mode to switch from view-only to editable screen * @@ -1811,185 +1623,154 @@ * @throws ServletException * @throws ToolException */ - public ActionForward editActivityQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - ToolException - { - logger.debug("dispatching editActivityQuestions..."); - - VoteMonitoringForm VoteMonitoringForm = (VoteMonitoringForm) form; - logger.debug("VoteMonitoringForm: " + VoteMonitoringForm); + public ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + VoteMonitoringAction.logger.debug("dispatching editActivityQuestions..."); - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - VoteGeneralMonitoringDTO generalMonitoringDTO = new VoteGeneralMonitoringDTO(); - - generalMonitoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - generalMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, generalMonitoringDTO); + VoteMonitoringForm VoteMonitoringForm = (VoteMonitoringForm) form; + VoteMonitoringAction.logger.debug("VoteMonitoringForm: " + VoteMonitoringForm); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - VoteMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - VoteMonitoringForm.setContentFolderID(contentFolderID); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - VoteMonitoringForm.setHttpSessionID(httpSessionID); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("existing voteContent:" + voteContent); - - VoteMonitoringForm.setTitle(voteContent.getTitle()); + VoteGeneralMonitoringDTO generalMonitoringDTO = new VoteGeneralMonitoringDTO(); - VoteUtils.setDefineLater(request, true,strToolContentID, voteService); + generalMonitoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); - prepareEditActivityScreenData(request, voteContent); - - //prepareReflectionData(request, voteContent, voteService, null, false, "All"); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - generalMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - generalMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + EditActivityDTO editActivityDTO = new EditActivityDTO(); + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, generalMonitoringDTO); - - - List listNominationContentDTO= new LinkedList(); + generalMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - Iterator queIterator=voteContent.getVoteQueContents().iterator(); - while (queIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO=new VoteNominationContentDTO(); - - VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); - if (voteQueContent != null) - { - logger.debug("question: " + voteQueContent.getQuestion()); - logger.debug("displayorder: " + new Integer(voteQueContent.getDisplayOrder()).toString()); - - voteNominationContentDTO.setQuestion(voteQueContent.getQuestion()); - voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); - listNominationContentDTO.add(voteNominationContentDTO); - } - } - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); + VoteMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, generalMonitoringDTO); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - VoteGeneralAuthoringDTO VoteGeneralAuthoringDTO = (VoteGeneralAuthoringDTO)request.getAttribute(VOTE_GENERAL_AUTHORING_DTO); - VoteGeneralAuthoringDTO.setActiveModule(MONITORING); - - VoteGeneralAuthoringDTO.setToolContentID(strToolContentID); - VoteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - VoteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + VoteMonitoringForm.setToolContentID(strToolContentID); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, VoteGeneralAuthoringDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)generalMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug(": " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + VoteMonitoringForm.setContentFolderID(contentFolderID); - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - MonitoringUtil.generateGroupsSessionData(request, voteService, voteContent); - - return (mapping.findForward(LOAD_MONITORING)); + String httpSessionID = request.getParameter("httpSessionID"); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + VoteMonitoringForm.setHttpSessionID(httpSessionID); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("existing voteContent:" + voteContent); + + VoteMonitoringForm.setTitle(voteContent.getTitle()); + + VoteUtils.setDefineLater(request, true, strToolContentID, voteService); + + prepareEditActivityScreenData(request, voteContent); + + // prepareReflectionData(request, voteContent, voteService, null, false, "All"); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + generalMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + generalMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + List listNominationContentDTO = new LinkedList(); + + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + while (queIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO(); + + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + VoteMonitoringAction.logger.debug("question: " + voteQueContent.getQuestion()); + VoteMonitoringAction.logger.debug("displayorder: " + + new Integer(voteQueContent.getDisplayOrder()).toString()); + + voteNominationContentDTO.setQuestion(voteQueContent.getQuestion()); + voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); + listNominationContentDTO.add(voteNominationContentDTO); + } + } + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + VoteGeneralAuthoringDTO VoteGeneralAuthoringDTO = (VoteGeneralAuthoringDTO) request + .getAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO); + VoteGeneralAuthoringDTO.setActiveModule(VoteAppConstants.MONITORING); + + VoteGeneralAuthoringDTO.setToolContentID(strToolContentID); + VoteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + VoteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, VoteGeneralAuthoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = generalMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug(": " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + MonitoringUtil.generateGroupsSessionData(request, voteService, voteContent); + + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } + public void prepareEditActivityScreenData(HttpServletRequest request, VoteContent voteContent) { + VoteMonitoringAction.logger.debug("starting prepareEditActivityScreenData: " + voteContent); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - public void prepareEditActivityScreenData(HttpServletRequest request, VoteContent voteContent) - { - logger.debug("starting prepareEditActivityScreenData: " + voteContent); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - - if (voteContent.getTitle() == null) - { - voteGeneralAuthoringDTO.setActivityTitle(DEFAULT_VOTING_TITLE); - } - else - { - voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); - } + if (voteContent.getTitle() == null) { + voteGeneralAuthoringDTO.setActivityTitle(VoteAppConstants.DEFAULT_VOTING_TITLE); + } else { + voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); + } - - if (voteContent.getInstructions() == null) - { - voteGeneralAuthoringDTO.setActivityInstructions(DEFAULT_VOTING_INSTRUCTIONS); - } - else - { - voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); - } - - - logger.debug("final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + if (voteContent.getInstructions() == null) { + voteGeneralAuthoringDTO.setActivityInstructions(VoteAppConstants.DEFAULT_VOTING_INSTRUCTIONS); + } else { + voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); } - - - - + VoteMonitoringAction.logger.debug("final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + } + /** - * submits content into the tool database - * ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException + * submits content into the tool database ActionForward submitAllContent(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -1999,257 +1780,240 @@ * @throws IOException * @throws ServletException */ - public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing submitAllContent :" +form); - - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; + public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + VoteMonitoringAction.logger.debug("dispathcing submitAllContent :" + form); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - Map mapNominationContent=AuthoringUtil.extractMapNominationContent(listNominationContentDTO); - logger.debug("extracted mapNominationContent: " + mapNominationContent); - + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); - Map mapFeedback=AuthoringUtil.extractMapFeedback(listNominationContentDTO); - logger.debug("extracted mapFeedback: " + mapFeedback); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - ActionMessages errors = new ActionMessages(); - logger.debug("mapNominationContent size: " + mapNominationContent.size()); - - if (mapNominationContent.size() == 0) - { - ActionMessage error = new ActionMessage("nominations.none.submitted"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - logger.debug("errors: " + errors); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - - logger.debug("activeModule: " + activeModule); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("there are no issues with input, continue and submit data"); + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); - VoteContent voteContentTest=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContentTest: " + voteContentTest); - + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); - logger.debug("errors: " + errors); - if(!errors.isEmpty()){ - saveErrors(request, errors); - logger.debug("errors saved: " + errors); - } - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); - VoteContent voteContent=voteContentTest; - if(errors.isEmpty()){ - logger.debug("errors is empty: " + errors); - /*to remove deleted entries in the questions table based on mapNominationContent */ - authoringUtil.removeRedundantNominations(mapNominationContent, voteService, voteAuthoringForm, request, strToolContentID); - logger.debug("end of removing unused entries... "); + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); - voteContent=authoringUtil.saveOrUpdateVoteContent(mapNominationContent, mapFeedback, voteService, voteAuthoringForm, request, voteContentTest, strToolContentID); - logger.debug("voteContent: " + voteContent); - - - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=voteService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (voteContent != null) - { - voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } - logger.debug("updated voteGeneralAuthoringDTO to: " + voteGeneralAuthoringDTO); - - authoringUtil.reOrganizeDisplayOrder(mapNominationContent, voteService, voteAuthoringForm, voteContent); + Map mapNominationContent = AuthoringUtil.extractMapNominationContent(listNominationContentDTO); + VoteMonitoringAction.logger.debug("extracted mapNominationContent: " + mapNominationContent); - logger.debug("strToolContentID: " + strToolContentID); - VoteUtils.setDefineLater(request, false, strToolContentID, voteService); - logger.debug("define later set to false"); - - //VoteUtils.setFormProperties(request, voteService, - // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + Map mapFeedback = AuthoringUtil.extractMapFeedback(listNominationContentDTO); + VoteMonitoringAction.logger.debug("extracted mapFeedback: " + mapFeedback); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); - } - else - { - logger.debug("errors is not empty: " + errors); - - if (voteContent != null) - { - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=voteService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (voteContent != null) - { - voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } + ActionMessages errors = new ActionMessages(); + VoteMonitoringAction.logger.debug("mapNominationContent size: " + mapNominationContent.size()); - //VoteUtils.setFormProperties(request, voteService, - // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - } - - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - } - + if (mapNominationContent.size() == 0) { + ActionMessage error = new ActionMessage("nominations.none.submitted"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + VoteMonitoringAction.logger.debug("errors: " + errors); - voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); - - voteAuthoringForm.resetUserAction(); - voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); - + AuthoringUtil authoringUtil = new AuthoringUtil(); - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - request.getSession().setAttribute(httpSessionID, sessionMap); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setCurrentTab("3"); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); - - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteMonitoringAction.logger.debug("there are no issues with input, continue and submit data"); + + VoteContent voteContentTest = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContentTest: " + voteContentTest); + + VoteMonitoringAction.logger.debug("errors: " + errors); + if (!errors.isEmpty()) { + saveErrors(request, errors); + VoteMonitoringAction.logger.debug("errors saved: " + errors); + } + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + + VoteContent voteContent = voteContentTest; + if (errors.isEmpty()) { + VoteMonitoringAction.logger.debug("errors is empty: " + errors); + /* to remove deleted entries in the questions table based on mapNominationContent */ + authoringUtil.removeRedundantNominations(mapNominationContent, voteService, voteAuthoringForm, request, + strToolContentID); + VoteMonitoringAction.logger.debug("end of removing unused entries... "); + + voteContent = authoringUtil.saveOrUpdateVoteContent(mapNominationContent, mapFeedback, voteService, + voteAuthoringForm, request, voteContentTest, strToolContentID, null); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); + + long defaultContentID = 0; + VoteMonitoringAction.logger.debug("attempt retrieving tool with signatute : " + + VoteAppConstants.MY_SIGNATURE); + defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); + VoteMonitoringAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (voteContent != null) { + voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); + } + VoteMonitoringAction.logger.debug("updated voteGeneralAuthoringDTO to: " + voteGeneralAuthoringDTO); + + authoringUtil.reOrganizeDisplayOrder(mapNominationContent, voteService, voteAuthoringForm, voteContent); + + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + VoteUtils.setDefineLater(request, false, strToolContentID, voteService); + VoteMonitoringAction.logger.debug("define later set to false"); + + // VoteUtils.setFormProperties(request, voteService, + // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, + // sessionMap, httpSessionID); + + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("errors is not empty: " + errors); + + if (voteContent != null) { + long defaultContentID = 0; + VoteMonitoringAction.logger.debug("attempt retrieving tool with signatute : " + + VoteAppConstants.MY_SIGNATURE); + defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); + VoteMonitoringAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (voteContent != null) { + voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); } - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("forwarding to :" + LOAD_MONITORING); - return mapping.findForward(LOAD_MONITORING); + // VoteUtils.setFormProperties(request, voteService, + // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, + // sessionMap, httpSessionID); + + } + + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + } + + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); + + voteAuthoringForm.resetUserAction(); + voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + request.getSession().setAttribute(httpSessionID, sessionMap); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setCurrentTab("3"); + + VoteMonitoringAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("forwarding to :" + VoteAppConstants.LOAD_MONITORING); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } - /** * saveSingleNomination + * * @param mapping * @param form * @param request @@ -2258,282 +2022,251 @@ * @throws IOException * @throws ServletException */ - public ActionForward saveSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing saveSingleNomination"); - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - String editNominationBoxRequest=request.getParameter("editNominationBoxRequest"); - logger.debug("editNominationBoxRequest: " + editNominationBoxRequest); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - - String newNomination=request.getParameter("newNomination"); - logger.debug("newNomination: " + newNomination); - - - String editableNominationIndex=request.getParameter("editableNominationIndex"); - logger.debug("editableNominationIndex: " + editableNominationIndex); - + public ActionForward saveSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - if ((newNomination != null) && (newNomination.length() > 0)) - { - if ((editNominationBoxRequest != null) && (editNominationBoxRequest.equals("false"))) - { - logger.debug("request for add and save"); - boolean duplicates=AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - VoteNominationContentDTO voteNominationContentDTO= null; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getQuestion()); - - String question=voteNominationContentDTO.getQuestion(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableNominationIndex)) - { - break; - } - - } - } - logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - - voteNominationContentDTO.setQuestion(newNomination); - voteNominationContentDTO.setDisplayOrder(editableNominationIndex); - - listNominationContentDTO=AuthoringUtil.reorderUpdateListNominationContentDTO(listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); - logger.debug("post reorderUpdateListNominationContentDTO listNominationContentDTO: " + listNominationContentDTO); - } - else - { - logger.debug("duplicate question entry, not adding"); - } - } - else - { - logger.debug("request for edit and save."); - VoteNominationContentDTO voteNominationContentDTO= null; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getQuestion()); - - String question=voteNominationContentDTO.getQuestion(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableNominationIndex)) - { - break; - } - - } - } - logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - - voteNominationContentDTO.setQuestion(newNomination); - voteNominationContentDTO.setDisplayOrder(editableNominationIndex); - - listNominationContentDTO=AuthoringUtil.reorderUpdateListNominationContentDTO(listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); - logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + listNominationContentDTO); - } - } - else - { - logger.debug("entry blank, not adding"); - } - - - + VoteMonitoringAction.logger.debug("dispathcing saveSingleNomination"); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - logger.debug("activeModule: " + activeModule); - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - //VoteUtils.setFormProperties(request, voteService, - // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setCurrentTab("3"); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); - logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + voteGeneralAuthoringDTO.getMapNominationContent()); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + String editNominationBoxRequest = request.getParameter("editNominationBoxRequest"); + VoteMonitoringAction.logger.debug("editNominationBoxRequest: " + editNominationBoxRequest); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + String newNomination = request.getParameter("newNomination"); + VoteMonitoringAction.logger.debug("newNomination: " + newNomination); + + String editableNominationIndex = request.getParameter("editableNominationIndex"); + VoteMonitoringAction.logger.debug("editableNominationIndex: " + editableNominationIndex); + + if (newNomination != null && newNomination.length() > 0) { + if (editNominationBoxRequest != null && editNominationBoxRequest.equals("false")) { + VoteMonitoringAction.logger.debug("request for add and save"); + boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); + VoteMonitoringAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + VoteNominationContentDTO voteNominationContentDTO = null; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteMonitoringAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteMonitoringAction.logger.debug("voteNominationContentDTO question:" + + voteNominationContentDTO.getQuestion()); + + String question = voteNominationContentDTO.getQuestion(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + VoteMonitoringAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableNominationIndex)) { + break; + } + } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + } + VoteMonitoringAction.logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + voteNominationContentDTO.setQuestion(newNomination); + voteNominationContentDTO.setDisplayOrder(editableNominationIndex); + + listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO( + listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); + VoteMonitoringAction.logger + .debug("post reorderUpdateListNominationContentDTO listNominationContentDTO: " + + listNominationContentDTO); + } else { + VoteMonitoringAction.logger.debug("duplicate question entry, not adding"); } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + } else { + VoteMonitoringAction.logger.debug("request for edit and save."); + VoteNominationContentDTO voteNominationContentDTO = null; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteMonitoringAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteMonitoringAction.logger.debug("voteNominationContentDTO question:" + + voteNominationContentDTO.getQuestion()); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + String question = voteNominationContentDTO.getQuestion(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + VoteMonitoringAction.logger.debug("displayOrder:" + displayOrder); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableNominationIndex)) { + break; + } + } } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); + VoteMonitoringAction.logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - - logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); - return (mapping.findForward(LOAD_MONITORING)); + voteNominationContentDTO.setQuestion(newNomination); + voteNominationContentDTO.setDisplayOrder(editableNominationIndex); + + listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO( + listNominationContentDTO, voteNominationContentDTO, editableNominationIndex); + VoteMonitoringAction.logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + + listNominationContentDTO); + } + } else { + VoteMonitoringAction.logger.debug("entry blank, not adding"); } - - + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + VoteMonitoringAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + // VoteUtils.setFormProperties(request, voteService, + // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, + // httpSessionID); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setCurrentTab("3"); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + + voteGeneralAuthoringDTO.getMapNominationContent()); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("fwd ing to LOAD_MONITORING: " + VoteAppConstants.LOAD_MONITORING); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); + } + /** * addSingleNomination + * * @param mapping * @param form * @param request @@ -2542,200 +2275,180 @@ * @throws IOException * @throws ServletException */ - public ActionForward addSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing addSingleNomination"); - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - String newNomination=request.getParameter("newNomination"); - logger.debug("newNomination: " + newNomination); - - int listSize=listNominationContentDTO.size(); - logger.debug("listSize: " + listSize); - - if ((newNomination != null) && (newNomination.length() > 0)) - { - boolean duplicates=AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - VoteNominationContentDTO voteNominationContentDTO=new VoteNominationContentDTO(); - voteNominationContentDTO.setDisplayOrder(new Long(listSize+1).toString()); - voteNominationContentDTO.setNomination(newNomination); - - listNominationContentDTO.add(voteNominationContentDTO); - logger.debug("updated listNominationContentDTO: " + listNominationContentDTO); - } - else - { - logger.debug("entry duplicate, not adding"); + public ActionForward addSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - } + VoteMonitoringAction.logger.debug("dispathcing addSingleNomination"); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; + + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); + + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + voteGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + String newNomination = request.getParameter("newNomination"); + VoteMonitoringAction.logger.debug("newNomination: " + newNomination); + + int listSize = listNominationContentDTO.size(); + VoteMonitoringAction.logger.debug("listSize: " + listSize); + + if (newNomination != null && newNomination.length() > 0) { + boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination); + VoteMonitoringAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO(); + voteNominationContentDTO.setDisplayOrder(new Long(listSize + 1).toString()); + voteNominationContentDTO.setNomination(newNomination); + + listNominationContentDTO.add(voteNominationContentDTO); + VoteMonitoringAction.logger.debug("updated listNominationContentDTO: " + listNominationContentDTO); + } else { + VoteMonitoringAction.logger.debug("entry duplicate, not adding"); + } - else - { - logger.debug("entry blank, not adding"); - } - - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + } else { + VoteMonitoringAction.logger.debug("entry blank, not adding"); + } - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - logger.debug("activeModule: " + activeModule); - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setCurrentTab("3"); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + voteGeneralAuthoringDTO.getMapNominationContent()); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - } + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); - - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); - return (mapping.findForward(LOAD_MONITORING)); + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setCurrentTab("3"); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO.getMapNominationContent(); " + + voteGeneralAuthoringDTO.getMapNominationContent()); + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); } - + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("fwd ing to LOAD_MONITORING: " + VoteAppConstants.LOAD_MONITORING); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); + } + /** * opens up an new screen within the current page for adding a new question * * newNominationBox + * * @param mapping * @param form * @param request @@ -2744,144 +2457,128 @@ * @throws IOException * @throws ServletException */ - public ActionForward newNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing newNominationBox"); - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + public ActionForward newNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("dispathcing newNominationBox"); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); - - logger.debug("fwd ing to newNominationBox: "); - return (mapping.findForward("newNominationBox")); - } + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("fwd ing to newNominationBox: "); + return mapping.findForward("newNominationBox"); + } + /** - * opens up an new screen within the current page for editing a question - * newEditableNominationBox + * opens up an new screen within the current page for editing a question newEditableNominationBox + * * @param mapping * @param form * @param request @@ -2890,173 +2587,152 @@ * @throws IOException * @throws ServletException */ - public ActionForward newEditableNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing newEditableNominationBox"); - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + public ActionForward newEditableNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("dispathcing newEditableNominationBox"); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - voteAuthoringForm.setEditableNominationIndex(questionIndex); - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - String editableNomination=""; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - String question=voteNominationContentDTO.getNomination(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - editableNomination=voteNominationContentDTO.getNomination(); - logger.debug("editableNomination found :" + editableNomination); - break; - } - - } + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String questionIndex = request.getParameter("questionIndex"); + VoteMonitoringAction.logger.debug("questionIndex: " + questionIndex); + + voteAuthoringForm.setEditableNominationIndex(questionIndex); + + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + String editableNomination = ""; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteMonitoringAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteMonitoringAction.logger.debug("voteNominationContentDTO question:" + + voteNominationContentDTO.getNomination()); + String question = voteNominationContentDTO.getNomination(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + editableNomination = voteNominationContentDTO.getNomination(); + VoteMonitoringAction.logger.debug("editableNomination found :" + editableNomination); + break; + } + } - logger.debug("editableNomination found :" + editableNomination); + } + VoteMonitoringAction.logger.debug("editableNomination found :" + editableNomination); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - voteGeneralAuthoringDTO.setEditableNominationText(editableNomination); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + voteGeneralAuthoringDTO.setEditableNominationText(editableNomination); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO now: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("fwd ing to editNominationBox: "); - return (mapping.findForward("editNominationBox")); + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("fwd ing to editNominationBox: "); + return mapping.findForward("editNominationBox"); } - - /** - * removes a question from the questions map - * ActionForward removeNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException + * removes a question from the questions map ActionForward removeNomination(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -3066,209 +2742,190 @@ * @throws IOException * @throws ServletException */ - public ActionForward removeNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching removeNomination"); - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); + public ActionForward removeNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("dispatching removeNomination"); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - VoteNominationContentDTO voteNominationContentDTO= null; - Iterator listIterator=listNominationContentDTO.iterator(); - while (listIterator.hasNext()) - { - voteNominationContentDTO= (VoteNominationContentDTO)listIterator.next(); - logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); - logger.debug("voteNominationContentDTO question:" + voteNominationContentDTO.getNomination()); - - String question=voteNominationContentDTO.getNomination(); - String displayOrder=voteNominationContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - break; - } - - } - } - - logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); - voteNominationContentDTO.setNomination(""); - logger.debug("listNominationContentDTO after remove:" + listNominationContentDTO); - - - listNominationContentDTO=AuthoringUtil.reorderListNominationContentDTO(listNominationContentDTO, questionIndex ); - logger.debug("listNominationContentDTO reordered:" + listNominationContentDTO); - - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + String questionIndex = request.getParameter("questionIndex"); + VoteMonitoringAction.logger.debug("questionIndex: " + questionIndex); + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - if (voteContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - voteContent=voteService.retrieveVote(new Long(defaultContentIdStr)); - + VoteNominationContentDTO voteNominationContentDTO = null; + Iterator listIterator = listNominationContentDTO.iterator(); + while (listIterator.hasNext()) { + voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next(); + VoteMonitoringAction.logger.debug("voteNominationContentDTO:" + voteNominationContentDTO); + VoteMonitoringAction.logger.debug("voteNominationContentDTO question:" + + voteNominationContentDTO.getNomination()); + + String question = voteNominationContentDTO.getNomination(); + String displayOrder = voteNominationContentDTO.getDisplayOrder(); + VoteMonitoringAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + break; } - logger.debug("final voteContent: " + voteContent); - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + } + } - AuthoringUtil authoringUtil= new AuthoringUtil(); - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); + VoteMonitoringAction.logger.debug("voteNominationContentDTO found:" + voteNominationContentDTO); + voteNominationContentDTO.setNomination(""); + VoteMonitoringAction.logger.debug("listNominationContentDTO after remove:" + listNominationContentDTO); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setCurrentTab("3"); + listNominationContentDTO = AuthoringUtil.reorderListNominationContentDTO(listNominationContentDTO, + questionIndex); + VoteMonitoringAction.logger.debug("listNominationContentDTO reordered:" + listNominationContentDTO); - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - logger.debug("voteNominationContentDTO now: " + voteNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); - return (mapping.findForward(LOAD_MONITORING)); + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); + + if (voteContent == null) { + VoteMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + voteContent = voteService.retrieveVote(new Long(defaultContentIdStr)); + + } + VoteMonitoringAction.logger.debug("final voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setCurrentTab("3"); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + VoteMonitoringAction.logger.debug("voteNominationContentDTO now: " + voteNominationContentDTO); + VoteMonitoringAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("fwd ing to LOAD_MONITORING: " + VoteAppConstants.LOAD_MONITORING); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } - - + /** - * moves a question down in the list - * moveNominationDown + * moves a question down in the list moveNominationDown + * * @param mapping * @param form * @param request @@ -3277,178 +2934,160 @@ * @throws IOException * @throws ServletException */ - public ActionForward moveNominationDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching moveNominationDown"); - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "down"); - logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); - logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); + public ActionForward moveNominationDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("dispatching moveNominationDown"); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setCurrentTab("3"); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); + String questionIndex = request.getParameter("questionIndex"); + VoteMonitoringAction.logger.debug("questionIndex: " + questionIndex); - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "down"); + VoteMonitoringAction.logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); - return (mapping.findForward(LOAD_MONITORING)); + listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); + VoteMonitoringAction.logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); + + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setCurrentTab("3"); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + VoteMonitoringAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("fwd ing to LOAD_MONITORING: " + VoteAppConstants.LOAD_MONITORING); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } - /** - * moves a question up in the list - * moveNominationUp + * moves a question up in the list moveNominationUp + * * @param mapping * @param form * @param request @@ -3457,387 +3096,347 @@ * @throws IOException * @throws ServletException */ - public ActionForward moveNominationUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching moveNominationUp"); - VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - - IVoteService voteService =VoteServiceProxy.getVoteService(getServlet().getServletContext()); - logger.debug("voteService: " + voteService); - - String httpSessionID=voteAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listNominationContentDTO=(List)sessionMap.get(LIST_NOMINATION_CONTENT_DTO_KEY); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "up"); - logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); - - listNominationContentDTO=AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); - logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); - - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentID)); - logger.debug("voteContent: " + voteContent); - - - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO= new VoteGeneralAuthoringDTO(); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); - voteAuthoringForm.setTitle(richTextTitle); - - voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + public ActionForward moveNominationUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + VoteMonitoringAction.logger.debug("dispatching moveNominationUp"); + VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form; - AuthoringUtil authoringUtil= new AuthoringUtil(); - - voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - voteGeneralAuthoringDTO.setToolContentID(strToolContentID); - voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - voteGeneralAuthoringDTO.setActiveModule(activeModule); - voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setToolContentID(strToolContentID); - voteAuthoringForm.setHttpSessionID(httpSessionID); - voteAuthoringForm.setActiveModule(activeModule); - voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - voteAuthoringForm.setCurrentTab("3"); - - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - logger.debug("listNominationContentDTO now: " + listNominationContentDTO); - - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); - + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + VoteMonitoringAction.logger.debug("voteService: " + voteService); - if (voteContent != null) - { - //prepareReflectionData(request, voteContent, voteService, null,false); - prepareReflectionData(request, voteContent, voteService, null, false, "All"); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=VoteUtils.isContentInUse(voteContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - } + String httpSessionID = voteAuthoringForm.getHttpSessionID(); + VoteMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(voteService, voteContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO= new VoteGeneralMonitoringDTO(); - voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - if (voteService.studentActivityOccurredGlobal(voteContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); - voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); - - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - logger.debug("attachmentList: " + attachmentList); - voteGeneralMonitoringDTO.setAttachmentList(attachmentList); - voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + VoteMonitoringAction.logger.debug("sessionMap: " + sessionMap); - - logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + String questionIndex = request.getParameter("questionIndex"); + VoteMonitoringAction.logger.debug("questionIndex: " + questionIndex); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildVoteStatsDTO(request,voteService, voteContent); - - logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); - return (mapping.findForward(LOAD_MONITORING)); + List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY); + VoteMonitoringAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + + listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "up"); + VoteMonitoringAction.logger.debug("listNominationContentDTO after swap: " + listNominationContentDTO); + + listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO); + VoteMonitoringAction.logger.debug("listNominationContentDTO after reordersimple: " + listNominationContentDTO); + + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE); + VoteMonitoringAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(VoteAppConstants.TITLE); + VoteMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS); + VoteMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR); + VoteMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID)); + VoteMonitoringAction.logger.debug("voteContent: " + voteContent); + + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); + VoteMonitoringAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + voteGeneralAuthoringDTO.setActivityTitle(richTextTitle); + voteAuthoringForm.setTitle(richTextTitle); + + voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + voteGeneralAuthoringDTO.setToolContentID(strToolContentID); + voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + voteGeneralAuthoringDTO.setActiveModule(activeModule); + voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setToolContentID(strToolContentID); + voteAuthoringForm.setHttpSessionID(httpSessionID); + voteAuthoringForm.setActiveModule(activeModule); + voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + voteAuthoringForm.setCurrentTab("3"); + + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + VoteMonitoringAction.logger.debug("listNominationContentDTO now: " + listNominationContentDTO); + + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteMonitoringAction.logger.debug("before saving final voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); + + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size())); + + if (voteContent != null) { + // prepareReflectionData(request, voteContent, voteService, null,false); + prepareReflectionData(request, voteContent, voteService, null, false, "All"); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = VoteUtils.isContentInUse(voteContent); + VoteMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + } + request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + } + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent); + VoteMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + if (voteService.studentActivityOccurredGlobal(voteContent)) { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + VoteMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + voteGeneralMonitoringDTO.setOnlineInstructions(voteContent.getOnlineInstructions()); + voteGeneralMonitoringDTO.setOfflineInstructions(voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + VoteMonitoringAction.logger.debug("attachmentList: " + attachmentList); + voteGeneralMonitoringDTO.setAttachmentList(attachmentList); + voteGeneralMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + VoteMonitoringAction.logger.debug("end of refreshSummaryData, voteGeneralMonitoringDTO" + + voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + + if (notebookEntriesExist) { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions(); + VoteMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + VoteMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent); + + VoteMonitoringAction.logger.debug("fwd ing to LOAD_MONITORING: " + VoteAppConstants.LOAD_MONITORING); + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } - - - - public void prepareReflectionData(HttpServletRequest request, VoteContent voteContent, - IVoteService voteService, String userID, boolean exportMode, String currentSessionId) - { - logger.debug("starting prepareReflectionData: " + voteContent); - logger.debug("currentSessionId: " + currentSessionId); - logger.debug("userID: " + userID); - logger.debug("exportMode: " + exportMode); + public void prepareReflectionData(HttpServletRequest request, VoteContent voteContent, IVoteService voteService, + String userID, boolean exportMode, String currentSessionId) { + VoteMonitoringAction.logger.debug("starting prepareReflectionData: " + voteContent); + VoteMonitoringAction.logger.debug("currentSessionId: " + currentSessionId); + VoteMonitoringAction.logger.debug("userID: " + userID); + VoteMonitoringAction.logger.debug("exportMode: " + exportMode); - List reflectionsContainerDTO= new LinkedList(); - - reflectionsContainerDTO=getReflectionList(voteContent, userID, voteService); - - logger.debug("reflectionsContainerDTO: " + reflectionsContainerDTO); - request.setAttribute(REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); - - if (exportMode) - { - request.getSession().setAttribute(REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); - } + List reflectionsContainerDTO = new LinkedList(); + + reflectionsContainerDTO = getReflectionList(voteContent, userID, voteService); + + VoteMonitoringAction.logger.debug("reflectionsContainerDTO: " + reflectionsContainerDTO); + request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); + + if (exportMode) { + request.getSession().setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); } - + } - /** * returns reflection data for all sessions * * getReflectionList + * * @param voteContent * @param userID * @param voteService * @return */ - public List getReflectionList(VoteContent voteContent, String userID, IVoteService voteService) - { - logger.debug("getting reflections for all sessions"); - List reflectionsContainerDTO= new LinkedList(); - if (userID == null) - { - logger.debug("all users mode"); - for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) - { - VoteSession voteSession = (VoteSession) sessionIter.next(); - logger.debug("voteSession: " + voteSession); - logger.debug("voteSession sessionId: " + voteSession.getVoteSessionId()); - - for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) - { - VoteQueUsr user = (VoteQueUsr) userIter.next(); - logger.debug("user: " + user); + public List getReflectionList(VoteContent voteContent, String userID, IVoteService voteService) { + VoteMonitoringAction.logger.debug("getting reflections for all sessions"); + List reflectionsContainerDTO = new LinkedList(); + if (userID == null) { + VoteMonitoringAction.logger.debug("all users mode"); + for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) { + VoteSession voteSession = (VoteSession) sessionIter.next(); + VoteMonitoringAction.logger.debug("voteSession: " + voteSession); + VoteMonitoringAction.logger.debug("voteSession sessionId: " + voteSession.getVoteSessionId()); - NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=VoteUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - } - else - { - logger.debug("single user mode"); - for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) - { - VoteSession voteSession = (VoteSession) sessionIter.next(); - logger.debug("voteSession: " + voteSession); - for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) - { - VoteQueUsr user = (VoteQueUsr) userIter.next(); - logger.debug("user: " + user); - - if (user.getQueUsrId().toString().equals(userID)) - { - logger.debug("getting reflection for user with userID: " + userID); - NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=VoteUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - } - } - - return reflectionsContainerDTO; + for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) { + VoteQueUsr user = (VoteQueUsr) userIter.next(); + VoteMonitoringAction.logger.debug("user: " + user); + + NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, VoteAppConstants.MY_SIGNATURE, new Integer(user + .getQueUsrId().toString())); + + VoteMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + } else { + VoteMonitoringAction.logger.debug("single user mode"); + for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) { + VoteSession voteSession = (VoteSession) sessionIter.next(); + VoteMonitoringAction.logger.debug("voteSession: " + voteSession); + for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) { + VoteQueUsr user = (VoteQueUsr) userIter.next(); + VoteMonitoringAction.logger.debug("user: " + user); + + if (user.getQueUsrId().toString().equals(userID)) { + VoteMonitoringAction.logger.debug("getting reflection for user with userID: " + userID); + NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, VoteAppConstants.MY_SIGNATURE, new Integer(user + .getQueUsrId().toString())); + + VoteMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + } + } + + return reflectionsContainerDTO; } - + /** * returns reflection data for a specific session * - * getReflectionListForSession(VoteContent voteContent, String userID, IVoteService voteService, String currentSessionId) + * getReflectionListForSession(VoteContent voteContent, String userID, IVoteService voteService, String + * currentSessionId) + * * @param voteContent * @param userID * @param voteService * @param currentSessionId * @return */ - public List getReflectionListForSession(VoteContent voteContent, String userID, IVoteService voteService, String currentSessionId) - { - logger.debug("getting reflections for a specific session"); - logger.debug("currentSessionId: " + currentSessionId); - - List reflectionsContainerDTO= new LinkedList(); - if (userID == null) - { - logger.debug("all users mode"); - for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) - { - VoteSession voteSession = (VoteSession) sessionIter.next(); - logger.debug("voteSession: " + voteSession); - logger.debug("voteSession sessionId: " + voteSession.getVoteSessionId()); - - if (currentSessionId.equals(voteSession.getVoteSessionId())) - { - - for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) - { - VoteQueUsr user = (VoteQueUsr) userIter.next(); - logger.debug("user: " + user); + public List getReflectionListForSession(VoteContent voteContent, String userID, IVoteService voteService, + String currentSessionId) { + VoteMonitoringAction.logger.debug("getting reflections for a specific session"); + VoteMonitoringAction.logger.debug("currentSessionId: " + currentSessionId); - NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=VoteUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - } - } - else - { - logger.debug("single user mode"); - for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) - { - VoteSession voteSession = (VoteSession) sessionIter.next(); - logger.debug("voteSession: " + voteSession); - - if (currentSessionId.equals(voteSession.getVoteSessionId())) - { - for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) - { - VoteQueUsr user = (VoteQueUsr) userIter.next(); - logger.debug("user: " + user); - - if (user.getQueUsrId().toString().equals(userID)) - { - logger.debug("getting reflection for user with userID: " + userID); - NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=VoteUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - - } - } - } - - return reflectionsContainerDTO; + List reflectionsContainerDTO = new LinkedList(); + if (userID == null) { + VoteMonitoringAction.logger.debug("all users mode"); + for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) { + VoteSession voteSession = (VoteSession) sessionIter.next(); + VoteMonitoringAction.logger.debug("voteSession: " + voteSession); + VoteMonitoringAction.logger.debug("voteSession sessionId: " + voteSession.getVoteSessionId()); + + if (currentSessionId.equals(voteSession.getVoteSessionId())) { + + for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) { + VoteQueUsr user = (VoteQueUsr) userIter.next(); + VoteMonitoringAction.logger.debug("user: " + user); + + NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, VoteAppConstants.MY_SIGNATURE, new Integer(user + .getQueUsrId().toString())); + + VoteMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + } + } else { + VoteMonitoringAction.logger.debug("single user mode"); + for (Iterator sessionIter = voteContent.getVoteSessions().iterator(); sessionIter.hasNext();) { + VoteSession voteSession = (VoteSession) sessionIter.next(); + VoteMonitoringAction.logger.debug("voteSession: " + voteSession); + + if (currentSessionId.equals(voteSession.getVoteSessionId())) { + for (Iterator userIter = voteSession.getVoteQueUsers().iterator(); userIter.hasNext();) { + VoteQueUsr user = (VoteQueUsr) userIter.next(); + VoteMonitoringAction.logger.debug("user: " + user); + + if (user.getQueUsrId().toString().equals(userID)) { + VoteMonitoringAction.logger.debug("getting reflection for user with userID: " + userID); + NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, VoteAppConstants.MY_SIGNATURE, new Integer( + user.getQueUsrId().toString())); + + VoteMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + + } + } + } + + return reflectionsContainerDTO; } - + /** - * Return ResourceService bean. - */ - private MessageService getMessageService() { - return VoteServiceProxy.getMessageService(getServlet().getServletContext()); - } + * Return ResourceService bean. + */ + private MessageService getMessageService() { + return VoteServiceProxy.getMessageService(getServlet().getServletContext()); + } } - \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java,v diff -u -r1.35 -r1.36 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java 29 Apr 2008 08:30:42 -0000 1.35 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java 2 Jul 2009 13:02:04 -0000 1.36 @@ -33,7 +33,7 @@ * * The tool must supply an authoring module, which will be called to create new content or edit existing content. It will be called by an authoring URL using the following format: - * /&toolContentID=123 + * /&toolContentID=123 * The initial data displayed on the authoring screen for a new tool content id may be the default tool content. @@ -68,62 +68,63 @@ * Tool path The URL path for the tool should be /tool/$TOOL_SIG. * - The author is given warnings when the content in use by learners OR when the content is being edited in the Monitoring interface. - - - - - + The author is given warnings when the content in use by learners OR when the content is being edited in the Monitoring interface. - + + - - - + - - - - - - - + -*/ + + + + + + + + + + + + */ + package org.lamsfoundation.lams.tool.vote.web; + import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; @@ -144,6 +145,7 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.learningdesign.DataFlowObject; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.VoteApplicationException; import org.lamsfoundation.lams.tool.vote.VoteComparator; @@ -158,475 +160,445 @@ import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; - public class VoteStarterAction extends Action implements VoteAppConstants { - /* - * This class is reused by defineLater and monitoring modules as well. - */ - static Logger logger = Logger.getLogger(VoteStarterAction.class.getName()); + /* + * This class is reused by defineLater and monitoring modules as well. + */ + static Logger logger = Logger.getLogger(VoteStarterAction.class.getName()); - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, VoteApplicationException { + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, VoteApplicationException { - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("init authoring mode. removed attributes..."); - - VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; - VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - voteAuthoringForm.setContentFolderID(contentFolderID); - - VoteAction voteAction= new VoteAction(); - voteAction.repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - + VoteUtils.cleanUpSessionAbsolute(request); + VoteStarterAction.logger.debug("init authoring mode. removed attributes..."); - logger.debug("getting voteService now: servlet is: " + getServlet()); - IVoteService voteService=null; - if (getServlet() != null) - voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - else - voteService=voteAuthoringForm.getVoteService(); - - logger.debug("final voteService: " + voteService); - - voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); - voteAuthoringForm.setSbmtSuccess(new Boolean(false).toString()); - - voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); - voteGeneralAuthoringDTO.setSbmtSuccess(new Boolean(false).toString()); - voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - String servletPath=request.getServletPath(); - logger.debug("getServletPath: "+ servletPath); - if (servletPath.indexOf("authoringStarter") > 0) - { - logger.debug("request is for authoring module"); - voteAuthoringForm.setActiveModule(AUTHORING); - voteGeneralAuthoringDTO.setActiveModule(AUTHORING); - - voteAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - } - else - { - logger.debug("request is for define later module. either direct or by monitoring module"); - voteAuthoringForm.setActiveModule(DEFINE_LATER); - voteGeneralAuthoringDTO.setActiveModule(DEFINE_LATER); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO(); - voteAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); - voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - } - - initialiseAttributes(request, voteGeneralAuthoringDTO, voteService); - - - SessionMap sessionMap = new SessionMap(); - sessionMap.put(ATTACHMENT_LIST_KEY, new ArrayList()); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); - sessionMap.put(ACTIVITY_TITLE_KEY, ""); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, ""); - voteAuthoringForm.setHttpSessionID(sessionMap.getSessionID()); - voteGeneralAuthoringDTO.setHttpSessionID(sessionMap.getSessionID()); - - /* determine whether the request is from Monitoring url Edit Activity. - * null sourceVoteStarter indicates that the request is from authoring url. - * */ - - String sourceVoteStarter = (String) request.getAttribute(SOURCE_VOTE_STARTER); - logger.debug("sourceVoteStarter: " + sourceVoteStarter); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + VoteStarterAction.logger.debug("contentFolderID: " + contentFolderID); + voteAuthoringForm.setContentFolderID(contentFolderID); - voteAuthoringForm.resetRadioBoxes(); - voteAuthoringForm.setExceptionMaxNominationInvalid(new Boolean(false).toString()); - voteGeneralAuthoringDTO.setExceptionMaxNominationInvalid(new Boolean(false).toString()); - - ActionForward validateSignature=readSignature(request,mapping, voteService, voteAuthoringForm); - logger.debug("validateSignature: " + validateSignature); - if (validateSignature != null) - { - logger.debug("validateSignature not null : " + validateSignature); - return validateSignature; - } - else - { - logger.debug("no problems getting the default content, will render authoring screen"); - String strToolContentId=""; - /*the authoring url must be passed a tool content id*/ - strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentId: " + strToolContentId); - - /* this will be fixed when making changes to Monitoring module */ - if (strToolContentId == null) - { - /*watch out for a possibility that the original request for authoring module is coming - * from monitoring url */ - logger.debug("we should IDEALLY not arrive here. The TOOL_CONTENT_ID is NOT available."); - /*use default content instead of giving a warning*/ - String defaultContentId=voteAuthoringForm.getDefaultContentId(); - logger.debug("using Voting defaultContentId: " + defaultContentId); - strToolContentId=defaultContentId; - } - logger.debug("final strToolContentId: " + strToolContentId); - - if ((strToolContentId == null) || (strToolContentId.equals(""))) - { - VoteUtils.cleanUpSessionAbsolute(request); - //saveInRequestError(request,"error.contentId.required"); - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } - - /* Process incoming tool content id. - * Either exists or not exists in the db yet, a toolContentID must be passed to the tool from the container */ - long toolContentID=0; - try - { - toolContentID=new Long(strToolContentId).longValue(); - logger.debug("passed TOOL_CONTENT_ID : " + toolContentID); - voteAuthoringForm.setToolContentID(new Long(strToolContentId).toString()); - voteGeneralAuthoringDTO.setToolContentID(new Long(strToolContentId).toString()); - } - catch(NumberFormatException e) - { - VoteUtils.cleanUpSessionAbsolute(request); - saveInRequestError(request,"error.numberFormatException"); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } + VoteAction voteAction = new VoteAction(); + voteAction.repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO); - /* - * find out if the passed tool content id exists in the db - * present user either a first timer screen with default content data or fetch the existing content. - * - * if the toolcontentid does not exist in the db, create the default Map, - * there is no need to check if the content is in use in this case. - * It is always unlocked -> not in use since it is the default content. - */ - Map mapOptionsContent= new TreeMap(new VoteComparator()); - logger.debug("mapOptionsContent: " + mapOptionsContent); - - if (!existsContent(toolContentID, request, voteService)) - { - logger.debug("getting default content"); - /*fetch default content*/ - String defaultContentIdStr=voteAuthoringForm.getDefaultContentIdStr(); - logger.debug("will get content for defaultContentIdStr:" + defaultContentIdStr); - retrieveContent(request, voteService, voteAuthoringForm, voteGeneralAuthoringDTO, mapOptionsContent, - new Long(defaultContentIdStr).longValue(), sessionMap); - - } - else - { - logger.debug("getting existing content"); - /* it is possible that the content is in use by learners.*/ - VoteContent voteContent=voteService.retrieveVote(new Long(strToolContentId)); - logger.debug("voteContent: " + voteContent); - if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("student activity occurred on this content:" + voteContent); - saveInRequestError(request, "error.content.inUse"); - return (mapping.findForward(ERROR_LIST)); - } - - if (servletPath.indexOf("authoringStarter") > 0) - { - boolean isDefineLater=VoteUtils.isDefineLater(voteContent); - logger.debug("isDefineLater:" + isDefineLater); - if (isDefineLater == true) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("student activity occurred on this content:" + voteContent); - saveInRequestError(request, "error.content.inUse"); - return (mapping.findForward(ERROR_LIST)); - - } - } - - logger.debug("will get content for strToolContentId:" + strToolContentId); - retrieveContent(request, voteService, voteAuthoringForm, voteGeneralAuthoringDTO, mapOptionsContent, - new Long(strToolContentId).longValue(), sessionMap); - } - } - - voteAuthoringForm.resetUserAction(); + VoteStarterAction.logger.debug("getting voteService now: servlet is: " + getServlet()); + IVoteService voteService = null; + if (getServlet() != null) { + voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + } else { + voteService = voteAuthoringForm.getVoteService(); + } - if (voteAuthoringForm != null) - voteAuthoringForm.setCurrentTab("1"); - - logger.debug("will return to jsp with: " + sourceVoteStarter); - String destination=VoteUtils.getDestination(sourceVoteStarter); - logger.debug("destination: " + destination); - logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); + VoteStarterAction.logger.debug("final voteService: " + voteService); - logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); - request.setAttribute(VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - - logger.debug("persisting sessionMap into session: " + sessionMap); - request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - return (mapping.findForward(destination)); - } - - - - protected void initialiseAttributes(HttpServletRequest request, VoteGeneralAuthoringDTO voteGeneralAuthoringDTO, IVoteService voteService) - { - logger.debug("starting initialiseAttributes..."); - - /* for development: needs to run only once per tool*/ - /* VoteUtils.configureContentRepository(request, voteService); */ - - /* these two are for Instructions jsp */ - LinkedList listUploadedOfflineFileNames= new LinkedList(); - LinkedList listUploadedOnlineFileNames= new LinkedList(); - - voteGeneralAuthoringDTO.setListUploadedOfflineFileNames(listUploadedOfflineFileNames); - voteGeneralAuthoringDTO.setListUploadedOnlineFileNames (listUploadedOnlineFileNames); - - LinkedList listOfflineFilesMetaData= new LinkedList(); - LinkedList listOnlineFilesMetaData= new LinkedList(); - - voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); - voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + voteAuthoringForm.setSubmissionAttempt(new Boolean(false).toString()); + voteAuthoringForm.setSbmtSuccess(new Boolean(false).toString()); + + voteGeneralAuthoringDTO.setSubmissionAttempt(new Boolean(false).toString()); + voteGeneralAuthoringDTO.setSbmtSuccess(new Boolean(false).toString()); + voteGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String servletPath = request.getServletPath(); + VoteStarterAction.logger.debug("getServletPath: " + servletPath); + if (servletPath.indexOf("authoringStarter") > 0) { + VoteStarterAction.logger.debug("request is for authoring module"); + voteAuthoringForm.setActiveModule(VoteAppConstants.AUTHORING); + voteGeneralAuthoringDTO.setActiveModule(VoteAppConstants.AUTHORING); + + voteAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + } else { + VoteStarterAction.logger.debug("request is for define later module. either direct or by monitoring module"); + voteAuthoringForm.setActiveModule(VoteAppConstants.DEFINE_LATER); + voteGeneralAuthoringDTO.setActiveModule(VoteAppConstants.DEFINE_LATER); + + voteAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); + voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); } - + initialiseAttributes(request, voteGeneralAuthoringDTO, voteService); - /** - * each tool has a signature. Voting tool's signature is stored in MY_SIGNATURE. The default tool content id and - * other depending content ids are obtained in this method. - * if all the default content has been setup properly the method saves DEFAULT_CONTENT_ID in the session. - * - * readSignature(HttpServletRequest request, ActionMapping mapping) - * @param request - * @param mapping - * @return ActionForward + SessionMap sessionMap = new SessionMap(); + sessionMap.put(VoteAppConstants.ATTACHMENT_LIST_KEY, new ArrayList()); + sessionMap.put(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, ""); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, ""); + voteAuthoringForm.setHttpSessionID(sessionMap.getSessionID()); + voteGeneralAuthoringDTO.setHttpSessionID(sessionMap.getSessionID()); + + /* + * determine whether the request is from Monitoring url Edit Activity. null sourceVoteStarter indicates that the + * request is from authoring url. */ - public ActionForward readSignature(HttpServletRequest request, ActionMapping mapping, IVoteService voteService, - VoteAuthoringForm voteAuthoringForm) - { - logger.debug("start reading tool signature: " + voteService); + + String sourceVoteStarter = (String) request.getAttribute(VoteAppConstants.SOURCE_VOTE_STARTER); + VoteStarterAction.logger.debug("sourceVoteStarter: " + sourceVoteStarter); + + voteAuthoringForm.resetRadioBoxes(); + voteAuthoringForm.setExceptionMaxNominationInvalid(new Boolean(false).toString()); + voteGeneralAuthoringDTO.setExceptionMaxNominationInvalid(new Boolean(false).toString()); + + ActionForward validateSignature = readSignature(request, mapping, voteService, voteAuthoringForm); + VoteStarterAction.logger.debug("validateSignature: " + validateSignature); + if (validateSignature != null) { + VoteStarterAction.logger.debug("validateSignature not null : " + validateSignature); + return validateSignature; + } else { + VoteStarterAction.logger.debug("no problems getting the default content, will render authoring screen"); + String strToolContentId = ""; + /* the authoring url must be passed a tool content id */ + strToolContentId = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + VoteStarterAction.logger.debug("strToolContentId: " + strToolContentId); + + /* this will be fixed when making changes to Monitoring module */ + if (strToolContentId == null) { /* - * retrieve the default content id based on tool signature + * watch out for a possibility that the original request for authoring module is coming from monitoring + * url */ - long defaultContentID=0; - try - { - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=voteService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - if (defaultContentID == 0) - { - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("default content id has not been setup"); - saveInRequestError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } + VoteStarterAction.logger + .debug("we should IDEALLY not arrive here. The TOOL_CONTENT_ID is NOT available."); + /* use default content instead of giving a warning */ + String defaultContentId = voteAuthoringForm.getDefaultContentId(); + VoteStarterAction.logger.debug("using Voting defaultContentId: " + defaultContentId); + strToolContentId = defaultContentId; + } + VoteStarterAction.logger.debug("final strToolContentId: " + strToolContentId); + + if (strToolContentId == null || strToolContentId.equals("")) { + VoteUtils.cleanUpSessionAbsolute(request); + // saveInRequestError(request,"error.contentId.required"); + VoteUtils.cleanUpSessionAbsolute(request); + VoteStarterAction.logger.debug("forwarding to: " + VoteAppConstants.ERROR_LIST); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + + /* + * Process incoming tool content id. Either exists or not exists in the db yet, a toolContentID must be + * passed to the tool from the container + */ + long toolContentID = 0; + try { + toolContentID = new Long(strToolContentId).longValue(); + VoteStarterAction.logger.debug("passed TOOL_CONTENT_ID : " + toolContentID); + voteAuthoringForm.setToolContentID(new Long(strToolContentId).toString()); + voteGeneralAuthoringDTO.setToolContentID(new Long(strToolContentId).toString()); + } catch (NumberFormatException e) { + VoteUtils.cleanUpSessionAbsolute(request); + saveInRequestError(request, "error.numberFormatException"); + VoteStarterAction.logger.debug("forwarding to: " + VoteAppConstants.ERROR_LIST); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + + /* + * find out if the passed tool content id exists in the db present user either a first timer screen with + * default content data or fetch the existing content. + * + * if the toolcontentid does not exist in the db, create the default Map, there is no need to check if the + * content is in use in this case. It is always unlocked -> not in use since it is the default content. + */ + Map mapOptionsContent = new TreeMap(new VoteComparator()); + VoteStarterAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + + if (!existsContent(toolContentID, request, voteService)) { + VoteStarterAction.logger.debug("getting default content"); + /* fetch default content */ + String defaultContentIdStr = voteAuthoringForm.getDefaultContentIdStr(); + VoteStarterAction.logger.debug("will get content for defaultContentIdStr:" + defaultContentIdStr); + retrieveContent(request, voteService, voteAuthoringForm, voteGeneralAuthoringDTO, mapOptionsContent, + new Long(defaultContentIdStr).longValue(), sessionMap); + + } else { + VoteStarterAction.logger.debug("getting existing content"); + /* it is possible that the content is in use by learners. */ + VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentId)); + VoteStarterAction.logger.debug("voteContent: " + voteContent); + if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteStarterAction.logger.debug("student activity occurred on this content:" + voteContent); + saveInRequestError(request, "error.content.inUse"); + return mapping.findForward(VoteAppConstants.ERROR_LIST); } - catch(Exception e) - { + + if (servletPath.indexOf("authoringStarter") > 0) { + boolean isDefineLater = VoteUtils.isDefineLater(voteContent); + VoteStarterAction.logger.debug("isDefineLater:" + isDefineLater); + if (isDefineLater == true) { VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("error getting the default content id: " + e.getMessage()); - saveInRequestError(request,"error.defaultContent.notSetup"); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } + VoteStarterAction.logger.debug("student activity occurred on this content:" + voteContent); + saveInRequestError(request, "error.content.inUse"); + return mapping.findForward(VoteAppConstants.ERROR_LIST); - - /* retrieve uid of the content based on default content id determined above */ - long contentUID=0; - try - { - logger.debug("retrieve uid of the content based on default content id determined above: " + defaultContentID); - VoteContent voteContent=voteService.retrieveVote(new Long(defaultContentID)); - logger.debug("voteContent: " + voteContent); - if (voteContent == null) - { - logger.debug("voteContent is null: " + voteContent); - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default content"); - saveInRequestError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - logger.debug("using voteContent: " + voteContent); - logger.debug("using mcContent uid: " + voteContent.getUid()); - contentUID=voteContent.getUid().longValue(); - logger.debug("contentUID: " + contentUID); + } } - catch(Exception e) - { - logger.debug("other problems: " + e); - VoteUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default question content"); - saveInRequestError(request,"error.defaultContent.notSetup"); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } - logger.debug("Voting tool has the default content id: " + defaultContentID); - - voteAuthoringForm.setDefaultContentId(new Long(defaultContentID).toString()); - voteAuthoringForm.setDefaultContentIdStr(new Long(defaultContentID).toString()); - return null; + VoteStarterAction.logger.debug("will get content for strToolContentId:" + strToolContentId); + retrieveContent(request, voteService, voteAuthoringForm, voteGeneralAuthoringDTO, mapOptionsContent, + new Long(strToolContentId).longValue(), sessionMap); + } } - - - protected void retrieveContent(HttpServletRequest request, IVoteService voteService, - VoteAuthoringForm voteAuthoringForm, VoteGeneralAuthoringDTO voteGeneralAuthoringDTO, - Map mapOptionsContent, long toolContentID, SessionMap sessionMap) - { - logger.debug("starting retrieve content for toolContentID: " + toolContentID); - logger.debug("voteService: " + voteService); + voteAuthoringForm.resetUserAction(); - logger.debug("getting existing content with id:" + toolContentID); - VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); - logger.debug("voteContent: " + voteContent); - - - VoteUtils.readContentValues(request, voteContent, voteAuthoringForm, voteGeneralAuthoringDTO); - logger.debug("form title is: : " + voteAuthoringForm.getTitle()); - - voteAuthoringForm.setIsDefineLater(new Boolean(voteContent.isDefineLater()).toString()); - voteGeneralAuthoringDTO.setIsDefineLater(new Boolean(voteContent.isDefineLater()).toString()); - - if (voteContent.getTitle() == null) - { - voteGeneralAuthoringDTO.setActivityTitle(DEFAULT_VOTING_TITLE); - voteAuthoringForm.setTitle(DEFAULT_VOTING_TITLE); - } - else - { - voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); - voteAuthoringForm.setTitle(voteContent.getTitle()); - } + if (voteAuthoringForm != null) { + voteAuthoringForm.setCurrentTab("1"); + } - - if (voteContent.getInstructions() == null) - { - voteGeneralAuthoringDTO.setActivityInstructions(DEFAULT_VOTING_INSTRUCTIONS); - voteAuthoringForm.setInstructions(DEFAULT_VOTING_INSTRUCTIONS); - } - else - { - voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); - voteAuthoringForm.setInstructions(voteContent.getInstructions()); - } - - sessionMap.put(ACTIVITY_TITLE_KEY, voteGeneralAuthoringDTO.getActivityTitle()); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, voteGeneralAuthoringDTO.getActivityInstructions()); + VoteStarterAction.logger.debug("will return to jsp with: " + sourceVoteStarter); + String destination = VoteUtils.getDestination(sourceVoteStarter); + VoteStarterAction.logger.debug("destination: " + destination); + VoteStarterAction.logger.debug("active module is: " + voteAuthoringForm.getActiveModule()); - - voteAuthoringForm.setReflectionSubject(voteContent.getReflectionSubject()); - voteGeneralAuthoringDTO.setReflectionSubject(voteContent.getReflectionSubject()); + VoteStarterAction.logger.debug("voteGeneralAuthoringDTO: " + voteGeneralAuthoringDTO); + request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO); - List listNominationContentDTO= new LinkedList(); - - /* - * get the nominations - */ - logger.debug("setting existing content data from the db"); - mapOptionsContent.clear(); - Iterator queIterator=voteContent.getVoteQueContents().iterator(); - Long mapIndex=new Long(1); - logger.debug("mapOptionsContent: " + mapOptionsContent); - while (queIterator.hasNext()) - { - VoteNominationContentDTO voteNominationContentDTO=new VoteNominationContentDTO(); - - VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); - if (voteQueContent != null) - { - logger.debug("question: " + voteQueContent.getQuestion()); - mapOptionsContent.put(mapIndex.toString(),voteQueContent.getQuestion()); - - - voteNominationContentDTO.setQuestion(voteQueContent.getQuestion()); - voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); - listNominationContentDTO.add(voteNominationContentDTO); - - mapIndex=new Long(mapIndex.longValue()+1); - } + VoteStarterAction.logger.debug("persisting sessionMap into session: " + sessionMap); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + return mapping.findForward(destination); + } + + protected void initialiseAttributes(HttpServletRequest request, VoteGeneralAuthoringDTO voteGeneralAuthoringDTO, + IVoteService voteService) { + VoteStarterAction.logger.debug("starting initialiseAttributes..."); + + /* for development: needs to run only once per tool */ + /* VoteUtils.configureContentRepository(request, voteService); */ + + /* these two are for Instructions jsp */ + LinkedList listUploadedOfflineFileNames = new LinkedList(); + LinkedList listUploadedOnlineFileNames = new LinkedList(); + + voteGeneralAuthoringDTO.setListUploadedOfflineFileNames(listUploadedOfflineFileNames); + voteGeneralAuthoringDTO.setListUploadedOnlineFileNames(listUploadedOnlineFileNames); + + LinkedList listOfflineFilesMetaData = new LinkedList(); + LinkedList listOnlineFilesMetaData = new LinkedList(); + + voteGeneralAuthoringDTO.setListOfflineFilesMetadata(listOfflineFilesMetaData); + voteGeneralAuthoringDTO.setListOnlineFilesMetadata(listOnlineFilesMetaData); + } + + /** + * each tool has a signature. Voting tool's signature is stored in MY_SIGNATURE. The default tool content id and + * other depending content ids are obtained in this method. if all the default content has been setup properly the + * method saves DEFAULT_CONTENT_ID in the session. + * + * readSignature(HttpServletRequest request, ActionMapping mapping) + * + * @param request + * @param mapping + * @return ActionForward + */ + public ActionForward readSignature(HttpServletRequest request, ActionMapping mapping, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm) { + VoteStarterAction.logger.debug("start reading tool signature: " + voteService); + /* + * retrieve the default content id based on tool signature + */ + long defaultContentID = 0; + try { + VoteStarterAction.logger.debug("attempt retrieving tool with signatute : " + VoteAppConstants.MY_SIGNATURE); + defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE); + VoteStarterAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + if (defaultContentID == 0) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteStarterAction.logger.debug("default content id has not been setup"); + saveInRequestError(request, "error.defaultContent.notSetup"); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + } catch (Exception e) { + VoteUtils.cleanUpSessionAbsolute(request); + VoteStarterAction.logger.debug("error getting the default content id: " + e.getMessage()); + saveInRequestError(request, "error.defaultContent.notSetup"); + VoteStarterAction.logger.debug("forwarding to: " + VoteAppConstants.ERROR_LIST); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + + /* retrieve uid of the content based on default content id determined above */ + long contentUID = 0; + try { + VoteStarterAction.logger.debug("retrieve uid of the content based on default content id determined above: " + + defaultContentID); + VoteContent voteContent = voteService.retrieveVote(new Long(defaultContentID)); + VoteStarterAction.logger.debug("voteContent: " + voteContent); + if (voteContent == null) { + VoteStarterAction.logger.debug("voteContent is null: " + voteContent); + VoteUtils.cleanUpSessionAbsolute(request); + VoteStarterAction.logger.debug("Exception occured: No default content"); + saveInRequestError(request, "error.defaultContent.notSetup"); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + VoteStarterAction.logger.debug("using voteContent: " + voteContent); + VoteStarterAction.logger.debug("using mcContent uid: " + voteContent.getUid()); + contentUID = voteContent.getUid().longValue(); + VoteStarterAction.logger.debug("contentUID: " + contentUID); + } catch (Exception e) { + VoteStarterAction.logger.debug("other problems: " + e); + VoteUtils.cleanUpSessionAbsolute(request); + VoteStarterAction.logger.debug("Exception occured: No default question content"); + saveInRequestError(request, "error.defaultContent.notSetup"); + VoteStarterAction.logger.debug("forwarding to: " + VoteAppConstants.ERROR_LIST); + return mapping.findForward(VoteAppConstants.ERROR_LIST); + } + + VoteStarterAction.logger.debug("Voting tool has the default content id: " + defaultContentID); + + voteAuthoringForm.setDefaultContentId(new Long(defaultContentID).toString()); + voteAuthoringForm.setDefaultContentIdStr(new Long(defaultContentID).toString()); + return null; + } + + protected void retrieveContent(HttpServletRequest request, IVoteService voteService, + VoteAuthoringForm voteAuthoringForm, VoteGeneralAuthoringDTO voteGeneralAuthoringDTO, + Map mapOptionsContent, long toolContentID, SessionMap sessionMap) { + VoteStarterAction.logger.debug("starting retrieve content for toolContentID: " + toolContentID); + VoteStarterAction.logger.debug("voteService: " + voteService); + + VoteStarterAction.logger.debug("getting existing content with id:" + toolContentID); + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + VoteStarterAction.logger.debug("voteContent: " + voteContent); + + VoteUtils.readContentValues(request, voteContent, voteAuthoringForm, voteGeneralAuthoringDTO); + VoteStarterAction.logger.debug("form title is: : " + voteAuthoringForm.getTitle()); + + voteAuthoringForm.setIsDefineLater(new Boolean(voteContent.isDefineLater()).toString()); + voteGeneralAuthoringDTO.setIsDefineLater(new Boolean(voteContent.isDefineLater()).toString()); + + if (voteContent.getTitle() == null) { + voteGeneralAuthoringDTO.setActivityTitle(VoteAppConstants.DEFAULT_VOTING_TITLE); + voteAuthoringForm.setTitle(VoteAppConstants.DEFAULT_VOTING_TITLE); + } else { + voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle()); + voteAuthoringForm.setTitle(voteContent.getTitle()); + } + + if (voteContent.getInstructions() == null) { + voteGeneralAuthoringDTO.setActivityInstructions(VoteAppConstants.DEFAULT_VOTING_INSTRUCTIONS); + voteAuthoringForm.setInstructions(VoteAppConstants.DEFAULT_VOTING_INSTRUCTIONS); + } else { + voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions()); + voteAuthoringForm.setInstructions(voteContent.getInstructions()); + } + + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, voteGeneralAuthoringDTO.getActivityTitle()); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, voteGeneralAuthoringDTO.getActivityInstructions()); + + voteAuthoringForm.setReflectionSubject(voteContent.getReflectionSubject()); + voteGeneralAuthoringDTO.setReflectionSubject(voteContent.getReflectionSubject()); + + List dataFlowObjects = voteService.getDataFlowObjects(new Long(toolContentID)); + + if (dataFlowObjects != null) { + List dataFlowObjectNames = new ArrayList(dataFlowObjects.size()); + int objectIndex = 1; + for (DataFlowObject dataFlowObject : dataFlowObjects) { + dataFlowObjectNames.add(dataFlowObject.getDisplayName()); + if (VoteAppConstants.DATA_FLOW_OBJECT_ASSIGMENT_ID.equals(dataFlowObject.getToolAssigmentId())) { + voteAuthoringForm.setAssignedDataFlowObject(objectIndex); } - - request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(mapOptionsContent.size())); - logger.debug("listNominationContentDTO: " + listNominationContentDTO); - request.setAttribute(LIST_NOMINATION_CONTENT_DTO,listNominationContentDTO); - sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); + objectIndex++; - - logger.debug("Map initialized with existing contentid to: " + mapOptionsContent); - voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); - sessionMap.put(MAP_OPTIONS_CONTENT_KEY, mapOptionsContent); - - int maxIndex=mapOptionsContent.size(); - voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); - - voteGeneralAuthoringDTO.setRichTextOfflineInstructions(voteContent.getOfflineInstructions()); - voteGeneralAuthoringDTO.setRichTextOnlineInstructions(voteContent.getOnlineInstructions()); - - voteAuthoringForm.setOfflineInstructions(voteContent.getOfflineInstructions()); - voteAuthoringForm.setOnlineInstructions(voteContent.getOnlineInstructions()); - - - if ((voteContent.getOnlineInstructions() == null) || (voteContent.getOnlineInstructions().length() == 0)) - { - voteGeneralAuthoringDTO.setRichTextOnlineInstructions(DEFAULT_ONLINE_INST); - voteAuthoringForm.setOnlineInstructions(DEFAULT_ONLINE_INST); - sessionMap.put(ONLINE_INSTRUCTIONS_KEY, DEFAULT_ONLINE_INST); } - - if ((voteContent.getOfflineInstructions() == null) || (voteContent.getOfflineInstructions().length() == 0)) - { - voteGeneralAuthoringDTO.setRichTextOfflineInstructions(DEFAULT_OFFLINE_INST); - voteAuthoringForm.setOfflineInstructions(DEFAULT_OFFLINE_INST); - sessionMap.put(OFFLINE_INSTRUCTIONS_KEY, DEFAULT_OFFLINE_INST); + voteGeneralAuthoringDTO.setDataFlowObjectNames(dataFlowObjectNames); + } + + List listNominationContentDTO = new LinkedList(); + + /* + * get the nominations + */ + VoteStarterAction.logger.debug("setting existing content data from the db"); + mapOptionsContent.clear(); + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + Long mapIndex = new Long(1); + VoteStarterAction.logger.debug("mapOptionsContent: " + mapOptionsContent); + while (queIterator.hasNext()) { + VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO(); + + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + VoteStarterAction.logger.debug("question: " + voteQueContent.getQuestion()); + mapOptionsContent.put(mapIndex.toString(), voteQueContent.getQuestion()); + + voteNominationContentDTO.setQuestion(voteQueContent.getQuestion()); + voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); + listNominationContentDTO.add(voteNominationContentDTO); + + mapIndex = new Long(mapIndex.longValue() + 1); } - - - sessionMap.put(ONLINE_INSTRUCTIONS_KEY, voteContent.getOnlineInstructions()); - sessionMap.put(OFFLINE_INSTRUCTIONS_KEY, voteContent.getOfflineInstructions()); + } - List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); - voteGeneralAuthoringDTO.setAttachmentList(attachmentList); - voteGeneralAuthoringDTO.setDeletedAttachmentList(new ArrayList()); + request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(mapOptionsContent.size())); + VoteStarterAction.logger.debug("listNominationContentDTO: " + listNominationContentDTO); + request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO); + sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO); - sessionMap.put(ATTACHMENT_LIST_KEY, attachmentList); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); + VoteStarterAction.logger.debug("Map initialized with existing contentid to: " + mapOptionsContent); + voteGeneralAuthoringDTO.setMapOptionsContent(mapOptionsContent); + sessionMap.put(VoteAppConstants.MAP_OPTIONS_CONTENT_KEY, mapOptionsContent); - voteAuthoringForm.resetUserAction(); + int maxIndex = mapOptionsContent.size(); + voteGeneralAuthoringDTO.setMaxOptionIndex(maxIndex); + + voteGeneralAuthoringDTO.setRichTextOfflineInstructions(voteContent.getOfflineInstructions()); + voteGeneralAuthoringDTO.setRichTextOnlineInstructions(voteContent.getOnlineInstructions()); + + voteAuthoringForm.setOfflineInstructions(voteContent.getOfflineInstructions()); + voteAuthoringForm.setOnlineInstructions(voteContent.getOnlineInstructions()); + + if (voteContent.getOnlineInstructions() == null || voteContent.getOnlineInstructions().length() == 0) { + voteGeneralAuthoringDTO.setRichTextOnlineInstructions(VoteAppConstants.DEFAULT_ONLINE_INST); + voteAuthoringForm.setOnlineInstructions(VoteAppConstants.DEFAULT_ONLINE_INST); + sessionMap.put(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY, VoteAppConstants.DEFAULT_ONLINE_INST); } - - public ActionForward executeDefineLater(ActionMapping mapping, VoteAuthoringForm voteAuthoringForm, - HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, VoteApplicationException { - logger.debug("calling execute..." + voteAuthoringForm); - return execute(mapping, voteAuthoringForm, request, response); + + if (voteContent.getOfflineInstructions() == null || voteContent.getOfflineInstructions().length() == 0) { + voteGeneralAuthoringDTO.setRichTextOfflineInstructions(VoteAppConstants.DEFAULT_OFFLINE_INST); + voteAuthoringForm.setOfflineInstructions(VoteAppConstants.DEFAULT_OFFLINE_INST); + sessionMap.put(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY, VoteAppConstants.DEFAULT_OFFLINE_INST); } - - protected boolean existsContent(long toolContentID, HttpServletRequest request, IVoteService voteService) - { - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - if (voteContent == null) - return false; - - return true; + sessionMap.put(VoteAppConstants.ONLINE_INSTRUCTIONS_KEY, voteContent.getOnlineInstructions()); + sessionMap.put(VoteAppConstants.OFFLINE_INSTRUCTIONS_KEY, voteContent.getOfflineInstructions()); + + List attachmentList = voteService.retrieveVoteUploadedFiles(voteContent); + voteGeneralAuthoringDTO.setAttachmentList(attachmentList); + voteGeneralAuthoringDTO.setDeletedAttachmentList(new ArrayList()); + + sessionMap.put(VoteAppConstants.ATTACHMENT_LIST_KEY, attachmentList); + sessionMap.put(VoteAppConstants.DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); + + voteAuthoringForm.resetUserAction(); + } + + public ActionForward executeDefineLater(ActionMapping mapping, VoteAuthoringForm voteAuthoringForm, + HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, + VoteApplicationException { + VoteStarterAction.logger.debug("calling execute..." + voteAuthoringForm); + return execute(mapping, voteAuthoringForm, request, response); + } + + protected boolean existsContent(long toolContentID, HttpServletRequest request, IVoteService voteService) { + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + if (voteContent == null) { + return false; } - - /** + return true; + } + + /** * saves error messages to request scope + * * @param request * @param message */ - public void saveInRequestError(HttpServletRequest request, String message) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY, new ActionMessage(message)); - logger.debug("add " + message +" to ActionMessages:"); - saveErrors(request,errors); - } -} + public void saveInRequestError(HttpServletRequest request, String message) { + ActionMessages errors = new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + VoteStarterAction.logger.debug("add " + message + " to ActionMessages:"); + saveErrors(request, errors); + } +} Index: lams_tool_vote/web/authoring/BasicContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/web/authoring/BasicContent.jsp,v diff -u -r1.41 -r1.42 --- lams_tool_vote/web/authoring/BasicContent.jsp 23 Nov 2006 07:07:28 -0000 1.41 +++ lams_tool_vote/web/authoring/BasicContent.jsp 2 Jul 2009 13:02:04 -0000 1.42 @@ -30,6 +30,7 @@ @@ -115,18 +137,28 @@

- ');" + ');" class="button-add-item"> + ');" + href="javascript:resetDataInput(); showMessage('');" class="button-add-item"> + + + + + + + ${dataFlowObject} + + +

Index: lams_tool_vote/web/authoring/itemlist.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/web/authoring/itemlist.jsp,v diff -u -r1.7 -r1.8 --- lams_tool_vote/web/authoring/itemlist.jsp 23 Nov 2006 07:07:28 -0000 1.7 +++ lams_tool_vote/web/authoring/itemlist.jsp 2 Jul 2009 13:02:04 -0000 1.8 @@ -40,7 +40,10 @@ - + + + + Index: lams_tool_vote/web/authoring/newNominationBox.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/web/authoring/newNominationBox.jsp,v diff -u -r1.9 -r1.10 --- lams_tool_vote/web/authoring/newNominationBox.jsp 8 Jun 2007 01:43:32 -0000 1.9 +++ lams_tool_vote/web/authoring/newNominationBox.jsp 2 Jul 2009 13:02:04 -0000 1.10 @@ -50,7 +50,7 @@ contentFolderID="${voteGeneralAuthoringDTO.contentFolderID}"> - Index: lams_tool_wiki/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/.classpath,v diff -u -r1.4 -r1.5 --- lams_tool_wiki/.classpath 1 Jul 2009 14:16:40 -0000 1.4 +++ lams_tool_wiki/.classpath 2 Jul 2009 13:02:55 -0000 1.5 @@ -9,4 +9,5 @@ + Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiOutputFactory.java,v diff -u -r1.1 -r1.2 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiOutputFactory.java 10 Oct 2008 05:42:09 -0000 1.1 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiOutputFactory.java 2 Jul 2009 13:02:55 -0000 1.2 @@ -33,8 +33,7 @@ import org.lamsfoundation.lams.tool.exception.ToolException; /** - * Creates the output definitions for wiki. - * There are two types of outputs: number of edits and number of pages added + * Creates the output definitions for wiki. There are two types of outputs: number of edits and number of pages added */ public class WikiOutputFactory extends OutputFactory { @@ -47,15 +46,18 @@ /** * @see org.lamsfoundation.lams.tool.OutputDefinitionFactory#getToolOutputDefinitions(java.lang.Object) */ - public SortedMap getToolOutputDefinitions(Object toolContentObject) + @Override + public SortedMap getToolOutputDefinitions(Object toolContentObject, int definitionType) throws ToolException { TreeMap definitionMap = new TreeMap(); - ToolOutputDefinition definition1 = buildRangeDefinition(OUTPUT_NAME_LEARNER_NUM_EDITS, new Long(0), null); - definitionMap.put(OUTPUT_NAME_LEARNER_NUM_EDITS, definition1); + ToolOutputDefinition definition1 = buildRangeDefinition(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS, + new Long(0), null); + definitionMap.put(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS, definition1); - ToolOutputDefinition definition2 = buildRangeDefinition(OUTPUT_NAME_LEARNER_NUM_ADDS, new Long(0), null); - definitionMap.put(OUTPUT_NAME_LEARNER_NUM_ADDS, definition2); + ToolOutputDefinition definition2 = buildRangeDefinition(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_ADDS, + new Long(0), null); + definitionMap.put(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_ADDS, definition2); return definitionMap; } @@ -64,22 +66,24 @@ Long toolSessionId, Long learnerId) { TreeMap map = new TreeMap(); - if (names == null || names.contains(OUTPUT_NAME_LEARNER_NUM_EDITS)) { - map.put(OUTPUT_NAME_LEARNER_NUM_EDITS, getNumEdits(wikiService, learnerId, toolSessionId)); + if (names == null || names.contains(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS)) { + map + .put(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS, getNumEdits(wikiService, learnerId, + toolSessionId)); } - if (names.contains(OUTPUT_NAME_LEARNER_NUM_ADDS)) { - map.put(OUTPUT_NAME_LEARNER_NUM_ADDS, getNumAdds(wikiService, learnerId, toolSessionId)); + if (names.contains(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_ADDS)) { + map.put(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_ADDS, getNumAdds(wikiService, learnerId, toolSessionId)); } return map; } public ToolOutput getToolOutput(String name, IWikiService wikiService, Long toolSessionId, Long learnerId) { - if (name != null && name.equals(OUTPUT_NAME_LEARNER_NUM_EDITS)) { + if (name != null && name.equals(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS)) { return getNumEdits(wikiService, learnerId, toolSessionId); } - if (name != null && name.equals(OUTPUT_NAME_LEARNER_NUM_ADDS)) { + if (name != null && name.equals(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_ADDS)) { return getNumAdds(wikiService, learnerId, toolSessionId); } @@ -88,27 +92,29 @@ /** * Gets the number of edits by this user for tool outputs + * * @param wikiService * @param learnerId * @param toolSessionId * @return */ private ToolOutput getNumEdits(IWikiService wikiService, Long learnerId, Long toolSessionId) { int num = wikiService.getEditsNum(learnerId, toolSessionId); - return new ToolOutput(OUTPUT_NAME_LEARNER_NUM_EDITS, getI18NText(OUTPUT_NAME_LEARNER_NUM_EDITS, true), - new Long(num)); + return new ToolOutput(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS, getI18NText( + WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS, true), new Long(num)); } /** * Gets the number of pages added by this user for tool outputs + * * @param wikiService * @param learnerId * @param toolSessionId * @return */ private ToolOutput getNumAdds(IWikiService wikiService, Long learnerId, Long toolSessionId) { int num = wikiService.getAddsNum(learnerId, toolSessionId); - return new ToolOutput(OUTPUT_NAME_LEARNER_NUM_EDITS, getI18NText(OUTPUT_NAME_LEARNER_NUM_EDITS, true), - new Long(num)); + return new ToolOutput(WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS, getI18NText( + WikiOutputFactory.OUTPUT_NAME_LEARNER_NUM_EDITS, true), new Long(num)); } } Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java,v diff -u -r1.12 -r1.13 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java 1 Jul 2009 02:46:50 -0000 1.12 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java 2 Jul 2009 13:02:55 -0000 1.13 @@ -96,8 +96,7 @@ /** * An implementation of the IWikiService interface. * - * As a requirement, all LAMS tool's service bean must implement - * ToolContentManager and ToolSessionManager. + * As a requirement, all LAMS tool's service bean must implement ToolContentManager and ToolSessionManager. */ public class WikiService implements ToolSessionManager, ToolContentManager, IWikiService, ToolContentImport102Manager { @@ -130,11 +129,11 @@ private ICoreNotebookService coreNotebookService; private WikiOutputFactory wikiOutputFactory; - + private IEventNotificationService eventNotificationService; - + private MessageService messageService; - + private ILessonService lessonService; public WikiService() { @@ -147,8 +146,8 @@ /** * (non-Javadoc) * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, - * java.lang.String, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, java.lang.String, + * java.lang.Long) */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { if (logger.isDebugEnabled()) { @@ -224,8 +223,8 @@ } /** - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) */ public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { @@ -238,8 +237,8 @@ } /** - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, - * java.lang.Long, java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) */ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { wikiOutputFactory = getWikiOutputFactory(); @@ -251,28 +250,26 @@ } /** - * Get the definitions for possible output for an activity, based on the - * toolContentId. + * Get the definitions for possible output for an activity, based on the toolContentId. * - * @return SortedMap of ToolOutputDefinitions with the key being the name of - * each definition + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) + throws ToolException { wikiOutputFactory = getWikiOutputFactory(); Wiki wiki = getWikiByContentId(toolContentId); if (wiki == null) { wiki = getDefaultContent(); } - return wikiOutputFactory.getToolOutputDefinitions(wiki); + return wikiOutputFactory.getToolOutputDefinitions(wiki, definitionType); } /* ************ Methods from ToolContentManager ************************* */ /** * (non-Javadoc) * - * @see org.lamsfoundation.lams.tool.ToolContentManager#copyToolContent(java.lang.Long, - * java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolContentManager#copyToolContent(java.lang.Long, java.lang.Long) */ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { @@ -323,8 +320,7 @@ } /** - * Export the XML fragment for the tool's content, along with any files - * needed for the content. + * Export the XML fragment for the tool's content, along with any files needed for the content. * * @throws DataMissingException * if no tool content matches the toolSessionId @@ -336,8 +332,9 @@ if (wiki == null) { wiki = getDefaultContent(); } - if (wiki == null) + if (wiki == null) { throw new DataMissingException("Unable to find default content for the wiki tool"); + } // set ResourceToolContentHandler as null to avoid copy file node in // repository again. @@ -377,8 +374,7 @@ } /** - * Import the XML fragment for the tool's content, along with any files - * needed for the content. + * Import the XML fragment for the tool's content, along with any files needed for the content. * * @throws ToolException * if any other error occurs @@ -391,15 +387,16 @@ Object toolPOJO = exportContentService.importToolContent(toolContentPath, wikiToolContentHandler, fromVersion, toVersion); - if (!(toolPOJO instanceof Wiki)) + if (!(toolPOJO instanceof Wiki)) { throw new ImportToolContentException("Import Wiki tool content failed. Deserialized object is " + toolPOJO); + } Wiki wiki = (Wiki) toolPOJO; // reset it to new toolContentId wiki.setToolContentId(toolContentId); wiki.setCreateBy(new Long(newUserUid.longValue())); - + // Making sure the wiki titles do not have trailing newline characters for (WikiPage wikiPage : wiki.getWikiPages()) { String title = wikiPage.getTitle(); @@ -420,8 +417,7 @@ * (non-Javadoc) * * @see org.lamsfoundation.lams.tool.wiki.service.IWikiService#createNotebookEntry(java.lang.Long, - * java.lang.Integer, java.lang.String, java.lang.Integer, - * java.lang.String) + * java.lang.Integer, java.lang.String, java.lang.Integer, java.lang.String) */ public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); @@ -507,14 +503,16 @@ line = line.replaceAll("[//r][//n][//t]", ""); // fix up lines that dont have the div tag on them - if (!line.startsWith(""); + } retBuf.append(line); // fix up lines that dont have the div tag on them - if (!line.contains("")) + if (!line.contains("")) { retBuf.append(""); + } } logger.debug("Result:"); logger.debug(retBuf); @@ -575,14 +573,14 @@ } /** - * Takes a transient wiki object and iterates down the tree ensureing each - * object is saved to the db and all references are maintained + * Takes a transient wiki object and iterates down the tree ensureing each object is saved to the db and all + * references are maintained * * @param wiki * @return */ private Wiki insertUnsavedWikiContent(Wiki wiki) { - + wikiDAO.saveOrUpdate(wiki); // Go through the wiki object and save all the pages and content for (WikiPage wikiPage : wiki.getWikiPages()) { @@ -600,7 +598,7 @@ wiki.getWikiPages().add(wikiPage); } - + // Update the wiki pages to reference their parent for (WikiPage wikiPage : wiki.getWikiPages()) { wikiPage.setParentWiki(wiki); @@ -611,7 +609,7 @@ } public Wiki getWikiByContentId(Long toolContentID) { - Wiki wiki = (Wiki) wikiDAO.getByContentId(toolContentID); + Wiki wiki = wikiDAO.getByContentId(toolContentID); if (wiki == null) { logger.debug("Could not find the content with toolContentID:" + toolContentID); } @@ -639,8 +637,9 @@ } public WikiAttachment uploadFileToContent(Long toolContentId, FormFile file, String type) { - if (file == null || StringUtils.isEmpty(file.getFileName())) + if (file == null || StringUtils.isEmpty(file.getFileName())) { throw new WikiException("Could not find upload file: " + file); + } NodeKey nodeKey = processFile(file, type); @@ -662,8 +661,7 @@ * (non-Javadoc) * * @see org.lamsfoundation.lams.tool.wiki.service.IWikiService#updateWikiPage(org.lamsfoundation.lams.tool.wiki.web.forms.WikiPageForm, - * org.lamsfoundation.lams.tool.wiki.model.WikiPage, - * org.lamsfoundation.lams.tool.wiki.model.WikiUser) + * org.lamsfoundation.lams.tool.wiki.model.WikiPage, org.lamsfoundation.lams.tool.wiki.model.WikiUser) */ public void updateWikiPage(WikiPageForm wikiPageForm, WikiPage wikiPage, WikiUser user) { @@ -699,8 +697,7 @@ * (non-Javadoc) * * @see org.lamsfoundation.lams.tool.wiki.service.IWikiService#insertWikiPage(org.lamsfoundation.lams.tool.wiki.web.forms.WikiPageForm, - * org.lamsfoundation.lams.tool.wiki.model.Wiki, - * org.lamsfoundation.lams.tool.wiki.model.WikiUser, + * org.lamsfoundation.lams.tool.wiki.model.Wiki, org.lamsfoundation.lams.tool.wiki.model.WikiUser, * org.lamsfoundation.lams.tool.wiki.model.WikiSession) */ public Long insertWikiPage(WikiPageForm wikiPageForm, Wiki wiki, WikiUser user, WikiSession session) { @@ -831,12 +828,11 @@ } /** - * This method verifies the credentials of the Wiki Tool and gives it the - * Ticket to login and access the Content Repository. + * This method verifies the credentials of the Wiki Tool and gives it the Ticket to login and access + * the Content Repository. * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. * * @return ITicket The ticket for repostory access * @throws SubmitFilesException @@ -901,8 +897,7 @@ } /* - * ===============Methods implemented from ToolContentImport102Manager - * =============== + * ===============Methods implemented from ToolContentImport102Manager =============== */ /** @@ -939,8 +934,7 @@ } /** - * Set the description, throws away the title value as this is not supported - * in 2.0 + * Set the description, throws away the title value as this is not supported in 2.0 */ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { @@ -964,7 +958,7 @@ } public void setWikiAttachmentDAO(IWikiAttachmentDAO attachmentDAO) { - this.wikiAttachmentDAO = attachmentDAO; + wikiAttachmentDAO = attachmentDAO; } public IWikiDAO getWikiDAO() { @@ -1004,7 +998,7 @@ } public void setWikiSessionDAO(IWikiSessionDAO sessionDAO) { - this.wikiSessionDAO = sessionDAO; + wikiSessionDAO = sessionDAO; } public ILamsToolService getToolService() { @@ -1020,7 +1014,7 @@ } public void setWikiUserDAO(IWikiUserDAO userDAO) { - this.wikiUserDAO = userDAO; + wikiUserDAO = userDAO; } public ILearnerService getLearnerService() { @@ -1060,25 +1054,25 @@ } public IEventNotificationService getEventNotificationService() { - return eventNotificationService; + return eventNotificationService; } public void setEventNotificationService(IEventNotificationService eventNotificationService) { - this.eventNotificationService = eventNotificationService; + this.eventNotificationService = eventNotificationService; } public MessageService getMessageService() { - return messageService; + return messageService; } public void setMessageService(MessageService messageService) { - this.messageService = messageService; + this.messageService = messageService; } - + public String getLocalisedMessage(String key, Object[] args) { return messageService.getMessage(key, args); } - + public List getMonitorsByToolSessionId(Long sessionId) { return getLessonService().getMonitorsByToolSessionId(sessionId); } @@ -1090,13 +1084,13 @@ public void setLessonService(ILessonService lessonService) { this.lessonService = lessonService; } - + public IRepositoryService getRepositoryService() { - return repositoryService; + return repositoryService; } public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; + this.repositoryService = repositoryService; } - + }