*/
package org.opendaylight.yangtools.yang.parser.util;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
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;
/**
* 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 {
/**
* Topological sort of module builder dependency graph.
- *
+ *
* @return Sorted list of Module builders. Modules can be further processed
* in returned order.
*/
/**
* Topological sort of module dependency graph.
- *
+ *
* @return Sorted list of Modules. Modules can be further processed in
* returned order.
*/
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)));
}
}
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