make sure logical models get a snapshot generated

This commit is contained in:
Grahame Grieve 2023-10-10 15:43:09 +11:00
parent c83b232f7c
commit 2cc40452d7
6 changed files with 7 additions and 19 deletions

View File

@ -250,11 +250,7 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
* @throws FHIRException * @throws FHIRException
*/ */
public void generateSnapshot(StructureDefinition p) throws DefinitionException, FHIRException { public void generateSnapshot(StructureDefinition p) throws DefinitionException, FHIRException {
generateSnapshot(p, false); if ((!p.hasSnapshot() || isProfileNeedsRegenerate(p))) {
}
public void generateSnapshot(StructureDefinition p, boolean ifLogical) {
if ((!p.hasSnapshot() || isProfileNeedsRegenerate(p) ) && (ifLogical || p.getKind() != StructureDefinitionKind.LOGICAL)) {
if (!p.hasBaseDefinition()) if (!p.hasBaseDefinition())
throw new DefinitionException(context.formatMessage(I18nConstants.PROFILE___HAS_NO_BASE_AND_NO_SNAPSHOT, p.getName(), p.getUrl())); throw new DefinitionException(context.formatMessage(I18nConstants.PROFILE___HAS_NO_BASE_AND_NO_SNAPSHOT, p.getName(), p.getUrl()));
StructureDefinition sd = context.fetchResource(StructureDefinition.class, p.getBaseDefinition(), p); StructureDefinition sd = context.fetchResource(StructureDefinition.class, p.getBaseDefinition(), p);

View File

@ -43,7 +43,7 @@ public class CDARoundTripTests {
for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) { for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) {
if (!sd.hasSnapshot()) { if (!sd.hasSnapshot()) {
// System.out.println("generate snapshot for " + sd.getUrl()); // System.out.println("generate snapshot for " + sd.getUrl());
new ContextUtilities(context).generateSnapshot(sd, true); new ContextUtilities(context).generateSnapshot(sd);
} }
} }
} }

View File

@ -41,7 +41,7 @@ public class XmlParserTests {
for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) { for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) {
if (!sd.hasSnapshot()) { if (!sd.hasSnapshot()) {
System.out.println("generate snapshot for " + sd.getUrl()); System.out.println("generate snapshot for " + sd.getUrl());
new ContextUtilities(context).generateSnapshot(sd, true); new ContextUtilities(context).generateSnapshot(sd);
} }
} }
} }

View File

@ -366,11 +366,7 @@ public class ValidationService {
List<StructureDefinition> structures = cu.allStructures(); List<StructureDefinition> structures = cu.allStructures();
for (StructureDefinition sd : structures) { for (StructureDefinition sd : structures) {
if (!sd.hasSnapshot()) { if (!sd.hasSnapshot()) {
if (sd.getKind() != null && sd.getKind() == StructureDefinitionKind.LOGICAL) { cu.generateSnapshot(sd);
cu.generateSnapshot(sd, true);
} else {
cu.generateSnapshot(sd, false);
}
} }
} }
validator.setMapLog(cliContext.getMapLog()); validator.setMapLog(cliContext.getMapLog());
@ -402,11 +398,7 @@ public class ValidationService {
List<StructureDefinition> structures = cu.allStructures(); List<StructureDefinition> structures = cu.allStructures();
for (StructureDefinition sd : structures) { for (StructureDefinition sd : structures) {
if (!sd.hasSnapshot()) { if (!sd.hasSnapshot()) {
if (sd.getKind() != null && sd.getKind() == StructureDefinitionKind.LOGICAL) { cu.generateSnapshot(sd);
cu.generateSnapshot(sd, true);
} else {
cu.generateSnapshot(sd, false);
}
} }
} }
validator.setMapLog(cliContext.getMapLog()); validator.setMapLog(cliContext.getMapLog());

View File

@ -76,7 +76,7 @@ public class StructureMappingTests {
for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) { for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) {
if (!sd.hasSnapshot()) { if (!sd.hasSnapshot()) {
System.out.println("generate snapshot for " + sd.getUrl()); System.out.println("generate snapshot for " + sd.getUrl());
new ContextUtilities(context).generateSnapshot(sd, true); new ContextUtilities(context).generateSnapshot(sd);
} }
} }
if (context.getValidatorFactory() == null) { if (context.getValidatorFactory() == null) {

View File

@ -384,7 +384,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
String contents = TestingUtilities.loadTestResource("validator", filename); String contents = TestingUtilities.loadTestResource("validator", filename);
CanonicalResource mr = (CanonicalResource) loadResource(filename, contents); CanonicalResource mr = (CanonicalResource) loadResource(filename, contents);
if (mr instanceof StructureDefinition) { if (mr instanceof StructureDefinition) {
new ContextUtilities(val.getContext()).generateSnapshot((StructureDefinition) mr, true); new ContextUtilities(val.getContext()).generateSnapshot((StructureDefinition) mr);
} }
logOutput("load resource "+mr.getUrl()); logOutput("load resource "+mr.getUrl());
val.getContext().cacheResource(mr); val.getContext().cacheResource(mr);