Skip to content

Commit

Permalink
Made Sync methods static
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCroftDKFZ committed Sep 11, 2024
1 parent 5001166 commit 6f4c5b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>de.samply</groupId>
<artifactId>directory_sync_service</artifactId>
<version>1.4.5</version>
<version>1.4.6</version>
<name>directory_sync_service</name>
<description>Directory sync</description>
<url>https://github.com/samply/directory_sync_service</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
31 changes: 3 additions & 28 deletions src/main/java/de/samply/directory_sync_service/sync/Sync.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,14 @@
*/
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
* succeeds, or the number of attempts exceeds a threshold.
*
* @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 {
Expand All @@ -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<String, String> correctedDiagnoses = null;
// Re-initialize helper classes every time this method gets called
FhirApi fhirApi = new FhirApi(fhirStoreUrl);
Expand Down

0 comments on commit 6f4c5b7

Please sign in to comment.