JAL-2210 instrument setDBRefs to call ensurePrimaries
authorJim Procter <jprocter@issues.jalview.org>
Wed, 28 Sep 2016 13:24:48 +0000 (14:24 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 28 Sep 2016 14:18:52 +0000 (15:18 +0100)
JAL-2210 defer setDBRefs to datasetSequence if available

src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceI.java

index 6b57ef7..d295480 100755 (executable)
@@ -944,7 +944,17 @@ public class Sequence extends ASequence implements SequenceI
   @Override
   public void setDBRefs(DBRefEntry[] dbref)
   {
+    if (dbrefs == null && datasetSequence != null
+            && this != datasetSequence)
+    {
+      datasetSequence.setDBRefs(dbref);
+      return;
+    }
     dbrefs = dbref;
+    if (dbrefs != null)
+    {
+      DBRefUtils.ensurePrimaries(this);
+    }
   }
 
   @Override
index b7a291e..a29e2ba 100755 (executable)
@@ -314,6 +314,14 @@ public interface SequenceI extends ASequenceI
 
   public void setVamsasId(String id);
 
+  /**
+   * set the array of Database references for the sequence.
+   * 
+   * @param dbs
+   * @deprecated - use is discouraged since side-effects may occur if DBRefEntry
+   *             set are not normalised.
+   */
+  @Deprecated
   public void setDBRefs(DBRefEntry[] dbs);
 
   public DBRefEntry[] getDBRefs();