Readded
[jalview.git] / src / jalview / 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.Date ;
27 import java.io.IOException;
28 import java.io.PrintWriter;
29 import java.io.StringWriter;
30
31
32 //import org.biojava.dasobert.das2.io.DasSourceWriter;
33 //import org.biojava.dasobert.das2.io.DasSourceWriterImpl;
34 //import org.biojava.utils.xml.PrettyXMLWriter;
35
36
37 /** a simple Bean class to be returned via SOAP
38  * @author Andreas Prlic
39  */
40
41 public class Das1Source implements DasSource {
42     String url                ;
43     protected String nickname           ;
44     String adminemail         ;
45     String description        ;
46     DasCoordinateSystem[] coordinateSystem ;
47     String[] capabilities     ;
48     String[] labels           ;
49     String helperurl          ;
50     Date   registerDate       ;
51     Date   leaseDate          ;
52     String id                 ;
53     boolean local;
54
55     boolean alertAdmin;
56
57     public static String EMPTY_ID = "UNK:-1" ;
58
59     public Das1Source () {
60         id               = EMPTY_ID;
61         url              = "";
62         adminemail       = "" ;
63         description      = "" ;
64         //String empty     = "" ;
65         nickname         = "" ;
66         coordinateSystem = new DasCoordinateSystem[0];
67         //coordinateSystem[0] = new DasCoordinateSystem();
68         capabilities     =  new String[0];
69         labels           = new String[0];
70         //capabilities[0]  = empty ;
71         registerDate     = new Date() ;
72         leaseDate        = new Date() ;
73         helperurl        = "";
74         local=true;
75     }
76
77
78     public boolean equals(DasSource other){
79         System.out.println("Das1Source equals, comparing with other DasSource");
80         if (! (other instanceof Das1Source))
81             return false;
82
83         Das1Source ods = (Das1Source) other;
84
85         if ( ods.getUrl().equals(url))
86             return true;
87         if ( ods.getNickname().equals(nickname))
88             return true;
89         return false;
90     }
91
92     public int hashCode() {
93         int h = 7;
94
95         h = 31 * h + ( null == nickname ? 0 : nickname.hashCode());
96         h = 31 * h + ( null == url ? 0 : url.hashCode());
97
98         return h;
99     }
100
101     /** the DAS2 string representation of this DAS source
102      *
103     public String toString() {
104
105         StringWriter writer = new StringWriter();
106
107         PrintWriter pw = new PrintWriter(writer);
108         PrettyXMLWriter xw = new PrettyXMLWriter(pw);
109
110         DasSourceWriter dswriter = new DasSourceWriterImpl();
111         try {
112             dswriter.writeDasSource(xw,this);
113         } catch (IOException e){
114             e.printStackTrace();
115         }
116
117         return writer.toString();
118
119     }
120     */
121     public void setLocal(boolean flag){ local = flag;}
122     public boolean isLocal(){return local;}
123
124     public void setId(String i) { id = i; }
125
126     /** get a the Id of the DasSource. The Id is a unique db
127      * identifier. The public DAS-Registry has Auto_Ids that look like
128      * DASSOURCE:12345; public look like XYZ:12345, where the XYZ
129      * prefix can be configured in the config file.
130      */
131     public String getId() { return id;}
132
133     public void setNickname(String name) {
134         nickname = name ;
135     }
136     public String getNickname(){
137         return nickname;
138     }
139     public void setUrl(String u) {
140         char lastChar = u.charAt(u.length()-1);
141         if ( lastChar  != '/')
142             u += "/";
143
144         url = u ;
145     }
146
147     public void setAdminemail (String u) {
148         adminemail = u ;
149     }
150
151     public void setDescription (String u) {
152         description = u;
153     }
154
155     public void setCoordinateSystem (DasCoordinateSystem[] u){
156         coordinateSystem=u ;
157     }
158
159     public void setCapabilities (String[] u){
160         capabilities = u ;
161     }
162
163     public String getUrl(){return url;}
164     public String getAdminemail(){return adminemail;}
165     public String getDescription(){return description;}
166     public String[] getCapabilities(){return capabilities;}
167     public DasCoordinateSystem[] getCoordinateSystem(){return coordinateSystem;}
168
169     public void setRegisterDate(Date d) {
170         registerDate = d;
171     }
172     public Date getRegisterDate() {
173         return registerDate ;
174     }
175     public void setLeaseDate(Date d) {
176         leaseDate =d ;
177     }
178     public Date getLeaseDate() {
179         return leaseDate ;
180     }
181
182     public void setLabels(String[] ls) {
183         labels = ls ;
184     }
185
186     public String[] getLabels() {
187         return labels;
188     }
189
190     public void setHelperurl(String url) {
191         helperurl = url;
192     }
193
194     public String getHelperurl() {
195         return helperurl;
196     }
197
198     public void setAlertAdmin(boolean flag) {
199         alertAdmin = flag;
200     }
201
202     public boolean getAlertAdmin() {
203         return alertAdmin;
204     }
205
206 }