Skip to content

Commit

Permalink
Merge pull request #79 from PeterSuna/bump
Browse files Browse the repository at this point in the history
Prepare release 17.0.0
  • Loading branch information
ihrasko authored Oct 24, 2022
2 parents 2fdd6c9 + 0f362d9 commit 5133ad1
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 46 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Go to the root directory `/lighty-yang-validator/` and use the command:
mvn clean install
```

The distribution will be stored in the **"target"** directory, as a file called *lighty-yang-validator-17.0.0-SNAPSHOT-bin.zip*
The distribution will be stored in the **"target"** directory, as a file called *lighty-yang-validator-17.0.0-bin.zip*

## Run from Distribution

1. Unzip the distribution:

```
unzip lighty-yang-validator-17.0.0-SNAPSHOT-bin.zip
unzip lighty-yang-validator-17.0.0-bin.zip
```

2. Enter the directory, to which the distribution was extracted to.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<parent>
<groupId>io.lighty.core</groupId>
<artifactId>lighty-parent</artifactId>
<version>16.1.0</version>
<version>17.0.0</version>
</parent>

<groupId>io.lighty.yang.validator</groupId>
<artifactId>lighty-yang-validator</artifactId>
<version>17.0.0-SNAPSHOT</version>
<version>17.0.0</version>
<name>${project.artifactId}</name>
<description>YANG model validator</description>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lighty/yang/validator/LyvParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class LyvParameters {

private final ArgumentParser lyvArgumentParser = ArgumentParsers.newFor("LYV").build()
.defaultHelp(true)
.version("Version: ${prog} 17.0.0-SNAPSHOT\nContact: [email protected]")
.version("Version: ${prog} 17.0.0\nContact: [email protected]")
.description("Yangtools based yang module parser");
private final Format formatter;
private final String[] args;
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/io/lighty/yang/validator/YangContextFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
import org.opendaylight.yangtools.yang.common.YangConstants;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangParser;
import org.opendaylight.yangtools.yang.parser.api.YangParserException;
Expand All @@ -44,7 +45,7 @@ final class YangContextFactory {
private final List<File> testFiles = new ArrayList<>();
private final List<File> libFiles = new ArrayList<>();
private final Set<QName> supportedFeatures;
private final List<RevisionSourceIdentifier> sourceIdentifiers = new ArrayList<>();
private final List<SourceIdentifier> sourceIdentifiers = new ArrayList<>();

YangContextFactory(final List<String> yangLibDirs, final List<String> yangTestFiles,
final Set<QName> supportedFeatures, final boolean recursiveSearch) throws IOException {
Expand Down Expand Up @@ -83,13 +84,13 @@ EffectiveModelContext createContext(final boolean useAllFiles) throws IOExceptio
final List<String> names = new ArrayList<>();
for (final File file : testFiles) {
final YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.forPath(file.toPath());
names.add(yangTextSchemaSource.getIdentifier().getName());
names.add(yangTextSchemaSource.getIdentifier().name().getLocalName());
parser.addSource(yangTextSchemaSource);
}
for (final File file : libFiles) {
if (useAllFiles) {
final YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.forPath(file.toPath());
final String name = yangTextSchemaSource.getIdentifier().getName();
final String name = yangTextSchemaSource.getIdentifier().name().getLocalName();

if (!names.contains(name)) {
parser.addSource(yangTextSchemaSource);
Expand All @@ -103,14 +104,14 @@ EffectiveModelContext createContext(final boolean useAllFiles) throws IOExceptio
for (final Module next : effectiveModelContext.getModules()) {
for (final String name : names) {
if (next.getName().equals(name)) {
sourceIdentifiers.add(RevisionSourceIdentifier.create(name, next.getRevision()));
sourceIdentifiers.add(new SourceIdentifier(Unqualified.of(name), next.getRevision().orElse(null)));
}
}
}
return effectiveModelContext;
}

List<RevisionSourceIdentifier> getTestFilesSourceIdentifiers() {
List<SourceIdentifier> getTestFilesSourceIdentifiers() {
return sourceIdentifiers;
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/lighty/yang/validator/formats/Depends.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.ModuleLike;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -46,9 +46,9 @@ public class Depends extends FormatPlugin {
justification = "Valid output from LYV is dependent on Logback output")
public void emitFormat() {
final DependConfiguration dependConfiguration = this.configuration.getDependConfiguration();
for (final RevisionSourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.getName(), source.getRevision())
.orElseThrow(() -> new NotFoundException("Module", source.getName()));
for (final SourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.name().getLocalName(), source.revision())
.orElseThrow(() -> new NotFoundException("Module", source.name().getLocalName()));
final StringBuilder dependantsBuilder = new StringBuilder(MODULE);
dependantsBuilder.append(module.getName())
.append(AT);
Expand Down Expand Up @@ -80,7 +80,7 @@ public void emitFormat() {

private void resolveImports(final ModuleLike module, final DependConfiguration dependConfiguration) {
for (final ModuleImport moduleImport : module.getImports()) {
final String moduleName = moduleImport.getModuleName();
final String moduleName = moduleImport.getModuleName().getLocalName();
if (dependConfiguration.getExcludedModuleNames().contains(moduleName)) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lighty/yang/validator/formats/Emitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import io.lighty.yang.validator.simplify.SchemaTree;
import java.util.List;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;

public interface Emitter {

Expand All @@ -24,7 +24,7 @@ public interface Emitter {
* @param schemaTree Tree representation of schema nodes
*/
void init(Configuration config, EffectiveModelContext context,
List<RevisionSourceIdentifier> testFilesSchemaSources, SchemaTree schemaTree);
List<SourceIdentifier> testFilesSchemaSources, SchemaTree schemaTree);

/**
* Create logic and emit output.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lighty/yang/validator/formats/Format.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.List;
import java.util.Optional;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;

public class Format implements Emitter, CommandLineOptions {

Expand All @@ -41,7 +41,7 @@ public void createOptions(final LyvParameters lyvParameters) {

@Override
public void init(final Configuration config, final EffectiveModelContext context,
final List<RevisionSourceIdentifier> testFilesSchemaSources,
final List<SourceIdentifier> testFilesSchemaSources,
final SchemaTree schemaTree) {
final String format = config.getFormat();
for (final FormatPlugin plugin : this.formatPlugins) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
import java.util.List;
import java.util.Optional;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;

public abstract class FormatPlugin {

EffectiveModelContext schemaContext;
List<RevisionSourceIdentifier> sources;
List<SourceIdentifier> sources;
SchemaTree schemaTree;
Path output;
Configuration configuration;

void init(final EffectiveModelContext context, final List<RevisionSourceIdentifier> testFilesSchemaSources,
void init(final EffectiveModelContext context, final List<SourceIdentifier> testFilesSchemaSources,
final SchemaTree tree, final Configuration config) {
this.schemaContext = context;
this.sources = testFilesSchemaSources;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/lighty/yang/validator/formats/JsTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -57,9 +57,9 @@ public class JsTree extends FormatPlugin {
justification = "Valid output from LYV is dependent on Logback output")
public void emitFormat() {
this.namespacePrefix = new HashMap<>();
for (final RevisionSourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.getName(), source.getRevision())
.orElseThrow(() -> new NotFoundException("Module", source.getName()));
for (final SourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.name().getLocalName(), source.revision())
.orElseThrow(() -> new NotFoundException("Module", source.name().getLocalName()));
final SingletonListInitializer singletonListInitializer = new SingletonListInitializer(1);

// Nodes
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/lighty/yang/validator/formats/JsonTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -87,7 +87,7 @@ public class JsonTree extends FormatPlugin {
private static final String COLON = ":";

@Override
void init(final EffectiveModelContext context, final List<RevisionSourceIdentifier> testFilesSchemaSources,
void init(final EffectiveModelContext context, final List<SourceIdentifier> testFilesSchemaSources,
final SchemaTree schemaTree, final Configuration config) {
super.init(context, testFilesSchemaSources, schemaTree, config);
}
Expand All @@ -96,9 +96,9 @@ void init(final EffectiveModelContext context, final List<RevisionSourceIdentifi
@SuppressFBWarnings(value = "SLF4J_SIGN_ONLY_FORMAT",
justification = "Valid output from LYV is dependent on Logback output")
public void emitFormat() {
for (final RevisionSourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.getName(), source.getRevision())
.orElseThrow(() -> new NotFoundException(MODULE_STRING, source.getName()));
for (final SourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.name().getLocalName(), source.revision())
.orElseThrow(() -> new NotFoundException(MODULE_STRING, source.name().getLocalName()));
final JSONObject moduleMetadata = resolveModuleMetadata(module);
final JSONObject jsonTree = new JSONObject();
final SchemaInferenceStack schemaInferenceStack = SchemaInferenceStack.of(this.schemaContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import java.util.TreeSet;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -76,7 +77,8 @@ private void printEachYangModule() {
.orElseThrow(() -> new NotFoundException("Revision of module", module.getName()));
final String suffix = module.getRevision().isPresent() ? withRev + ".yang" : ".yang";
final String name = module.getName() + suffix;
if (!this.sources.contains(RevisionSourceIdentifier.create(module.getName(), module.getRevision()))
if (!this.sources.contains(
new SourceIdentifier(Unqualified.of(module.getName()), module.getRevision().get()))
&& !this.sources.isEmpty()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.Optional;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -29,9 +29,9 @@ public class NameRevision extends FormatPlugin {
@SuppressFBWarnings(value = "SLF4J_SIGN_ONLY_FORMAT",
justification = "Valid output from LYV is dependent on Logback output")
public void emitFormat() {
for (final RevisionSourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.getName(), source.getRevision())
.orElseThrow(() -> new NotFoundException("Module", source.getName()));
for (final SourceIdentifier source : this.sources) {
final Module module = this.schemaContext.findModule(source.name().getLocalName(), source.revision())
.orElseThrow(() -> new NotFoundException("Module", source.name().getLocalName()));
final Optional<Revision> revision = module.getRevision();
String moduleName = module.getName();
if (revision.isPresent()) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/lighty/yang/validator/formats/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -66,7 +66,7 @@ public class Tree extends FormatPlugin {
private int lineLength;

@Override
void init(final EffectiveModelContext context, final List<RevisionSourceIdentifier> testFilesSchemaSources,
void init(final EffectiveModelContext context, final List<SourceIdentifier> testFilesSchemaSources,
final SchemaTree schemaTree, final Configuration config) {
super.init(context, testFilesSchemaSources, schemaTree, config);
this.namespacePrefix = new HashMap<>();
Expand All @@ -83,9 +83,9 @@ public void emitFormat() {
if (this.configuration.getTreeConfiguration().isHelp()) {
printHelp();
}
for (final RevisionSourceIdentifier source : this.sources) {
usedModule = this.schemaContext.findModule(source.getName(), source.getRevision())
.orElseThrow(() -> new NotFoundException("Module", source.getName()));
for (final SourceIdentifier source : this.sources) {
usedModule = this.schemaContext.findModule(source.name().getLocalName(), source.revision())
.orElseThrow(() -> new NotFoundException("Module", source.name().getLocalName()));
final String firstLine = MODULE + usedModule.getName();
LOG.info("{}", firstLine.substring(0, min(firstLine.length(), lineLength)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private ModulePrinter(final Set<SchemaTree> schemaTree, final EffectiveModelCont
.orElseThrow(() -> new NotFoundException("Module ", moduleName.toString()));
moduleToPrefix = module.getImports().stream()
.collect(Collectors.toMap(i -> schemaContext
.findModules(i.getModuleName()).iterator().next().getQNameModule(),
.findModules(i.getModuleName().getLocalName()).iterator().next().getQNameModule(),
ModuleImport::getPrefix));
typePrinter = new SmartTypePrintingStrategy(module, moduleToPrefix);
}
Expand Down Expand Up @@ -439,8 +439,8 @@ private void doPrintSimpleRevision(final Revision revision) {

private void printImports() {
for (final ModuleImport anImport : module.getImports()) {
if (this.usedImports.contains(anImport.getModuleName())) {
printer.openStatement(Statement.IMPORT, anImport.getModuleName());
if (this.usedImports.contains(anImport.getModuleName().getLocalName())) {
printer.openStatement(Statement.IMPORT, anImport.getModuleName().getLocalName());
printer.printSimple("prefix", anImport.getPrefix());
printer.closeStatement();
printer.printEmptyLine();
Expand Down

0 comments on commit 5133ad1

Please sign in to comment.