AuthoringAction
action.
+ *
+ * @author Marcin Cieslak
+ * @see org.lamsfoundation.lams.tool.notebook.web.action.AuthoringAction
+ *
+ */
+@Controller
+@RequestMapping("/authoringCondition")
+public class AuthoringChatConditionController {
+
+ @Autowired
+ @Qualifier("chatService")
+ private IChatService chatService;
+
+ @Autowired
+ @Qualifier("chatMessageService")
+ private MessageService messageService;
+
+ /**
+ * Display empty page for new taskList item.
+ */
+ @RequestMapping("/newConditionInit")
+ public String newConditionInit(@ModelAttribute ChatConditionForm chatConditionForm, HttpServletRequest request) {
+
+ String sessionMapID = request.getParameter(ChatConstants.ATTR_SESSION_MAP_ID);
+ chatConditionForm.setSessionMapID(sessionMapID);
+ chatConditionForm.setOrderId(-1);
+ return "pages/authoring/addCondition";
+ }
+
+ /**
+ * Display edit page for existed taskList item.
+ */
+ @RequestMapping("/editCondition")
+ public String editCondition(@ModelAttribute ChatConditionForm chatConditionForm, HttpServletRequest request) {
+
+ String sessionMapID = chatConditionForm.getSessionMapID();
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
+
+ int orderId = NumberUtils.stringToInt(request.getParameter(ChatConstants.PARAM_ORDER_ID), -1);
+ ChatCondition condition = null;
+ if (orderId != -1) {
+ SortedSetHttpSession
ChatItemList. 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.
+ */
+ @RequestMapping("/saveOrUpdateCondition")
+ public String saveOrUpdateCondition(@ModelAttribute ChatConditionForm chatConditionForm,
+ HttpServletRequest request) {
+
+ MultiValueMapjava.util.List
from HttpSession by given name.
+ */
+ 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.
+ */
+ private void populateConditionToForm(int orderId, ChatCondition condition, ChatConditionForm chatConditionForm,
+ HttpServletRequest request) {
+ chatConditionForm.populateForm(condition);
+ if (orderId >= 0) {
+ chatConditionForm.setOrderId(orderId + 1);
+ }
+ }
+
+ /**
+ * Extract form content to taskListContent.
+ */
+ private void extractFormToChatCondition(HttpServletRequest request, ChatConditionForm chatConditionForm)
+ throws Exception {
+
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(chatConditionForm.getSessionMapID());
+ // check whether it is "edit(old item)" or "add(new item)"
+ SortedSettoolContentID
will be passed in. This will be used to retrieve content for this tool.
+ */
+ @RequestMapping("/authoring")
+ public String unspecified(@ModelAttribute AuthoringForm authoringForm, HttpServletRequest request) {
+
+ // Extract toolContentID from parameters.
+ Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID));
+
+ String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
+
+ ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request);
+
+ // retrieving Chat with given toolContentID
+ Chat chat = chatService.getChatByContentId(toolContentID);
+ if (chat == null) {
+ chat = chatService.copyDefaultContent(toolContentID);
+ chat.setCreateDate(new Date());
+ chatService.saveOrUpdateChat(chat);
+ // TODO NOTE: this causes DB orphans when LD not saved.
+ }
+
+ if (mode.isTeacher()) {
+ // Set the defineLater flag so that learners cannot use content
+ // while we
+ // are editing. This flag is released when updateContent is called.
+ chat.setDefineLater(true);
+ chatService.saveOrUpdateChat(chat);
+
+ //audit log the teacher has started editing activity in monitor
+ chatService.auditLogStartEditingActivityInMonitor(toolContentID);
+ }
+
+ // Set up the authForm.
+ updateAuthForm(authoringForm, chat);
+
+ // Set up sessionMap
+ SessionMap
- |
-
- |
-
- |
-
- |
-
- |
-
- |
-
- |
-
- |
-
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
-
-
- |
-
-
- |
-
+
+
+ |
+
+
+ |
+