Merge "Added path to child nodes in documentation generator."
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / util / ModuleDependencySort.java
index a377eb5548f0ebc097c83ddae0745d9cc155391c..fd417493d2376440a9a08068703c031a2e8c5c2a 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.parser.util;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -19,7 +20,6 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserListenerImpl;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
 import org.slf4j.Logger;
@@ -33,9 +33,9 @@ import com.google.common.collect.Sets;
 
 /**
  * Creates a module dependency graph from provided {@link ModuleBuilder}s and
- * provides a {@link #sort()} method. It is topological sort and returns modules
- * in order in which they should be processed (e.g. if A imports B, sort returns
- * {B, A}).
+ * provides a {@link #sort(ModuleBuilder...)} method. It is topological sort and
+ * returns modules in order in which they should be processed (e.g. if A imports
+ * B, sort returns {B, A}).
  */
 public final class ModuleDependencySort {
 
@@ -50,7 +50,7 @@ public final class ModuleDependencySort {
 
     /**
      * Topological sort of module builder dependency graph.
-     * 
+     *
      * @return Sorted list of Module builders. Modules can be further processed
      *         in returned order.
      */
@@ -88,7 +88,7 @@ public final class ModuleDependencySort {
 
     /**
      * Topological sort of module dependency graph.
-     * 
+     *
      * @return Sorted list of Modules. Modules can be further processed in
      *         returned order.
      */
@@ -194,11 +194,14 @@ public final class ModuleDependencySort {
             if (moduleGraph.get(toName) != null && !moduleGraph.get(toName).isEmpty()
                     && toRevision.equals(DEFAULT_REVISION)) {
                 to = moduleGraph.get(toName).values().iterator().next();
-                LOGGER.warn(String
+                LOGGER.debug(String
                         .format("Import:%s:%s by module:%s:%s does not specify revision, using:%s:%s for module dependency sort",
                                 toName, formatRevDate(toRevision), fromName, formatRevDate(fromRevision), to.getName(),
                                 formatRevDate(to.getRevision())));
             } else {
+                LOGGER.warn(String.format("Not existing module imported:%s:%s by:%s:%s", toName,
+                        formatRevDate(toRevision), fromName, formatRevDate(fromRevision)));
+                LOGGER.warn("Available models: {}", moduleGraph);
                 ex(String.format("Not existing module imported:%s:%s by:%s:%s", toName, formatRevDate(toRevision),
                         fromName, formatRevDate(fromRevision)));
             }
@@ -253,7 +256,7 @@ public final class ModuleDependencySort {
     }
 
     private static String formatRevDate(Date rev) {
-        return rev.equals(DEFAULT_REVISION) ? "default" : YangParserListenerImpl.SIMPLE_DATE_FORMAT.format(rev);
+        return rev.equals(DEFAULT_REVISION) ? "default" : new SimpleDateFormat("yyyy-MM-dd").format(rev);
     }
 
     @VisibleForTesting