TaskListCondition
.
+ *
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.taskList.model.TaskListCondition
+ */
+public class TaskListConditionComparator implements ComparatorAuthoringTaskListConditionAction
action.
+ *
* @author Steve.Ni
- * @version $Revision$
+ * @author Andrey Balan
+ * @see org.lamsfoundation.lams.tool.taskList.web.action.AuthoringTaskListConditionAction
*/
public class AuthoringAction extends Action {
@@ -86,7 +92,8 @@
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String param = mapping.getParameter();
- //-----------------------TaskList Author function ---------------------------
+
+ //----------------------- solid taskList methods ---------------------------
if(param.equals("start")){
ToolAccessMode mode = getAccessMode(request);
//teacher mode "check for new" button enter.
@@ -111,7 +118,6 @@
if (param.equals("initPage")) {
return initPage(mapping, form, request, response);
}
-
if (param.equals("updateContent")) {
return updateContent(mapping, form, request, response);
}
@@ -127,7 +133,8 @@
if (param.equals("deleteOfflineFile")) {
return deleteOfflineFile(mapping, form, request, response);
}
- //----------------------- Add taskList item function ---------------------------
+
+ //----------------------- Add taskListItem methods ---------------------------
if (param.equals("newItemInit")) {
return newItemlInit(mapping, form, request, response);
}
@@ -146,190 +153,27 @@
if (param.equals("downItem")) {
return downItem(mapping, form, request, response);
}
-
+
return mapping.findForward(TaskListConstants.ERROR);
}
-
- /**
- * Remove taskList item from HttpSession list and update page display. As authoring rule, all persist only happen when
- * user submit whole page. So this remove is just impact HttpSession values.
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- private ActionForward removeItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
-
-// get back sessionMAP
- String sessionMapID = WebUtil.readStrParam(request, TaskListConstants.ATTR_SESSION_MAP_ID);
- SessionMap sessionMap = (SessionMap)request.getSession().getAttribute(sessionMapID);
-
- int itemIdx = NumberUtils.stringToInt(request.getParameter(TaskListConstants.PARAM_ITEM_INDEX),-1);
- if(itemIdx != -1){
- SortedSetHttpSession
TaskListItemList. Notice, this save is not persist them into database,
- * just save HttpSession
temporarily. Only they will be persist when the entire authoring
- * page is being persisted.
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws ServletException
- */
- private ActionForward saveOrUpdateItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
- TaskListItemForm itemForm = (TaskListItemForm)form;
- ActionErrors errors = validateTaskListItem(itemForm);
-
- if(!errors.isEmpty()){
- this.addErrors(request,errors);
- return mapping.findForward("task");
- }
-
- try {
- extractFormToTaskListItem(request, itemForm);
- } catch (Exception e) {
- //any upload exception will display as normal error message rather then throw exception directly
- errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(TaskListConstants.ERROR_MSG_UPLOAD_FAILED,e.getMessage()));
- if(!errors.isEmpty()){
- this.addErrors(request,errors);
- return mapping.findForward("task");
- }
- }
- //set session map ID so that itemlist.jsp can get sessionMAP
- request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, itemForm.getSessionMapID());
- //return null to close this window
- return mapping.findForward(TaskListConstants.SUCCESS);
- }
-
- /**
* Read taskList data from database and put them into HttpSession. It will redirect to init.do directly after this
* method run successfully.
*
* This method will avoid read database again and lost un-saved resouce item lost when user "refresh page",
* @throws ServletException
- *
*/
private ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException {
- //save toolContentID into HTTPSession
+ // save toolContentID into HTTPSession
Long contentId = new Long(WebUtil.readLongParam(request,TaskListConstants.PARAM_TOOL_CONTENT_ID));
-// get back the taskList and item list and display them on page
+ // get back the taskList and item list and display them on page
ITaskListService service = getTaskListService();
ListHttpSession
TaskListItemList. Notice, this save is not persist them into database,
+ * just save HttpSession
temporarily. Only they will be persist when the entire authoring
+ * page is being persisted.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws ServletException
+ */
+ private ActionForward saveOrUpdateItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
+ TaskListItemForm itemForm = (TaskListItemForm)form;
+ ActionErrors errors = validateTaskListItem(itemForm);
+
+ if(!errors.isEmpty()){
+ this.addErrors(request,errors);
+ return mapping.findForward("task");
+ }
+
+ try {
+ extractFormToTaskListItem(request, itemForm);
+ } catch (Exception e) {
+ //any upload exception will display as normal error message rather then throw exception directly
+ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(TaskListConstants.ERROR_MSG_UPLOAD_FAILED,e.getMessage()));
+ if(!errors.isEmpty()){
+ this.addErrors(request,errors);
+ return mapping.findForward("task");
+ }
+ }
+ //set session map ID so that itemlist.jsp can get sessionMAP
+ request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, itemForm.getSessionMapID());
+ //return null to close this window
+ return mapping.findForward(TaskListConstants.SUCCESS);
+ }
+
+ /**
+ * Remove taskList item from HttpSession list and update page display. As authoring rule, all persist only happen when
+ * user submit whole page. So this remove is just impact HttpSession values.
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward removeItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
+
+ // get back sessionMAP
+ String sessionMapID = WebUtil.readStrParam(request, TaskListConstants.ATTR_SESSION_MAP_ID);
+ SessionMap sessionMap = (SessionMap)request.getSession().getAttribute(sessionMapID);
+
+ int itemIdx = NumberUtils.stringToInt(request.getParameter(TaskListConstants.PARAM_ITEM_INDEX),-1);
+ if(itemIdx != -1){
+ SortedSetHttpSession
TaskListItemList. Notice, this save is not persist them into database,
+ * just save HttpSession
temporarily. Only they will be persist when the entire authoring
+ * page is being persisted.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws ServletException
+ */
+ private ActionForward saveOrUpdateCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
+
+ TaskListConditionForm conditionForm = (TaskListConditionForm)form;
+ ActionErrors errors = validateTaskListCondition(conditionForm, request);
+
+ if(!errors.isEmpty()){
+ populateFormWithPossibleItems(form, request);
+ this.addErrors(request,errors);
+ return mapping.findForward("addcondition");
+ }
+
+ try {
+ extractFormToTaskListCondition(request, conditionForm);
+ } catch (Exception e) {
+ //any upload exception will display as normal error message rather then throw exception directly
+ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(TaskListConstants.ERROR_MSG_UPLOAD_FAILED,e.getMessage()));
+ if(!errors.isEmpty()){
+ populateFormWithPossibleItems(form, request);
+ this.addErrors(request,errors);
+ return mapping.findForward("addcondition");
+ }
+ }
+ //set session map ID so that itemlist.jsp can get sessionMAP
+ request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID());
+ //return null to close this window
+ return mapping.findForward(TaskListConstants.SUCCESS);
+ }
+
+ /**
+ * Remove taskList item from HttpSession list and update page display. As authoring rule, all persist only happen when
+ * user submit whole page. So this remove is just impact HttpSession values.
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
+
+ // get back sessionMAP
+ String sessionMapID = WebUtil.readStrParam(request, TaskListConstants.ATTR_SESSION_MAP_ID);
+ SessionMap sessionMap = (SessionMap)request.getSession().getAttribute(sessionMapID);
+
+ int sequenceId = NumberUtils.stringToInt(request.getParameter(TaskListConstants.PARAM_SEQUENCE_ID),-1);
+ if(sequenceId != -1){
+ SortedSetjava.util.List
from HttpSession by given name.
+ *
+ * @param request
+ * @param name
+ * @return
+ */
+ private List getListFromSession(SessionMap sessionMap,String name) {
+ List list = (List) sessionMap.get(name);
+ if(list == null){
+ list = new ArrayList();
+ sessionMap.put(name,list);
+ }
+ return list;
+ }
+
+ /**
+ * This method will populate taskList item information to its form for edit use.
+ * @param sequenceId
+ * @param condition
+ * @param form
+ * @param request
+ */
+ private void populateConditionToForm(int sequenceId, TaskListCondition condition, TaskListConditionForm form, HttpServletRequest request) {
+ if(sequenceId >=0)
+ form.setSequenceId(new Integer(sequenceId).toString());
+ form.setName(condition.getName());
+
+ SetTaskListCondition
objects on a view layer.
+ *
+ * @author Andrey Balan
+ *
+ * @struts.form name="taskListConditionForm"
+ */
+public class TaskListConditionForm extends ActionForm {
+
+ //tool access mode;
+ private String mode;
+ private String sessionMapID;
+
+ private String sequenceId;
+ private String name;
+// private String taskListItemName;
+ private LabelValueBean[] possibleItems;
+ private String[] selectedItems;
+
+ public TaskListConditionForm() {
+ super();
+ LabelValueBean[] lvBeans = new LabelValueBean[4];
+
+ lvBeans[0] = new LabelValueBean("Alpha", "A");
+ lvBeans[1] = new LabelValueBean("Beta", "B");
+ lvBeans[2] = new LabelValueBean("Charlie", "C");
+ lvBeans[3] = new LabelValueBean("Delta", "D");
+
+ this.possibleItems = lvBeans;
+ }
+
+ /**
+ * Returns TaskListCondition name.
+ *
+ * @return TaskListCondition name
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * Sets TaskListCondition title.
+ *
+ * @param title TaskListCondition title
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns TaskListCondition sequence Id.
+ *
+ * @return TaskListCondition sequence Id
+ */
+ public String getSequenceId() {
+ return sequenceId;
+ }
+ /**
+ * Sets TaskListCondition sequence Id.
+ *
+ * @param sequenceId TaskListCondition sequence Id
+ */
+ public void setSequenceId(String sequenceId) {
+ this.sequenceId = sequenceId;
+ }
+
+ /**
+ * Returns current SessionMapID.
+ *
+ * @return current SessionMapID
+ */
+ public String getSessionMapID() {
+ return sessionMapID;
+ }
+ /**
+ * Sets current SessionMapID.
+ *
+ * @param sessionMapID current SessionMapID
+ */
+ public void setSessionMapID(String sessionMapID) {
+ this.sessionMapID = sessionMapID;
+ }
+
+ /**
+ * Returns working mode.
+ *
+ * @return working mode
+ */
+ public String getMode() {
+ return mode;
+ }
+ /**
+ * Returns working mode.
+ *
+ * @param mode working mode
+ */
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+// /**
+// * Returns TaskLiskItem
name.
+// *
+// * @return TaskLiskItem
name
+// */
+// public String getTaskListItemName() {
+// return taskListItemName;
+// }
+// /**
+// * Sets TaskLiskItem
name.
+// *
+// * @param taskListItemName TaskLiskItem
name
+// */
+// public void setTaskListItemName(String taskListItemName) {
+// this.taskListItemName = taskListItemName;
+// }
+
+
+
+ public LabelValueBean[] getPossibleItems() {
+ return possibleItems;
+ }
+
+ public void setPossibleItems(LabelValueBean[] lvBeans) {
+ this.possibleItems = lvBeans;
+ }
+
+ public String[] getSelectedItems() {
+ return selectedItems;
+ }
+
+ public void setSelectedItems(String[] selectedItems) {
+ this.selectedItems = selectedItems;
+ }
+
+}
+
+
\ No newline at end of file
Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java,v
diff -u -r1.5 -r1.6
--- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java 31 Mar 2008 06:09:45 -0000 1.5
+++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java 7 Apr 2008 07:33:30 -0000 1.6
@@ -25,12 +25,14 @@
import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;
+
/**
- * TaskList Item Form.
- * @struts.form name="taskListItemForm"
+ * Form responsible for representing TaskListItem
objects on a view layer.
+ *
* @author Steve.Ni
+ * @author Andrey Balan
*
- * @version $Revision$
+ * @struts.form name="taskListItemForm"
*/
public class TaskListItemForm extends ActionForm {
private String itemIndex;
@@ -52,82 +54,206 @@
private FormFile uploadedFile;
private String comment;
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
+ /**
+ * Returns TaskListItem title.
+ *
+ * @return TaskListItem title
+ */
public String getTitle() {
return title;
}
+ /**
+ * Sets TaskListItem title.
+ *
+ * @param title TaskListItem title
+ */
public void setTitle(String title) {
this.title = title;
}
+
+ /**
+ * Returns TaskListItem description.
+ *
+ * @return TaskListItem description
+ */
+ public String getDescription() {
+ return description;
+ }
+ /**
+ * Sets TaskListItem description.
+ *
+ * @param description TaskListItem description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Returns TaskListItem order index.
+ *
+ * @return TaskListItem order index
+ */
public String getItemIndex() {
return itemIndex;
}
+ /**
+ * Sets TaskListItem order index.
+ *
+ * @param itemIndex TaskListItem order index
+ */
public void setItemIndex(String itemIndex) {
this.itemIndex = itemIndex;
}
+
+ /**
+ * Returns current SessionMapID.
+ *
+ * @return current SessionMapID
+ */
public String getSessionMapID() {
return sessionMapID;
}
+ /**
+ * Sets current SessionMapID.
+ *
+ * @param sessionMapID current SessionMapID
+ */
public void setSessionMapID(String sessionMapID) {
this.sessionMapID = sessionMapID;
}
+
+ /**
+ * Returns working mode.
+ *
+ * @return working mode
+ */
public String getMode() {
return mode;
}
+ /**
+ * Returns working mode.
+ *
+ * @param mode working mode
+ */
public void setMode(String mode) {
this.mode = mode;
}
+ /**
+ * Returns whether this TaskLiskItem
is required to finish activity.
+ *
+ * @return true if the TaskLiskItem
is required to finish activity, false otherwise.
+ */
public boolean isRequired() {
return isRequired;
}
+ /**
+ * Sets whether this TaskLiskItem
is required to finish activity.
+ *
+ * @param isRequired true if the TaskLiskItem
is required to finish activity, false otherwise.
+ */
public void setRequired(boolean isRequired) {
this.isRequired = isRequired;
}
+ /**
+ * Returns whether comments are allowed in this TaskLiskItem
.
+ *
+ * @return true if comments are allowed in this TaskLiskItem
, false otherwise.
+ */
public boolean isCommentsAllowed() {
return isCommentsAllowed;
}
+ /**
+ * Sets whether comments are allowed in this TaskLiskItem
.
+ *
+ * @param isCommentsAllowed true if comments are allowed in this TaskLiskItem
, false otherwise.
+ */
public void setCommentsAllowed(boolean isCommentsAllowed) {
this.isCommentsAllowed = isCommentsAllowed;
}
+ /**
+ * Returns whether comments are allowed to be shown to everybody for this TaskLiskItem
.
+ *
+ * @return true if comments are allowed to be shown to everybody for this TaskLiskItem
, false otherwise.
+ */
public boolean getShowCommentsToAll() {
return showCommentsToAll;
}
+ /**
+ * Sets whether comments are allowed to be shown to everybody for this TaskLiskItem
or not.
+ *
+ * @param showCommentsToAll true if comments are allowed to be shown to everybody for this TaskLiskItem
, false otherwise.
+ */
public void setShowCommentsToAll(boolean showCommentsToAll) {
this.showCommentsToAll = showCommentsToAll;
}
+ /**
+ * Returns whether this TaskLiskItem
is a child task.
+ *
+ * @return true if this TaskLiskItem
is a child task, false otherwise.
+ */
public boolean isChildTask() {
return isChildTask;
}
+ /**
+ * Sets whether this TaskLiskItem
is a child task or not.
+ *
+ * @param isChildTask true if this TaskLiskItem
is a child task, false otherwise.
+ */
public void setChildTask(boolean isChildTask) {
this.isChildTask = isChildTask;
}
+ /**
+ * If the TaskLiskItem
is a child task then it has a parent. So this method returns its title.
+ *
+ * @return parent's title
+ */
public String getParentTaskName() {
return parentTaskName;
}
+ /**
+ * If the TaskLiskItem
is a child task then it has a parent. So this method sets its title.
+ *
+ * @param parentTaskName parent's title
+ */
public void setParentTaskName(String parentTaskName) {
this.parentTaskName = parentTaskName;
}
+ /**
+ * Returns attachment for this TaskLiskItem
.
+ *
+ * @return attachment for this TaskLiskItem
+ */
public FormFile getUploadedFile() {
return uploadedFile;
}
+ /**
+ * Sets attachment for this TaskLiskItem
.
+ *
+ * @param uploadedFile attachment for this TaskLiskItem
+ */
public void setUploadedFile(FormFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
+ /**
+ * Returns comment for this TaskLiskItem
.
+ *
+ * @return comment for this TaskLiskItem
+ */
public String getComment() {
return comment;
}
+ /**
+ * Sets comment for this TaskLiskItem
.
+ *
+ * @param comment comment for this TaskLiskItem
+ */
public void setComment(String comment) {
this.comment = comment;
}
Index: lams_tool_task/web/pages/authoring/authoring.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_task/web/pages/authoring/authoring.jsp,v
diff -u -r1.2 -r1.3
--- lams_tool_task/web/pages/authoring/authoring.jsp 14 Mar 2008 08:01:01 -0000 1.2
+++ lams_tool_task/web/pages/authoring/authoring.jsp 7 Apr 2008 07:33:31 -0000 1.3
@@ -27,6 +27,10 @@
var tag = document.getElementById("currentTab");
tag.value = tabId;
// end optional tab controller stuff
+
+ //if we're leaving Condition tab its addCondition area should be closed
+ if (tabId != 4) window.parent.hideConditionMessage();
+
selectTab(tabId);
}
@@ -55,6 +59,7 @@
- ');" class="button-add-item">
+ ');" class="button-add-item">
+ ');" class="button-add-item">
+
+ +
Index: lams_tool_task/web/pages/authoring/parts/addcondition.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/web/pages/authoring/parts/addcondition.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_task/web/pages/authoring/parts/addcondition.jsp 7 Apr 2008 07:33:30 -0000 1.1 @@ -0,0 +1,52 @@ + +<%@ include file="/common/taglibs.jsp"%> + ++ ${condition.name} + | + +
+ ![]() ![]() ![]() ![]() |
+
+
+ ![]() |
+
+
+ ![]() |
+