JAL-3914 fix up pdbentry get/setters
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 15 Nov 2024 13:50:52 +0000 (13:50 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 15 Nov 2024 13:50:52 +0000 (13:50 +0000)
src/jalview/datamodel/PDBEntry.java
test/jalview/datamodel/PDBEntryTest.java

index 6385210..08eea3f 100755 (executable)
@@ -277,6 +277,12 @@ public class PDBEntry
     {
       this.properties = new Hashtable<String, Object>();
     }
+    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
index a006833..e96b968 100644 (file)
@@ -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); 
+  }
 }