From 439dcbf32a4e113263d393b2a60e38133668f6f5 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 15 Nov 2024 13:50:52 +0000 Subject: [PATCH] JAL-3914 fix up pdbentry get/setters --- src/jalview/datamodel/PDBEntry.java | 20 +++++++++++++++++--- test/jalview/datamodel/PDBEntryTest.java | 7 +++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/jalview/datamodel/PDBEntry.java b/src/jalview/datamodel/PDBEntry.java index 6385210..08eea3f 100755 --- a/src/jalview/datamodel/PDBEntry.java +++ b/src/jalview/datamodel/PDBEntry.java @@ -277,6 +277,12 @@ public class PDBEntry { this.properties = new Hashtable(); } + if (key!=null && value==null) + { + properties.remove(key); + return; + } + // null key throws a runtime exception properties.put(key, value); } @@ -678,7 +684,7 @@ public class PDBEntry public void setTempFacType(TFType tempfactype) { - setProperty(TEMPFACTYPE, tempfactype); + setProperty(TEMPFACTYPE, tempfactype.name()); } /** @@ -691,7 +697,10 @@ public class PDBEntry } public TFType getTempFacTypeTFType() { - return TFType.valueOf((String) getProperty(TEMPFACTYPE)); + if (_hasProperty(TEMPFACTYPE)) { + return TFType.valueOf((String) getProperty(TEMPFACTYPE)); + } + return null; } public boolean hasTempFacType() @@ -767,6 +776,11 @@ public class PDBEntry } public DataSourceType getProtocol() { - return DataSourceType.valueOf((String) getProperty(PROTOCOL)); + if (_hasProperty(PROTOCOL)) + { + return DataSourceType.valueOf((String) getProperty(PROTOCOL)); + } + // default protocol is + return DataSourceType.FILE; } } \ No newline at end of file diff --git a/test/jalview/datamodel/PDBEntryTest.java b/test/jalview/datamodel/PDBEntryTest.java index a006833..e96b968 100644 --- a/test/jalview/datamodel/PDBEntryTest.java +++ b/test/jalview/datamodel/PDBEntryTest.java @@ -32,6 +32,7 @@ import static org.testng.Assert.fail; import jalview.datamodel.PDBEntry.Type; import jalview.gui.JvOptionPane; +import jalview.structure.StructureImportSettings.TFType; //import org.testng.Assert; import org.testng.annotations.AfterMethod; @@ -322,4 +323,10 @@ public class PDBEntryTest } } + @Test(groups= {"Functional"}) + public void testMetadataProperties() + { + PDBEntry pdb = new PDBEntry("af:1xyz","A",null,"a/b/c/File"); + assertEquals(pdb.getTempFacTypeTFType(),null); + } } -- 1.7.10.2