--- /dev/null
+package jalview.fts.service.threedbeacons;
+
+import java.util.Map;
+import java.util.Objects;
+
+import jalview.fts.api.FTSData;
+
+/**
+ * TDB result bean - holds filtered fields for GUI and essential metadata fields
+ * for back end
+ *
+ * @author jprocter
+ *
+ */
+public class TDB_FTSData implements FTSData
+{
+ String primaryKey;
+
+ Object[] summaryRowData;
+
+ /*
+ * fields in the JSON object
+ */
+ public static String Uniprot_Id= "id";
+ public static String Uniprot_Start= "uniprot_start";
+ public static String Uniprot_End= "uniprot_end";
+ public static String Provider= "provider";
+ public static String Model_id= "model_identifier";
+ public static String Model_Category= "model_category";
+ public static String Model_Type= "model_type";
+ public static String Model_Title="model_title";
+ public static String Resolution= "resolution";
+ public static String Confidence= "confidence_avg_local_score";
+ public static String Confidence_Score_Type= "confidence_type";
+ public static String Confidence_Score_Version= "confidence_version";
+ public static String Coverage= "coverage";
+ public static String Sequence_Identity= "sequence_identity";
+ public static String Created_Date= "created";
+ public static String UniProt_Accession= "uniprot_accession";
+ public static String Url= "model_url";
+ public static String Page_URL= "model_page_url";
+ public static String Ensemble_Sample_Url= "ensembl_sample_url";
+
+ /**
+ * original response from server
+ */
+ Map<String, Object> tdb_entry;
+
+ public TDB_FTSData(String primaryKey,
+ Map<String, Object> tdbJsonStructure, Object[] summaryData)
+ {
+ this.primaryKey = primaryKey;
+ tdb_entry = tdbJsonStructure;
+ this.summaryRowData = summaryData;
+ }
+
+ public Object getField(String key)
+ {
+ return tdb_entry.get(key);
+ }
+
+ @Override
+ public Object[] getSummaryData()
+ {
+ return summaryRowData;
+ }
+
+ @Override
+ public Object getPrimaryKey()
+ {
+ return primaryKey;
+ }
+
+ /**
+ * Returns a string representation of this object;
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder summaryFieldValues = new StringBuilder();
+ for (Object summaryField : summaryRowData)
+ {
+ summaryFieldValues
+ .append(summaryField == null ? " " : summaryField.toString())
+ .append("\t");
+ }
+ return summaryFieldValues.toString();
+ }
+
+ /**
+ * Returns hash code value for this object
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(primaryKey, this.toString());
+ }
+
+ @Override
+ public boolean equals(Object that)
+ {
+ return this.toString().equals(that.toString());
+ }
+
+ public String getProvider()
+ {
+ return (String) getField(Provider);
+ }
+
+ public String getModelViewUrl()
+ {
+ return (String) getField(Page_URL);
+ }
+
+}
private static FTSData getFTSData(Map<String, Object> tdbJsonStructure,
FTSRestRequest tdbRequest)
{
- // TODO: consider reusing PDBFTSRestClient.getFTSData ?
-
String primaryKey = null;
Object[] summaryRowData;
final String primaryKey1 = primaryKey;
final Object[] summaryRowData1 = summaryRowData;
- return new FTSData()
- {
-
- @Override
- public Object[] getSummaryData()
- {
- return summaryRowData1;
- }
-
- @Override
- public Object getPrimaryKey()
- {
- return primaryKey1;
- }
-
- /**
- * Returns a string representation of this object;
- */
- @Override
- public String toString()
- {
- StringBuilder summaryFieldValues = new StringBuilder();
- for (Object summaryField : summaryRowData1)
- {
- summaryFieldValues.append(
- summaryField == null ? " " : summaryField.toString())
- .append("\t");
- }
- return summaryFieldValues.toString();
- }
-
- /**
- * Returns hash code value for this object
- */
- @Override
- public int hashCode()
- {
- return Objects.hash(primaryKey1, this.toString());
- }
-
- @Override
- public boolean equals(Object that)
- {
- return this.toString().equals(that.toString());
- }
- };
+ return new TDB_FTSData(primaryKey, tdbJsonStructure, summaryRowData1);
}
// private static FTSData getFTSData(Map<String, Object> doc,
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
import jalview.fts.core.FTSRestRequest;
import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.threedbeacons.TDB_FTSData;
import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
import jalview.jbgui.FilterOption;
{
int prov_idx = lastTdbRequest.getFieldIndex("Provider");
boolean hasPDBe=false;
- for (FTSData row : tdbEntries)
+ for (FTSData _row : tdbEntries)
{
- String provider = (String) row.getSummaryData()[prov_idx];
+ // tdb returns custom object
+ TDB_FTSData row = (TDB_FTSData) _row;
+ String provider = (String) row.getProvider();
FilterOption providerOpt = new FilterOption(
"3DB Provider - " + provider,
FILTER_SOURCE_PREFIX + provider, VIEWS_FILTER, false, this);