source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java@ 29307

Last change on this file since 29307 was 25538, checked in by sjm84, 12 years ago

A collection constructor can now be given a manifest file (for importing)

  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1package org.greenstone.gsdl3.build;
2
3import java.io.File;
4
5import org.greenstone.gsdl3.util.*;
6//import java.util.Thread
7import javax.swing.event.EventListenerList;
8import org.w3c.dom.Element;
9
10/** base class for collection construction */
11public abstract class CollectionConstructor extends Thread
12{
13
14 /** the site in which building is to take place */
15 protected String site_home = null;
16 /** the name of the site */
17 protected String site_name = null;
18 /** the name of the collection */
19 protected String collection_name = null;
20 /** the stage of construction */
21 protected int process_type = -1;
22 /** other arguments/parameters for the construction process - in a paramList */
23 protected Element process_params = null;
24 /** the list of listeners for the process */
25 protected EventListenerList listeners = null;
26 /** A flag used to determine if this process has been asked to cancel. */
27 protected boolean cancel = false;
28 /** Stores the name of the manifest file (if one is needed) */
29 protected String manifest_file = null;
30
31 public CollectionConstructor(String name)
32 {
33 super(name);
34 this.listeners = new EventListenerList();
35 }
36
37 /**
38 * carry out any set up stuff - returns false if couldn't set up properly
39 */
40 public boolean configure()
41 {
42 return true;
43 }
44
45 public void stopAction()
46 {
47 this.cancel = true;
48 }
49
50 public void setActionType(int type)
51 {
52 this.process_type = type;
53 }
54
55 public void setSiteHome(String site_home)
56 {
57 this.site_home = site_home;
58
59 File siteHomeFile = new File(site_home);
60 this.site_name = siteHomeFile.getName();
61 }
62
63 public void setCollectionName(String coll_name)
64 {
65 this.collection_name = coll_name;
66 }
67
68 public void setProcessParams(Element params)
69 {
70 this.process_params = params;
71 }
72
73 public void setManifestFile(String manifestFile)
74 {
75 this.manifest_file = manifestFile;
76 }
77
78 public boolean addListener(ConstructionListener listener)
79 {
80 this.listeners.add(ConstructionListener.class, listener);
81 return true;
82 }
83
84 public boolean removeListener(ConstructionListener listener)
85 {
86 this.listeners.remove(ConstructionListener.class, listener);
87 return true;
88 }
89
90 protected void sendProcessBegun(ConstructionEvent evt)
91 {
92 Object[] concerned = this.listeners.getListenerList();
93 for (int i = 0; i < concerned.length; i += 2)
94 {
95 if (concerned[i] == ConstructionListener.class)
96 {
97 ((ConstructionListener) concerned[i + 1]).processBegun(evt);
98 }
99 }
100 }
101
102 protected void sendProcessComplete(ConstructionEvent evt)
103 {
104 Object[] concerned = this.listeners.getListenerList();
105 for (int i = 0; i < concerned.length; i += 2)
106 {
107 if (concerned[i] == ConstructionListener.class)
108 {
109 ((ConstructionListener) concerned[i + 1]).processComplete(evt);
110 }
111 }
112 }
113
114 protected void sendProcessStatus(ConstructionEvent evt)
115 {
116
117 Object[] concerned = this.listeners.getListenerList();
118 for (int i = 0; i < concerned.length; i += 2)
119 {
120 if (concerned[i] == ConstructionListener.class)
121 {
122 ((ConstructionListener) concerned[i + 1]).processStatus(evt);
123 }
124 }
125 }
126
127 protected void sendMessage(ConstructionEvent evt)
128 {
129
130 Object[] concerned = this.listeners.getListenerList();
131 for (int i = 0; i < concerned.length; i += 2)
132 {
133 if (concerned[i] == ConstructionListener.class)
134 {
135 ((ConstructionListener) concerned[i + 1]).message(evt);
136 }
137 }
138 }
139
140 abstract public void run();
141}
Note: See TracBrowser for help on using the repository browser.