[#5301] Display a warning in the generator logs for regexes that never match
This commit is contained in:
parent
4755504dfa
commit
d3ec840bd8
@ -267,8 +267,12 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
|
||||
if (generateImmutablePojos && generateInterfaces)
|
||||
log.info(" immutable pojos", "Immutable POJOs do not have any setters. Hence, setters are also missing from interfaces");
|
||||
else
|
||||
log.info(" none");
|
||||
|
||||
if (contains(db.getIncludes(), ',') && db.getIncluded().isEmpty())
|
||||
log.info(" includes", "The <includes/> element takes a Java regular expression, not a comma-separated list. This might be why no objects were included.");
|
||||
|
||||
if (contains(db.getExcludes(), ',') && db.getExcluded().isEmpty())
|
||||
log.info(" excludes", "The <excludes/> element takes a Java regular expression, not a comma-separated list. This might be why no objects were excluded.");
|
||||
|
||||
log.info("");
|
||||
log.info("----------------------------------------------------------");
|
||||
@ -287,6 +291,34 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmpty(Database db) {
|
||||
for (SchemaDefinition schema : db.getSchemata()) {
|
||||
for (TableDefinition table : db.getTables(schema))
|
||||
return false;
|
||||
for (SequenceDefinition sequence : db.getSequences(schema))
|
||||
return false;
|
||||
for (PackageDefinition pkg : db.getPackages(schema))
|
||||
return false;
|
||||
for (RoutineDefinition routine : db.getRoutines(schema))
|
||||
return false;
|
||||
for (UDTDefinition udt : db.getUDTs(schema))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean contains(String[] array, char c) {
|
||||
if (array == null)
|
||||
return false;
|
||||
|
||||
for (String string : array)
|
||||
if (string != null && string.indexOf(c) > -1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void generate(CatalogDefinition catalog) {
|
||||
String newVersion = catalog.getDatabase().getCatalogVersionProvider().version(catalog);
|
||||
|
||||
|
||||
@ -168,6 +168,9 @@ public abstract class AbstractDatabase implements Database {
|
||||
private transient boolean initialised;
|
||||
|
||||
// Other caches
|
||||
private final List<Definition> all;
|
||||
private final List<Definition> included;
|
||||
private final List<Definition> excluded;
|
||||
private final Map<Table<?>, Boolean> exists;
|
||||
private final Map<String, Pattern> patterns;
|
||||
|
||||
@ -175,6 +178,9 @@ public abstract class AbstractDatabase implements Database {
|
||||
exists = new HashMap<Table<?>, Boolean>();
|
||||
patterns = new HashMap<String, Pattern>();
|
||||
filters = new ArrayList<Filter>();
|
||||
all = new ArrayList<Definition>();
|
||||
included = new ArrayList<Definition>();
|
||||
excluded = new ArrayList<Definition>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -877,6 +883,7 @@ public abstract class AbstractDatabase implements Database {
|
||||
try {
|
||||
List<SequenceDefinition> s = getSequences0();
|
||||
|
||||
all.addAll(s);
|
||||
sequences = filterExcludeInclude(s);
|
||||
log.info("Sequences fetched", fetchedSize(s, sequences));
|
||||
}
|
||||
@ -979,6 +986,7 @@ public abstract class AbstractDatabase implements Database {
|
||||
try {
|
||||
List<TableDefinition> t = getTables0();
|
||||
|
||||
all.addAll(t);
|
||||
tables = filterExcludeInclude(t);
|
||||
log.info("Tables fetched", fetchedSize(t, tables));
|
||||
}
|
||||
@ -1238,6 +1246,7 @@ public abstract class AbstractDatabase implements Database {
|
||||
try {
|
||||
List<RoutineDefinition> r = getRoutines0();
|
||||
|
||||
all.addAll(r);
|
||||
routines = filterExcludeInclude(r);
|
||||
log.info("Routines fetched", fetchedSize(r, routines));
|
||||
}
|
||||
@ -1264,6 +1273,7 @@ public abstract class AbstractDatabase implements Database {
|
||||
try {
|
||||
List<PackageDefinition> p = getPackages0();
|
||||
|
||||
all.addAll(p);
|
||||
packages = filterExcludeInclude(p);
|
||||
log.info("Packages fetched", fetchedSize(p, packages));
|
||||
}
|
||||
@ -1311,11 +1321,9 @@ public abstract class AbstractDatabase implements Database {
|
||||
else {
|
||||
List<T> result = new ArrayList<T>();
|
||||
|
||||
for (T definition : definitions) {
|
||||
if (definition.getSchema().equals(schema)) {
|
||||
for (T definition : definitions)
|
||||
if (definition.getSchema().equals(schema))
|
||||
result.add(definition);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1323,7 +1331,29 @@ public abstract class AbstractDatabase implements Database {
|
||||
|
||||
@Override
|
||||
public final <T extends Definition> List<T> filterExcludeInclude(List<T> definitions) {
|
||||
return filterExcludeInclude(definitions, excludes, includes, filters);
|
||||
List<T> result = filterExcludeInclude(definitions, excludes, includes, filters);
|
||||
|
||||
this.all.addAll(definitions);
|
||||
this.included.addAll(result);
|
||||
this.excluded.addAll(definitions);
|
||||
this.excluded.removeAll(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Definition> getIncluded() {
|
||||
return Collections.unmodifiableList(included);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Definition> getExcluded() {
|
||||
return Collections.unmodifiableList(excluded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<Definition> getAll() {
|
||||
return Collections.unmodifiableList(all);
|
||||
}
|
||||
|
||||
protected final <T extends Definition> List<T> filterExcludeInclude(List<T> definitions, String[] e, String[] i, List<Filter> f) {
|
||||
|
||||
@ -363,6 +363,21 @@ public interface Database {
|
||||
*/
|
||||
<D extends Definition> List<D> filterExcludeInclude(List<D> definitions);
|
||||
|
||||
/**
|
||||
* Retrieve all included objects.
|
||||
*/
|
||||
List<Definition> getIncluded();
|
||||
|
||||
/**
|
||||
* Retrieve all excluded objects.
|
||||
*/
|
||||
List<Definition> getExcluded();
|
||||
|
||||
/**
|
||||
* Retrieve all objects.
|
||||
*/
|
||||
List<Definition> getAll();
|
||||
|
||||
/**
|
||||
* The regular expression flags that should be applied when using regular expressions.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user