use of org.hl7.elm_modelinfo.r1.TypeInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetBaseTypeNameIncludedNamespacePrefixMissing.
@Test
public void testGetBaseTypeNameIncludedNamespacePrefixMissing() {
ModelSpecifier otherModel = new ModelSpecifier().withName("Other").withVersion("1.2.3").withUrl("urn:oid:Other");
ModelInfo modelInfo = new ModelInfo();
modelInfo.setName("Dummy");
modelInfo.setVersion("5.4.3");
modelInfo.setUrl("urn:oid:Dummy");
modelInfo.getRequiredModelInfo().add(otherModel);
ClassInfo typeInfo = new ClassInfo();
typeInfo.setName("MyType");
typeInfo.setBaseType("Missing.BaseType");
IllegalArgumentException iex = assertThrows(IllegalArgumentException.class, () -> ModelUtils.getBaseTypeName(modelInfo, typeInfo));
assertTrue(iex.getMessage(), iex.getMessage().contains("Missing"));
assertTrue(iex.getMessage(), iex.getMessage().contains(modelInfo.getName()));
assertTrue(iex.getMessage(), iex.getMessage().contains(modelInfo.getVersion()));
}
use of org.hl7.elm_modelinfo.r1.TypeInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetBaseTypeNameNoNamespacePrefix.
@Test
public void testGetBaseTypeNameNoNamespacePrefix() {
ModelInfo modelInfo = new ModelInfo();
modelInfo.setName("Dummy");
modelInfo.setUrl("urn:oid:Dummy");
ClassInfo typeInfo = new ClassInfo();
typeInfo.setName("MyType");
typeInfo.setBaseType("BaseType");
QName qname = ModelUtils.getBaseTypeName(modelInfo, typeInfo);
assertEquals(new QName(modelInfo.getUrl(), "BaseType"), qname);
}
use of org.hl7.elm_modelinfo.r1.TypeInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetBaseTypeNameSystemNamespacePrefix.
@Test
public void testGetBaseTypeNameSystemNamespacePrefix() {
ModelInfo modelInfo = new ModelInfo();
modelInfo.setName("Dummy");
modelInfo.setUrl("urn:oid:Dummy");
ClassInfo typeInfo = new ClassInfo();
typeInfo.setName("MyType");
typeInfo.setBaseType("System.BaseType");
QName qname = ModelUtils.getBaseTypeName(modelInfo, typeInfo);
assertEquals(new QName(CqlConstants.SYSTEM_MODEL_URI, "BaseType"), qname);
}
use of org.hl7.elm_modelinfo.r1.TypeInfo in project coral by linkedin.
the class TypeConverter method convert.
// Mimic the StructTypeInfo conversion to convert a UnionTypeInfo to the corresponding RelDataType
// The schema of output Struct conforms to https://github.com/trinodb/trino/pull/3483
// except we adopted "integer" for the type of "tag" field instead of "tinyint" in the Trino patch
// for compatibility with other platforms that Iceberg currently doesn't support tinyint type.
// Note: this is subject to change in the future pending on the discussion in
// https://mail-archives.apache.org/mod_mbox/iceberg-dev/202112.mbox/browser
public static RelDataType convert(UnionTypeInfo unionType, RelDataTypeFactory dtFactory) {
List<RelDataType> fTypes = unionType.getAllUnionObjectTypeInfos().stream().map(typeInfo -> convert(typeInfo, dtFactory)).collect(Collectors.toList());
List<String> fNames = IntStream.range(0, unionType.getAllUnionObjectTypeInfos().size()).mapToObj(i -> "field" + i).collect(Collectors.toList());
fTypes.add(0, dtFactory.createSqlType(SqlTypeName.INTEGER));
fNames.add(0, "tag");
RelDataType rowType = dtFactory.createStructType(fTypes, fNames);
return dtFactory.createTypeWithNullability(rowType, true);
}
use of org.hl7.elm_modelinfo.r1.TypeInfo in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtilsTest method testGetChoiceTypesValid.
@Test
public void testGetChoiceTypesValid() {
ModelInfo modelInfo = JAXB.unmarshal(new File("src/test/resources/abstract-context/modelinfo/abstract-modelinfo-1.0.0.xml"), ModelInfo.class);
TypeInfo typeInfo = modelInfo.getTypeInfo().stream().map(ClassInfo.class::cast).filter(classInfo -> classInfo.getName().equals("AlphaNumeric")).findFirst().orElse(null);
Collection<String> choiceTypes = ModelUtils.getChoiceTypeNames(typeInfo);
assertThat(choiceTypes, Matchers.containsInAnyOrder("Alpha", "Numeric"));
}
Aggregations