X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FPDBEntry.java;h=1c1d192fcbabc754b547bff599aa21408d7af19c;hp=673c12a212f313b8e4c5f87659eda3543f46875d;hb=c06a9af4331b34a8537b28b5e749c442e1bc1682;hpb=b61782b2a240d1b218221b1b827ecb4d5eb62b6a diff --git a/src/jalview/datamodel/PDBEntry.java b/src/jalview/datamodel/PDBEntry.java index 673c12a..1c1d192 100755 --- a/src/jalview/datamodel/PDBEntry.java +++ b/src/jalview/datamodel/PDBEntry.java @@ -245,4 +245,54 @@ public class PDBEntry { return id; } + + /** + * update entry with details from another entry concerning the same PDB + * ID/file spec. + * + * @param newEntry + * @return true if modifications were made + */ + public boolean updateFrom(PDBEntry newEntry) + { + boolean modified = false; + + if (getFile() == null) + { + // update file and type of file + modified |= newEntry.getFile() != null; + setFile(newEntry.getFile()); + } + if (newEntry.getType() != null && newEntry.getFile() != null + && newEntry.getFile().equals(getFile())) + { + setType(newEntry.getType()); + } + if (getChainCode() == null + || (getChainCode() != null && getChainCode().length() == 0 && newEntry + .getChainCode() != null)) + { + modified |= getChainCode() == null + || !newEntry.getChainCode().equals(getChainCode()); + setChainCode(newEntry.getChainCode()); + } + if (newEntry.getProperty() != null) + { + if (properties == null) + { + properties = new Hashtable(); + } + // TODO: getProperty -> Map + for (Object p : newEntry.getProperty().keySet()) + { + if (properties.get(p) == null + || !properties.get(p).equals(newEntry.getProperty().get(p))) + { + modified = true; + } + properties.put(p, newEntry.getProperty().get(p)); + } + } + return modified; + } }