Merge branch 'feature/JAL-3143ensemblJSON' into trialMerge
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 29 Jan 2019 11:32:18 +0000 (11:32 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 29 Jan 2019 11:32:18 +0000 (11:32 +0000)
Conflicts:
src/jalview/ext/ensembl/EnsemblFeatures.java

1  2 
src/jalview/analysis/AlignmentUtils.java
src/jalview/ext/ensembl/EnsemblFeatures.java

@@@ -108,24 -111,20 +108,22 @@@ class EnsemblFeatures extends EnsemblRe
     * @param br
     * @return
     */
 -  private SequenceI parseFeaturesJson(BufferedReader br)
 +  @SuppressWarnings("unchecked")
- private SequenceI parseFeaturesJson(List<String> queries)
++  private SequenceI parseFeaturesJson(List<String> queries)
    {
-         
-         
      SequenceI seq = new Sequence("Dummy", "");
--
 -    JSONParser jp = new JSONParser();
      try
      {
-       
 -      JSONArray responses = (JSONArray) jp.parse(br);
 -      Iterator rvals = responses.iterator();
 -      while (rvals.hasNext())
 +      Iterator<Object> rvals = (Iterator<Object>) getJSON(null, queries, -1, MODE_ITERATOR, null);
 +      if (rvals == null)
+       {
 +        return null;
++      }
 +      while (rvals.hasNext())
 +      {         
          try
          {
 -          JSONObject obj = (JSONObject) rvals.next();
 +          Map<String, Object> obj = (Map<String, Object>) rvals.next();
            String type = obj.get("feature_type").toString();
            int start = Integer.parseInt(obj.get("start").toString());
            int end = Integer.parseInt(obj.get("end").toString());
     * @param keys
     * @return
     */
 -  protected String getFirstNotNull(JSONObject obj, String... keys)
++  @SuppressWarnings("unchecked")
 +  protected String getFirstNotNull(Map<String, Object> obj, String... keys)
    {
--    String desc = null;
--
      for (String key : keys)
      {
        Object val = obj.get(key);
        if (val != null)
        {
-         String s = val.toString();
 -        String s = val instanceof JSONArray
 -                ? JSONUtils.arrayToList((JSONArray) val)
++        String s = val instanceof List<?>
++                ? JSONUtils.arrayToStringList((List<Object>) val)
+                 : val.toString();
          if (!s.isEmpty())
          {
            return s;
          }
        }
      }
--    return desc;
++    return null;
    }
  
    /**