import jalview.datamodel.SequenceI;\r
import jalview.io.VamsasAppDatastore;\r
import uk.ac.vamsas.objects.core.DataSet;\r
+import uk.ac.vamsas.objects.core.DbRef;\r
import uk.ac.vamsas.objects.core.Sequence;\r
\r
/**\r
sequence.setName(sq.getName());\r
modified = true;\r
}\r
+ modified |= updateJvDbRefs();\r
+ // updateJvFeatures();\r
} \r
}\r
\r
+/*\r
+ private void updateJvFeatures()\r
+ {\r
+ Sequence vsq = (Sequence) vobj;\r
+ \r
+ // add or update any new features/references on dataset sequence\r
+ if (vsq.getgetSequenceFeatures() != null)\r
+ {\r
+ int sfSize = sq.getSequenceFeatures().length;\r
+\r
+ for (int sf = 0; sf < sfSize; sf++)\r
+ {\r
+ new jalview.io.vamsas.Sequencefeature(datastore, (jalview.datamodel.SequenceFeature) sq\r
+ .getSequenceFeatures()[sf], dataset, (Sequence) vobj);\r
+ }\r
+ } \r
+ }\r
+*/\r
+ private boolean updateSqFeatures()\r
+ {\r
+ boolean modified=false;\r
+ SequenceI sq = (SequenceI) jvobj;\r
+ \r
+ // add or update any new features/references on dataset sequence\r
+ if (sq.getSequenceFeatures() != null)\r
+ {\r
+ int sfSize = sq.getSequenceFeatures().length;\r
+\r
+ for (int sf = 0; sf < sfSize; sf++)\r
+ {\r
+ modified|=new jalview.io.vamsas.Sequencefeature(datastore, (jalview.datamodel.SequenceFeature) sq\r
+ .getSequenceFeatures()[sf], dataset, (Sequence) vobj).docWasUpdated();\r
+ }\r
+ }\r
+ return modified;\r
+ }\r
\r
public void addToDocument()\r
{\r
sequence.setDescription(sq.getDescription());\r
dataset.addSequence(sequence);\r
vobj = sequence;\r
- // add or update any new features/references on dataset sequence\r
- if (sq.getSequenceFeatures() != null)\r
- {\r
- int sfSize = sq.getSequenceFeatures().length;\r
-\r
- for (int sf = 0; sf < sfSize; sf++)\r
- {\r
- new jalview.io.vamsas.Sequencefeature(datastore, (jalview.datamodel.SequenceFeature) sq\r
- .getSequenceFeatures()[sf], dataset, (Sequence) vobj);\r
- }\r
- }\r
+ updateSqFeatures();\r
+ updateDbRefs();//sq,(Sequence) vobj, dataset);\r
+ }\r
+ /**\r
+ * sync database references from jv to document\r
+ * @return true if document was modified\r
+ */\r
+ private boolean updateDbRefs() {\r
+ boolean modifiedthedoc=false;\r
+ SequenceI sq = (SequenceI) jvobj;\r
+ \r
if (sq.getDatasetSequence() == null && sq.getDBRef() != null)\r
{\r
// only sync database references for dataset sequences\r
DBRefEntry[] entries = sq.getDBRef();\r
- jalview.datamodel.DBRefEntry dbentry;\r
+ //jalview.datamodel.DBRefEntry dbentry;\r
for (int db = 0; db < entries.length; db++)\r
{\r
- Rangetype dbr = new jalview.io.vamsas.Dbref(datastore,\r
- dbentry = entries[db], sq, (Sequence) vobj, dataset);\r
+ modifiedthedoc|= new jalview.io.vamsas.Dbref(datastore,\r
+ //dbentry = \r
+ entries[db], sq, (Sequence) vobj, dataset).docWasUpdated();\r
+ \r
}\r
\r
}\r
- \r
+ return modifiedthedoc;\r
+ }\r
+ /**\r
+ * sync database references from document to jv sequence\r
+ * @return true if local sequence refs were modified\r
+ */\r
+ private boolean updateJvDbRefs() {\r
+ boolean modifiedtheseq=false;\r
+ SequenceI sq = (SequenceI) jvobj;\r
+ Sequence vsq = (Sequence) vobj;\r
+ if (vsq.getDbRefCount()>0) {\r
+ // only sync database references for dataset sequences\r
+ DbRef[] entries = vsq.getDbRef();\r
+ //DbRef dbentry;\r
+ for (int db = 0; db < entries.length; db++)\r
+ {\r
+ modifiedtheseq|= new jalview.io.vamsas.Dbref(datastore,\r
+ //dbentry = \r
+ entries[db], vsq, sq).jvWasUpdated();\r
+ }\r
+ }\r
+ return modifiedtheseq;\r
}\r
\r
public void conflict()\r
sequence.setName(sq.getName());\r
modified = true;\r
}\r
+ modified |= updateDbRefs();\r
+ modified |= updateSqFeatures();\r
}\r
\r
/**\r