01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.datadictionary.exporter;
17:
18: import java.util.Iterator;
19: import java.util.Map;
20:
21: import org.kuali.core.datadictionary.CollectionDefinition;
22: import org.kuali.core.datadictionary.DataDictionaryEntryBase;
23:
24: /**
25: * CollectionsMapBuilder
26: *
27: *
28: */
29: public class CollectionsMapBuilder {
30:
31: /**
32: * Default constructor
33: */
34: public CollectionsMapBuilder() {
35: }
36:
37: /**
38: * @param entry
39: * @return ExportMap containing the standard entries for the entry's CollectionsDefinition
40: */
41: public ExportMap buildCollectionsMap(DataDictionaryEntryBase entry) {
42: ExportMap collectionsMap = new ExportMap("collections");
43:
44: for (Iterator i = entry.getCollections().entrySet().iterator(); i
45: .hasNext();) {
46: Map.Entry e = (Map.Entry) i.next();
47:
48: CollectionDefinition collection = (CollectionDefinition) e
49: .getValue();
50: collectionsMap.set(buildCollectionMap(collection));
51: }
52:
53: return collectionsMap;
54: }
55:
56: private ExportMap buildCollectionMap(CollectionDefinition collection) {
57: ExportMap collectionMap = new ExportMap(collection.getName());
58:
59: collectionMap.set("name", collection.getName());
60: collectionMap.set("label", collection.getLabel());
61: collectionMap.set("shortLabel", collection.getShortLabel());
62: if (collection.getSummary() != null) {
63: collectionMap.set("summary", collection.getSummary());
64: }
65: if (collection.getDescription() != null) {
66: collectionMap.set("description", collection
67: .getDescription());
68: }
69:
70: return collectionMap;
71: }
72:
73: }
|