Skip to content

Commit

Permalink
Ensure abstract classes are set to retrievable = false in ModelInfo. (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukedegruchy authored Aug 26, 2024
1 parent 6dd2f5c commit eb2ec44
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1402,9 +1402,9 @@ private ClassInfo buildClassInfo(String modelName, StructureDefinition sd) throw
logger.info("Building ClassInfo for {}", typeName);
ClassInfo info = new ClassInfo().withName(typeName).withNamespace(modelName).withLabel(this.getLabel(sd))
.withIdentifier(sd.getUrl())
.withRetrievable(sd.getKind() == StructureDefinitionKind.RESOURCE);
.withRetrievable(isStructureDefinitionRetrievable(sd));

if (sd.getKind() == StructureDefinitionKind.RESOURCE) {
if (isStructureDefinitionResource(sd)) {
String targetTypeName = getTargetTypeName(sd);
if (targetTypeName != null) {
info.setTarget(targetTypeName);
Expand Down Expand Up @@ -1442,7 +1442,7 @@ private ClassInfo buildClassInfo(String modelName, StructureDefinition sd) throw
}

String baseDefinition = sd.getBaseDefinition();
String baseTypeName = sd.getKind() == StructureDefinitionKind.RESOURCE
String baseTypeName = isStructureDefinitionResource(sd)
? resolveBaseTypeName(sd.getType()) : resolveTypeName(baseDefinition);

if (baseTypeName != null && !this.typeInfos.containsKey(baseTypeName)) {
Expand Down Expand Up @@ -1473,6 +1473,14 @@ private ClassInfo buildClassInfo(String modelName, StructureDefinition sd) throw
return info;
}

protected static boolean isStructureDefinitionRetrievable(StructureDefinition theStructureDefinition) {
return isStructureDefinitionResource(theStructureDefinition) && ! theStructureDefinition.getAbstract();
}

protected static boolean isStructureDefinitionResource(StructureDefinition theStructureDefinition) {
return theStructureDefinition.getKind() == StructureDefinitionKind.RESOURCE;
}

@SuppressWarnings("unused")
private StructureDefinition getBaseDefinitionStructureDef(String model, StructureDefinition sd) {
String baseSd = (sd.getBaseDefinition() == null) ? null : getTail(sd.getBaseDefinition());
Expand Down

0 comments on commit eb2ec44

Please sign in to comment.