use of org.ehrbase.webtemplate.model.FilteredWebTemplate in project openEHR_SDK by ehrbase.
the class Filter method filter.
@Override
public FilteredWebTemplate filter(WebTemplate webTemplate) {
FilteredWebTemplate clone = new FilteredWebTemplate(webTemplate);
Pair<List<WebTemplateNode>, Map<Pair<String, String>, Deque<WebTemplateNode>>> filter = filter(clone.getTree(), webTemplate, new ArrayDeque<>());
clone.setTree(filter.getLeft().get(0));
clone.setFilteredNodeMap(filter.getRight());
return clone;
}
use of org.ehrbase.webtemplate.model.FilteredWebTemplate in project openEHR_SDK by ehrbase.
the class WalkerTest method testClone.
@Test
public void testClone() throws IOException, XmlException {
OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.CORONA_ANAMNESE.getStream()).getTemplate();
WebTemplate webTemplate = new OPTParser(template).parse();
FilteredWebTemplate filteredWebTemplate = new Filter().filter(webTemplate);
assertThat(filteredWebTemplate).isNotNull();
FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
String flat = IOUtils.toString(CompositionTestDataSimSDTJson.CORONA.getStream(), StandardCharsets.UTF_8);
Composition actual = cut.unmarshal(flat, webTemplate);
assertThat(actual).isNotNull();
FilteredWebTemplate filteredWebTemplateAfter = new Filter().filter(webTemplate);
assertThat(filteredWebTemplateAfter).isNotNull();
}
use of org.ehrbase.webtemplate.model.FilteredWebTemplate in project openEHR_SDK by ehrbase.
the class ClassGenerator method generate.
public ClassGeneratorResult generate(String packageName, WebTemplate webTemplate) {
ClassGeneratorContext context = new ClassGeneratorContext();
context.currentPackageName = packageName;
FilteredWebTemplate filteredWebTemplate = this.filter.filter(webTemplate);
context.webTemplate = filteredWebTemplate;
TypeSpec.Builder builder = build(context, filteredWebTemplate.getTree());
AnnotationSpec templateAnnotation = AnnotationSpec.builder(Template.class).addMember(Template.VALUE, "$S", webTemplate.getTemplateId()).build();
builder.addAnnotation(templateAnnotation);
addVersionUid(builder);
context.classes.put(packageName + "." + context.currentMainClass.toLowerCase(), builder.build());
ClassGeneratorResult generatorResult = new ClassGeneratorResult();
context.classes.entries().forEach(e -> generatorResult.addClass(e.getKey(), e.getValue()));
return generatorResult;
}
Aggregations