@Test public void testOnlyChild() { Archetype parent = TestAdlParser.parseAdl( "adl15/reference/features/annotations/openEHR-EHR-EVALUATION.annotations_parent.v1.adls"); Archetype specialized = TestAdlParser.parseAdl( "adl15/reference/features/annotations/openEHR-EHR-EVALUATION.annotations_only_child.v1.adls"); Archetype flattened = flatten(parent, specialized); assertThat(flattened.getAnnotations().getItems()).hasSize(1); ResourceAnnotationNodes annotations = flattened.getAnnotations().getItems().get(0); assertThat(annotations.getLanguage()).isEqualTo("en"); assertThat(annotations.getItems()).hasSize(2); assertThat(getAnnotation(annotations, "/data[id2]")) .isEqualTo(ImmutableMap.of("ui", "passthrough")); assertThat(getAnnotation(annotations, "/data[id2]/items[id3]")) .isEqualTo( ImmutableMap.of( "requirements note", "this is a requirements note on Statement", "medline ref", "this is a medline ref on Statement", "design note", "this is a SPECIALISED design note on Statement", "NEW TAG", "this is a SPECIALISED design note on Statement")); }
@SuppressWarnings("unchecked") public static <T extends AmObject, C extends AmConstraintContext> void walkConstraints( AmVisitor<T, C> visitor, Archetype archetype, C context) { if (!(visitor instanceof ConstraintAmVisitor<?>)) { visitor = new ConstraintAmVisitor<>().add(AmObject.class, (AmVisitor) visitor); } ArchetypeWalker<C> walker = new ArchetypeWalker<>((AmVisitor<AmObject, C>) visitor, context); Action<?> action = walker.walk(archetype.getDefinition()); if (action.act != Action.Act.next) { throw new AssertionError("Cannot remove or replace root constraint"); } }
public static Archetype createDifferentialArchetypeClone(Archetype source) { checkArgument(!source.isIsDifferential(), "source archetype must be a flat archetype"); Archetype result = makeClone(source); result.setIsDifferential(true); return result; }
public static Archetype createFlatArchetypeClone(Archetype source) { checkArgument(source.isIsDifferential(), "source archetype must be a differential archetype"); Archetype result = makeClone(source); result.setIsDifferential(false); return result; }
public static void fillArchetypeFields(Archetype target, Archetype source) { target.setIsControlled(source.isIsControlled()); target.setBuildUid(source.getBuildUid()); target.setAdlVersion(source.getAdlVersion()); target.setDescription(source.getDescription()); target.setOriginalLanguage(source.getOriginalLanguage()); target.setRevisionHistory(source.getRevisionHistory()); target.setAnnotations(source.getAnnotations()); target.setIsGenerated(source.isIsGenerated()); target.setRmRelease(source.getRmRelease()); target.getOtherMetadata().addAll(source.getOtherMetadata()); target.getTranslations().addAll(source.getTranslations()); target.setDefinition(source.getDefinition()); target.setArchetypeId(source.getArchetypeId()); target.setIsDifferential(source.isIsDifferential()); target.setConcept(source.getConcept()); target.setTerminology(source.getTerminology()); target.setParentArchetypeId(source.getParentArchetypeId()); target.getInvariants().addAll(source.getInvariants()); target.setIsOverlay(source.isIsOverlay()); target.setIsTemplate(source.isIsTemplate()); }