Das client files
[jalview.git] / src / org / biojava / dasobert / dasregistry / DasCoordinateSystem.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
27 /** a Bean to be returned via SOAP. It takes care of the DAS -  coordinate Systems 
28  * @author Andreas Prlic
29  */
30 public class DasCoordinateSystem {
31
32     String name;
33     String category;
34     String organism_name;
35     int ncbi_tax_id ;
36     String uniqueId ;
37     String version;
38     String testCode;
39     
40     public DasCoordinateSystem () {
41         uniqueId = "";
42         name = "";
43         category ="";
44         organism_name = "";
45         ncbi_tax_id = 0;
46         version = "";
47         testCode = "";
48     }
49
50     public boolean equals(DasCoordinateSystem other){
51         boolean match = true;
52         System.out.println("comparing " + this.toString() + " to " + other.toString());
53         // URI has piority 
54         if ( (! uniqueId.equals("")) && ( uniqueId.equals( other.getUniqueId())))
55             return true;
56         
57         if ( ncbi_tax_id != other.getNCBITaxId()) {
58             System.out.println("mismatch in ncbi tax id " + ncbi_tax_id + " != " + other.getNCBITaxId());
59             match = false;
60         }
61         if ( ! version.equals(other.getVersion() )){
62             System.out.println("mismatch in version");
63             match = false;
64         }
65         if ( ! category.equals(other.getCategory())  ) {
66             System.out.println("mismatch in category");
67             match = false;
68         }
69         if ( ! name.equals(other.getName())) {
70             System.out.println("mismatch in name");   
71             match = false;
72         }
73         System.out.println(" match: " + match);
74         
75         return match;
76     }
77     
78     public Object clone() {
79         DasCoordinateSystem d = new DasCoordinateSystem();
80         d.setTestCode(testCode);
81         d.setCategory(category);
82         d.setName(name);
83         d.setNCBITaxId(ncbi_tax_id);
84         d.setUniqueId(getUniqueId());
85         d.setOrganismName(getOrganismName());
86         d.setVersion(getVersion());
87         return d;
88     }
89     
90     public String getTestCode() {
91         return testCode;
92     }
93
94
95
96     public void setTestCode(String testCode) {
97         if ( testCode == null)
98             testCode = "";
99         this.testCode = testCode;
100     }
101
102
103
104     public void setUniqueId(String id) { uniqueId = id ;   }
105     public String getUniqueId() { return uniqueId;         }
106
107     public void setName(String n) { name = n; }
108     public String getName() { return name; }
109     
110     public void setCategory(String c) { category = c;}
111     public String getCategory() { return category;}
112
113     public void setOrganismName(String t) { organism_name  =t;} 
114     public String getOrganismName() { return organism_name;}
115
116     public void setNCBITaxId(int id) { ncbi_tax_id = id;}
117     public int getNCBITaxId(){ return ncbi_tax_id ;}
118     
119     
120     
121
122     public String getVersion() {
123         return version;
124     }
125
126     public void setVersion(String version) {
127         if ( version == null)
128             version = "";
129         this.version = version;
130     }
131
132     public String toString() {
133         String nam = name;
134         if ( ! version.equals(""))
135             nam += "_" + version;
136         
137         if ( organism_name.equals("") ) 
138             return nam+","+category ;
139         else 
140             return nam+","+category+"," + organism_name ;
141     }
142
143     public static DasCoordinateSystem fromString(String rawString) {
144         String[] spl = rawString.split(",");
145         DasCoordinateSystem dcs = new DasCoordinateSystem();
146         if ( spl.length == 2 ) {
147             dcs.setName(spl[0]);           
148             dcs.setCategory(spl[1]);
149         } 
150         if ( spl.length == 3 ) {
151             dcs.setName(spl[0]);
152             dcs.setCategory(spl[1]);
153             dcs.setOrganismName(spl[2]);
154         }
155         return dcs;
156     }
157
158
159 }