001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/matrix/tool/src/java/org/theospi/portfolio/matrix/control/ResourceDeleteController.java $
003: * $Id: ResourceDeleteController.java 12563 2006-07-19 18:34:10Z chmaurer@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 ResourceDeleteController 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 artifactId = idManager.getId((String) request
070: .get("resource_id"));
071: Cell cell = getMatrixManager().getCellFromPage(cellId);
072: boolean sessionPage = true;
073: if (page == null) {
074: sessionPage = false;
075: page = cell.getWizardPage();
076: }
077: String submitAction = (String) request.get("submit");
078: String cancelAction = (String) request.get("cancel");
079: if (submitAction != null) {
080: if (page != null) {
081: getMatrixManager().detachArtifact(page.getId(),
082: artifactId);
083:
084: if (sessionPage) {
085: session.remove(WizardPageHelper.WIZARD_PAGE);
086: session.put(WizardPageHelper.WIZARD_PAGE,
087: getMatrixManager().getWizardPage(
088: page.getId()));
089: }
090: }
091: return new ModelAndView("continue", "page_id", page.getId()
092: .getValue());
093: }
094: if (cancelAction != null) {
095: return new ModelAndView("continue", "page_id", page.getId()
096: .getValue());
097: }
098: return new ModelAndView("success", "cell", cell);
099: }
100:
101: /**
102: * @return Returns the idManager.
103: */
104: public IdManager getIdManager() {
105: return idManager;
106: }
107:
108: /**
109: * @param idManager The idManager to set.
110: */
111: public void setIdManager(IdManager idManager) {
112: this .idManager = idManager;
113: }
114:
115: /**
116: * @return Returns the matrixManager.
117: */
118: public MatrixManager getMatrixManager() {
119: return matrixManager;
120: }
121:
122: /**
123: * @param matrixManager The matrixManager to set.
124: */
125: public void setMatrixManager(MatrixManager matrixManager) {
126: this.matrixManager = matrixManager;
127: }
128: }
|