JAL-3746 apply copyright to source
[jalview.git] / src / jalview / fts / service / threedbeacons / TDB_FTSData.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.fts.service.threedbeacons;
22
23 import java.util.Map;
24 import java.util.Objects;
25
26 import jalview.fts.api.FTSData;
27
28 /**
29  * TDB result bean - holds filtered fields for GUI and essential metadata fields
30  * for back end
31  * 
32  * @author jprocter
33  *
34  */
35 public class TDB_FTSData implements FTSData
36 {
37   String primaryKey;
38
39   Object[] summaryRowData;
40
41   /*
42    * fields in the JSON object 
43    */
44   public static String Uniprot_Id = "id";
45
46   public static String Uniprot_Start = "uniprot_start";
47
48   public static String Uniprot_End = "uniprot_end";
49
50   public static String Provider = "provider";
51
52   public static String Model_id = "model_identifier";
53
54   public static String Model_Category = "model_category";
55
56   public static String Model_Type = "model_type";
57
58   public static String Model_Title = "model_title";
59
60   public static String Resolution = "resolution";
61
62   public static String Confidence = "confidence_avg_local_score";
63
64   public static String Confidence_Score_Type = "confidence_type";
65
66   public static String Confidence_Score_Version = "confidence_version";
67
68   public static String Coverage = "coverage";
69
70   public static String Sequence_Identity = "sequence_identity";
71
72   public static String Created_Date = "created";
73
74   public static String UniProt_Accession = "uniprot_accession";
75
76   public static String Url = "model_url";
77
78   public static String Page_URL = "model_page_url";
79
80   public static String Ensemble_Sample_Url = "ensembl_sample_url";
81
82   /**
83    * original response from server
84    */
85   Map<String, Object> tdb_entry;
86
87   public TDB_FTSData(String primaryKey,
88           Map<String, Object> tdbJsonStructure, Object[] summaryData)
89   {
90     this.primaryKey = primaryKey;
91     tdb_entry = tdbJsonStructure;
92     this.summaryRowData = summaryData;
93   }
94
95   public Object getField(String key)
96   {
97     return tdb_entry.get(key);
98   }
99
100   @Override
101   public Object[] getSummaryData()
102   {
103     return summaryRowData;
104   }
105
106   @Override
107   public Object getPrimaryKey()
108   {
109     return primaryKey;
110   }
111
112   /**
113    * Returns a string representation of this object;
114    */
115   @Override
116   public String toString()
117   {
118     StringBuilder summaryFieldValues = new StringBuilder();
119     for (Object summaryField : summaryRowData)
120     {
121       summaryFieldValues
122               .append(summaryField == null ? " " : summaryField.toString())
123               .append("\t");
124     }
125     return summaryFieldValues.toString();
126   }
127
128   /**
129    * Returns hash code value for this object
130    */
131   @Override
132   public int hashCode()
133   {
134     return Objects.hash(primaryKey, this.toString());
135   }
136
137   @Override
138   public boolean equals(Object that)
139   {
140     return this.toString().equals(that.toString());
141   }
142
143   public String getProvider()
144   {
145     return (String) getField(Provider);
146   }
147
148   public String getModelViewUrl()
149   {
150     return (String) getField(Page_URL);
151   }
152
153   public String getModelId()
154   {
155     return (String) getField(Model_id);
156   }
157
158 }