use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetBaseTypeNameNamespacePrefixNotFound.
@Test
public void testGetBaseTypeNameNamespacePrefixNotFound() {
ModelInfo modelInfo = new ModelInfo();
modelInfo.setName("Dummy");
modelInfo.setVersion("1.1.1");
modelInfo.setUrl("urn:oid:Dummy");
ClassInfo typeInfo = new ClassInfo();
typeInfo.setName("MyType");
typeInfo.setBaseType("Other.BaseType");
IllegalArgumentException iex = assertThrows(IllegalArgumentException.class, () -> ModelUtils.getBaseTypeName(modelInfo, typeInfo));
assertTrue(iex.getMessage(), iex.getMessage().contains("Other"));
assertTrue(iex.getMessage(), iex.getMessage().contains(modelInfo.getName()));
assertTrue(iex.getMessage(), iex.getMessage().contains(modelInfo.getVersion()));
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class DataTypeRequirementsProcessor method addToChildTypes.
protected <T> void addToChildTypes(Map<String, VersionedIdentifier> models, Map<QName, Set<T>> valuesByDataType) {
for (Map.Entry<String, VersionedIdentifier> modelData : models.entrySet()) {
Map<QName, TypeNode> typeMap = typeMapByModelUri.computeIfAbsent(modelData.getKey(), key -> {
ModelInfo modelInfo = modelManager.resolveModel(modelData.getValue()).getModelInfo();
return ModelUtils.buildTypeMap(modelInfo);
});
// Create a temporary set and then merge later to avoid concurrent modification
Map<QName, Set<T>> newValues = new HashMap<>();
for (Map.Entry<QName, Set<T>> paths : valuesByDataType.entrySet()) {
Set<QName> names = getDescendants(typeMap, paths.getKey());
for (QName name : names) {
Set<T> childValues = newValues.computeIfAbsent(name, key -> new HashSet<>());
childValues.addAll(paths.getValue());
}
}
for (Map.Entry<QName, Set<T>> entry : newValues.entrySet()) {
valuesByDataType.merge(entry.getKey(), entry.getValue(), (oldSet, newSet) -> {
oldSet.addAll(newSet);
return oldSet;
});
}
}
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtils method buildTypeMap.
public static Map<QName, TypeNode> buildTypeMap(ModelInfo modelInfo) {
Map<QName, TypeNode> typeMap = new HashMap<>();
for (TypeInfo typeInfo : modelInfo.getTypeInfo()) {
if (typeInfo instanceof ClassInfo) {
ClassInfo classInfo = (ClassInfo) typeInfo;
QName qname = new QName(modelInfo.getUrl(), classInfo.getName());
TypeNode node = typeMap.computeIfAbsent(qname, key -> new TypeNode(key));
if (typeInfo.getBaseType() != null) {
QName baseQName = getBaseTypeName(modelInfo, typeInfo);
if (baseQName != null && baseQName.getNamespaceURI().equals(modelInfo.getUrl())) {
TypeNode parentNode = typeMap.computeIfAbsent(baseQName, key -> new TypeNode(key));
parentNode.getChildTypes().add(node);
node.getParentTypes().add(parentNode);
}
}
}
}
return typeMap;
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class CustomModelInfoProvider method addModel.
public void addModel(Reader modelInfoXML) {
ModelInfo modelInfo = JAXB.unmarshal(modelInfoXML, ModelInfo.class);
addModel(modelInfo);
}
use of org.hl7.elm_modelinfo.r1.ModelInfo in project quality-measure-and-cohort-service by Alvearie.
the class CustomModelInfoProvider method addModel.
public void addModel(File modelInfoXML) {
ModelInfo modelInfo = JAXB.unmarshal(modelInfoXML, ModelInfo.class);
addModel(modelInfo);
}
Aggregations