Search in sources :

Example 1 with MappingInclude

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.MappingInclude in project legend-engine by finos.

the class MappingValidator method visitMappingInclude.

private void visitMappingInclude(Mapping mapping, PureModel pureModel, Map<String, Mapping> mappings, Set<Mapping> visited, Set<Mapping> discovered) {
    discovered.add(mapping);
    mapping.includedMappings.forEach(mappingInclude -> {
        Mapping includedMapping = mappings.get(mappingInclude.getIncludedMapping());
        if (includedMapping != null) {
            if (discovered.contains(includedMapping)) {
                throw new EngineException(pureModel.buildPackageString(mapping._package, mapping.name) + " -> " + pureModel.buildPackageString(includedMapping._package, includedMapping.name));
            } else if (!visited.contains(includedMapping)) {
                try {
                    this.visitMappingInclude(includedMapping, pureModel, mappings, visited, discovered);
                } catch (Exception e) {
                    throw new EngineException(pureModel.buildPackageString(mapping._package, mapping.name) + " -> " + e.getMessage());
                }
            }
        }
    // NOTE: if the included mapping is not the map, it is either in system or it
    // belongs to another project, and by right, we should ensure there is not circular dependency in project
    // dependency chain, so we don't have to check that case.
    // For the case the included mapping does not exist, other compilation flows would catch that error anyway
    });
    discovered.remove(mapping);
    visited.add(mapping);
}
Also used : EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Mapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)

Example 2 with MappingInclude

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.MappingInclude in project legend-engine by finos.

the class MappingParseTreeWalker method visitMappingInclude.

private MappingInclude visitMappingInclude(MappingParserGrammar.IncludeMappingContext ctx) {
    MappingInclude mappingInclude = new MappingInclude();
    mappingInclude.setIncludedMapping(PureGrammarParserUtility.fromQualifiedName(ctx.qualifiedName().packagePath() == null ? Collections.emptyList() : ctx.qualifiedName().packagePath().identifier(), ctx.qualifiedName().identifier()));
    mappingInclude.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    List<MappingParserGrammar.StoreSubPathContext> storeSubPathContextList = ctx.storeSubPath();
    if (storeSubPathContextList.size() == 1) {
        visitStoreSubPath(storeSubPathContextList.get(0), mappingInclude);
    } else {
        mappingInclude.sourceDatabasePath = null;
        mappingInclude.targetDatabasePath = null;
    }
    return mappingInclude;
}
Also used : MappingInclude(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.MappingInclude)

Aggregations

Mapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping)1 MappingInclude (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.MappingInclude)1 EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)1