Source Code Cross Referenced for WizardActivityProducerImpl.java in  » ERP-CRM-Financial » sakai » org » theospi » portfolio » wizard » taggable » impl » 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.wizard.taggable.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/wizard/api-impl/src/java/org/theospi/portfolio/wizard/taggable/impl/WizardActivityProducerImpl.java $
003:         * $Id: WizardActivityProducerImpl.java 28733 2007-04-12 01:03:37Z ajpoland@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 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.wizard.taggable.impl;
021:
022:        import java.util.ArrayList;
023:        import java.util.Iterator;
024:        import java.util.List;
025:
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:        import org.sakaiproject.assignment.taggable.api.TaggableActivity;
029:        import org.sakaiproject.assignment.taggable.api.TaggableItem;
030:        import org.sakaiproject.assignment.taggable.api.TaggingManager;
031:        import org.sakaiproject.assignment.taggable.api.TaggingProvider;
032:        import org.sakaiproject.metaobj.shared.mgt.IdManager;
033:        import org.sakaiproject.tool.api.SessionManager;
034:        import org.sakaiproject.util.ResourceLoader;
035:        import org.theospi.portfolio.matrix.MatrixFunctionConstants;
036:        import org.theospi.portfolio.matrix.MatrixManager;
037:        import org.theospi.portfolio.matrix.model.ScaffoldingCell;
038:        import org.theospi.portfolio.matrix.model.WizardPage;
039:        import org.theospi.portfolio.matrix.model.WizardPageDefinition;
040:        import org.theospi.portfolio.security.AuthorizationFacade;
041:        import org.theospi.portfolio.wizard.WizardFunctionConstants;
042:        import org.theospi.portfolio.wizard.mgt.WizardManager;
043:        import org.theospi.portfolio.wizard.model.CompletedWizard;
044:        import org.theospi.portfolio.wizard.model.Wizard;
045:        import org.theospi.portfolio.wizard.model.WizardPageSequence;
046:        import org.theospi.portfolio.wizard.taggable.api.WizardActivityProducer;
047:
048:        public class WizardActivityProducerImpl implements 
049:                WizardActivityProducer {
050:
051:            private static final Log logger = LogFactory
052:                    .getLog(WizardActivityProducerImpl.class);
053:
054:            protected static ResourceLoader messages = new ResourceLoader(
055:                    "org.theospi.portfolio.wizard.bundle.Messages");
056:
057:            MatrixManager matrixManager;
058:
059:            WizardManager wizardManager;
060:
061:            IdManager idManager;
062:
063:            TaggingManager taggingManager;
064:
065:            AuthorizationFacade authzManager;
066:
067:            SessionManager sessionManager;
068:
069:            List<String> ratingProviderIds;
070:
071:            public boolean allowGetItems(TaggableActivity activity,
072:                    TaggingProvider provider) {
073:                // FIXME http://bugs.sakaiproject.org/jira/browse/GM-84
074:                return !getItems(activity, provider).isEmpty();
075:            }
076:
077:            public boolean allowRemoveTags(TaggableActivity activity) {
078:                WizardPageDefinition pageDef = (WizardPageDefinition) activity
079:                        .getObject();
080:                // Try to get a wizard page sequence
081:                WizardPageSequence ps = wizardManager
082:                        .getWizardPageSeqByDef(pageDef.getId());
083:                boolean authorized = false;
084:                if (ps != null) {
085:                    Wizard wizard = ps.getCategory().getWizard();
086:                    /*
087:                     * If you own the wizard, or if you can delete wizards, or if you
088:                     * can revise wizards, then you are able to delete page definitions
089:                     * and can, therefore, remove tags.
090:                     */
091:                    authorized = sessionManager.getCurrentSessionUserId()
092:                            .equalsIgnoreCase(
093:                                    wizard.getOwner().getId().getValue())
094:                            || authzManager.isAuthorized(
095:                                    WizardFunctionConstants.EDIT_WIZARD, wizard
096:                                            .getId())
097:                            || authzManager.isAuthorized(
098:                                    WizardFunctionConstants.DELETE_WIZARD,
099:                                    wizard.getId());
100:                } else {
101:                    ScaffoldingCell cell = matrixManager
102:                            .getScaffoldingCellByWizardPageDef(pageDef.getId());
103:                    /*
104:                     * If you can create or delete scaffolding, then you are able to
105:                     * delete scaffolding cells and can, therefore, remove tags.
106:                     */
107:                    authorized = authzManager.isAuthorized(
108:                            MatrixFunctionConstants.CREATE_SCAFFOLDING, cell
109:                                    .getScaffolding().getId())
110:                            || authzManager.isAuthorized(
111:                                    MatrixFunctionConstants.DELETE_SCAFFOLDING,
112:                                    cell.getScaffolding().getId());
113:                }
114:                return authorized;
115:            }
116:
117:            public boolean allowRemoveTags(TaggableItem item) {
118:                // It doesn't appear that you can remove individual items (pages)
119:                return false;
120:            }
121:
122:            public boolean allowTransferCopyTags(TaggableActivity activity) {
123:                return false;
124:            }
125:
126:            private boolean canEvaluate(WizardPage page) {
127:                boolean allowed = false;
128:                CompletedWizard cw = wizardManager
129:                        .getCompletedWizardByPage(page.getId());
130:                allowed = authzManager
131:                        .isAuthorized(
132:                                (cw != null) ? WizardFunctionConstants.EVALUATE_SPECIFIC_WIZARDPAGE
133:                                        : MatrixFunctionConstants.EVALUATE_SPECIFIC_MATRIXCELL,
134:                                page.getId());
135:                return allowed;
136:            }
137:
138:            /**
139:             * {@inheritDoc}
140:             * 
141:             * Checks that this can be returned as a valid instance of
142:             * {@link WizardReference}.
143:             */
144:            public boolean checkReference(String ref) {
145:                return (WizardReference.getReference(ref) != null ? true
146:                        : false);
147:            }
148:
149:            public List<TaggableActivity> getActivities(String context,
150:                    TaggingProvider provider) {
151:                // We aren't picky about the provider, so ignore that argument.
152:                List<TaggableActivity> activities = new ArrayList<TaggableActivity>();
153:                for (WizardPageDefinition def : wizardManager
154:                        .findWizardPageDefs(context, true)) {
155:                    activities.add(getActivity(def));
156:                }
157:                return activities;
158:            }
159:
160:            public TaggableActivity getActivity(String activityRef,
161:                    TaggingProvider provider) {
162:                // We aren't picky about the provider, so ignore that argument.
163:                TaggableActivity activity = null;
164:                if (checkReference(activityRef)) {
165:                    WizardReference reference = WizardReference
166:                            .getReference(activityRef);
167:                    if (reference != null) {
168:                        WizardPageDefinition def = wizardManager
169:                                .getWizardPageDefinition(idManager
170:                                        .getId(reference.getId()), true);
171:                        activity = getActivity(def);
172:                    }
173:                }
174:                return activity;
175:            }
176:
177:            public TaggableActivity getActivity(
178:                    WizardPageDefinition wizardPageDef) {
179:                return new WizardActivityImpl(wizardPageDef, this );
180:            }
181:
182:            public String getContext(String ref) {
183:                String context = null;
184:                WizardReference reference = WizardReference.getReference(ref);
185:                if (reference != null) {
186:                    if (WizardReference.REF_DEF.equals(reference.getType())) {
187:                        context = wizardManager.getWizardPageDefinition(
188:                                idManager.getId(reference.getId())).getSiteId();
189:                    } else {
190:                        context = matrixManager.getWizardPage(
191:                                idManager.getId(reference.getId()))
192:                                .getPageDefinition().getSiteId();
193:                    }
194:                }
195:                return context;
196:            }
197:
198:            public String getId() {
199:                return WizardActivityProducer.PRODUCER_ID;
200:            }
201:
202:            public TaggableItem getItem(String itemRef, TaggingProvider provider) {
203:                TaggableItem item = null;
204:                if (checkReference(itemRef)) {
205:                    // Only return item to a specified rating (evalutation) provider
206:                    if (ratingProviderIds.contains(provider.getId())) {
207:                        WizardReference reference = WizardReference
208:                                .getReference(itemRef);
209:                        if (reference != null) {
210:                            WizardPage page = matrixManager
211:                                    .getWizardPage(idManager.getId(reference
212:                                            .getId()));
213:                            if (page != null
214:                                    && (page
215:                                            .getStatus()
216:                                            .equals(
217:                                                    MatrixFunctionConstants.PENDING_STATUS) || page
218:                                            .getStatus()
219:                                            .equals(
220:                                                    MatrixFunctionConstants.COMPLETE_STATUS))
221:                                    && (page
222:                                            .getOwner()
223:                                            .getId()
224:                                            .getValue()
225:                                            .equals(
226:                                                    sessionManager
227:                                                            .getCurrentSessionUserId()) || canEvaluate(page))) {
228:                                item = getItem(page);
229:                            }
230:                        }
231:                    } else {
232:                        // Notify other tagging providers that they aren't accepted here
233:                        // yet
234:                        logger.warn(this  + ".getItem(): Provider with id "
235:                                + provider.getId() + " not allowed!");
236:                    }
237:                }
238:                return item;
239:            }
240:
241:            public TaggableItem getItem(WizardPage wizardPage) {
242:                return new WizardItemImpl(wizardPage, getActivity(wizardPage
243:                        .getPageDefinition()));
244:            }
245:
246:            public List<TaggableItem> getItems(TaggableActivity activity,
247:                    String userId, TaggingProvider provider) {
248:                List<TaggableItem> items = new ArrayList<TaggableItem>();
249:                // Return custom list of items to rating providers. This
250:                // list should match that seen in the evaluation item list (?)
251:                if (ratingProviderIds.contains(provider.getId())) {
252:                    WizardPageDefinition def = (WizardPageDefinition) activity
253:                            .getObject();
254:                    for (Iterator<WizardPage> i = def.getPages().iterator(); i
255:                            .hasNext();) {
256:                        // Make sure this page is evaluatable by the current
257:                        // user
258:                        WizardPage page = i.next();
259:                        if (page != null
260:                                && (page.getStatus().equals(
261:                                        MatrixFunctionConstants.PENDING_STATUS) || page
262:                                        .getStatus()
263:                                        .equals(
264:                                                MatrixFunctionConstants.COMPLETE_STATUS))
265:                                && (page.getOwner().getId().getValue().equals(
266:                                        userId) || canEvaluate(page))) {
267:                            items.add(getItem(page));
268:                            // There is only one submitted page per definition, so break
269:                            // here
270:                            break;
271:                        }
272:                    }
273:                } else {
274:                    // Notify other tagging providers that they aren't accepted here yet
275:                    logger.warn(this  + ".getItems() 2: Provider with id "
276:                            + provider.getId() + " not allowed!");
277:                }
278:                return items;
279:            }
280:
281:            public List<TaggableItem> getItems(TaggableActivity activity,
282:                    TaggingProvider provider) {
283:                List<TaggableItem> items = new ArrayList<TaggableItem>();
284:                // Only return items to a specified rating provider
285:                if (ratingProviderIds.contains(provider.getId())) {
286:                    WizardPageDefinition def = (WizardPageDefinition) activity
287:                            .getObject();
288:                    for (Iterator<WizardPage> i = def.getPages().iterator(); i
289:                            .hasNext();) {
290:                        // Make sure this page is evaluatable by the current
291:                        // user
292:                        WizardPage page = i.next();
293:                        if (page != null
294:                                && (page.getStatus().equals(
295:                                        MatrixFunctionConstants.PENDING_STATUS) || page
296:                                        .getStatus()
297:                                        .equals(
298:                                                MatrixFunctionConstants.COMPLETE_STATUS))
299:                                && canEvaluate(page)) {
300:                            items.add(getItem(page));
301:                        }
302:                    }
303:                } else {
304:                    // Notify other tagging providers that they aren't accepted here yet
305:                    logger.warn(this  + ".getItems(): Provider with id "
306:                            + provider.getId() + " not allowed!");
307:                }
308:                return items;
309:            }
310:
311:            public String getName() {
312:                return messages.getString("service_name");
313:            }
314:
315:            public List<String> getRatingProviderIds() {
316:                return ratingProviderIds;
317:            }
318:
319:            public void init() {
320:                logger.info("init()");
321:
322:                taggingManager.registerProducer(this );
323:            }
324:
325:            public void setAuthzManager(AuthorizationFacade authzManager) {
326:                this .authzManager = authzManager;
327:            }
328:
329:            public void setIdManager(IdManager idManager) {
330:                this .idManager = idManager;
331:            }
332:
333:            public void setMatrixManager(MatrixManager matrixManager) {
334:                this .matrixManager = matrixManager;
335:            }
336:
337:            public void setRatingProviderIds(List<String> ratingProviderIds) {
338:                this .ratingProviderIds = ratingProviderIds;
339:            }
340:
341:            public void setSessionManager(SessionManager sessionManager) {
342:                this .sessionManager = sessionManager;
343:            }
344:
345:            public void setTaggingManager(TaggingManager taggingManager) {
346:                this .taggingManager = taggingManager;
347:            }
348:
349:            public void setWizardManager(WizardManager wizardManager) {
350:                this.wizardManager = wizardManager;
351:            }
352:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.