01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/site-manage/tags/sakai_2-4-1/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/SectionFieldManagerImpl.java $
03: * $Id: SectionFieldManagerImpl.java 23019 2007-03-19 22:38:21Z jholtzman@berkeley.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2007 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.sakaiproject.sitemanage.impl;
21:
22: import java.util.ArrayList;
23: import java.util.List;
24:
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27: import org.sakaiproject.sitemanage.api.SectionField;
28: import org.sakaiproject.sitemanage.api.SectionFieldManager;
29: import org.sakaiproject.util.ResourceLoader;
30:
31: public class SectionFieldManagerImpl implements SectionFieldManager {
32: private static final Log log = LogFactory
33: .getLog(SectionFieldManagerImpl.class);
34:
35: public List<SectionField> getRequiredFields() {
36: ResourceLoader resourceLoader = new ResourceLoader(
37: "SectionFields");
38: List<SectionField> fieldList = new ArrayList<SectionField>();
39:
40: fieldList.add(new SectionFieldImpl(resourceLoader
41: .getString("required_fields_subject"), null, 8));
42: fieldList.add(new SectionFieldImpl(resourceLoader
43: .getString("required_fields_course"), null, 3));
44: fieldList.add(new SectionFieldImpl(resourceLoader
45: .getString("required_fields_section"), null, 3));
46:
47: return fieldList;
48: }
49:
50: public String getSectionEid(String academicSessionEid,
51: List<SectionField> fields) {
52: if (fields == null || fields.isEmpty()) {
53: if (log.isDebugEnabled())
54: log
55: .debug("Returning an empty sectionEID for an empty (or null) list of fields");
56: return "";
57: }
58:
59: String[] values = new String[fields.size() + 1];
60: for (int i = 0; i < fields.size(); i++) {
61: SectionField sf = fields.get(i);
62: values[i] = sf.getValue();
63: }
64: values[fields.size()] = academicSessionEid;
65:
66: ResourceLoader resourceLoader = new ResourceLoader(
67: "SectionFields");
68: String sectionEid = resourceLoader.getFormattedMessage(
69: "section_eid", values);
70: if (log.isDebugEnabled())
71: log.debug("Generated section eid = " + sectionEid);
72: return sectionEid;
73: }
74:
75: public void init() {
76: }
77:
78: public void destroy() {
79: }
80:
81: }
|