Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.icatproject</groupId>
<artifactId>icat.server</artifactId>
<version>6.2.1-SNAPSHOT</version>
<version>7.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>ICAT Server</name>
<description>A metadata catalogue to support Large Facility experimental data,
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/icatproject/core/entity/Facility.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public class Facility extends EntityBaseBean implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "facility")
private List<ParameterType> parameterTypes = new ArrayList<ParameterType>();

@OneToMany(cascade = CascadeType.ALL, mappedBy = "facility")
private List<SampleType> sampleTypes = new ArrayList<SampleType>();

@Comment("A URL associated with this facility")
private String url;

Expand Down Expand Up @@ -129,10 +126,6 @@ public List<ParameterType> getParameterTypes() {
return parameterTypes;
}

public List<SampleType> getSampleTypes() {
return sampleTypes;
}

public String getUrl() {
return url;
}
Expand Down Expand Up @@ -193,10 +186,6 @@ public void setParameterTypes(List<ParameterType> parameterTypes) {
this.parameterTypes = parameterTypes;
}

public void setSampleTypes(List<SampleType> sampleTypes) {
this.sampleTypes = sampleTypes;
}

public void setUrl(String url) {
this.url = url;
}
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/org/icatproject/core/entity/SampleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@
@Comment("A sample to be used in an investigation")
@SuppressWarnings("serial")
@Entity
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "FACILITY_ID", "NAME",
"MOLECULARFORMULA" }) })
@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;

@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")
Expand All @@ -54,8 +52,8 @@ public class SampleType extends EntityBaseBean implements Serializable {
public SampleType() {
}

public Facility getFacility() {
return facility;
public String getPid() {
return pid;
}

public String getMolecularFormula() {
Expand All @@ -74,8 +72,8 @@ public List<Sample> getSamples() {
return samples;
}

public void setFacility(Facility facility) {
this.facility = facility;
public void setPid(String pid) {
this.pid = pid;
}

public void setMolecularFormula(String molecularFormula) {
Expand Down
28 changes: 28 additions & 0 deletions src/main/scripts/upgrade_mysql_7_0.sql
Original file line number Diff line number Diff line change
@@ -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);
30 changes: 30 additions & 0 deletions src/main/scripts/upgrade_oracle_7_0.sql
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 12 additions & 2 deletions src/test/java/org/icatproject/integration/TestRS.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -292,6 +292,16 @@ 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":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 = '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)));

/*
* Expected: <[{"Sample":{"id":2181,"createId":"db/notroot","createTime":
* "2019-03-11T15:58:33.000Z","modId":"db/notroot","modTime":
Expand Down Expand Up @@ -1316,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
Expand Down
13 changes: 10 additions & 3 deletions src/test/java/org/icatproject/integration/TestWS.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -103,7 +103,7 @@ private static void create() throws Exception {
Facility facility = session.createFacility("Test Facility", 90);

SampleType sampleType = new SampleType();
sampleType.setFacility(facility);
/* FIXME: sampleType.setPid("somepid"); */
sampleType.setName("somename");
sampleType.setMolecularFormula("Someformula");
session.create(sampleType);
Expand Down Expand Up @@ -519,6 +519,7 @@ public void authz5() throws Exception {
}
}

@Disabled("Requires an icat.client built with the schema extensions")
@Test
public void authz6() throws Exception {
create();
Expand Down Expand Up @@ -586,6 +587,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 {
Expand Down Expand Up @@ -1004,7 +1006,7 @@ public void getInvestigationWithVeryManyDatasets() throws Exception {
Facility facility = session.createFacility("Test Facility", 90);

SampleType sampleType = new SampleType();
sampleType.setFacility(facility);
/* FIXME: sampleType.setPid("somepid"); */
sampleType.setName("somename");
sampleType.setMolecularFormula("Someformula");
session.create(sampleType);
Expand Down Expand Up @@ -1105,6 +1107,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();
Expand Down Expand Up @@ -1185,6 +1188,7 @@ public void inapplicableParameterType() throws Exception {
}
}

@Disabled("Requires an icat.client built with the schema extensions")
@Test
public void includes() throws Exception {
create();
Expand Down Expand Up @@ -1488,6 +1492,7 @@ public void numericParameterRanges() throws Exception {

}

@Disabled("Requires an icat.client built with the schema extensions")
@Test
public void oldGets() throws Exception {
create();
Expand Down Expand Up @@ -1527,6 +1532,7 @@ public void oldGets() throws Exception {
}
}

@Disabled("Requires an icat.client built with the schema extensions")
@Test
public void oldSearches() throws Exception {
create();
Expand Down Expand Up @@ -1683,6 +1689,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();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/icatproject/integration/WSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> names) throws IcatException_Exception {
Expand Down
17 changes: 9 additions & 8 deletions src/test/resources/icat-import-check.port
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"Test port facility", "diamond", "C", "fairly harmless"
"Test port facility", "graphite", "C", "bit messy"
"Test port facility", "rust", "Fe3O4", "messy"

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"
Expand Down
17 changes: 9 additions & 8 deletions src/test/resources/icat.port
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"Test port facility", "diamond", "C", "fairly harmless"
"Test port facility", "graphite", "C", "bit messy"
"Test port facility", "rust", "Fe3O4", "messy"

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"
Expand Down