01: /**********************************************************************************
02: *
03: * $Id: FrameworkManagerSectionsImpl.java 18134 2006-11-14 18:59:25Z jholtzman@berkeley.edu $
04: *
05: ***********************************************************************************
06: *
07: * Copyright (c) 2005, 2006 The Regents of the University of California, The MIT Corporation
08: *
09: * Licensed under the Educational Community License, Version 1.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.opensource.org/licenses/ecl1.php
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: *
21: **********************************************************************************/package org.sakaiproject.tool.gradebook.ui.standalone;
22:
23: import java.util.ArrayList;
24: import java.util.Iterator;
25: import java.util.List;
26:
27: import org.apache.commons.logging.Log;
28: import org.apache.commons.logging.LogFactory;
29: import org.sakaiproject.section.api.coursemanagement.Course;
30: import org.sakaiproject.section.api.coursemanagement.ParticipationRecord;
31: import org.sakaiproject.component.section.support.IntegrationSupport;
32: import org.sakaiproject.service.gradebook.shared.GradebookNotFoundException;
33: import org.sakaiproject.tool.gradebook.Gradebook;
34: import org.sakaiproject.tool.gradebook.business.GradebookManager;
35:
36: public class FrameworkManagerSectionsImpl implements FrameworkManager {
37: private static Log log = LogFactory
38: .getLog(FrameworkManagerSectionsImpl.class);
39:
40: private IntegrationSupport integrationSupport;
41: private GradebookManager gradebookManager;
42:
43: public List getAccessibleGradebooks(String userUid) {
44: List gradebooks = new ArrayList();
45: List siteMemberships = integrationSupport
46: .getAllSiteMemberships(userUid);
47: for (Iterator iter = siteMemberships.iterator(); iter.hasNext();) {
48: ParticipationRecord participationRecord = (ParticipationRecord) iter
49: .next();
50: Course course = (Course) participationRecord
51: .getLearningContext();
52: String siteContext = course.getSiteContext();
53: Gradebook gradebook = null;
54: try {
55: gradebook = getGradebookManager().getGradebook(
56: siteContext);
57: gradebooks.add(gradebook);
58: } catch (GradebookNotFoundException gnfe) {
59: if (log.isInfoEnabled())
60: log.info("no gradebook found for " + siteContext);
61: }
62: }
63: return gradebooks;
64: }
65:
66: public IntegrationSupport getIntegrationSupport() {
67: return integrationSupport;
68: }
69:
70: public void setIntegrationSupport(
71: IntegrationSupport integrationSupport) {
72: this .integrationSupport = integrationSupport;
73: }
74:
75: public GradebookManager getGradebookManager() {
76: return gradebookManager;
77: }
78:
79: public void setGradebookManager(GradebookManager gradebookManager) {
80: this.gradebookManager = gradebookManager;
81: }
82:
83: }
|