Source Code Cross Referenced for EditScaffoldingCellController.java in  » ERP-CRM-Financial » sakai » org » theospi » portfolio » matrix » control » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.theospi.portfolio.matrix.control 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL:https://source.sakaiproject.org/svn/osp/trunk/matrix/tool/src/java/org/theospi/portfolio/matrix/control/EditScaffoldingCellController.java $
003:         * $Id:EditScaffoldingCellController.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006, 2007 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 org.apache.commons.logging.Log;
023:        import org.apache.commons.logging.LogFactory;
024:        import org.sakaiproject.assignment.taggable.api.TaggableActivity;
025:        import org.sakaiproject.assignment.taggable.api.TaggingHelperInfo;
026:        import org.sakaiproject.assignment.taggable.api.TaggingProvider;
027:        import org.sakaiproject.metaobj.shared.mgt.AgentManager;
028:        import org.sakaiproject.metaobj.shared.mgt.StructuredArtifactDefinitionManager;
029:        import org.sakaiproject.metaobj.shared.model.Agent;
030:        import org.sakaiproject.metaobj.shared.model.Id;
031:        import org.sakaiproject.metaobj.shared.model.StructuredArtifactDefinitionBean;
032:        import org.sakaiproject.metaobj.utils.mvc.intf.FormController;
033:        import org.sakaiproject.metaobj.utils.mvc.intf.LoadObjectController;
034:        import org.sakaiproject.metaobj.worksite.mgt.WorksiteManager;
035:        import org.sakaiproject.tool.api.Placement;
036:        import org.sakaiproject.tool.api.ToolSession;
037:        import org.sakaiproject.tool.cover.ToolManager;
038:        import org.springframework.validation.Errors;
039:        import org.springframework.web.servlet.ModelAndView;
040:        import org.springframework.web.servlet.view.RedirectView;
041:        import org.theospi.portfolio.guidance.mgt.GuidanceHelper;
042:        import org.theospi.portfolio.guidance.mgt.GuidanceManager;
043:        import org.theospi.portfolio.guidance.model.Guidance;
044:        import org.theospi.portfolio.matrix.MatrixFunctionConstants;
045:        import org.theospi.portfolio.matrix.model.ScaffoldingCell;
046:        import org.theospi.portfolio.matrix.model.WizardPageDefinition;
047:        import org.theospi.portfolio.security.AudienceSelectionHelper;
048:        import org.theospi.portfolio.security.Authorization;
049:        import org.theospi.portfolio.security.AuthorizationFacade;
050:        import org.theospi.portfolio.shared.model.CommonFormBean;
051:        import org.theospi.portfolio.wizard.WizardFunctionConstants;
052:        import org.theospi.portfolio.wizard.mgt.WizardManager;
053:        import org.theospi.portfolio.wizard.model.Wizard;
054:        import org.theospi.portfolio.wizard.taggable.api.WizardActivityProducer;
055:        import org.theospi.portfolio.matrix.model.Matrix;
056:        import org.theospi.portfolio.matrix.model.Cell;
057:        import org.theospi.portfolio.matrix.model.WizardPage;
058:        import org.theospi.portfolio.matrix.taggable.tool.DecoratedTaggingProvider;
059:        import org.theospi.portfolio.matrix.taggable.tool.DecoratedTaggingProvider.Pager;
060:        import org.theospi.portfolio.matrix.taggable.tool.DecoratedTaggingProvider.Sort;
061:        import org.theospi.portfolio.review.mgt.ReviewManager;
062:
063:        import java.text.MessageFormat;
064:        import java.util.*;
065:
066:        /**
067:         * @author chmaurer
068:         */
069:        public class EditScaffoldingCellController extends
070:                BaseScaffoldingCellController implements  FormController,
071:                LoadObjectController {
072:
073:            protected final Log logger = LogFactory.getLog(getClass());
074:
075:            private WorksiteManager worksiteManager = null;
076:
077:            private AgentManager agentManager;
078:
079:            private WizardManager wizardManager;
080:
081:            private AuthorizationFacade authzManager = null;
082:
083:            private WizardActivityProducer wizardActivityProducer;
084:
085:            private StructuredArtifactDefinitionManager structuredArtifactDefinitionManager;
086:
087:            private ReviewManager reviewManager;
088:
089:            // TODO move this constant somewhere where I can get to them from here and
090:            // in WizardTool
091:            public final static String FORM_TYPE = "form";
092:
093:            /*
094:             * (non-Javadoc)
095:             * 
096:             * @see org.theospi.utils.mvc.intf.FormController#referenceData(java.util.Map,
097:             *      java.lang.Object, org.springframework.validation.Errors)
098:             */
099:            public Map referenceData(Map request, Object command, Errors errors) {
100:                ScaffoldingCell sCell = (ScaffoldingCell) command;
101:                Map model = new HashMap();
102:
103:                WizardPageDefinition def = sCell.getWizardPageDefinition();
104:                if (def != null && def.getId() != null) {
105:                    TaggableActivity activity = wizardActivityProducer
106:                            .getActivity(def);
107:                    if (getTaggingManager().isTaggable()) {
108:                        model.put("taggable", "true");
109:                        ToolSession session = getSessionManager()
110:                                .getCurrentToolSession();
111:                        List<DecoratedTaggingProvider> providers = (List) session
112:                                .getAttribute(PROVIDERS_PARAM);
113:                        if (providers == null) {
114:                            providers = getDecoratedProviders(activity);
115:                            session.setAttribute(PROVIDERS_PARAM, providers);
116:                        }
117:                        model.put("helperInfoList", getHelperInfo(activity));
118:                        model.put("providers", providers);
119:                    }
120:                }
121:
122:                model.put("reflectionDevices", getReflectionDevices());
123:                model.put("evaluationDevices", getEvaluationDevices());
124:                model.put("reviewDevices", getReviewDevices());
125:                model.put("additionalFormDevices", getAdditionalFormDevices());
126:                model.put("selectedAdditionalFormDevices",
127:                        getSelectedAdditionalFormDevices(sCell));
128:                model.put("evaluators", getEvaluators(sCell
129:                        .getWizardPageDefinition()));
130:                model.put("pageTitleKey", "title_editCell");
131:                model.put("pageInstructionsKey", "instructions_cellSettings");
132:                model.put("styleReturnView", getStyleReturnView());
133:
134:                if (sCell != null && sCell.getScaffolding() != null)
135:                    model.put("isCellUsed", sCell.getScaffolding()
136:                            .isPublished()
137:                            && isCellUsed(sCell));
138:                else
139:                    model.put("isCellUsed", false);
140:
141:                return model;
142:            }
143:
144:            /*
145:             * (non-Javadoc)
146:             * 
147:             * @see org.theospi.utils.mvc.intf.CustomCommandController#formBackingObject(java.util.Map,
148:             *      java.util.Map, java.util.Map)
149:             */
150:            // public Object formBackingObject(Map request, Map session, Map
151:            // application) {
152:            // return new ScaffoldingCell();
153:            // }
154:            /*
155:             * (non-Javadoc)
156:             * 
157:             * @see org.theospi.utils.mvc.intf.Controller#handleRequest(java.lang.Object,
158:             *      java.util.Map, java.util.Map, java.util.Map,
159:             *      org.springframework.validation.Errors)
160:             */
161:
162:            public ModelAndView handleRequest(Object requestModel, Map request,
163:                    Map session, Map application, Errors errors) {
164:                ScaffoldingCell scaffoldingCell = (ScaffoldingCell) requestModel;
165:                String action = (String) request.get("action");
166:                String addFormAction = (String) request.get("addForm");
167:                String saveAction = (String) request.get("saveAction");
168:                Map model = new HashMap();
169:                if (addFormAction != null) {
170:
171:                    String id = (String) request.get("selectAdditionalFormId");
172:                    if (id != null
173:                            && !id.equals("")
174:                            && !scaffoldingCell.getAdditionalForms().contains(
175:                                    id))
176:                        scaffoldingCell.getAdditionalForms().add(id);
177:                    session.put(
178:                            EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
179:                            "true");
180:                    model.put("scaffoldingCell", scaffoldingCell);
181:                    return new ModelAndView("success", model);
182:                }
183:                if (saveAction != null) {
184:
185:                    if (isPublished(scaffoldingCell)) {
186:                        model.put("scaffoldingCell", scaffoldingCell);
187:                        model
188:                                .put(
189:                                        EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
190:                                        "true");
191:                        return new ModelAndView("editScaffoldingCellConfirm",
192:                                model);
193:                    }
194:
195:                    if (getTaggingManager().isTaggable()) {
196:                        session.remove(PROVIDERS_PARAM);
197:                    }
198:
199:                    saveScaffoldingCell(request, scaffoldingCell);
200:                    session
201:                            .remove(EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG);
202:                    session
203:                            .remove(EditedScaffoldingStorage.EDITED_SCAFFOLDING_STORAGE_SESSION_KEY);
204:                    prepareModelWithScaffoldingId(model, scaffoldingCell);
205:                    return new ModelAndView("return", model);
206:                }
207:
208:                if (action == null)
209:                    action = (String) request.get("submitAction");
210:
211:                if (action != null && action.length() > 0) {
212:
213:                    if (request.get("reviewers") == null) {
214:                        scaffoldingCell.getEvaluators().clear();
215:                    }
216:                    if (action.equals("removeFormDef")) {
217:                        String params = (String) request.get("params");
218:                        Map parmModel = parseParams(params);
219:                        String formDefId = (String) parmModel.get("id");
220:                        scaffoldingCell.getWizardPageDefinition()
221:                                .getAdditionalForms().remove(formDefId);
222:                        session
223:                                .put(
224:                                        EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
225:                                        "true");
226:                        model.put("scaffoldingCell", scaffoldingCell);
227:                        return new ModelAndView("success", model);
228:                    } else if (action.equals("forward")) {
229:                        String forwardView = (String) request.get("dest");
230:                        Map forwardModel = doForwardAction(forwardView,
231:                                request, session, scaffoldingCell);
232:                        model.putAll(forwardModel);
233:                        return new ModelAndView(forwardView, model);
234:                    } else if (action.equals("cancel")) {
235:                        session.remove(PROVIDERS_PARAM);
236:                        return new ModelAndView(new RedirectView(
237:                                "viewScaffolding.osp?scaffolding_id="
238:                                        + scaffoldingCell.getScaffolding()
239:                                                .getId()));
240:                    } else if (action.equals("tagActivity")) {
241:                        return tagActivity(scaffoldingCell, model, request,
242:                                session);
243:                    } else if (action.equals("sortList")) {
244:                        return sortList(scaffoldingCell, model, request,
245:                                session);
246:                    } else if (action.equals("pageList")) {
247:                        return pageList(scaffoldingCell, model, request,
248:                                session);
249:                    }
250:                    prepareModelWithScaffoldingId(model, scaffoldingCell);
251:                    return new ModelAndView("return", model);
252:                }
253:
254:                return new ModelAndView("success");
255:            }
256:
257:            protected ModelAndView tagActivity(ScaffoldingCell scaffoldingCell,
258:                    Map model, Map request, Map session) {
259:                EditedScaffoldingStorage sessionBean = (EditedScaffoldingStorage) session
260:                        .get(EditedScaffoldingStorage.EDITED_SCAFFOLDING_STORAGE_SESSION_KEY);
261:                sessionBean.setScaffoldingCell(scaffoldingCell);
262:                session.put(EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
263:                        "true");
264:                ModelAndView view = null;
265:                // Get appropriate helperInfo
266:                for (TaggingHelperInfo info : getHelperInfo(wizardActivityProducer
267:                        .getActivity(scaffoldingCell.getWizardPageDefinition()))) {
268:                    if (info.getProvider().getId().equals(
269:                            request.get("providerId"))) {
270:                        // Add parameters to session
271:                        for (String key : info.getParameterMap().keySet()) {
272:                            session.put(key, info.getParameterMap().get(key));
273:                        }
274:                        session.remove(PROVIDERS_PARAM);
275:                        view = new ModelAndView(new RedirectView(info
276:                                .getHelperId()
277:                                + ".helper"));
278:                        break;
279:                    }
280:                }
281:                return view;
282:            }
283:
284:            protected ModelAndView sortList(ScaffoldingCell scaffoldingCell,
285:                    Map model, Map request, Map session) {
286:                EditedScaffoldingStorage sessionBean = (EditedScaffoldingStorage) session
287:                        .get(EditedScaffoldingStorage.EDITED_SCAFFOLDING_STORAGE_SESSION_KEY);
288:                sessionBean.setScaffoldingCell(scaffoldingCell);
289:                prepareModelWithScaffoldingId(model, scaffoldingCell);
290:                model.put("scaffoldingCell_id", scaffoldingCell.getId());
291:
292:                String providerId = (String) request.get("providerId");
293:                String criteria = (String) request.get("criteria");
294:
295:                List<DecoratedTaggingProvider> providers = (List) getSessionManager()
296:                        .getCurrentToolSession().getAttribute(PROVIDERS_PARAM);
297:                for (DecoratedTaggingProvider dtp : providers) {
298:                    if (dtp.getProvider().getId().equals(providerId)) {
299:                        Sort sort = dtp.getSort();
300:                        if (sort.getSort().equals(criteria)) {
301:                            sort
302:                                    .setAscending(sort.isAscending() ? false
303:                                            : true);
304:                        } else {
305:                            sort.setSort(criteria);
306:                            sort.setAscending(true);
307:                        }
308:                        break;
309:                    }
310:                }
311:                return new ModelAndView("success", model);
312:            }
313:
314:            protected ModelAndView pageList(ScaffoldingCell scaffoldingCell,
315:                    Map model, Map request, Map session) {
316:                EditedScaffoldingStorage sessionBean = (EditedScaffoldingStorage) session
317:                        .get(EditedScaffoldingStorage.EDITED_SCAFFOLDING_STORAGE_SESSION_KEY);
318:                sessionBean.setScaffoldingCell(scaffoldingCell);
319:                prepareModelWithScaffoldingId(model, scaffoldingCell);
320:                model.put("scaffoldingCell_id", scaffoldingCell.getId());
321:
322:                String page = (String) request.get("page");
323:                String pageSize = (String) request.get("pageSize");
324:                String providerId = (String) request.get("providerId");
325:
326:                List<DecoratedTaggingProvider> providers = (List) getSessionManager()
327:                        .getCurrentToolSession().getAttribute(PROVIDERS_PARAM);
328:                for (DecoratedTaggingProvider dtp : providers) {
329:                    if (dtp.getProvider().getId().equals(providerId)) {
330:                        Pager pager = dtp.getPager();
331:                        pager.setPageSize(Integer.valueOf(pageSize));
332:                        if (Pager.FIRST.equals(page)) {
333:                            pager.setFirstItem(0);
334:                        } else if (Pager.PREVIOUS.equals(page)) {
335:                            pager.setFirstItem(pager.getFirstItem()
336:                                    - pager.getPageSize());
337:                        } else if (Pager.NEXT.equals(page)) {
338:                            pager.setFirstItem(pager.getFirstItem()
339:                                    + pager.getPageSize());
340:                        } else if (Pager.LAST.equals(page)) {
341:                            pager.setFirstItem((pager.getTotalItems() / pager
342:                                    .getPageSize())
343:                                    * pager.getPageSize());
344:                        }
345:                        break;
346:                    }
347:                }
348:                return new ModelAndView("success", model);
349:            }
350:
351:            protected void prepareModelWithScaffoldingId(Map model,
352:                    ScaffoldingCell scaffoldingCell) {
353:                model.put("scaffolding_id", scaffoldingCell.getScaffolding()
354:                        .getId());
355:            }
356:
357:            protected boolean isPublished(ScaffoldingCell scaffoldingCell) {
358:                return scaffoldingCell.getScaffolding().isPublished();
359:            }
360:
361:            protected String getGuidanceViewPermission() {
362:                return MatrixFunctionConstants.VIEW_SCAFFOLDING_GUIDANCE;
363:            }
364:
365:            protected String getGuidanceEditPermission() {
366:                return MatrixFunctionConstants.EDIT_SCAFFOLDING_GUIDANCE;
367:            }
368:
369:            protected String getGuidanceTitle() {
370:                ResourceBundle myResources = ResourceBundle
371:                        .getBundle("org.theospi.portfolio.matrix.bundle.Messages");
372:                return myResources.getString("cell_guidance_title");
373:                // return "Guidance for Cell";
374:            }
375:
376:            protected String getStyleReturnView() {
377:                return "cell";
378:            }
379:
380:            private Map doForwardAction(String forwardView, Map request,
381:                    Map session, ScaffoldingCell scaffoldingCell) {
382:                Map model = new HashMap();
383:
384:                EditedScaffoldingStorage sessionBean = (EditedScaffoldingStorage) session
385:                        .get(EditedScaffoldingStorage.EDITED_SCAFFOLDING_STORAGE_SESSION_KEY);
386:                sessionBean.setScaffoldingCell(scaffoldingCell);
387:                prepareModelWithScaffoldingId(model, scaffoldingCell);
388:                model.put("scaffoldingCell_id", scaffoldingCell.getId());
389:
390:                if (forwardView.equals("createGuidance")
391:                        || forwardView.equals("editInstructions")
392:                        || forwardView.equals("editRationale")
393:                        || forwardView.equals("editExamples")) {
394:                    Boolean bTrue = new Boolean(true);
395:                    Boolean bFalse = new Boolean(false);
396:                    session.put(GuidanceHelper.SHOW_INSTRUCTION_FLAG, bFalse);
397:                    session.put(GuidanceHelper.SHOW_RATIONALE_FLAG, bFalse);
398:                    session.put(GuidanceHelper.SHOW_EXAMPLE_FLAG, bFalse);
399:
400:                    if (forwardView.equals("editInstructions")
401:                            || forwardView.equals("createGuidance"))
402:                        session
403:                                .put(GuidanceHelper.SHOW_INSTRUCTION_FLAG,
404:                                        bTrue);
405:                    if (forwardView.equals("editRationale")
406:                            || forwardView.equals("createGuidance"))
407:                        session.put(GuidanceHelper.SHOW_RATIONALE_FLAG, bTrue);
408:                    if (forwardView.equals("editExamples")
409:                            || forwardView.equals("createGuidance"))
410:                        session.put(GuidanceHelper.SHOW_EXAMPLE_FLAG, bTrue);
411:
412:                    Placement placement = ToolManager.getCurrentPlacement();
413:                    String currentSite = placement.getContext();
414:                    session.put(
415:                            EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
416:                            "true");
417:                    model.put(EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
418:                            "true");
419:
420:                    Guidance guidance = scaffoldingCell.getGuidance();
421:                    if (guidance == null) {
422:                        String title = getGuidanceTitle();
423:                        guidance = getGuidanceManager().createNew(
424:                                title,
425:                                currentSite,
426:                                scaffoldingCell.getWizardPageDefinition()
427:                                        .getId(), getGuidanceViewPermission(),
428:                                getGuidanceEditPermission());
429:                    }
430:
431:                    session.put(GuidanceManager.CURRENT_GUIDANCE, guidance);
432:                } else if (forwardView.equals("deleteGuidance")) {
433:                    scaffoldingCell.setDeleteGuidanceId(scaffoldingCell
434:                            .getGuidance().getId());
435:                    scaffoldingCell.setGuidance(null);
436:                    session.put(
437:                            EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
438:                            "true");
439:                    model.put(EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
440:                            "true");
441:                } else if (!forwardView.equals("selectEvaluators")) {
442:                    model.put("label", request.get("label"));
443:                    model.put("finalDest", request.get("finalDest"));
444:                    model.put("displayText", request.get("displayText"));
445:                    String params = (String) request.get("params");
446:                    model.put("params", params);
447:                    if (!params.equals("")) {
448:                        model.putAll(parseParams(params));
449:                    }
450:                } else {
451:                    session.put(
452:                            EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
453:                            "true");
454:                    model.put(EditedScaffoldingStorage.STORED_SCAFFOLDING_FLAG,
455:                            "true");
456:                    setAudienceSelectionVariables(session, scaffoldingCell
457:                            .getWizardPageDefinition());
458:
459:                }
460:                return model;
461:
462:            }
463:
464:            protected Map parseParams(String params) {
465:                Map model = new HashMap();
466:                if (!params.equals("")) {
467:                    String[] paramsList = params.split(":");
468:                    for (int i = 0; i < paramsList.length; i++) {
469:                        String[] pair = paramsList[i].split("=");
470:                        String val = null;
471:                        if (pair.length > 1)
472:                            val = pair[1];
473:                        model.put(pair[0], val);
474:                    }
475:                }
476:                return model;
477:            }
478:
479:            protected List getEvaluators(WizardPageDefinition wpd) {
480:                ResourceBundle myResources = ResourceBundle
481:                        .getBundle("org.theospi.portfolio.matrix.bundle.Messages");
482:
483:                List evalList = new ArrayList();
484:                Id id = wpd.getId() == null ? wpd.getNewId() : wpd.getId();
485:
486:                List evaluators = getAuthzManager().getAuthorizations(null,
487:                        MatrixFunctionConstants.EVALUATE_MATRIX, id);
488:
489:                for (Iterator iter = evaluators.iterator(); iter.hasNext();) {
490:                    Authorization az = (Authorization) iter.next();
491:                    Agent agent = az.getAgent();
492:                    String userId = az.getAgent().getEid().getValue();
493:                    if (agent.isRole()) {
494:                        evalList.add(MessageFormat.format(myResources
495:                                .getString("decorated_role_format"),
496:                                new Object[] { agent.getDisplayName() }));
497:                    } else {
498:                        evalList.add(MessageFormat
499:                                .format(myResources
500:                                        .getString("decorated_user_format"),
501:                                        new Object[] { agent.getDisplayName(),
502:                                                userId }));
503:                    }
504:                }
505:
506:                return evalList;
507:            }
508:
509:            protected void setAudienceSelectionVariables(Map session,
510:                    WizardPageDefinition wpd) {
511:                ResourceBundle myResources = ResourceBundle
512:                        .getBundle("org.theospi.portfolio.matrix.bundle.Messages");
513:
514:                session.put(AudienceSelectionHelper.AUDIENCE_FUNCTION,
515:                        MatrixFunctionConstants.EVALUATE_MATRIX);
516:
517:                String id = wpd.getId() != null ? wpd.getId().getValue() : wpd
518:                        .getNewId().getValue();
519:
520:                session.put(AudienceSelectionHelper.AUDIENCE_QUALIFIER, id);
521:                session.put(AudienceSelectionHelper.AUDIENCE_INSTRUCTIONS,
522:                        myResources.getString("eval_audience_instructions"));
523:                session.put(AudienceSelectionHelper.AUDIENCE_GLOBAL_TITLE,
524:                        myResources.getString("eval_audience_global_title"));
525:                session
526:                        .put(
527:                                AudienceSelectionHelper.AUDIENCE_INDIVIDUAL_TITLE,
528:                                myResources
529:                                        .getString("eval_audience_individual_title"));
530:                session.put(AudienceSelectionHelper.AUDIENCE_GROUP_TITLE,
531:                        myResources.getString("eval_audience_group_title"));
532:                session.put(AudienceSelectionHelper.AUDIENCE_PUBLIC_FLAG,
533:                        "false");
534:                session
535:                        .put(AudienceSelectionHelper.AUDIENCE_PUBLIC_TITLE,
536:                                null);
537:                session.put(AudienceSelectionHelper.AUDIENCE_SELECTED_TITLE,
538:                        myResources.getString("eval_audience_selected_title"));
539:                session
540:                        .put(
541:                                AudienceSelectionHelper.AUDIENCE_FILTER_INSTRUCTIONS,
542:                                myResources
543:                                        .getString("eval_audience_filter_instructions"));
544:                session.put(AudienceSelectionHelper.AUDIENCE_GUEST_EMAIL, null);
545:                session.put(AudienceSelectionHelper.AUDIENCE_WORKSITE_LIMITED,
546:                        "true");
547:                session.put(AudienceSelectionHelper.AUDIENCE_BROWSE_INDIVIDUAL,
548:                        myResources
549:                                .getString("eval_audience_browse_individual"));
550:            }
551:
552:            protected void clearAudienceSelectionVariables(Map session) {
553:                session.remove(AudienceSelectionHelper.AUDIENCE_FUNCTION);
554:                session.remove(AudienceSelectionHelper.AUDIENCE_QUALIFIER);
555:                session.remove(AudienceSelectionHelper.AUDIENCE_INSTRUCTIONS);
556:                session.remove(AudienceSelectionHelper.AUDIENCE_GLOBAL_TITLE);
557:                session
558:                        .remove(AudienceSelectionHelper.AUDIENCE_INDIVIDUAL_TITLE);
559:                session.remove(AudienceSelectionHelper.AUDIENCE_GROUP_TITLE);
560:                session.remove(AudienceSelectionHelper.AUDIENCE_PUBLIC_FLAG);
561:                session.remove(AudienceSelectionHelper.AUDIENCE_PUBLIC_TITLE);
562:                session.remove(AudienceSelectionHelper.AUDIENCE_SELECTED_TITLE);
563:                session
564:                        .remove(AudienceSelectionHelper.AUDIENCE_FILTER_INSTRUCTIONS);
565:                session.remove(AudienceSelectionHelper.AUDIENCE_GUEST_EMAIL);
566:                session
567:                        .remove(AudienceSelectionHelper.AUDIENCE_WORKSITE_LIMITED);
568:                session
569:                        .remove(AudienceSelectionHelper.AUDIENCE_BROWSE_INDIVIDUAL);
570:            }
571:
572:            protected Collection getAvailableForms(String siteId, String type) {
573:                return getStructuredArtifactDefinitionManager().findHomes(
574:                        getIdManager().getId(siteId), true);
575:            }
576:
577:            protected Collection getFormsForSelect(String type) {
578:                Placement placement = ToolManager.getCurrentPlacement();
579:                String currentSiteId = placement.getContext();
580:                Collection commentForms = getAvailableForms(currentSiteId, type);
581:
582:                List retForms = new ArrayList();
583:                for (Iterator iter = commentForms.iterator(); iter.hasNext();) {
584:                    StructuredArtifactDefinitionBean sad = (StructuredArtifactDefinitionBean) iter
585:                            .next();
586:                    retForms.add(new CommonFormBean(sad.getId().getValue(), sad
587:                            .getDecoratedDescription(), FORM_TYPE, sad
588:                            .getOwner().getName(), sad.getModified()));
589:                }
590:
591:                Collections.sort(retForms, CommonFormBean.beanComparator);
592:                return retForms;
593:            }
594:
595:            protected Collection getWizardsForSelect(String type) {
596:                Placement placement = ToolManager.getCurrentPlacement();
597:                String currentSiteId = placement.getContext();
598:                List wizards = getWizardManager().listWizardsByType(
599:                        getSessionManager().getCurrentSessionUserId(),
600:                        currentSiteId, type);
601:                List retWizards = new ArrayList();
602:                for (Iterator iter = wizards.iterator(); iter.hasNext();) {
603:                    Wizard wizard = (Wizard) iter.next();
604:                    retWizards.add(new CommonFormBean(
605:                            wizard.getId().getValue(), wizard.getName(),
606:                            WizardFunctionConstants.WIZARD_TYPE_SEQUENTIAL,
607:                            wizard.getOwner().getName(), wizard.getModified()));
608:                }
609:
610:                Collections.sort(retWizards, CommonFormBean.beanComparator);
611:                return retWizards;
612:            }
613:
614:            protected Collection getReviewDevices() {
615:                Collection all = getFormsForSelect(WizardFunctionConstants.COMMENT_TYPE);
616:                all
617:                        .addAll(getWizardsForSelect(WizardFunctionConstants.COMMENT_TYPE));
618:                return all;
619:            }
620:
621:            protected Collection getReflectionDevices() {
622:                Collection all = getFormsForSelect(WizardFunctionConstants.REFLECTION_TYPE);
623:                all
624:                        .addAll(getWizardsForSelect(WizardFunctionConstants.REFLECTION_TYPE));
625:                return all;
626:            }
627:
628:            protected Collection getEvaluationDevices() {
629:                Collection all = getFormsForSelect(WizardFunctionConstants.EVALUATION_TYPE);
630:                all
631:                        .addAll(getWizardsForSelect(WizardFunctionConstants.EVALUATION_TYPE));
632:                return all;
633:            }
634:
635:            protected Collection getAdditionalFormDevices() {
636:                // Return all forms
637:                return getFormsForSelect(null);
638:            }
639:
640:            protected Collection getSelectedAdditionalFormDevices(
641:                    ScaffoldingCell sCell) {
642:                // cwm need to preserve the ordering
643:                Collection returnCol = new ArrayList();
644:                Collection col = getAdditionalFormDevices();
645:                for (Iterator iter = col.iterator(); iter.hasNext();) {
646:                    CommonFormBean bean = (CommonFormBean) iter.next();
647:                    if (sCell.getAdditionalForms().contains(bean.getId()))
648:                        returnCol.add(bean);
649:                }
650:                return returnCol;
651:            }
652:
653:            /**
654:             * @return Returns the worksiteManager.
655:             */
656:            public WorksiteManager getWorksiteManager() {
657:                return worksiteManager;
658:            }
659:
660:            /**
661:             * @param worksiteManager
662:             *            The worksiteManager to set.
663:             */
664:            public void setWorksiteManager(WorksiteManager worksiteManager) {
665:                this .worksiteManager = worksiteManager;
666:            }
667:
668:            /**
669:             * @return Returns the agentManager.
670:             */
671:            public AgentManager getAgentManager() {
672:                return agentManager;
673:            }
674:
675:            /**
676:             * @param agentManager
677:             *            The agentManager to set.
678:             */
679:            public void setAgentManager(AgentManager agentManager) {
680:                this .agentManager = agentManager;
681:            }
682:
683:            public StructuredArtifactDefinitionManager getStructuredArtifactDefinitionManager() {
684:                return structuredArtifactDefinitionManager;
685:            }
686:
687:            public void setStructuredArtifactDefinitionManager(
688:                    StructuredArtifactDefinitionManager structuredArtifactDefinitionManager) {
689:                this .structuredArtifactDefinitionManager = structuredArtifactDefinitionManager;
690:            }
691:
692:            public WizardManager getWizardManager() {
693:                return wizardManager;
694:            }
695:
696:            public void setWizardManager(WizardManager wizardManager) {
697:                this .wizardManager = wizardManager;
698:            }
699:
700:            /**
701:             * @return Returns the authzManager.
702:             */
703:            public AuthorizationFacade getAuthzManager() {
704:                return authzManager;
705:            }
706:
707:            /**
708:             * @param authzManager
709:             *            The authzManager to set.
710:             */
711:            public void setAuthzManager(AuthorizationFacade authzManager) {
712:                this .authzManager = authzManager;
713:            }
714:
715:            public WizardActivityProducer getWizardActivityProducer() {
716:                return wizardActivityProducer;
717:            }
718:
719:            public void setWizardActivityProducer(
720:                    WizardActivityProducer wizardActivityProducer) {
721:                this .wizardActivityProducer = wizardActivityProducer;
722:            }
723:
724:            /**
725:             * @return Returns the reviewManager.
726:             */
727:            public ReviewManager getReviewManager() {
728:                return reviewManager;
729:            }
730:
731:            /**
732:             * @param reviewManager
733:             *            The reviewManager to set.
734:             */
735:            public void setReviewManager(ReviewManager reviewManager) {
736:                this .reviewManager = reviewManager;
737:            }
738:
739:            /**
740:             * * Determine if any matrix cell with the specified scaffoldingCell has
741:             * been 'used' * (containing reflections and/or added form items)
742:             */
743:            private boolean isCellUsed(ScaffoldingCell scaffoldingCell) {
744:                Id scaffoldingId = scaffoldingCell.getScaffolding().getId();
745:                List matrices = getMatrixManager().getMatrices(scaffoldingId);
746:
747:                for (Iterator matrixIt = matrices.iterator(); matrixIt
748:                        .hasNext();) {
749:                    Matrix matrix = (Matrix) matrixIt.next();
750:                    Set cells = matrix.getCells();
751:
752:                    for (Iterator cellIt = cells.iterator(); cellIt.hasNext();) {
753:                        Cell cell = (Cell) cellIt.next();
754:
755:                        if (cell.getScaffoldingCell().equals(scaffoldingCell)) {
756:                            WizardPage wizardPage = cell.getWizardPage();
757:                            String pageId = wizardPage.getId().getValue();
758:                            if (wizardPage.getReflections() != null
759:                                    && wizardPage.getReflections().size() > 0)
760:                                return true;
761:                            if (wizardPage.getPageForms() != null
762:                                    && wizardPage.getPageForms().size() > 0)
763:                                return true;
764:                            if (wizardPage.getFeedback() != null
765:                                    && wizardPage.getFeedback().size() > 0)
766:                                return true;
767:                            if (wizardPage.getAttachments() != null
768:                                    && wizardPage.getAttachments().size() > 0)
769:                                return true;
770:                            if (reviewManager.getReviewsByParent(pageId) != null
771:                                    && reviewManager.getReviewsByParent(pageId)
772:                                            .size() > 0)
773:                                return true;
774:                            // note: wizardPage.[get|set]Feedback() does not appear to
775:                            // be used
776:                        }
777:                    }
778:                }
779:
780:                return false;
781:            }
782:
783:            protected List<TaggingHelperInfo> getHelperInfo(
784:                    TaggableActivity activity) {
785:                List<TaggingHelperInfo> infoList = new ArrayList<TaggingHelperInfo>();
786:                if (getTaggingManager().isTaggable()) {
787:                    for (TaggingProvider provider : getTaggingManager()
788:                            .getProviders()) {
789:                        TaggingHelperInfo info = provider
790:                                .getActivityHelperInfo(activity.getReference());
791:                        if (info != null) {
792:                            infoList.add(info);
793:                        }
794:                    }
795:                }
796:                return infoList;
797:            }
798:
799:            protected List<DecoratedTaggingProvider> getDecoratedProviders(
800:                    TaggableActivity activity) {
801:                List<DecoratedTaggingProvider> providers = new ArrayList<DecoratedTaggingProvider>();
802:                for (TaggingProvider provider : getTaggingManager()
803:                        .getProviders()) {
804:                    providers.add(new DecoratedTaggingProvider(activity,
805:                            provider));
806:                }
807:                return providers;
808:            }
809:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.