Search in sources :

Example 1 with TemplateOverlay

use of com.nedap.archie.aom.TemplateOverlay in project archetype-languageserver by nedap.

the class BroadcastingArchetypeRepository method invalidateAndRecompileArchetypes.

public void invalidateAndRecompileArchetypes(Archetype newArchetype) {
    // now invalidate all related archetypes
    Set<String> archetypesToInvalidate = new HashSet<>();
    archetypesToInvalidate.add(newArchetype.getArchetypeId().toString());
    for (Archetype result : getAllArchetypes()) {
        if (isDescendant(result, newArchetype.getArchetypeId().getFullId())) {
            archetypesToInvalidate.add(result.getArchetypeId().toString());
        }
        // this assumes templates cannot be further specialized
        if (result instanceof Template) {
            Template template = (Template) result;
            for (TemplateOverlay overlay : template.getTemplateOverlays()) {
                // TODO: not only direct descendants, but also those far below should be checked with (a variant of?) isDescendant
                if (archetypesToInvalidate.contains(overlay.getParentArchetypeId())) {
                    archetypesToInvalidate.add(result.getArchetypeId().getFullId());
                }
            }
        }
    }
    for (String archetypeId : archetypesToInvalidate) {
        removeValidationResult(archetypeId);
    }
    // TODO: for operational templates we need to scan way more, all archetype roots as well. future addition
    if (compile) {
        for (String archetypeId : archetypesToInvalidate) {
            Archetype archetype = getArchetype(archetypeId);
            if (archetype != null && getValidationResult(archetypeId) == null) {
                validator.validate(archetype, this);
            }
        }
        resolveDocumentLinks();
    }
}
Also used : TemplateOverlay(com.nedap.archie.aom.TemplateOverlay) Archetype(com.nedap.archie.aom.Archetype) HashSet(java.util.HashSet) Template(com.nedap.archie.aom.Template)

Aggregations

Archetype (com.nedap.archie.aom.Archetype)1 Template (com.nedap.archie.aom.Template)1 TemplateOverlay (com.nedap.archie.aom.TemplateOverlay)1 HashSet (java.util.HashSet)1