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
*/
public void generateSnapshot(StructureDefinition p) throws DefinitionException, FHIRException {
generateSnapshot(p, false);
}
public void generateSnapshot(StructureDefinition p, boolean ifLogical) {
if ((!p.hasSnapshot() || isProfileNeedsRegenerate(p) ) && (ifLogical || p.getKind() != StructureDefinitionKind.LOGICAL)) {
if ((!p.hasSnapshot() || isProfileNeedsRegenerate(p))) {
if (!p.hasBaseDefinition())
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);

View File

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

View File

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

View File

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