use of org.eclipse.winery.repository.backend.consistencycheck.ConsistencyCheckerProgressListener in project winery by eclipse.
the class WineryCli method doConsistencyCheck.
private static void doConsistencyCheck(CommandLine line, IRepository repository) {
EnumSet<ConsistencyCheckerVerbosity> verbosity;
if (line.hasOption("v")) {
verbosity = EnumSet.of(ConsistencyCheckerVerbosity.OUTPUT_NUMBER_OF_TOSCA_COMPONENTS, ConsistencyCheckerVerbosity.OUTPUT_CURRENT_TOSCA_COMPONENT_ID, ConsistencyCheckerVerbosity.OUTPUT_ERRORS);
} else {
verbosity = EnumSet.of(ConsistencyCheckerVerbosity.OUTPUT_NUMBER_OF_TOSCA_COMPONENTS);
}
boolean serviceTemplatesOnly = line.hasOption("so");
boolean checkDocumentation = line.hasOption("cd");
ConsistencyCheckerConfiguration configuration = new ConsistencyCheckerConfiguration(serviceTemplatesOnly, checkDocumentation, verbosity, repository);
final ConsistencyChecker consistencyChecker = new ConsistencyChecker(configuration);
int numberOfDefinitionsToCheck = consistencyChecker.numberOfDefinitionsToCheck();
ProgressBar progressBar = new ProgressBar("Check", numberOfDefinitionsToCheck, ProgressBarStyle.ASCII);
consistencyChecker.setConsistencyCheckerProgressListener(new ConsistencyCheckerProgressListener() {
@Override
public void updateProgress(float progress) {
progressBar.stepTo((long) (progress * numberOfDefinitionsToCheck));
}
@Override
public void updateProgress(float progress, String checkingDefinition) {
progressBar.setExtraMessage("Now checking " + checkingDefinition);
progressBar.stepTo((long) (progress * numberOfDefinitionsToCheck));
}
});
progressBar.start();
consistencyChecker.checkCorruption();
progressBar.stop();
ConsistencyErrorCollector errors = consistencyChecker.getErrorCollector();
System.out.println();
if (errors.getErrorList().isEmpty()) {
System.out.println("No errors exist.");
} else {
System.out.println("Errors found in the repository:");
System.out.println();
for (Map.Entry<QName, ElementErrorList> qName : errors.getErrorList().entrySet()) {
System.out.println(qName.getKey());
ElementErrorList elementErrorList = qName.getValue();
if (!elementErrorList.getErrors().isEmpty()) {
System.out.println("\tErrors:");
for (String error : elementErrorList.getErrors()) {
System.out.println("\t\t" + error);
}
}
if (!elementErrorList.getWarnings().isEmpty()) {
System.out.println("\n\tWarnings:");
for (String error : elementErrorList.getWarnings()) {
System.out.println("\t\t" + error);
}
}
System.out.println();
}
System.exit(1);
}
}
Aggregations