Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ CMD mvn -B -q checkstyle:check | \
# ===== stage 2 =====
FROM setup-env AS build-jar

RUN mvn clean compile assembly:single
RUN mvn clean package


# ===== stage 3 =====
FROM eclipse-temurin:11-jre-focal

ARG REPO_DIR

ARG JAR_FILE=target/update-dois-*-jar-with-dependencies.jar
ARG JAR_FILE=target/update-dois-jar-with-dependencies.jar

WORKDIR ${REPO_DIR}

Expand Down
36 changes: 29 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pipeline {
}
}
}

// This stage backs up the gk_central (on curator server) and release_current databases before they are modified.
stage('Setup: Back up DBs'){
steps{
Expand All @@ -30,26 +31,29 @@ pipeline {
}
}
}

// This stage builds the jar file using maven.
stage('Setup: Build jar file'){
steps{
script{
utils.buildJarFile()
sh "mvn clean package -DskipTests"
}
}
}

// This stage executes UpdateDOIs without specifying a 'report' file, which should contain a list of updateable DOIS, as one of the arguments.
// This results in test mode behaviour, which includes generating the report file that contains updateable DOIS for release.
stage('Main: UpdateDOIs Test Run'){
steps{
script{
withCredentials([file(credentialsId: 'Config', variable: 'ConfigFile')]) {
sh "touch src/main/resources/UpdateDOIs.report"
sh "java -jar target/update-dois.jar $ConfigFile"
sh "java -jar target/update-dois-jar-with-dependencies.jar $ConfigFile"
}
}
}
}

// This stage takes the generated report file and sends it to the curator overseeing release.
// Before moving onto the next stage of UpdateDOIs, their confirmation that the contents of the report file are correct is needed.
stage('Main: Send email of updateable DOIs to curator'){
Expand All @@ -65,6 +69,7 @@ pipeline {
}
}
}

// UpdateDOIs should pause at this stage until the curator confirms the report file is correct. Once they do, respond with 'yes' to the user input form that Jenkins brings up.
stage('User Input Required: Confirm DOIs'){
steps{
Expand All @@ -79,18 +84,33 @@ pipeline {
}
}
}

// Now that you have curator approval regarding the report file, this step executes the same jar file again -- this time providing the report file as an argument.
// With the report file as the second argument, UpdateDOIs executes database modifications.
stage('Main: UpdateDOIs'){
steps{
script{
withCredentials([file(credentialsId: 'Config', variable: 'ConfigFile')]) {
def releaseVersion = utils.getReleaseVersion()
sh "java -jar target/update-dois-*-jar-with-dependencies.jar $ConfigFile doisToBeUpdated-v${releaseVersion}.txt"
sh "java -jar target/update-dois-jar-with-dependencies.jar $ConfigFile doisToBeUpdated-v${releaseVersion}.txt"
}
}
}
}

stage('Post: Verify UpdateDOIs') {
steps {
script {
withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'releasePass', usernameVariable: 'releaseUser')]){
withCredentials([usernamePassword(credentialsId: 'mySQLCuratorUsernamePassword', passwordVariable: 'curatorPass', usernameVariable: 'curatorUser')]){
def releaseVersion = utils.getReleaseVersion()
sh "java -jar target/update-dois-verifier-jar-with-dependencies.jar --r $releaseVersion --cu $curatorUser --cp $curatorPass --ru $releaseUser --rp $releasePass --ch curator.reactome.org"
}
}
}
}
}

// This stage backs up the gk_central and release_current databases after they are modified.
stage('Post: Backup DBs'){
steps{
Expand All @@ -104,6 +124,7 @@ pipeline {
}
}
}

// All databases, logs, and data files generated by this step are compressed before moving them to the Reactome S3 bucket. All files are then deleted.
stage('Post: Archive Outputs'){
steps{
Expand All @@ -117,16 +138,17 @@ pipeline {
}
}
}

// This sends an email notifying the mailing list that both the UpdateStableIdentifiers and UpdateDOIs steps have completed. This indicates that gk_central can be reopened.
stage('Post: Send completion email') {
steps{
script{
def releaseVersion = utils.getReleaseVersion()
script{
def releaseVersion = utils.getReleaseVersion()
def emailSubject = "UpdateStableIdentifier and UpdateDOIs complete for v${releaseVersion}"
def emailBody = "Hello,\n\nThis is an automated message from Jenkins regarding an update for v${releaseVersion}: Both UpdateStableIdentifiers and UpdateDOIs steps have completed. ${env.GK_CENTRAL_DB} can likely be reopened, but Curation should get \'Human\' confirmation before doing so. \n\nThanks!"
utils.sendEmail("${emailSubject}", "${emailBody}")
}
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="LineLength">
<property name="max" value="150"/>
<property name="max" value="175"/>
</module>
<!-- Add more modules as needed -->
</module>
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.jcommander</groupId>
<artifactId>jcommander</artifactId>
<version>1.83</version>
</dependency>
<dependency>
<groupId>org.reactome.release</groupId>
<artifactId>release-common-lib</artifactId>
Expand Down Expand Up @@ -118,7 +123,7 @@
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>update-dois.jar</finalName>
<finalName>update-dois</finalName>
</configuration>
<phase>package</phase>
<goals>
Expand All @@ -138,7 +143,7 @@
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<finalName>update-dois-verifier.jar</finalName>
<finalName>update-dois-verifier</finalName>
</configuration>
<phase>package</phase>
<goals>
Expand Down
41 changes: 29 additions & 12 deletions src/main/java/org/reactome/release/updateDOIs/ReportTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,32 @@ public static boolean verifyDOIMatches( GKInstance trDOI, GKInstance gkDOI, Stri
if (trDOI.getDBID().equals(gkDOI.getDBID()) && trDOI.getDisplayName().equals(gkDOI.getDisplayName())) {
return true;
} else if (trDOI.getDBID().equals(gkDOI.getDBID()) && !trDOI.getDisplayName().equals(gkDOI.getDisplayName())) {
warningsLog.warn("[" + newDOI + "] Display names do not match: [Test Reactome]: " + trDOI.getDisplayName() + " ~ [GK Central]: " + gkDOI.getDisplayName());
warningsLog.warn("[" + newDOI + "] Display names do not match: [Test Reactome]: " + trDOI.getDisplayName() +
" ~ [GK Central]: " + gkDOI.getDisplayName());
return false;
} else if (!trDOI.getDBID().equals(gkDOI.getDBID()) && trDOI.getDisplayName().equals(gkDOI.getDisplayName())) {
warningsLog.warn("[" + newDOI + "] DB IDs do not match: [Test Reactome]: " + trDOI.getDBID() + " ~ [GK Central]: " + gkDOI.getDBID());
warningsLog.warn("[" + newDOI + "] DB IDs do not match: [Test Reactome]: " + trDOI.getDBID() +
" ~ [GK Central]: " + gkDOI.getDBID());
return false;
} else {
warningsLog.warn("DB ID and display name do not match: [Test Reactome]: " + trDOI + " ~ [GK Central]: " + gkDOI);
warningsLog.warn("DB ID and display name do not match: [Test Reactome]: " + trDOI + " ~ [GK Central]: " +
gkDOI);
return false;
}

}

public static void expectedUpdatesTests(Map<String,Map<String,String>> expectedUpdatedDOIs, List<String> updated, List<String> notUpdated, int expectedNumberOfUpdatedDOIs, String REACTOME_DOI_PREFIX) {
// Checking if provided list matched updated instances. Any that don't, it attempts to determine why they might not of been updated.
// This entails comparing the DB ID, display name and the stable ID version of the provided list (UpdateDOIs.report) with the actual updated instances
public static void expectedUpdatesTests(
Map<String,Map<String,String>> expectedUpdatedDOIs,
List<String> updated,
List<String> notUpdated,
int expectedNumberOfUpdatedDOIs,
String REACTOME_DOI_PREFIX
) {
// Checking if provided list matched updated instances. Any that don't, it attempts to determine why they
// might not of been updated.
// This entails comparing the DB ID, display name and the stable ID version of the provided list
// (UpdateDOIs.report) with the actual updated instances
if (notUpdated.size() > 0)
{
warningsLog.warn("Some DOIs from UpdateDOIs.report were not updated");
Expand All @@ -46,25 +57,30 @@ public static void expectedUpdatesTests(Map<String,Map<String,String>> expectedU
String missedStableId = missedClean.split("\\.")[0];
String missedStableIdVersion = missedClean.split("\\.")[1];
int resolved = 0;
// Iterate through each of the DOI's provided in UpdateDOIs.report, trying to find a match for the DOI that wasn't updated.
// If it finds a match of either DB ID, stable ID version, or the display name, it will try to determine which of those 3 fields don't match.
// Iterate through each of the DOI's provided in UpdateDOIs.report, trying to find a match for the DOI
// that wasn't updated.
// If it finds a match of either DB ID, stable ID version, or the display name, it will try to
// determine which of those 3 fields don't match.
// Once it finds the field that doesn't match, it logs it and then ends the current iteration.
for (String key : expectedUpdatedDOIs.keySet())
{
if (expectedUpdatedDOIs.get(key).get("stableId").equals(missedStableId))
{
if (!expectedUpdatedDOIs.get(key).get("stableIdVersion").equals(missedStableIdVersion))
{
warningsLog.warn("[" + key + "] StableID 'version' in DB different from expected: [DB] " + missedDoi + "* ~ [Expected] " + key + "*");
warningsLog.warn("[" + key + "] StableID 'version' in DB different from expected: [DB] " +
missedDoi + "* ~ [Expected] " + key + "*");
resolved++;
continue;
} else if (!expectedUpdatedDOIs.get(key).get("displayName").equals(missedName)) {
warningsLog.warn("[" + key + "] 'Display name' in DB different from expected: [DB] " + missedName + " ~ [Expected] " + expectedUpdatedDOIs.get(key).get("displayName"));
warningsLog.warn("[" + key + "] 'Display name' in DB different from expected: [DB] " +
missedName + " ~ [Expected] " + expectedUpdatedDOIs.get(key).get("displayName"));
resolved++;
continue;
}
} else if (expectedUpdatedDOIs.get(key).get("displayName").equals(missedName)) {
warningsLog.warn("[" + key + "] 'DB ID' from DB different from expected, but found matching display name: ~ [DB] " + missed + " [Expected] " + key + ":" + missedName);
warningsLog.warn("[" + key + "] 'DB ID' from DB different from expected, but found matching " +
"display name: ~ [DB] " + missed + " [Expected] " + key + ":" + missedName);
resolved++;
continue;
}
Expand All @@ -78,7 +94,8 @@ public static void expectedUpdatesTests(Map<String,Map<String,String>> expectedU
{
for (String unresolvedDOI : unresolvedDOIs)
{
warningsLog.warn("[" + unresolvedDOI + "]" + "DOI does not match any DOIs expected to be updated -- Could not match display name or DB ID");
warningsLog.warn("[" + unresolvedDOI + "]" + "DOI does not match any DOIs expected to be updated " +
"-- Could not match display name or DB ID");
}
}
} else if (expectedUpdatedDOIs.size() != 0 && expectedNumberOfUpdatedDOIs > expectedUpdatedDOIs.size()) {
Expand Down
42 changes: 28 additions & 14 deletions src/main/java/org/reactome/release/updateDOIs/UpdateDOIs.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static void setAdaptors(MySQLAdaptor adaptorTR, MySQLAdaptor adaptorGK) {
}

@SuppressWarnings("unchecked")
public static void findAndUpdateDOIs(long personId, Path pathToReport, int releaseNumber, boolean testMode) throws IOException {
public static void findAndUpdateDOIs(long personId, Path pathToReport, int releaseNumber, boolean testMode)
throws IOException {

Path doisListFilepath = Paths.get("doisToBeUpdated-v" + releaseNumber + ".txt");
if (testMode) {
Expand All @@ -61,14 +62,17 @@ public static void findAndUpdateDOIs(long personId, Path pathToReport, int relea
expectedUpdatedDOIs = UpdateDOIs.getExpectedUpdatedDOIs(pathToReport.toString());
}
if (expectedUpdatedDOIs.size() == 0) {
logger.warn("No DOIs listed in UpdateDOIs.report. Please add expected DOI and displayName to UpdateDOIs.report.");
logger.warn("No DOIs listed in UpdateDOIs.report. " +
"Please add expected DOI and displayName to UpdateDOIs.report.");
}
List<String> updated = new ArrayList<>();
List<String> notUpdated = new ArrayList<>();
try
{
// Get all instances in Test Reactome in the Pathway table that don't have a 'doi' attribute starting with 10.3180, the Reactome DOI standard
doisTR = dbaTestReactome.fetchInstanceByAttribute(ReactomeJavaConstants.Pathway, "doi", "NOT REGEXP", "^" + REACTOME_DOI_PREFIX);
// Get all instances in Test Reactome in the Pathway table that don't have a 'doi' attribute starting
// with 10.3180, the Reactome DOI standard
doisTR = dbaTestReactome.fetchInstanceByAttribute(
ReactomeJavaConstants.Pathway, "doi", "NOT REGEXP", "^" + REACTOME_DOI_PREFIX);
logger.info("Found " + doisTR.size() + " Pathway instances that need a DOI");
// GKCentral should require transactional support
if (dbaGkCentral.supportsTransactions())
Expand All @@ -78,14 +82,17 @@ public static void findAndUpdateDOIs(long personId, Path pathToReport, int relea
outerloop:
for (GKInstance trDOI : doisTR)
{
// The dois are constructed from the instances 'stableIdentifier', which should be in the db already
String stableIdFromDb = ((GKInstance) trDOI.getAttributeValue(ReactomeJavaConstants.stableIdentifier)).getDisplayName();
// The dois are constructed from the instances 'stableIdentifier',
// which should be in the db already
String stableIdFromDb = ((GKInstance)
trDOI.getAttributeValue(ReactomeJavaConstants.stableIdentifier)).getDisplayName();
String nameFromDb = trDOI.getAttributeValue(ReactomeJavaConstants.name).toString();
String updatedDoi = REACTOME_DOI_PREFIX + "/" + stableIdFromDb;
String dbId = trDOI.getAttributeValue(ReactomeJavaConstants.DB_ID).toString();

// Used to verify that report contents are as expected, based on provided list from curators
if (expectedUpdatedDOIs.get(updatedDoi) != null && expectedUpdatedDOIs.get(updatedDoi).get("displayName").equals(nameFromDb))
if (expectedUpdatedDOIs.get(updatedDoi) != null &&
expectedUpdatedDOIs.get(updatedDoi).get("displayName").equals(nameFromDb))
{
updated.add(updatedDoi);
} else {
Expand All @@ -95,14 +102,16 @@ public static void findAndUpdateDOIs(long personId, Path pathToReport, int relea
continue;
}
}
// This updates the 'modified' field for Pathways instances, keeping track of when changes happened for each instance
// This updates the 'modified' field for Pathways instances, keeping track of when changes
// happened for each instance
trDOI.getAttributeValuesList(ReactomeJavaConstants.modified);
trDOI.addAttributeValue(ReactomeJavaConstants.modified, instanceEditTR);
trDOI.setAttributeValue("doi", updatedDoi);

// Grabs instance from GKCentral based on DB_ID taken from Test Reactome and updates it's DOI
// Grabs instance from GKCentral based on DB_ID taken from Test Reactome and updates its DOI
dbaGkCentral.startTransaction();
doisGK = dbaGkCentral.fetchInstanceByAttribute(ReactomeJavaConstants.Pathway, ReactomeJavaConstants.DB_ID, "=", dbId);
doisGK = dbaGkCentral.fetchInstanceByAttribute(
ReactomeJavaConstants.Pathway, ReactomeJavaConstants.DB_ID, "=", dbId);
if (!doisGK.isEmpty())
{
for (GKInstance gkDOI : doisGK)
Expand Down Expand Up @@ -136,7 +145,8 @@ public static void findAndUpdateDOIs(long personId, Path pathToReport, int relea
dbaTestReactome.updateInstanceAttribute(trDOI, "doi");
}
}
ReportTests.expectedUpdatesTests(expectedUpdatedDOIs, updated, notUpdated, doisTR.size(), REACTOME_DOI_PREFIX);
ReportTests.expectedUpdatesTests(
expectedUpdatedDOIs, updated, notUpdated, doisTR.size(), REACTOME_DOI_PREFIX);
} else {
logger.info("No DOIs to update");
}
Expand Down Expand Up @@ -177,7 +187,10 @@ public static Map<String, Map<String,String>> getExpectedUpdatedDOIs(String path
String reactomeDoi = commaSplit[0];
String displayName = commaSplit[1];
int lastPeriodIndex = commaSplit[0].lastIndexOf(".");
String[] versionSplit = {reactomeDoi.substring(0, lastPeriodIndex), reactomeDoi.substring(lastPeriodIndex+1)};
String[] versionSplit = {
reactomeDoi.substring(0, lastPeriodIndex),
reactomeDoi.substring(lastPeriodIndex + 1)
};
String stableId = versionSplit[0].replace(REACTOME_DOI_PREFIX + "/", "");
String stableIdVersion = versionSplit[1];
doiAttributes.put("displayName", displayName);
Expand Down Expand Up @@ -233,8 +246,9 @@ public static GKInstance createInstanceEdit(MySQLAdaptor dbAdaptor, long personI
* @return an InstanceEdit object.
* @throws Exception
*/
public static GKInstance createDefaultIE(MySQLAdaptor dba, Long defaultPersonId, boolean needStore, String note)
throws Exception {
public static GKInstance createDefaultIE(
MySQLAdaptor dba, Long defaultPersonId, boolean needStore, String note) throws Exception {

GKInstance defaultPerson = dba.fetchInstance(defaultPersonId);
if (defaultPerson != null) {
GKInstance newIE = UpdateDOIs.createDefaultInstanceEdit(defaultPerson);
Expand Down
Loading