private static URI getModuleNamespace(final SchemaContext ctx, final String moduleName) { for (final Module module : ctx.getModules()) { if (moduleName.equals(module.getName())) { return module.getNamespace(); } } throw new IllegalArgumentException("Module " + moduleName + "does not exists in provided schema context"); }
@Override @SuppressWarnings("checkstyle:parameterName") public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line, final int charPositionInLine, final String msg, final RecognitionException e) { LOG.debug("Syntax error in module {} at {}:{}: {}", module.getName(), line, charPositionInLine, msg, e); exceptions.add(new LeafRefPathSyntaxErrorException(module.getName(), line, charPositionInLine, msg, e)); }
@Override protected String prefixForNamespace(final URI namespace) { final Iterator<Module> modules = context.findModules(namespace).iterator(); return modules.hasNext() ? modules.next().getName() : null; }
@Override public boolean apply(final Module input) { final ModuleIdentifierImpl id = new ModuleIdentifierImpl(input.getName(), Optional.fromNullable(input.getNamespace()), Optional.fromNullable(input.getRevision())); return id.equals(moduleIdentifier); } }).getSource();
@Override protected String prefixForNamespace(final URI namespace) { final Module module = context.findModuleByNamespaceAndRevision(namespace, null); return module == null ? null : module.getName(); }
private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.module.list.Module createModuleEntryFromModule(final Module module) { final ModuleBuilder moduleBuilder = new ModuleBuilder(); // TODO Conformance type is always set to Implement value, but it should it really be like this? // TODO Add also deviations and features lists to module entries moduleBuilder.setName(new YangIdentifier(module.getName())) .setRevision(new OptionalRevision(SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()))) .setNamespace(new Uri(module.getNamespace().toString())) .setConformanceType(ConformanceType.Implement) .setSubmodules(createSubmodulesForModule(module)); return moduleBuilder.build(); }
@Override protected String prefixForNamespace(final URI namespace) { final Iterator<Module> modules = context.findModules(namespace).iterator(); return modules.hasNext() ? modules.next().getName() : null; } }
@Override protected String prefixForNamespace(final URI namespace) { final Iterator<Module> modules = context.findModules(namespace).iterator(); return modules.hasNext() ? modules.next().getName() : null; }
@Override protected String prefixForNamespace(final URI namespace) { final Iterator<Module> modules = context.findModules(namespace).iterator(); return modules.hasNext() ? modules.next().getName() : null; }
private String toModuleNames(final Set<URI> potentialUris) { final StringBuilder builder = new StringBuilder(); for (final URI potentialUri : potentialUris) { builder.append('\n'); //FIXME how to get information about revision from JSON input? currently first available is used. builder.append(codecs.getSchemaContext().findModules(potentialUri).iterator().next().getName()); } return builder.toString(); }
public static Module getSortedQName(final Set<Module> modules, final String name) { final TreeMap<Optional<Revision>, Module> sorted = new TreeMap<>(Revision::compare); for (Module module : modules) { if (name.equals(module.getName())) { sorted.put(module.getRevision(), module); } } return sorted.lastEntry().getValue(); }
/** * Returns module instances (from the context) with a concrete name. Returned Set is required to have its iteration * order guarantee that the latest revision is encountered first. * * @param name * string with the module name * @return set of module instances with specified name. */ default Set<Module> findModules(final String name) { return Sets.filter(getModules(), m -> name.equals(m.getName())); }
@Override public void enterPrefix(final PrefixContext ctx) { final String prefix = ctx.getText(); if (!leafrefModule.getPrefix().equals(prefix)) { final Optional<QNameModule> qnameModuleOpt = getQNameModuleForImportPrefix(leafrefModule, prefix); checkArgument(qnameModuleOpt.isPresent(), "No module import for prefix: %s in module: %s", prefix, leafrefModule.getName()); currentQnameModule = qnameModuleOpt.get(); } else { currentQnameModule = leafrefModule.getQNameModule(); } }
@Override void addCodegenInformation(final GeneratedTypeBuilder interfaceBuilder, final Module module, final String description, final Set<? extends SchemaNode> nodes) { interfaceBuilder.addComment(TypeComments.javadoc("Interface for implementing the following YANG " + description + " defined in module <b>" + module.getName() + "</b>").get()); YangSourceDefinition.of(module, nodes).ifPresent(interfaceBuilder::setYangSourceDefinition); }
private String findModuleName(final YangInstanceIdentifier id, final SchemaContext context) { PathArgument rootQName = id.getPathArguments().iterator().next(); for (Module mod : context.getModules()) { if (mod.getDataChildByName(rootQName.getNodeType()) != null) { return mod.getName(); } } return null; }
private void processContainersAndLists(final Module module, final JSONObject models, final SchemaContext schemaContext) throws IOException, JSONException { String moduleName = module.getName(); for (DataSchemaNode childNode : module.getChildNodes()) { // For every container and list in the module if (childNode instanceof ContainerSchemaNode || childNode instanceof ListSchemaNode) { processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, true, schemaContext); processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, false, schemaContext); } } }
private String findYangModuleName(final QName qname, final SchemaContext schemaContext) throws ConfigXMLReaderException { for (Module m : schemaContext.getModules()) { if (qname.getModule().equals(m.getQNameModule())) { return m.getName(); } } throw new ConfigXMLReaderException( String.format("%s: Could not find yang module for QName %s", logName, qname)); }
private String findYangModuleName(QName qname, SchemaContext schemaContext) { for(Module m: schemaContext.getModules()) { if(qname.getModule().equals(m.getQNameModule())) { return m.getName(); } } setFailureMessage(String.format("%s: Could not find yang module for QName %s", logName(), qname)); return null; }
private void addRootPostLink(final Module module, final DataNodeContainer node, final List<Parameter> pathParams, final String resourcePath, final List<Api> apis) { if (containsListOrContainer(module.getChildNodes())) { final Api apiForRootPostUri = new Api(); apiForRootPostUri.setPath(resourcePath); apiForRootPostUri.setOperations(operationPost(module.getName() + MODULE_NAME_SUFFIX, module.getDescription(), module, pathParams, true)); apis.add(apiForRootPostUri); } }
void emitModule(final Module input) { super.writer.startModuleNode(input.getName()); emitModuleHeader(input); emitLinkageNodes(input); emitMetaNodes(input); emitRevisionNodes(input); emitBodyNodes(input); super.writer.endNode(); }