01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/archive/tags/sakai_2-4-1/import-impl/src/java/org/sakaiproject/importer/impl/BasicImportDataSource.java $
03: * $Id: BasicImportDataSource.java 17726 2006-11-01 15:39:28Z lance@indiana.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2006 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.importer.impl;
21:
22: import java.util.ArrayList;
23: import java.util.Collection;
24: import java.util.HashSet;
25: import java.util.Iterator;
26: import java.util.List;
27: import java.util.Set;
28:
29: import org.sakaiproject.archive.api.ImportMetadata;
30: import org.sakaiproject.importer.api.ImportDataSource;
31: import org.sakaiproject.importer.api.Importable;
32:
33: public class BasicImportDataSource implements ImportDataSource {
34:
35: private List itemCategories;
36: private Collection items;
37:
38: public List getItemCategories() {
39: return itemCategories;
40: }
41:
42: public void setItemCategories(List itemCategories) {
43: this .itemCategories = itemCategories;
44: }
45:
46: public Collection getItemsForCategories(List categories) {
47: Collection rv = new ArrayList();
48: // create the Set of selected archive items
49: Set selectedCategories = new HashSet();
50: for (Iterator iter = categories.iterator(); iter.hasNext();) {
51: selectedCategories.add(((ImportMetadata) iter.next())
52: .getLegacyTool());
53: }
54:
55: Importable item;
56: for (Iterator iter = items.iterator(); iter.hasNext();) {
57: item = (Importable) iter.next();
58: if ("".equals(item.getLegacyGroup())
59: || selectedCategories.contains(item
60: .getLegacyGroup())) {
61: rv.add(item);
62: }
63: }
64: return rv;
65: }
66:
67: public void setItems(Collection items) {
68: this.items = items;
69: }
70:
71: }
|