01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/matrix/tool/src/java/org/theospi/portfolio/matrix/control/PublishScaffoldingConfirmationController.java $
03: * $Id: PublishScaffoldingConfirmationController.java 21150 2007-02-08 19:34:50Z bkirschn@umich.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.matrix.control;
21:
22: import java.util.HashMap;
23: import java.util.Map;
24: import java.util.List;
25: import java.util.Iterator;
26:
27: import org.sakaiproject.metaobj.shared.mgt.IdManager;
28: import org.sakaiproject.metaobj.shared.model.Id;
29: import org.sakaiproject.metaobj.utils.mvc.intf.Controller;
30: import org.springframework.validation.Errors;
31: import org.springframework.web.servlet.ModelAndView;
32: import org.theospi.portfolio.matrix.MatrixManager;
33: import org.theospi.portfolio.matrix.model.Matrix;
34:
35: /**
36: * @author chmaurer
37: */
38: public class PublishScaffoldingConfirmationController implements
39: Controller {
40:
41: MatrixManager matrixManager = null;
42: IdManager idManager = null;
43:
44: /* (non-Javadoc)
45: * @see org.theospi.utils.mvc.intf.Controller#handleRequest(java.lang.Object, java.util.Map, java.util.Map, java.util.Map, org.springframework.validation.Errors)
46: */
47:
48: public ModelAndView handleRequest(Object requestModel, Map request,
49: Map session, Map application, Errors errors) {
50: String viewName = "success";
51: Id id = idManager.getId((String) request.get("scaffolding_id"));
52:
53: Map model = new HashMap();
54: model.put("scaffolding_id", id);
55:
56: String cancel = (String) request.get("cancel");
57: String next = (String) request.get("continue");
58: if (cancel != null) {
59: viewName = "cancel";
60: } else if (next != null) {
61: viewName = "publish";
62:
63: // First delete any associated matrix data from 'preview' mode
64: List matrices = getMatrixManager().getMatrices(id);
65: for (Iterator matrixIt = matrices.iterator(); matrixIt
66: .hasNext();) {
67: Matrix matrix = (Matrix) matrixIt.next();
68: getMatrixManager().deleteMatrix(matrix.getId());
69: }
70:
71: matrixManager.publishScaffolding(id);
72: }
73:
74: return new ModelAndView(viewName, model);
75: }
76:
77: public IdManager getIdManager() {
78: return idManager;
79: }
80:
81: public void setIdManager(IdManager idManager) {
82: this .idManager = idManager;
83: }
84:
85: public MatrixManager getMatrixManager() {
86: return matrixManager;
87: }
88:
89: public void setMatrixManager(MatrixManager matrixManager) {
90: this.matrixManager = matrixManager;
91: }
92: }
|