SyncModel processor = null;
try
{
Application.setArguments(args);
CommandLineParser cp = new CommandLineParser();
cp
.setUsageMsgHeader(new String[]
{
"Model synchronization utility.",
"Copies model data between different model manager types",
"", "Usage:",
});
cp.addArgumentOption("SourceMgr", "Source model manager (classpath|filesystem|database) (default: filesystem)");
cp.addArgumentOption("TargetMgr", "Target model manager (filesystem|database) (default: database)");
cp.addArgumentOption("Mode", "Operation mode (Copy|CopyAll|Remove|RemoveAll) (default: copy)");
cp.addBooleanOption("Overwrite", "Forces existing models that exist in the target manager to be removed before the copy operation takes place (default: false)");
try
{
cp.parse(args);
}
catch (CommandLineParserException e)
{
System.err.println(e.getMessage());
cp.printUsageAndExit();
}
processor = new SyncModel();
processor.setProcessServer(new ProcessServerFactory().createProcessServer("OpenBP-SyncModel-Hibernate.spring.xml"));
int mode = 0;
String m = cp.getStringOption("Mode");
if (m.equalsIgnoreCase("Copy"))
{
mode = MODE_COPY;
}
else if (m.equalsIgnoreCase("CopyAll"))
{
mode = MODE_COPY_ALL;
}
else if (m.equalsIgnoreCase("Remove"))
{
mode = MODE_REMOVE;
}
else if (m.equalsIgnoreCase("RemoveAll"))
{
mode = MODE_REMOVE_ALL;
}
else
{
printError("Unknown operation mode '" + m + "'.");
}
processor.setMode(mode);
String sourceMgrType = cp.getStringOption("SourceMgr");
if (sourceMgrType == null)
sourceMgrType = "filesystem";
processor.setSourceMgrType(sourceMgrType);
String targetMgrType = cp.getStringOption("TargetMgr");
if (targetMgrType == null)
targetMgrType = "database";
processor.setTargetMgrType(targetMgrType);
processor.setOverwrite(cp.getBooleanOption("Overwrite"));
boolean hasArguments = false;
String [] modelNames = cp.getArguments();
if (modelNames != null)
{
for (int i = 0; i < modelNames.length; ++i)
{
processor.addModel(modelNames[i]);