[#5609] Better fix

This commit is contained in:
lukaseder 2016-10-21 11:28:15 +02:00
parent 6c0bc2413b
commit a79e8008f0
2 changed files with 32 additions and 19 deletions

View File

@ -312,6 +312,9 @@ public class GenerationTool {
catalog.setOutputCatalogToDefault(d.isOutputCatalogToDefault());
catalogs.add(catalog);
if (!StringUtils.isBlank(catalog.getInputCatalog()))
catalogsEmpty = false;
// For convenience and backwards-compatibility, the schema configuration can be set also directly
// in the <database/> element
if (schemataEmpty) {
@ -320,6 +323,9 @@ public class GenerationTool {
schema.setOutputSchema(trim(d.getOutputSchema()));
schema.setOutputSchemaToDefault(d.isOutputSchemaToDefault());
catalog.getSchemata().add(schema);
if (!StringUtils.isBlank(schema.getInputSchema()))
schemataEmpty = false;
}
else {
catalog.getSchemata().addAll(schemata);

View File

@ -480,25 +480,13 @@ public abstract class AbstractDatabase implements Database {
inputSchemata = new ArrayList<String>();
inputSchemataPerCatalog = new LinkedHashMap<String, List<String>>();
// [#1312] [#5609] Allow for ommitting inputSchema configuration. Generate all schemata instead.
if (configuredSchemata.size() == 0 ||
(configuredSchemata.size() == 1 && StringUtils.isBlank(configuredSchemata.get(0).getInputSchema()))) {
try {
for (SchemaDefinition schema : getSchemata0()) {
inputSchemata.add(schema.getName());
List<String> list = inputSchemataPerCatalog.get(schema.getCatalog().getName());
if (list == null) {
list = new ArrayList<String>();
inputSchemataPerCatalog.put(schema.getCatalog().getName(), list);
}
list.add(schema.getName());
}
}
catch (Exception e) {
log.error("Could not load schemata", e);
}
// [#1312] Allow for ommitting inputSchema configuration. Generate all schemata instead.
if (configuredSchemata.size() == 1 && StringUtils.isBlank(configuredSchemata.get(0).getInputSchema())) {
initAllSchemata();
}
else if (configuredCatalogs.size() == 1 && StringUtils.isBlank(configuredCatalogs.get(0).getInputCatalog())
&& configuredCatalogs.get(0).getSchemata().size() == 1 && StringUtils.isBlank(configuredCatalogs.get(0).getSchemata().get(0).getInputSchema())) {
initAllSchemata();
}
else if (configuredCatalogs.isEmpty()) {
inputSchemataPerCatalog.put("", inputSchemata);
@ -551,6 +539,25 @@ public abstract class AbstractDatabase implements Database {
return inputSchemata;
}
private void initAllSchemata() {
try {
for (SchemaDefinition schema : getSchemata0()) {
inputSchemata.add(schema.getName());
List<String> list = inputSchemataPerCatalog.get(schema.getCatalog().getName());
if (list == null) {
list = new ArrayList<String>();
inputSchemataPerCatalog.put(schema.getCatalog().getName(), list);
}
list.add(schema.getName());
}
}
catch (Exception e) {
log.error("Could not load schemata", e);
}
}
@Override
public final List<String> getInputSchemata(CatalogDefinition catalog) {
return getInputSchemata(catalog.getInputName());