001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/wizard/tool/src/java/org/theospi/portfolio/wizard/tool/DecoratedCompletedPage.java $
003: * $Id:DecoratedCompletedPage.java 9134 2006-05-08 20:28:42Z 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.wizard.tool;
021:
022: import java.io.IOException;
023: import java.util.ArrayList;
024: import java.util.Iterator;
025: import java.util.List;
026:
027: import javax.faces.context.ExternalContext;
028: import javax.faces.context.FacesContext;
029:
030: import org.sakaiproject.tool.api.ToolSession;
031: import org.sakaiproject.tool.cover.SessionManager;
032: import org.theospi.portfolio.matrix.WizardPageHelper;
033: import org.theospi.portfolio.matrix.model.WizardPage;
034: import org.theospi.portfolio.wizard.WizardFunctionConstants;
035: import org.theospi.portfolio.wizard.model.CompletedWizardPage;
036: import org.theospi.portfolio.wizard.model.Wizard;
037:
038: /**
039: * Created by IntelliJ IDEA.
040: * User: John Ellis
041: * Date: Jan 24, 2006
042: * Time: 9:06:32 AM
043: * To change this template use File | Settings | File Templates.
044: */
045: public class DecoratedCompletedPage {
046:
047: private WizardTool parent;
048: private DecoratedWizardPage page;
049: private CompletedWizardPage base;
050:
051: public DecoratedCompletedPage() {
052: }
053:
054: public DecoratedCompletedPage(WizardTool parent,
055: DecoratedWizardPage page, CompletedWizardPage base) {
056: this .parent = parent;
057: this .page = page;
058: this .base = base;
059: }
060:
061: public WizardTool getParent() {
062: return parent;
063: }
064:
065: public void setParent(WizardTool parent) {
066: this .parent = parent;
067: }
068:
069: public DecoratedWizardPage getPage() {
070: return page;
071: }
072:
073: public void setPage(DecoratedWizardPage page) {
074: this .page = page;
075: }
076:
077: public CompletedWizardPage getBase() {
078: return base;
079: }
080:
081: public void setBase(CompletedWizardPage base) {
082: this .base = base;
083: }
084:
085: public DecoratedCategoryChild getCategoryChild() {
086: return (DecoratedCategoryChild) page;
087: }
088:
089: public String processActionEdit() {
090: ExternalContext context = FacesContext.getCurrentInstance()
091: .getExternalContext();
092: ToolSession session = SessionManager.getCurrentToolSession();
093: WizardPage page = getParent().getMatrixManager().getWizardPage(
094: getBase().getWizardPage().getId());
095: session.setAttribute(WizardPageHelper.WIZARD_PAGE, page);
096: String redirectAddress = "osp.wizard.page.helper/wizardPage.osp";
097:
098: if (!parent.getCurrentUserId().equalsIgnoreCase(
099: SessionManager.getCurrentSessionUserId()))
100: session.setAttribute("readOnlyMatrix", "true");
101: session.setAttribute(WizardPageHelper.WIZARD_OWNER, parent
102: .getCurrent().getRunningWizard().getBase().getOwner());
103:
104: if (WizardFunctionConstants.WIZARD_TYPE_SEQUENTIAL
105: .equals(getBase().getCategory().getWizard().getWizard()
106: .getType())) {
107: session.setAttribute(
108: WizardPageHelper.SEQUENTIAL_WIZARD_PAGES,
109: getPageList());
110: session.setAttribute(
111: WizardPageHelper.SEQUENTIAL_WIZARD_CURRENT_STEP,
112: new Integer(getBase().getSequence()));
113: redirectAddress = "osp.wizard.page.helper/sequentialWizardPage.osp";
114: }
115:
116: try {
117: context.redirect(redirectAddress);
118: } catch (IOException e) {
119: throw new RuntimeException("Failed to redirect to helper",
120: e);
121: }
122:
123: return null;
124: }
125:
126: protected List getPageList() {
127: List pageList = new ArrayList();
128:
129: for (Iterator i = getBase().getCategory().getChildPages()
130: .iterator(); i.hasNext();) {
131: CompletedWizardPage page = (CompletedWizardPage) i.next();
132: pageList.add(page.getWizardPage());
133: }
134: return pageList;
135: }
136: }
|