4b8ae2a10399dc1a088671b667a3492a6c7f4489
[jalview.git] / src / org / biojava / dasobert / dasregistry / Das1Source.java
1 /*
2  *                    BioJava development code
3  *
4  * This code may be freely distributed and modified under the
5  * terms of the GNU Lesser General Public Licence.  This should
6  * be distributed with the code.  If you do not have a copy,
7  * see:
8  *
9  *      http://www.gnu.org/copyleft/lesser.html
10  *
11  * Copyright for this code is held jointly by the individual
12  * authors.  These should be listed in @author doc comments.
13  *
14  * For more information on the BioJava project and its aims,
15  * or to join the biojava-l mailing list, visit the home page
16  * at:
17  *
18  *      http://www.biojava.org/
19  *
20  * Created on 15.04.2004
21  * @author Andreas Prlic
22  *
23  */
24 package org.biojava.dasobert.dasregistry;
25
26 import java.util.*;
27
28 //import org.biojava.dasobert.das2.io.DasSourceWriter;
29 //import org.biojava.dasobert.das2.io.DasSourceWriterImpl;
30 //import org.biojava.utils.xml.PrettyXMLWriter;
31
32
33 /** a simple Bean class to be returned via SOAP
34  * @author Andreas Prlic
35  */
36
37 public class Das1Source
38     implements DasSource
39 {
40   String url;
41   protected String nickname;
42   String adminemail;
43   String description;
44   DasCoordinateSystem[] coordinateSystem;
45   String[] capabilities;
46   String[] labels;
47   String helperurl;
48   Date registerDate;
49   Date leaseDate;
50   String id;
51   boolean local;
52
53   boolean alertAdmin;
54
55   public static String EMPTY_ID = "UNK:-1";
56
57   public Das1Source()
58   {
59     id = EMPTY_ID;
60     url = "";
61     adminemail = "";
62     description = "";
63     //String empty     = "" ;
64     nickname = "";
65     coordinateSystem = new DasCoordinateSystem[0];
66     //coordinateSystem[0] = new DasCoordinateSystem();
67     capabilities = new String[0];
68     labels = new String[0];
69     //capabilities[0]  = empty ;
70     registerDate = new Date();
71     leaseDate = new Date();
72     helperurl = "";
73     local = true;
74   }
75
76   public boolean equals(DasSource other)
77   {
78     System.out.println("Das1Source equals, comparing with other DasSource");
79     if (! (other instanceof Das1Source))
80     {
81       return false;
82     }
83
84     Das1Source ods = (Das1Source) other;
85
86     if (ods.getUrl().equals(url))
87     {
88       return true;
89     }
90     if (ods.getNickname().equals(nickname))
91     {
92       return true;
93     }
94     return false;
95   }
96
97   public int hashCode()
98   {
99     int h = 7;
100
101     h = 31 * h + (null == nickname ? 0 : nickname.hashCode());
102     h = 31 * h + (null == url ? 0 : url.hashCode());
103
104     return h;
105   }
106
107   /** the DAS2 string representation of this DAS source
108    *
109        public String toString() {
110
111       StringWriter writer = new StringWriter();
112
113       PrintWriter pw = new PrintWriter(writer);
114       PrettyXMLWriter xw = new PrettyXMLWriter(pw);
115
116       DasSourceWriter dswriter = new DasSourceWriterImpl();
117       try {
118           dswriter.writeDasSource(xw,this);
119       } catch (IOException e){
120           e.printStackTrace();
121       }
122
123       return writer.toString();
124
125        }
126    */
127   public void setLocal(boolean flag)
128   {
129     local = flag;
130   }
131
132   public boolean isLocal()
133   {
134     return local;
135   }
136
137   public void setId(String i)
138   {
139     id = i;
140   }
141
142   /** get a the Id of the DasSource. The Id is a unique db
143    * identifier. The public DAS-Registry has Auto_Ids that look like
144    * DASSOURCE:12345; public look like XYZ:12345, where the XYZ
145    * prefix can be configured in the config file.
146    */
147   public String getId()
148   {
149     return id;
150   }
151
152   public void setNickname(String name)
153   {
154     nickname = name;
155   }
156
157   public String getNickname()
158   {
159     return nickname;
160   }
161
162   public void setUrl(String u)
163   {
164     char lastChar = u.charAt(u.length() - 1);
165     if (lastChar != '/')
166     {
167       u += "/";
168     }
169
170     url = u;
171   }
172
173   public void setAdminemail(String u)
174   {
175     adminemail = u;
176   }
177
178   public void setDescription(String u)
179   {
180     description = u;
181   }
182
183   public void setCoordinateSystem(DasCoordinateSystem[] u)
184   {
185     coordinateSystem = u;
186   }
187
188   public void setCapabilities(String[] u)
189   {
190     capabilities = u;
191   }
192
193   public String getUrl()
194   {
195     return url;
196   }
197
198   public String getAdminemail()
199   {
200     return adminemail;
201   }
202
203   public String getDescription()
204   {
205     return description;
206   }
207
208   public String[] getCapabilities()
209   {
210     return capabilities;
211   }
212
213   public DasCoordinateSystem[] getCoordinateSystem()
214   {
215     return coordinateSystem;
216   }
217
218   public void setRegisterDate(Date d)
219   {
220     registerDate = d;
221   }
222
223   public Date getRegisterDate()
224   {
225     return registerDate;
226   }
227
228   public void setLeaseDate(Date d)
229   {
230     leaseDate = d;
231   }
232
233   public Date getLeaseDate()
234   {
235     return leaseDate;
236   }
237
238   public void setLabels(String[] ls)
239   {
240     labels = ls;
241   }
242
243   public String[] getLabels()
244   {
245     return labels;
246   }
247
248   public void setHelperurl(String url)
249   {
250     helperurl = url;
251   }
252
253   public String getHelperurl()
254   {
255     return helperurl;
256   }
257
258   public void setAlertAdmin(boolean flag)
259   {
260     alertAdmin = flag;
261   }
262
263   public boolean getAlertAdmin()
264   {
265     return alertAdmin;
266   }
267
268 }