Skip to content

Commit

Permalink
Resolved some bugs associated with the recent refactoring and -all
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Nov 27, 2006
1 parent 044fba5 commit 34b3d0c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/net/sourceforge/schemaspy/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ protected void dumpUsage(String errorMessage, boolean detailedDb) {
System.out.println("Sample usage using the default database type (implied -t ora):");
System.out.println(" java -jar schemaSpy.jar -db mydb -s myschema -u devuser -p password -o output");
System.out.println();
System.out.flush();
}

public List asList() throws IOException {
Expand Down Expand Up @@ -759,9 +760,9 @@ public List asList() throws IOException {
list.add(value);
}
list.add("-i");
list.add(getInclusions());
list.add(getInclusions().toString());
list.add("-x");
list.add(getExclusions());
list.add(getExclusions().toString());
list.add("-dbthreads");
list.add(String.valueOf(getMaxDbThreads()));
list.add("-maxdet");
Expand Down
5 changes: 4 additions & 1 deletion src/net/sourceforge/schemaspy/MultipleSchemaAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public int analyze(String dbName, DatabaseMetaData meta, String schemaSpec, List
genericCommand.add("-jar");
genericCommand.add(loadedFrom);
}
genericCommand.addAll(args);

for (Iterator iter = args.iterator(); iter.hasNext(); )
genericCommand.add("\"" + iter.next() + "\"");

System.out.println("Analyzing schemas that match regular expression '" + schemaSpec + "':");
System.out.println("(use -schemaSpec on command line or in .properties to exclude other schemas)");
Expand All @@ -52,6 +54,7 @@ public int analyze(String dbName, DatabaseMetaData meta, String schemaSpec, List
command.add("-o");
command.add(new File(outputDir, schema).toString());
System.out.println("Analyzing " + schema);
System.out.flush();
Process java = Runtime.getRuntime().exec((String[])command.toArray(new String[]{}));
new ProcessOutputReader(java.getInputStream(), System.out).start();
new ProcessOutputReader(java.getErrorStream(), System.err).start();
Expand Down
8 changes: 8 additions & 0 deletions src/net/sourceforge/schemaspy/SchemaAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.xml.parsers.*;
import net.sourceforge.schemaspy.model.*;
import net.sourceforge.schemaspy.util.*;
import net.sourceforge.schemaspy.util.ConnectionURLBuilder.*;
import net.sourceforge.schemaspy.view.*;
import org.w3c.dom.*;

Expand Down Expand Up @@ -61,6 +62,13 @@ public int analyze(Config config, String[] argv) throws Exception {

if (config.isEvaluateAllEnabled()) {
List args = config.asList();
Iterator iter = urlBuilder.getOptions().iterator();
while (iter.hasNext()) {
DbOption option = (DbOption)iter.next();
args.add("-" + option.name);
args.add(option.value);
}

yankParam(args, "-o"); // param will be replaced by something appropriate
yankParam(args, "-s"); // param will be replaced by something appropriate
args.remove("-all"); // param will be replaced by something appropriate
Expand Down
53 changes: 28 additions & 25 deletions src/net/sourceforge/schemaspy/util/ConnectionURLBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ public class ConnectionURLBuilder {
private final String description;
private final String connectionURL;
private String dbName = null;
private final List params = new ArrayList();
private final List descriptions = new ArrayList();
private final List options = new ArrayList();
public class DbOption {
public final String name;
public final String value;
public final String description;

public DbOption(String name, String value, String description) {
this.name = name;
this.value = value;
this.description = description;
}
}

/**
* @param config
Expand All @@ -24,16 +34,16 @@ public class ConnectionURLBuilder {
public ConnectionURLBuilder(Config config, Properties properties) throws IOException {
this.type = config.getDbType();

List options = new ArrayList();
List opts = new ArrayList();
Iterator iter = config.getDbSpecificOptions().keySet().iterator();
while (iter.hasNext()) {
String key = iter.next().toString();
options.add((key.startsWith("-") ? "" : "-") + key);
options.add(config.getDbSpecificOptions().get(key));
opts.add((key.startsWith("-") ? "" : "-") + key);
opts.add(config.getDbSpecificOptions().get(key));
}
options.addAll(config.getRemainingParameters());
opts.addAll(config.getRemainingParameters());

connectionURL = parseParameters(options, properties);
connectionURL = parseParameters(opts, properties);

if (dbName == null) {
dbName = connectionURL;
Expand All @@ -42,10 +52,10 @@ public ConnectionURLBuilder(Config config, Properties properties) throws IOExcep
description = properties.getProperty("description");

List remaining = config.getRemainingParameters();
iter = params.iterator();
iter = options.iterator();
while (iter.hasNext()) {
String param = iter.next().toString();
int idx = remaining.indexOf(param);
DbOption option = (DbOption)iter.next();
int idx = remaining.indexOf("-" + option.name);
if (idx >= 0) {
remaining.remove(idx); // -paramKey
remaining.remove(idx); // paramValue
Expand Down Expand Up @@ -114,22 +124,15 @@ public String getDbName() {
return dbName;
}

public List getParams() {
return params;
}

public List getParamDescriptions() {
return descriptions;
public List getOptions() {
return options;
}

private String getParam(List args, String paramName, Properties properties) {
String param = null;
int paramIndex = args != null ? args.indexOf("-" + paramName) : -1;
String description = properties.getProperty(paramName);

params.add("-" + paramName);
descriptions.add(description);

if (args != null) {
if (paramIndex < 0)
throw new Config.MissingRequiredParameterException(paramName, description, true);
Expand All @@ -138,20 +141,20 @@ private String getParam(List args, String paramName, Properties properties) {
param = args.get(paramIndex).toString();
args.remove(paramIndex);
}

options.add(new DbOption(paramName, param, description));

return param;
}

public void dumpUsage() {
System.out.println(" " + new File(type).getName() + ":");
System.out.println(" " + description);
List params = getParams();
List paramDescriptions = getParamDescriptions();
Iterator iter = getOptions().iterator();

for (int i = 0; i < params.size(); ++i) {
String param = params.get(i).toString();
String paramDescription = (String)paramDescriptions.get(i);
System.out.println(" " + param + " " + (paramDescription != null ? " \t" + paramDescription : ""));
while (iter.hasNext()) {
DbOption option = (DbOption)iter.next();
System.out.println(" -" + option.name + " " + (option.description != null ? " \t" + option.description : ""));
}
}
}

0 comments on commit 34b3d0c

Please sign in to comment.