source: other-projects/GlamED/trunk/src/org/honours/collection/Collection.java@ 26588

Last change on this file since 26588 was 26588, checked in by davidb, 11 years ago

Initial import of Korii's 520 project for managing digital cultural collections from Greenstone in Expeditee.

File size: 2.2 KB
Line 
1package org.honours.collection;
2
3import java.util.List;
4import java.util.concurrent.CopyOnWriteArrayList;
5
6import org.expeditee.gui.Frame;
7import org.honours.Main;
8
9public class Collection {
10
11 private String _name;
12 private CopyOnWriteArrayList<CollectionItem> _items;
13 private CollectionInformation _collectionInfo;
14
15 public Collection() {}
16
17 public Collection(String name){
18 _name = name;
19 _items = new CopyOnWriteArrayList<CollectionItem>();
20 }
21
22 public void setName(String s){
23 _name = s;
24 }
25
26 public String getName(){
27 return _name;
28 }
29
30 public void setCollectionInformation(CollectionInformation ci){
31 _collectionInfo = ci;
32 }
33
34 public CollectionInformation getCollectionInformation(){
35 return _collectionInfo;
36 }
37
38 public void addItem(CollectionItem item){
39 _items.add(item);
40 }
41
42 public List<CollectionItem> getItems()
43 {
44 return _items;
45 }
46
47 public void resetItems(){
48 //_items = new ArrayList<CollectionItem>();
49 _items = new CopyOnWriteArrayList<CollectionItem>();
50 }
51
52public static Collection findCollection(Frame frame){
53
54 if(frame == null)
55 return null;
56
57 String framesetName = frame.getFramesetName();
58 for(Collection c : Main._collections){
59 if(c.getName().equals(framesetName))
60 return c;
61 }
62 return null;
63 }
64
65 /**
66 * Find a collection with the matching
67 * passed (frameset) name.
68 * @param name
69 * @return
70 */
71 public static Collection findCollection(String name){
72
73 if(name == null)
74 return null;
75 else if(name.equals(""))
76 return null;
77
78 for(Collection c : Main._collections){
79 if(c.getName().equals(name))
80 return c;
81 }
82
83 return null;
84 }
85
86 public static int getCollectionPosition(Collection c){
87
88 if(c == null)
89 return -1;
90
91 for(int i = 0; i < Main._collections.size(); i++){
92 Collection currCol = Main._collections.get(i);
93 if(currCol == c)
94 return i;
95 }
96
97 return -1;
98 }
99
100 public static int getCollectionPosition(Frame frame){
101 Collection find = findCollection(frame);
102 if(find == null)
103 return -1;
104
105 for(int i = 0; i < Main._collections.size(); i++){
106
107 Collection currCol = Main._collections.get(i);
108 if(currCol == find)
109 return i;
110
111 }
112
113 return -1;
114 }
115
116}
Note: See TracBrowser for help on using the repository browser.