diff options
author | Michal Cmarada <michal.cmarada@pantheon.tech> | 2018-05-04 11:49:52 +0200 |
---|---|---|
committer | Michal Cmarada <michal.cmarada@pantheon.tech> | 2018-05-09 14:35:57 +0200 |
commit | d5883157bff11ee89b95bc1abe7f62fca3509950 (patch) | |
tree | bedae4a94bf7787dd318071940340e3d1a8022bf /vpp-integration | |
parent | 6bfb3a997ad5f0993808db92b484f3d0d5dac452 (diff) |
HC2VPP-316 - Fix docs generation for augments without qname
this fixes bug when model augments case
and augment generated class does not contain qname.
Change-Id: I6b088d9dce46015e2c7c374b0197bedb5e868e79
Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
Diffstat (limited to 'vpp-integration')
2 files changed, 25 insertions, 1 deletions
diff --git a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java index bc94a74cb..fb9e3a629 100644 --- a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java +++ b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java @@ -97,6 +97,7 @@ public class CoverageGenerator implements VppApiUtils { // binds Yang types with links from pre-build index // TODO - use deserialized yii e.g. /module:parent-node/child-node builder.setYangTypes(handler.getHandledNodes().stream() + .filter(YangTypeLinkIndex::hasQname) .map(type -> new YangType(type, yangTypeIndex.getLinkForType(type))) .collect(Collectors.toList())); diff --git a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java index b4002b636..4b0a3c1bd 100644 --- a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java +++ b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java @@ -20,10 +20,16 @@ import static java.lang.String.format; import java.io.IOException; import java.lang.reflect.Field; +import java.util.Arrays; + import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class YangTypeLinkIndex { + private static final Logger LOG = LoggerFactory.getLogger(YangTypeLinkIndex.class); + private final ModelLinkIndex modelLinkIndex; private final ModelTypeIndex modelTypeIndex; @@ -36,6 +42,24 @@ public class YangTypeLinkIndex { } } + // to be able to skip augments without QNAME field + static boolean hasQname(final String classname) { + final Class<?> loadedClass; + try { + loadedClass = YangTypeLinkIndex.class.getClassLoader().loadClass(classname); + boolean + hasQname = Arrays.stream(loadedClass.getFields()) + .anyMatch(field -> field.getName().equalsIgnoreCase("QNAME")); + if (!hasQname) { + LOG.warn("Class {} does not have a QNAME field", classname); + } + + return hasQname; + } catch (ClassNotFoundException e) { + throw new IllegalStateException(format("Unable to load classname: %s", classname), e); + } + } + public String getLinkForType(final String classname) { final Class<?> loadedClass; final QName qname; @@ -47,7 +71,6 @@ public class YangTypeLinkIndex { throw new IllegalStateException(format("Unable to extract QNAME from %s", classname), e); } - final String namespace = qname.getNamespace().toString(); final String formattedRevision = qname.getRevision().get().toString(); final String model = modelTypeIndex.namespaceToModule(namespace, formattedRevision); |