001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/common/api-impl/src/java/org/theospi/portfolio/list/impl/BaseListGenerator.java $
003: * $Id:BaseListGenerator.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 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.list.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.metaobj.shared.mgt.IdManager;
029: import org.theospi.portfolio.list.intf.CustomLinkListGenerator;
030: import org.theospi.portfolio.list.intf.ListGenerator;
031: import org.theospi.portfolio.list.intf.ListService;
032: import org.theospi.portfolio.list.model.ColumnConfig;
033:
034: /**
035: * Created by IntelliJ IDEA.
036: * User: John Ellis
037: * Date: Feb 10, 2006
038: * Time: 3:15:45 PM
039: * To change this template use File | Settings | File Templates.
040: */
041: public abstract class BaseListGenerator implements
042: CustomLinkListGenerator {
043: private String listGeneratorId;
044: private ListService listService;
045: private ListGenerator listGenerator;
046: private List columnConfig;
047: private IdManager idManager;
048:
049: protected final Log logger = LogFactory.getLog(getClass());
050:
051: public void init() {
052: listService.register(listGeneratorId, listGenerator);
053: }
054:
055: public String getListGeneratorId() {
056: return listGeneratorId;
057: }
058:
059: public void setListGeneratorId(String listGeneratorId) {
060: this .listGeneratorId = listGeneratorId;
061: }
062:
063: public ListService getListService() {
064: return listService;
065: }
066:
067: public void setListService(ListService listService) {
068: this .listService = listService;
069: }
070:
071: public ListGenerator getListGenerator() {
072: return listGenerator;
073: }
074:
075: public void setListGenerator(ListGenerator listGenerator) {
076: this .listGenerator = listGenerator;
077: }
078:
079: public List getColumns() {
080: List columns = new ArrayList();
081: for (Iterator i = getColumnConfig().iterator(); i.hasNext();) {
082: ColumnConfig config = (ColumnConfig) i.next();
083: columns.add(config.getColumnName());
084: }
085: return columns;
086: }
087:
088: public List getDefaultColumns() {
089: List defaultColumns = new ArrayList();
090: for (Iterator i = getColumnConfig().iterator(); i.hasNext();) {
091: ColumnConfig config = (ColumnConfig) i.next();
092: if (config.isDefaultSelected())
093: defaultColumns.add(config.getColumnName());
094: }
095: return defaultColumns;
096: }
097:
098: public List getSortableColumns() {
099: List sortableColumns = new ArrayList();
100: for (Iterator i = getColumnConfig().iterator(); i.hasNext();) {
101: ColumnConfig config = (ColumnConfig) i.next();
102: if (config.isSortable())
103: sortableColumns.add(config.getColumnName());
104: }
105: return sortableColumns;
106: }
107:
108: public String getDefaultSortColumn() {
109: String retCol = null;
110: for (Iterator i = getColumnConfig().iterator(); i.hasNext();) {
111: ColumnConfig config = (ColumnConfig) i.next();
112: if (config.isSortable() && config.isDefaultSort()) {
113: retCol = config.getColumnName();
114: break;
115: }
116: }
117: return retCol;
118: }
119:
120: public List getBundleLookupColumns() {
121: List lookupColumns = new ArrayList();
122: for (Iterator i = getColumnConfig().iterator(); i.hasNext();) {
123: ColumnConfig config = (ColumnConfig) i.next();
124: if (config.isLookupInBundle()) {
125: lookupColumns.add(config.getColumnName());
126: }
127: }
128: return lookupColumns;
129: }
130:
131: /**
132: * @return the columnConfig
133: */
134: public List getColumnConfig() {
135: return columnConfig;
136: }
137:
138: /**
139: * @param columnConfig the columnConfig to set
140: */
141: public void setColumnConfig(List columnConfig) {
142: this .columnConfig = columnConfig;
143: }
144:
145: /**
146: * @return the idManager
147: */
148: public IdManager getIdManager() {
149: return idManager;
150: }
151:
152: /**
153: * @param idManager the idManager to set
154: */
155: public void setIdManager(IdManager idManager) {
156: this.idManager = idManager;
157: }
158: }
|