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_
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