sdnopendaylightyang

Which package the YangInferencePipeline in yang parser library has moved to?


I upgraded my opendaylight yangtools libraries to 6.0.3 and the code breaks with the below errror(s):

import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
The import cannot be resolved

I am not sure to which package/module the YangInferencePipeline has moved? It is used in code to build the schemaContext

CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();

What should be the rfc7950 equivalent invocation for it in the updated libraries? Have already looked up the Javadoc at https://javadoc.io/doc/org.opendaylight.yangtools/yangtools-docs/latest/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/package-summary.html but cannot locate the class. Thanks in advance.


Solution

  • The below code is latest model 7.0.14 version. make sure you have updated pom.xml

    pom.xml

    <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-parser-impl</artifactId>
       <version>${opendaylight.yangtools.version}</version>
    </dependency>
    <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-model-util</artifactId>
       <version>${opendaylight.yangtools.version}</version>
    </dependency>
    

    Code Changes

    String folderPath - yang file location
    List<String> files - yang files retrived list
    
    final CustomCrossSourceStatementReactorBuilder builder = RFC7950Reactors.defaultReactorBuilder();
    final BuildAction buildAction = builder.build().newBuild();
    
    for (final String fileName : files) {
        final File file = new File(folderPath.concat("" + File.separatorChar).concat(fileName));
        buildAction.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forFile(file)));
    }
    final SchemaContext schemaContext = buildAction.buildEffective();
    Collection<? extends Module> yangModules = schemaContext.getModules();