Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure abstract classes are set to retrievable = false in ModelInfo. #533

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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