use of org.jumpmind.symmetric.io.DbCompareReport in project symmetric-ds by JumpMind.
the class DbCompareCommand method executeWithOptions.
@Override
protected boolean executeWithOptions(CommandLine line) throws Exception {
String source = line.getOptionValue('s');
if (source == null) {
source = line.getOptionValue(OPTION_SOURCE);
}
if (StringUtils.isEmpty(source)) {
throw new ParseException(String.format("-source properties file is required."));
}
File sourceProperies = new File(source);
if (!sourceProperies.exists()) {
throw new SymmetricException("Source properties file '" + sourceProperies + "' does not exist.");
}
String target = line.getOptionValue('t');
if (target == null) {
target = line.getOptionValue(OPTION_TARGET);
}
if (StringUtils.isEmpty(target)) {
throw new ParseException(String.format("-target properties file is required."));
}
File targetProperties = new File(target);
if (!targetProperties.exists()) {
throw new SymmetricException("Target properties file '" + targetProperties + "' does not exist.");
}
DbCompareConfig config = new DbCompareConfig();
if (line.hasOption(OPTION_OUTPUT_SQL)) {
config.setSqlDiffFileName(line.getOptionValue(OPTION_OUTPUT_SQL));
}
if (line.hasOption(OPTION_USE_SYM_CONFIG)) {
config.setUseSymmetricConfig(Boolean.valueOf(line.getOptionValue(OPTION_USE_SYM_CONFIG)));
}
if (line.hasOption(OPTION_EXCLUDE)) {
config.setExcludedTableNames(Arrays.asList(line.getOptionValue(OPTION_EXCLUDE).split(",")));
}
config.setWhereClauses(parseWhereClauses(line));
if (!CollectionUtils.isEmpty(line.getArgList())) {
config.setIncludedTableNames(Arrays.asList(line.getArgList().get(0).toString().split(",")));
}
String numericScaleArg = line.getOptionValue(OPTION_NUMERIC_SCALE);
if (!StringUtils.isEmpty(numericScaleArg)) {
try {
config.setNumericScale(Integer.parseInt(numericScaleArg.trim()));
} catch (Exception ex) {
throw new ParseException("Failed to parse arg [" + numericScaleArg + "] " + ex);
}
}
ISymmetricEngine sourceEngine = new ClientSymmetricEngine(sourceProperies);
ISymmetricEngine targetEngine = new ClientSymmetricEngine(targetProperties);
DbCompare dbCompare = new DbCompare(sourceEngine, targetEngine, config);
DbCompareReport report = dbCompare.compare();
return false;
}
Aggregations