From 6f4c5b7a6f62b4301623770f85c2bf5dc8715298 Mon Sep 17 00:00:00 2001 From: DavidCroftDKFZ <46788708+DavidCroftDKFZ@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:11:13 +0200 Subject: [PATCH] Made Sync methods static --- pom.xml | 2 +- .../service/DirectorySyncJob.java | 3 +- .../directory_sync_service/sync/Sync.java | 31 ++----------------- 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index db640b1..a1d3f51 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ de.samply directory_sync_service - 1.4.5 + 1.4.6 directory_sync_service Directory sync https://github.com/samply/directory_sync_service diff --git a/src/main/java/de/samply/directory_sync_service/service/DirectorySyncJob.java b/src/main/java/de/samply/directory_sync_service/service/DirectorySyncJob.java index 04d9e98..1e94e0c 100644 --- a/src/main/java/de/samply/directory_sync_service/service/DirectorySyncJob.java +++ b/src/main/java/de/samply/directory_sync_service/service/DirectorySyncJob.java @@ -53,8 +53,7 @@ public void execute(Configuration configuration) { int directoryMaxFacts = Integer.parseInt(configuration.getDirectoryMaxFacts()); boolean directoryMock = Boolean.parseBoolean(configuration.getDirectoryMock()); - Sync sync = new Sync(retryMax, retryInterval, fhirStoreUrl, directoryUrl, directoryUserName, directoryUserPass, directoryDefaultCollectionId, directoryAllowStarModel, directoryMinDonors, directoryMaxFacts, directoryMock); - sync.syncWithDirectoryFailover(); + Sync.syncWithDirectoryFailover(retryMax, retryInterval, fhirStoreUrl, directoryUrl, directoryUserName, directoryUserPass, directoryDefaultCollectionId, directoryAllowStarModel, directoryMinDonors, directoryMaxFacts, directoryMock); } /** diff --git a/src/main/java/de/samply/directory_sync_service/sync/Sync.java b/src/main/java/de/samply/directory_sync_service/sync/Sync.java index 9911c49..9c90580 100644 --- a/src/main/java/de/samply/directory_sync_service/sync/Sync.java +++ b/src/main/java/de/samply/directory_sync_service/sync/Sync.java @@ -30,31 +30,6 @@ */ public class Sync { private static final Logger logger = LoggerFactory.getLogger(Sync.class); - private final String retryMax; - private final String retryInterval; - private final String fhirStoreUrl; - private final String directoryUrl; - private final String directoryUserName; - private final String directoryUserPass; - private final String directoryDefaultCollectionId; - private final boolean directoryAllowStarModel; - private final int directoryMinDonors; - private final int directoryMaxFacts; - private final boolean directoryMock; - - public Sync(String retryMax, String retryInterval, String fhirStoreUrl, String directoryUrl, String directoryUserName, String directoryUserPass, String directoryDefaultCollectionId, boolean directoryAllowStarModel, int directoryMinDonors, int directoryMaxFacts, boolean directoryMock) { - this.retryMax = retryMax; - this.retryInterval = retryInterval; - this.fhirStoreUrl = fhirStoreUrl; - this.directoryUrl = directoryUrl; - this.directoryUserName = directoryUserName; - this.directoryUserPass = directoryUserPass; - this.directoryDefaultCollectionId = directoryDefaultCollectionId; - this.directoryAllowStarModel = directoryAllowStarModel; - this.directoryMinDonors = directoryMinDonors; - this.directoryMaxFacts = directoryMaxFacts; - this.directoryMock = directoryMock; - } /** * Attempts to perform synchronization with the Directory repeatedly, until it either @@ -62,7 +37,7 @@ public Sync(String retryMax, String retryInterval, String fhirStoreUrl, String d * * @throws IOException */ - public void syncWithDirectoryFailover() { + public static void syncWithDirectoryFailover(String retryMax, String retryInterval, String fhirStoreUrl, String directoryUrl, String directoryUserName, String directoryUserPass, String directoryDefaultCollectionId, boolean directoryAllowStarModel, int directoryMinDonors, int directoryMaxFacts, boolean directoryMock) { for (int retryNum = 0; retryNum < Integer.parseInt(retryMax); retryNum++) { if (retryNum > 0) { try { @@ -72,12 +47,12 @@ public void syncWithDirectoryFailover() { } logger.info("syncWithDirectoryFailover: retrying sync, attempt " + retryNum + " of " + retryMax); } - if (syncWithDirectory()) + if (syncWithDirectory(retryMax, retryInterval, fhirStoreUrl, directoryUrl, directoryUserName, directoryUserPass, directoryDefaultCollectionId, directoryAllowStarModel, directoryMinDonors, directoryMaxFacts, directoryMock)) break; } } - private boolean syncWithDirectory() { + private static boolean syncWithDirectory(String retryMax, String retryInterval, String fhirStoreUrl, String directoryUrl, String directoryUserName, String directoryUserPass, String directoryDefaultCollectionId, boolean directoryAllowStarModel, int directoryMinDonors, int directoryMaxFacts, boolean directoryMock) { Map correctedDiagnoses = null; // Re-initialize helper classes every time this method gets called FhirApi fhirApi = new FhirApi(fhirStoreUrl);