001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/matrix/tool/src/java/org/theospi/portfolio/matrix/control/FormDeleteController.java $
003: * $Id: FormDeleteController.java 15711 2006-10-05 20:34:44Z andersjb@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.portfolio.matrix.control;
021:
022: import java.util.HashMap;
023: import java.util.Map;
024:
025: import org.sakaiproject.metaobj.shared.mgt.IdManager;
026: import org.sakaiproject.metaobj.shared.model.Id;
027: import org.sakaiproject.metaobj.utils.mvc.intf.CustomCommandController;
028: import org.sakaiproject.metaobj.utils.mvc.intf.LoadObjectController;
029: import org.springframework.validation.Errors;
030: import org.springframework.web.servlet.ModelAndView;
031: import org.theospi.portfolio.matrix.MatrixManager;
032: import org.theospi.portfolio.matrix.WizardPageHelper;
033: import org.theospi.portfolio.matrix.model.Cell;
034: import org.theospi.portfolio.matrix.model.WizardPage;
035:
036: /**
037: * @author chmaurer
038: */
039: public class FormDeleteController implements LoadObjectController,
040: CustomCommandController {
041:
042: IdManager idManager = null;
043: MatrixManager matrixManager = null;
044:
045: /* (non-Javadoc)
046: * @see org.theospi.utils.mvc.intf.CustomCommandController#formBackingObject(java.util.Map, java.util.Map, java.util.Map)
047: */
048: public Object formBackingObject(Map request, Map session,
049: Map application) {
050: return new HashMap();
051: }
052:
053: /* (non-Javadoc)
054: * @see org.theospi.utils.mvc.intf.LoadObjectController#fillBackingObject(java.lang.Object, java.util.Map, java.util.Map, java.util.Map)
055: */
056: public Object fillBackingObject(Object incomingModel, Map request,
057: Map session, Map application) throws Exception {
058: return incomingModel;
059: }
060:
061: /* (non-Javadoc)
062: * @see org.theospi.utils.mvc.intf.Controller#handleRequest(java.lang.Object, java.util.Map, java.util.Map, java.util.Map, org.springframework.validation.Errors)
063: */
064: public ModelAndView handleRequest(Object requestModel, Map request,
065: Map session, Map application, Errors errors) {
066: WizardPage page = (WizardPage) session
067: .get(WizardPageHelper.WIZARD_PAGE);
068: Id cellId = idManager.getId((String) request.get("page_id"));
069: Id formId = idManager.getId((String) request
070: .get("current_form_id"));
071: Cell cell = getMatrixManager().getCellFromPage(cellId);
072: boolean sessionPage = true;
073: if (page == null) {
074: sessionPage = false;
075: page = cell.getWizardPage();
076: }
077:
078: String submitAction = (String) request.get("submit");
079: String cancelAction = (String) request.get("cancel");
080: if (submitAction != null) {
081: if (page != null) {
082: session.remove(WizardPageHelper.WIZARD_PAGE);
083: getMatrixManager().removeFromSession(page);
084: getMatrixManager().detachForm(page.getId(), formId);
085: if (sessionPage) {
086:
087: session.put(WizardPageHelper.WIZARD_PAGE,
088: getMatrixManager().getWizardPage(
089: page.getId()));
090: }
091: }
092: }
093:
094: // if not submit, then cancel, but both submit and cancel have the some view, so
095: return new ModelAndView("continue", "page_id", page.getId()
096: .getValue());
097: }
098:
099: /**
100: * @return Returns the idManager.
101: */
102: public IdManager getIdManager() {
103: return idManager;
104: }
105:
106: /**
107: * @param idManager The idManager to set.
108: */
109: public void setIdManager(IdManager idManager) {
110: this .idManager = idManager;
111: }
112:
113: /**
114: * @return Returns the matrixManager.
115: */
116: public MatrixManager getMatrixManager() {
117: return matrixManager;
118: }
119:
120: /**
121: * @param matrixManager The matrixManager to set.
122: */
123: public void setMatrixManager(MatrixManager matrixManager) {
124: this.matrixManager = matrixManager;
125: }
126: }
|