From 2a7cf59f6360e1077cc49e3448b45df92eccb937 Mon Sep 17 00:00:00 2001 From: HZBPhilippA Date: Tue, 24 Jun 2025 09:51:47 +0200 Subject: [PATCH 01/12] Refactor SampleType: Move PID column to unique constraints and add getter/setter methods --- .../org/icatproject/core/entity/SampleType.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/icatproject/core/entity/SampleType.java b/src/main/java/org/icatproject/core/entity/SampleType.java index 5dedd1da..f6dfe2e6 100644 --- a/src/main/java/org/icatproject/core/entity/SampleType.java +++ b/src/main/java/org/icatproject/core/entity/SampleType.java @@ -26,7 +26,7 @@ @SuppressWarnings("serial") @Entity @Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "FACILITY_ID", "NAME", - "MOLECULARFORMULA" }) }) + "PID" }) }) public class SampleType extends EntityBaseBean implements Serializable { @Comment("The facility which has defined this sample type") @@ -34,8 +34,12 @@ public class SampleType extends EntityBaseBean implements Serializable { @ManyToOne(fetch = FetchType.LAZY) private Facility facility; + @Comment("A persistent identifier attributed to this sample type, ideally referring to a vocabulary term") + @Column(name = "PID", nullable = false) + private String pid; + @Comment("The formula written as a string -e.g. C2H6O2 for ethylene glycol") - @Column(nullable = false, name = "MOLECULARFORMULA") + @Column(name = "MOLECULARFORMULA") private String molecularFormula; @Column(nullable = false, name = "NAME") @@ -58,6 +62,10 @@ public Facility getFacility() { return facility; } + public String getPid() { + return pid; + } + public String getMolecularFormula() { return molecularFormula; } @@ -78,6 +86,10 @@ public void setFacility(Facility facility) { this.facility = facility; } + public void setPid(String pid) { + this.pid = pid; + } + public void setMolecularFormula(String molecularFormula) { this.molecularFormula = molecularFormula; } From 4795c59ece9c3aa6c737df965ed8a92b53e9413e Mon Sep 17 00:00:00 2001 From: HZBPhilippA Date: Tue, 24 Jun 2025 10:02:03 +0200 Subject: [PATCH 02/12] Update SampleType: Add PID column and corresponding values in icat.port --- src/test/resources/icat.port | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/resources/icat.port b/src/test/resources/icat.port index f3eaba68..ddb92f2c 100644 --- a/src/test/resources/icat.port +++ b/src/test/resources/icat.port @@ -40,10 +40,11 @@ Shift(investigation(facility(name:0), name:1, visitId:2), startDate:3, endDate:4 "Test port facility", "expt1", "zero", 2014-01-01T00:00:00+01:00, 2014-01-01T18:00:00+01:00, "beamtime", "EDDI" "Test port facility", "expt1", "two", 2014-04-29T14:00:00+02:00, 2014-04-30T18:15:00+02:00, "preparing", null -SampleType(facility(name:0), name:1, molecularFormula:2, safetyInformation:3) -"Test port facility", "diamond", "C", "fairly harmless" -"Test port facility", "graphite", "C", "bit messy" -"Test port facility", "rust", "Fe3O4", "messy" +SampleType(facility(name:0), name:1, molecularFormula:2, safetyInformation:3, pid:4) +"Test port facility", "diamond", "C", "fairly harmless", "st:001" +"Test port facility", "graphite", "C", "bit messy", "st:002" +"Test port facility", "rust", "Fe3O4", "messy", "st:003" +"Test port facility", "N/A", null, "N/A", "st:004" Sample(investigation(facility(name:0), name:1, visitId:2), type(facility(name:0), name:3, molecularFormula:4), name:5, pid:6) "Test port facility", "expt1", "one", "diamond", "C", "Koh-I-Noor", "sdb:374717" From 31d693ec9cf29ce13612f3bd941f7c884adb3337 Mon Sep 17 00:00:00 2001 From: HZBPhilippA Date: Tue, 24 Jun 2025 10:28:24 +0200 Subject: [PATCH 03/12] Add test for SampleType with expected PID and null molecular formula --- src/test/java/org/icatproject/integration/TestRS.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/org/icatproject/integration/TestRS.java b/src/test/java/org/icatproject/integration/TestRS.java index ba4dd30a..a7c0e3ab 100644 --- a/src/test/java/org/icatproject/integration/TestRS.java +++ b/src/test/java/org/icatproject/integration/TestRS.java @@ -287,6 +287,17 @@ public void TestJsoniseBean() throws Exception { JsonArray st_response = search(session, "SELECT st from SampleType st WHERE st.name = 'diamond'", 1); collector.checkThat(st_response.getJsonObject(0).containsKey("SampleType"), is(true)); + /* + * Expected: <[{"SampleType":{"id":????,"createId":"db/notroot","createTime": + * "2019-03-11T15:58:33.000Z","modId":"db/notroot","modTime": + * "2019-03-11T15:58:33.000Z","molecularFormula":null,"name":"N/A", + * "pid":"st:004","safetyInformation":"N/A","samples":[]}}]> + */ + JsonArray st_null_response = search(session, "SELECT st from SampleType st WHERE st.name = 'N/A'", 1); + collector.checkThat(st_null_response.getJsonObject(0).containsKey("SampleType"), is(true)); + collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").getString("pid"), is("st:004")); + collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").get("molecularFormula"), is(JsonValue.NULL)); + /* * Expected: <[{"Sample":{"id":2181,"createId":"db/notroot","createTime": * "2019-03-11T15:58:33.000Z","modId":"db/notroot","modTime": From d5ae3d21023a4b691d1732e6349ddd892daf1157 Mon Sep 17 00:00:00 2001 From: HZBPhilippA Date: Tue, 24 Jun 2025 11:38:15 +0200 Subject: [PATCH 04/12] Update TestRS: Change assertion for molecularFormula to use equalTo(null) --- src/test/java/org/icatproject/integration/TestRS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/icatproject/integration/TestRS.java b/src/test/java/org/icatproject/integration/TestRS.java index a7c0e3ab..388c1232 100644 --- a/src/test/java/org/icatproject/integration/TestRS.java +++ b/src/test/java/org/icatproject/integration/TestRS.java @@ -296,7 +296,7 @@ public void TestJsoniseBean() throws Exception { JsonArray st_null_response = search(session, "SELECT st from SampleType st WHERE st.name = 'N/A'", 1); collector.checkThat(st_null_response.getJsonObject(0).containsKey("SampleType"), is(true)); collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").getString("pid"), is("st:004")); - collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").get("molecularFormula"), is(JsonValue.NULL)); + collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").get("molecularFormula"), is(equalTo(null))); /* * Expected: <[{"Sample":{"id":2181,"createId":"db/notroot","createTime": From 01967068e338713bddd34a880640d8b795261a18 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 17 Dec 2025 12:06:21 +0100 Subject: [PATCH 05/12] Fix indentation --- .../java/org/icatproject/core/entity/SampleType.java | 12 ++++++------ .../java/org/icatproject/integration/TestRS.java | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/icatproject/core/entity/SampleType.java b/src/main/java/org/icatproject/core/entity/SampleType.java index f6dfe2e6..382ffb05 100644 --- a/src/main/java/org/icatproject/core/entity/SampleType.java +++ b/src/main/java/org/icatproject/core/entity/SampleType.java @@ -35,8 +35,8 @@ public class SampleType extends EntityBaseBean implements Serializable { private Facility facility; @Comment("A persistent identifier attributed to this sample type, ideally referring to a vocabulary term") - @Column(name = "PID", nullable = false) - private String pid; + @Column(name = "PID", nullable = false) + private String pid; @Comment("The formula written as a string -e.g. C2H6O2 for ethylene glycol") @Column(name = "MOLECULARFORMULA") @@ -63,8 +63,8 @@ public Facility getFacility() { } public String getPid() { - return pid; - } + return pid; + } public String getMolecularFormula() { return molecularFormula; @@ -87,8 +87,8 @@ public void setFacility(Facility facility) { } public void setPid(String pid) { - this.pid = pid; - } + this.pid = pid; + } public void setMolecularFormula(String molecularFormula) { this.molecularFormula = molecularFormula; diff --git a/src/test/java/org/icatproject/integration/TestRS.java b/src/test/java/org/icatproject/integration/TestRS.java index 388c1232..550a69b6 100644 --- a/src/test/java/org/icatproject/integration/TestRS.java +++ b/src/test/java/org/icatproject/integration/TestRS.java @@ -288,11 +288,11 @@ public void TestJsoniseBean() throws Exception { collector.checkThat(st_response.getJsonObject(0).containsKey("SampleType"), is(true)); /* - * Expected: <[{"SampleType":{"id":????,"createId":"db/notroot","createTime": - * "2019-03-11T15:58:33.000Z","modId":"db/notroot","modTime": - * "2019-03-11T15:58:33.000Z","molecularFormula":null,"name":"N/A", - * "pid":"st:004","safetyInformation":"N/A","samples":[]}}]> - */ + * Expected: <[{"SampleType":{"id":????,"createId":"db/notroot","createTime": + * "2019-03-11T15:58:33.000Z","modId":"db/notroot","modTime": + * "2019-03-11T15:58:33.000Z","molecularFormula":null,"name":"N/A", + * "pid":"st:004","safetyInformation":"N/A","samples":[]}}]> + */ JsonArray st_null_response = search(session, "SELECT st from SampleType st WHERE st.name = 'N/A'", 1); collector.checkThat(st_null_response.getJsonObject(0).containsKey("SampleType"), is(true)); collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").getString("pid"), is("st:004")); From da6424ba385a74f068d6b2881512e2f6d4352234 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 17 Dec 2025 12:29:38 +0100 Subject: [PATCH 06/12] Disable tests that require an updated icat.client --- src/test/java/org/icatproject/integration/TestWS.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/org/icatproject/integration/TestWS.java b/src/test/java/org/icatproject/integration/TestWS.java index ed028725..f0f4f9ab 100644 --- a/src/test/java/org/icatproject/integration/TestWS.java +++ b/src/test/java/org/icatproject/integration/TestWS.java @@ -103,6 +103,7 @@ private static void create() throws Exception { Facility facility = session.createFacility("Test Facility", 90); SampleType sampleType = new SampleType(); + /* FIXME: sampleType.setPid("somepid"); */ sampleType.setFacility(facility); sampleType.setName("somename"); sampleType.setMolecularFormula("Someformula"); @@ -519,6 +520,7 @@ public void authz5() throws Exception { } } + @Disabled("Requires an icat.client built with the schema extensions") @Test public void authz6() throws Exception { create(); @@ -586,6 +588,7 @@ public void authz6() throws Exception { * Create two rules allowing access to the same investigation and ensure * that only one instance is returned - i.e, no DISTINCT problem remains */ + @Disabled("Requires an icat.client built with the schema extensions") @Test public void authz7() throws Exception { try { @@ -1004,6 +1007,7 @@ public void getInvestigationWithVeryManyDatasets() throws Exception { Facility facility = session.createFacility("Test Facility", 90); SampleType sampleType = new SampleType(); + /* FIXME: sampleType.setPid("somepid"); */ sampleType.setFacility(facility); sampleType.setName("somename"); sampleType.setMolecularFormula("Someformula"); @@ -1105,6 +1109,7 @@ public void groupAuthz() throws Exception { assertEquals(invId, inv.getId()); } + @Disabled("Requires an icat.client built with the schema extensions") @Test public void gets() throws Exception { create(); @@ -1185,6 +1190,7 @@ public void inapplicableParameterType() throws Exception { } } + @Disabled("Requires an icat.client built with the schema extensions") @Test public void includes() throws Exception { create(); @@ -1488,6 +1494,7 @@ public void numericParameterRanges() throws Exception { } + @Disabled("Requires an icat.client built with the schema extensions") @Test public void oldGets() throws Exception { create(); @@ -1527,6 +1534,7 @@ public void oldGets() throws Exception { } } + @Disabled("Requires an icat.client built with the schema extensions") @Test public void oldSearches() throws Exception { create(); @@ -1683,6 +1691,7 @@ public void performance() throws Exception { + (System.currentTimeMillis() - start) / (results.size() + 0.) + "ms"); } + @Disabled("Requires an icat.client built with the schema extensions") @Test public void searches() throws Exception { create(); From 0a711748ca86404e007661cdddcafddd75ce25c9 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 17 Dec 2025 12:37:57 +0100 Subject: [PATCH 07/12] Add dummy pid values to SampleTypes in test data --- src/test/resources/icat-import-check.port | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/resources/icat-import-check.port b/src/test/resources/icat-import-check.port index f3eaba68..9d0b3a68 100644 --- a/src/test/resources/icat-import-check.port +++ b/src/test/resources/icat-import-check.port @@ -40,10 +40,10 @@ Shift(investigation(facility(name:0), name:1, visitId:2), startDate:3, endDate:4 "Test port facility", "expt1", "zero", 2014-01-01T00:00:00+01:00, 2014-01-01T18:00:00+01:00, "beamtime", "EDDI" "Test port facility", "expt1", "two", 2014-04-29T14:00:00+02:00, 2014-04-30T18:15:00+02:00, "preparing", null -SampleType(facility(name:0), name:1, molecularFormula:2, safetyInformation:3) -"Test port facility", "diamond", "C", "fairly harmless" -"Test port facility", "graphite", "C", "bit messy" -"Test port facility", "rust", "Fe3O4", "messy" +SampleType(facility(name:0), name:1, molecularFormula:2, safetyInformation:3, pid:4) +"Test port facility", "diamond", "C", "fairly harmless", "st:001" +"Test port facility", "graphite", "C", "bit messy", "st:002" +"Test port facility", "rust", "Fe3O4", "messy", "st:003" Sample(investigation(facility(name:0), name:1, visitId:2), type(facility(name:0), name:3, molecularFormula:4), name:5, pid:6) "Test port facility", "expt1", "one", "diamond", "C", "Koh-I-Noor", "sdb:374717" From 6585fceb139b68a7ea521f4b1569025cc2cd3c8a Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 17 Dec 2025 13:18:09 +0100 Subject: [PATCH 08/12] Fix proper implementation of #326: - Remove relation from SampleType to Facility - Change uniqueness constraint for SampleType to be pid alone --- .../org/icatproject/core/entity/Facility.java | 11 ----------- .../icatproject/core/entity/SampleType.java | 16 +--------------- .../core/manager/TestEntityInfo.java | 2 +- .../org/icatproject/integration/TestRS.java | 11 +++++------ .../org/icatproject/integration/TestWS.java | 2 -- .../org/icatproject/integration/WSession.java | 2 +- src/test/resources/icat-import-check.port | 17 +++++++++-------- src/test/resources/icat.port | 18 +++++++++--------- 8 files changed, 26 insertions(+), 53 deletions(-) diff --git a/src/main/java/org/icatproject/core/entity/Facility.java b/src/main/java/org/icatproject/core/entity/Facility.java index f4a3304f..3d2cf9f5 100644 --- a/src/main/java/org/icatproject/core/entity/Facility.java +++ b/src/main/java/org/icatproject/core/entity/Facility.java @@ -63,9 +63,6 @@ public class Facility extends EntityBaseBean implements Serializable { @OneToMany(cascade = CascadeType.ALL, mappedBy = "facility") private List parameterTypes = new ArrayList(); - @OneToMany(cascade = CascadeType.ALL, mappedBy = "facility") - private List sampleTypes = new ArrayList(); - @Comment("A URL associated with this facility") private String url; @@ -129,10 +126,6 @@ public List getParameterTypes() { return parameterTypes; } - public List getSampleTypes() { - return sampleTypes; - } - public String getUrl() { return url; } @@ -193,10 +186,6 @@ public void setParameterTypes(List parameterTypes) { this.parameterTypes = parameterTypes; } - public void setSampleTypes(List sampleTypes) { - this.sampleTypes = sampleTypes; - } - public void setUrl(String url) { this.url = url; } diff --git a/src/main/java/org/icatproject/core/entity/SampleType.java b/src/main/java/org/icatproject/core/entity/SampleType.java index c5b14c76..21c55d6b 100644 --- a/src/main/java/org/icatproject/core/entity/SampleType.java +++ b/src/main/java/org/icatproject/core/entity/SampleType.java @@ -25,15 +25,9 @@ @Comment("A sample to be used in an investigation") @SuppressWarnings("serial") @Entity -@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "FACILITY_ID", "NAME", - "PID" }) }) +@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "PID" }) }) public class SampleType extends EntityBaseBean implements Serializable { - @Comment("The facility which has defined this sample type") - @JoinColumn(name = "FACILITY_ID", nullable = false) - @ManyToOne(fetch = FetchType.LAZY) - private Facility facility; - @Comment("A persistent identifier attributed to this sample type, ideally referring to a vocabulary term") @Column(name = "PID", nullable = false) private String pid; @@ -58,10 +52,6 @@ public class SampleType extends EntityBaseBean implements Serializable { public SampleType() { } - public Facility getFacility() { - return facility; - } - public String getPid() { return pid; } @@ -82,10 +72,6 @@ public List getSamples() { return samples; } - public void setFacility(Facility facility) { - this.facility = facility; - } - public void setPid(String pid) { this.pid = pid; } diff --git a/src/test/java/org/icatproject/core/manager/TestEntityInfo.java b/src/test/java/org/icatproject/core/manager/TestEntityInfo.java index f12b55c0..40a09a57 100644 --- a/src/test/java/org/icatproject/core/manager/TestEntityInfo.java +++ b/src/test/java/org/icatproject/core/manager/TestEntityInfo.java @@ -170,7 +170,7 @@ public void testExportNull() throws Exception { public void testFields() throws Exception { testField( "applications,dataPublicationTypes,dataPublications,datafileFormats,datasetTypes,daysUntilRelease,description,facilityCycles," - + "fullName,instruments,investigationTypes,investigations,name,parameterTypes,sampleTypes,url", + + "fullName,instruments,investigationTypes,investigations,name,parameterTypes,url", Facility.class); testField("description,facility,investigations,name", InvestigationType.class); testField( diff --git a/src/test/java/org/icatproject/integration/TestRS.java b/src/test/java/org/icatproject/integration/TestRS.java index f7bfdcd8..087442b5 100644 --- a/src/test/java/org/icatproject/integration/TestRS.java +++ b/src/test/java/org/icatproject/integration/TestRS.java @@ -187,7 +187,7 @@ public void TestJsoniseBean() throws Exception { * "2019-03-11T15:58:33.000Z","applications":[],"datafileFormats":[], * "datasetTypes":[],"daysUntilRelease":90,"facilityCycles":[],"instruments":[], * "investigationTypes":[],"investigations":[],"name":"Test port facility" - * ,"parameterTypes":[],"sampleTypes":[]}}]> + * ,"parameterTypes":[]}}]> */ JsonArray fac_response = search(session, "SELECT f from Facility f WHERE f.name = 'Test port facility'", 1); collector.checkThat(fac_response.getJsonObject(0).containsKey("Facility"), is(true)); @@ -293,12 +293,11 @@ public void TestJsoniseBean() throws Exception { collector.checkThat(st_response.getJsonObject(0).containsKey("SampleType"), is(true)); /* - * Expected: <[{"SampleType":{"id":????,"createId":"db/notroot","createTime": - * "2019-03-11T15:58:33.000Z","modId":"db/notroot","modTime": - * "2019-03-11T15:58:33.000Z","molecularFormula":null,"name":"N/A", - * "pid":"st:004","safetyInformation":"N/A","samples":[]}}]> + * Expected: <[{"SampleType":{"id":420,"createId":"db/notroot","createTime": + * "2025-12-17T13:23:13.000Z","modId":"db/notroot","modTime": + * "2025-12-17T13:23:13.000Z","name":"fossil","pid":"st:004","samples":[]}}]> */ - JsonArray st_null_response = search(session, "SELECT st from SampleType st WHERE st.name = 'N/A'", 1); + JsonArray st_null_response = search(session, "SELECT st from SampleType st WHERE st.name = 'fossil'", 1); collector.checkThat(st_null_response.getJsonObject(0).containsKey("SampleType"), is(true)); collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").getString("pid"), is("st:004")); collector.checkThat(st_null_response.getJsonObject(0).getJsonObject("SampleType").get("molecularFormula"), is(equalTo(null))); diff --git a/src/test/java/org/icatproject/integration/TestWS.java b/src/test/java/org/icatproject/integration/TestWS.java index f0f4f9ab..b5f9f989 100644 --- a/src/test/java/org/icatproject/integration/TestWS.java +++ b/src/test/java/org/icatproject/integration/TestWS.java @@ -104,7 +104,6 @@ private static void create() throws Exception { SampleType sampleType = new SampleType(); /* FIXME: sampleType.setPid("somepid"); */ - sampleType.setFacility(facility); sampleType.setName("somename"); sampleType.setMolecularFormula("Someformula"); session.create(sampleType); @@ -1008,7 +1007,6 @@ public void getInvestigationWithVeryManyDatasets() throws Exception { SampleType sampleType = new SampleType(); /* FIXME: sampleType.setPid("somepid"); */ - sampleType.setFacility(facility); sampleType.setName("somename"); sampleType.setMolecularFormula("Someformula"); session.create(sampleType); diff --git a/src/test/java/org/icatproject/integration/WSession.java b/src/test/java/org/icatproject/integration/WSession.java index 026883d5..2fa80de1 100644 --- a/src/test/java/org/icatproject/integration/WSession.java +++ b/src/test/java/org/icatproject/integration/WSession.java @@ -195,7 +195,7 @@ public void addUserGroupMember(String groupName, String userName) throws Excepti } public void clear() throws Exception { - deleteAll(Arrays.asList("Facility", "DataCollection", "Study", "FundingReference", "Technique")); + deleteAll(Arrays.asList("Facility", "DataCollection", "Study", "FundingReference", "Technique", "SampleType")); } private void deleteAll(List names) throws IcatException_Exception { diff --git a/src/test/resources/icat-import-check.port b/src/test/resources/icat-import-check.port index 9d0b3a68..bb2e51bc 100644 --- a/src/test/resources/icat-import-check.port +++ b/src/test/resources/icat-import-check.port @@ -40,14 +40,15 @@ Shift(investigation(facility(name:0), name:1, visitId:2), startDate:3, endDate:4 "Test port facility", "expt1", "zero", 2014-01-01T00:00:00+01:00, 2014-01-01T18:00:00+01:00, "beamtime", "EDDI" "Test port facility", "expt1", "two", 2014-04-29T14:00:00+02:00, 2014-04-30T18:15:00+02:00, "preparing", null -SampleType(facility(name:0), name:1, molecularFormula:2, safetyInformation:3, pid:4) -"Test port facility", "diamond", "C", "fairly harmless", "st:001" -"Test port facility", "graphite", "C", "bit messy", "st:002" -"Test port facility", "rust", "Fe3O4", "messy", "st:003" - -Sample(investigation(facility(name:0), name:1, visitId:2), type(facility(name:0), name:3, molecularFormula:4), name:5, pid:6) -"Test port facility", "expt1", "one", "diamond", "C", "Koh-I-Noor", "sdb:374717" -"Test port facility", "expt1", "one", "rust", "Fe3O4", "Ford\t\"Anglia\"", null +SampleType(name:0, molecularFormula:1, safetyInformation:2, pid:3) +"diamond", "C", "fairly harmless", "st:001" +"graphite", "C", "bit messy", "st:002" +"rust", "Fe3O4", "messy", "st:003" +"fossil", null, null, "st:004" + +Sample(investigation(facility(name:0), name:1, visitId:2), type(pid:3), name:4, pid:5) +"Test port facility", "expt1", "one", "st:001", "Koh-I-Noor", "sdb:374717" +"Test port facility", "expt1", "one", "st:003", "Ford\t\"Anglia\"", null InvestigationParameter(investigation(facility(name:0), name:1, visitId:2), type(facility(name:0), name:3 , units:4),stringValue:5) "Test port facility", "expt1", "one", "colour" , "name", "green" diff --git a/src/test/resources/icat.port b/src/test/resources/icat.port index a821cf2f..2d134d70 100644 --- a/src/test/resources/icat.port +++ b/src/test/resources/icat.port @@ -40,15 +40,15 @@ Shift(investigation(facility(name:0), name:1, visitId:2), startDate:3, endDate:4 "Test port facility", "expt1", "zero", 2014-01-01T00:00:00+01:00, 2014-01-01T18:00:00+01:00, "beamtime", "EDDI" "Test port facility", "expt1", "two", 2014-04-29T14:00:00+02:00, 2014-04-30T18:15:00+02:00, "preparing", null -SampleType(facility(name:0), name:1, molecularFormula:2, safetyInformation:3, pid:4) -"Test port facility", "diamond", "C", "fairly harmless", "st:001" -"Test port facility", "graphite", "C", "bit messy", "st:002" -"Test port facility", "rust", "Fe3O4", "messy", "st:003" -"Test port facility", "N/A", null, "N/A", "st:004" - -Sample(investigation(facility(name:0), name:1, visitId:2), type(facility(name:0), name:3, molecularFormula:4), name:5, pid:6) -"Test port facility", "expt1", "one", "diamond", "C", "Koh-I-Noor", "sdb:374717" -"Test port facility", "expt1", "one", "rust", "Fe3O4", "Ford\t\"Anglia\"", null +SampleType(name:0, molecularFormula:1, safetyInformation:2, pid:3) +"diamond", "C", "fairly harmless", "st:001" +"graphite", "C", "bit messy", "st:002" +"rust", "Fe3O4", "messy", "st:003" +"fossil", null, null, "st:004" + +Sample(investigation(facility(name:0), name:1, visitId:2), type(pid:3), name:4, pid:5) +"Test port facility", "expt1", "one", "st:001", "Koh-I-Noor", "sdb:374717" +"Test port facility", "expt1", "one", "st:003", "Ford\t\"Anglia\"", null InvestigationParameter(investigation(facility(name:0), name:1, visitId:2), type(facility(name:0), name:3 , units:4),stringValue:5) "Test port facility", "expt1", "one", "colour" , "name", "green" From 425a4987d20d232878f9bea03a7caad8d2716610 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 17 Dec 2025 14:49:28 +0100 Subject: [PATCH 09/12] Bump version to 7.0.0-SNAPSHOT --- pom.xml | 2 +- src/test/java/org/icatproject/integration/TestRS.java | 2 +- src/test/java/org/icatproject/integration/TestWS.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index bf318645..67b33f3a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.icatproject icat.server - 6.2.1-SNAPSHOT + 7.0.0-SNAPSHOT war ICAT Server A metadata catalogue to support Large Facility experimental data, diff --git a/src/test/java/org/icatproject/integration/TestRS.java b/src/test/java/org/icatproject/integration/TestRS.java index 087442b5..a9141dea 100644 --- a/src/test/java/org/icatproject/integration/TestRS.java +++ b/src/test/java/org/icatproject/integration/TestRS.java @@ -1326,7 +1326,7 @@ private JsonObject searchInvestigations(Session session, String user, String tex @Test public void testVersion() throws Exception { ICAT icat = new ICAT(System.getProperty("serverUrl")); - assertTrue(icat.getVersion().startsWith("6.")); + assertTrue(icat.getVersion().startsWith("7.0.")); } @Test diff --git a/src/test/java/org/icatproject/integration/TestWS.java b/src/test/java/org/icatproject/integration/TestWS.java index b5f9f989..82c6a8f0 100644 --- a/src/test/java/org/icatproject/integration/TestWS.java +++ b/src/test/java/org/icatproject/integration/TestWS.java @@ -72,7 +72,7 @@ */ public class TestWS { - private static final String version = "6.2."; + private static final String version = "7.0."; private static Random random; private static WSession session; From f24cf111f7a4f972a9042b4e3dd188c902af776d Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Wed, 17 Dec 2025 18:11:25 +0100 Subject: [PATCH 10/12] Use no-icat-install branch of icat-ansible --- .github/workflows/ci-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index fc949723..996e6a12 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -37,6 +37,7 @@ jobs: uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4.0.0 with: repository: icatproject-contrib/icat-ansible + ref: no-icat-install path: icat-ansible - name: Install Ansible run: pip install -r icat-ansible/requirements.txt From 2de0439bfe4d6ebcf37783138fd63f7eb6847329 Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Fri, 16 Jan 2026 13:51:23 +0100 Subject: [PATCH 11/12] Add mysql upgrade script, still need to the corresponding script for oracle --- src/main/scripts/upgrade_mysql_7_0.sql | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/scripts/upgrade_mysql_7_0.sql diff --git a/src/main/scripts/upgrade_mysql_7_0.sql b/src/main/scripts/upgrade_mysql_7_0.sql new file mode 100644 index 00000000..0e22890a --- /dev/null +++ b/src/main/scripts/upgrade_mysql_7_0.sql @@ -0,0 +1,28 @@ +-- Alter the SampleType table, the constraint on PID needs to be done +-- after populating it + +ALTER TABLE SAMPLETYPE DROP CONSTRAINT FK_SAMPLETYPE_FACILITY_ID; +ALTER TABLE SAMPLETYPE DROP CONSTRAINT UNQ_SAMPLETYPE_0; +ALTER TABLE SAMPLETYPE DROP COLUMN FACILITY_ID; +ALTER TABLE SAMPLETYPE MODIFY COLUMN MOLECULARFORMULA VARCHAR(255) DEFAULT NULL; +ALTER TABLE SAMPLETYPE ADD COLUMN PID VARCHAR(255); + +-- Populate the PID column for SampleTypes + +DELIMITER // + +CREATE PROCEDURE SET_SAMPLETYPES_PID() +BEGIN + UPDATE SAMPLETYPE SET PID = CONCAT('_local:', LPAD(ID, 8, '0')), MOD_ID = 'schema_upgrade', MOD_TIME = NOW(); +END; // + +DELIMITER ; + +CALL SET_SAMPLETYPES_PID(); + +DROP PROCEDURE SET_SAMPLETYPES_PID; + +-- Alter the SampleType table: set the constraint on PID + +ALTER TABLE SAMPLETYPE MODIFY COLUMN PID VARCHAR(255) NOT NULL; +ALTER TABLE SAMPLETYPE ADD CONSTRAINT UNQ_SAMPLETYPE_0 UNIQUE (PID); From 67efa33921e04f20f0c773008d0f66f5354bf2bb Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Fri, 16 Jan 2026 15:46:44 +0100 Subject: [PATCH 12/12] Add oracle upgrade script --- src/main/scripts/upgrade_oracle_7_0.sql | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/scripts/upgrade_oracle_7_0.sql diff --git a/src/main/scripts/upgrade_oracle_7_0.sql b/src/main/scripts/upgrade_oracle_7_0.sql new file mode 100644 index 00000000..1b6e45bb --- /dev/null +++ b/src/main/scripts/upgrade_oracle_7_0.sql @@ -0,0 +1,30 @@ +-- Alter the SampleType table, the constraint on PID needs to be done +-- after populating it + +ALTER TABLE SAMPLETYPE DROP CONSTRAINT FK_SAMPLETYPE_FACILITY_ID; +ALTER TABLE SAMPLETYPE DROP CONSTRAINT UNQ_SAMPLETYPE_0; +ALTER TABLE SAMPLETYPE DROP COLUMN FACILITY_ID; +ALTER TABLE SAMPLETYPE MODIFY (MOLECULARFORMULA NULL); +ALTER TABLE SAMPLETYPE ADD PID VARCHAR2(255); + +-- Populate the PID column for SampleTypes + +CREATE PROCEDURE SET_SAMPLETYPES_PID AS +BEGIN + UPDATE SAMPLETYPE SET PID = '_local:' || LPAD(ID, 8, '0'), MOD_ID = 'schema_upgrade', MOD_TIME = CURRENT_TIMESTAMP WHERE PID IS NULL; +END; +/ + +BEGIN + SET_SAMPLETYPES_PID; +END; +/ + +DROP PROCEDURE SET_SAMPLETYPES_PID; + +-- Alter the SampleType table: set the constraint on PID + +ALTER TABLE SAMPLETYPE MODIFY (PID NOT NULL); +ALTER TABLE SAMPLETYPE ADD CONSTRAINT UNQ_SAMPLETYPE_0 UNIQUE (PID); + +exit