better tracking and reporting of snapshot generation issues

This commit is contained in:
Grahame Grieve 2023-01-09 08:03:24 +11:00
parent b6cec730b5
commit 8902898428
7 changed files with 52 additions and 9 deletions

View File

@ -271,6 +271,7 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
throw new FHIRException(context.formatMessage(I18nConstants.PROFILE___ERROR_GENERATING_SNAPSHOT, p.getName(), p.getUrl()));
pu = null;
}
p.setGeneratedSnapshot(true);
}

View File

@ -705,6 +705,7 @@ public interface IWorkerContext {
}
public void logMessage(String message); // status messages, always display
public void logDebugMessage(LogCategory category, String message); // verbose; only when debugging
public boolean isDebugLogging(); // whether to log debug information
}
public void setLogger(@Nonnull ILoggingService logger);
public ILoggingService getLogger();

View File

@ -670,11 +670,27 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
T r = super.fetchResource(class_, uri, source);
if (r instanceof StructureDefinition) {
StructureDefinition p = (StructureDefinition)r;
try {
new ContextUtilities(this).generateSnapshot(p);
} catch (Exception e) {
// not sure what to do in this case?
System.out.println("Unable to generate snapshot for "+uri+": "+e.getMessage());
if (!p.isGeneratedSnapshot()) {
if (p.isGeneratingSnapshot()) {
throw new FHIRException("Attempt to fetch the profile "+p.getVersionedUrl()+" while generating the snapshot for it");
}
try {
if (logger.isDebugLogging()) {
System.out.println("Generating snapshot for "+p.getVersionedUrl());
}
p.setGeneratingSnapshot(true);
try {
new ContextUtilities(this).generateSnapshot(p);
} finally {
p.setGeneratingSnapshot(false);
}
} catch (Exception e) {
// not sure what to do in this case?
System.out.println("Unable to generate snapshot for "+p.getVersionedUrl()+": "+e.getMessage());
if (logger.isDebugLogging()) {
e.printStackTrace();
}
}
}
}
return r;

View File

@ -19,7 +19,13 @@ public class SystemOutLoggingService implements IWorkerContext.ILoggingService {
@Override
public void logDebugMessage(LogCategory category, String message) {
if (debug) {
System.out.println(" -" + category.name().toLowerCase() + ": " + message);
}
System.out.println(" -" + category.name().toLowerCase() + ": " + message);
}
}
@Override
public boolean isDebugLogging() {
return debug;
}
}

View File

@ -124,6 +124,7 @@ public abstract class Base implements Serializable, IBase, IElement {
if (userData != null)
userData.remove(name);
}
public void setUserDataINN(String name, Object value) {
if (value == null)

View File

@ -5179,9 +5179,27 @@ public class StructureDefinition extends CanonicalResource {
} else {
return getType();
}
}
}
private boolean generatedSnapshot;
private boolean generatingSnapshot;
public boolean isGeneratedSnapshot() {
return generatedSnapshot;
}
public void setGeneratedSnapshot(boolean generatedSnapshot) {
this.generatedSnapshot = generatedSnapshot;
}
public boolean isGeneratingSnapshot() {
return generatingSnapshot;
}
public void setGeneratingSnapshot(boolean generatingSnapshot) {
this.generatingSnapshot = generatingSnapshot;
}
// end addition
}

View File

@ -19,7 +19,7 @@
<properties>
<hapi_fhir_version>6.2.1</hapi_fhir_version>
<validator_test_case_version>1.2.6</validator_test_case_version>
<validator_test_case_version>1.2.7-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version>