Search in sources :

Example 1 with FilteredWebTemplate

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;
}
Also used : FilteredWebTemplate(org.ehrbase.webtemplate.model.FilteredWebTemplate) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with FilteredWebTemplate

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();
}
Also used : OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Composition(com.nedap.archie.rm.composition.Composition) FilteredWebTemplate(org.ehrbase.webtemplate.model.FilteredWebTemplate) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) FilteredWebTemplate(org.ehrbase.webtemplate.model.FilteredWebTemplate) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) Filter(org.ehrbase.webtemplate.filter.Filter) FlatJsonUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.FlatJsonUnmarshaller) Test(org.junit.Test)

Example 3 with FilteredWebTemplate

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;
}
Also used : FilteredWebTemplate(org.ehrbase.webtemplate.model.FilteredWebTemplate) AnnotationSpec(com.squareup.javapoet.AnnotationSpec) TypeSpec(com.squareup.javapoet.TypeSpec)

Aggregations

FilteredWebTemplate (org.ehrbase.webtemplate.model.FilteredWebTemplate)3 Composition (com.nedap.archie.rm.composition.Composition)1 AnnotationSpec (com.squareup.javapoet.AnnotationSpec)1 TypeSpec (com.squareup.javapoet.TypeSpec)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 FlatJsonUnmarshaller (org.ehrbase.serialisation.flatencoding.std.umarshal.FlatJsonUnmarshaller)1 Filter (org.ehrbase.webtemplate.filter.Filter)1 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)1 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)1 OPTParser (org.ehrbase.webtemplate.parser.OPTParser)1 Test (org.junit.Test)1 OPERATIONALTEMPLATE (org.openehr.schemas.v1.OPERATIONALTEMPLATE)1