Skip to content

Commit

Permalink
PN-252: Run local matches search only for patients updated/created si…
Browse files Browse the repository at this point in the history
…nce last search

Added more logging and more error catching
  • Loading branch information
allasm committed Jan 22, 2018
1 parent 1dfa1cf commit e676aab
Showing 1 changed file with 19 additions and 15 deletions.
Expand Up @@ -49,7 +49,6 @@
import org.slf4j.LoggerFactory;

import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.BaseObject;

Expand Down Expand Up @@ -89,9 +88,9 @@ public class LocalMatchFinder implements MatchFinder, Initializable
@Override
public void initialize() throws InitializationException
{
XWikiContext context = this.provider.get();

try {
XWikiContext context = this.provider.get();

this.prefsDoc = context.getWiki().getDocument(MATCHING_RUN_INFO_DOCUMENT, context);

if (this.prefsDoc != null && !this.prefsDoc.isNew()) {
Expand All @@ -102,7 +101,7 @@ public void initialize() throws InitializationException
context.getWiki().saveDocument(this.prefsDoc, context);
}
}
} catch (XWikiException e) {
} catch (Exception e) {
this.logger.error("Failed to modify matching run info document: {}", e.getMessage(), e);
}
}
Expand Down Expand Up @@ -142,39 +141,44 @@ public List<PatientMatch> findMatches(Patient patient)
@Override
public void recordStartMatchesSearch()
{
// note: error() is used intentionally since this is important information we always want to have in the logs
this.logger.error("Starting find all local matches run...");

if (this.prefsDoc == null) {
return;
}

BaseObject object = this.prefsDoc.getXObject(MATCHING_RUN_INFO_CLASS, "serverName", "localhost", false);
try {
BaseObject object = this.prefsDoc.getXObject(MATCHING_RUN_INFO_CLASS, "serverName", "localhost", false);

// cash last started search date to compare with last modification date for patient
this.previousStartedTime = object.getDateValue("startedTime");
// set new started time
object.setDateValue("startedTime", new Date());
// cash last started search date to compare with last modification date for patient
this.previousStartedTime = object.getDateValue("startedTime");
// set new started time
object.setDateValue("startedTime", new Date());

try {
XWikiContext context = this.provider.get();
context.getWiki().saveDocument(this.prefsDoc, context);
} catch (XWikiException e) {
} catch (Exception e) {
this.logger.error("Failed to save matching run start time for localhost.", e.getMessage(), e);
}
}

@Override
public void recordEndMatchesSearch()
{
this.logger.error("Finished find all local matches run");

if (this.prefsDoc == null) {
return;
}

BaseObject object = this.prefsDoc.getXObject(MATCHING_RUN_INFO_CLASS, "serverName", "localhost", false);
object.setDateValue("completedTime", new Date());

try {
BaseObject object = this.prefsDoc.getXObject(MATCHING_RUN_INFO_CLASS, "serverName", "localhost", false);
object.setDateValue("completedTime", new Date());

XWikiContext context = this.provider.get();
context.getWiki().saveDocument(this.prefsDoc, context);
} catch (XWikiException e) {
} catch (Exception e) {
this.logger.error("Failed to save matching run complete time for localhost.", e.getMessage(), e);
}
}
Expand Down

0 comments on commit e676aab

Please sign in to comment.