use of org.molgenis.vcf.meta.VcfMetaFormat in project molgenis by molgenis.
the class VcfToEntity method createSampleEntityType.
private EntityType createSampleEntityType(String entityTypeId, Iterable<VcfMetaFormat> formatMetaData) {
EntityType result = null;
if (formatMetaData.iterator().hasNext()) {
String sampleEntityTypeId = entityTypeId + "Sample";
result = entityTypeFactory.create(sampleEntityTypeId);
result.setLabel(sampleEntityTypeId);
Attribute idAttr = attrMetaFactory.create().setName(ID).setAggregatable(true).setVisible(false);
Attribute nameAttr = attrMetaFactory.create().setName(NAME).setDataType(TEXT).setAggregatable(true).setNillable(false);
Attribute originalNameAttr = attrMetaFactory.create().setName(ORIGINAL_NAME).setDataType(TEXT);
result.addAttribute(idAttr, ROLE_ID);
result.addAttribute(nameAttr, ROLE_LABEL, ROLE_LOOKUP);
for (VcfMetaFormat meta : formatMetaData) {
String name = meta.getId();
if (NameValidator.KEYWORDS.contains(name) || NameValidator.KEYWORDS.contains(name.toUpperCase())) {
name = name + "_";
}
Attribute attr = attrMetaFactory.create().setName(name.replaceAll("[-.*$&%^()#!@?_]", "")).setDataType(vcfFieldTypeToMolgenisFieldType(meta)).setAggregatable(true).setLabel(meta.getId());
result.addAttribute(attr);
}
result.addAttribute(originalNameAttr);
}
return result;
}
Aggregations