[jOOQ/jOOQ#12093] Add <includeExcludePackageRoutines/> to let code generator <includes/> and <excludes/> match package procedures and functions

This commit is contained in:
Lukas Eder 2021-07-01 16:13:51 +02:00
parent 0680d7e41f
commit e946c6f09a
7 changed files with 83 additions and 4 deletions

View File

@ -530,6 +530,7 @@ public class GenerationTool {
database.setIncludes(new String[] { defaultString(d.getIncludes()) });
database.setExcludes(new String[] { defaultString(d.getExcludes()) });
database.setIncludeExcludeColumns(TRUE.equals(d.isIncludeExcludeColumns()));
database.setIncludeExcludePackageRoutines(TRUE.equals(d.isIncludeExcludePackageRoutines()));
database.setIncludeForeignKeys(!FALSE.equals(d.isIncludeForeignKeys()));
database.setIncludePackages(!FALSE.equals(d.isIncludePackages()));
database.setIncludePackageRoutines(!FALSE.equals(d.isIncludePackageRoutines()));

View File

@ -159,7 +159,8 @@ public abstract class AbstractDatabase implements Database {
private List<Filter> filters;
private String[] excludes;
private String[] includes = { ".*" };
private boolean includeExcludeColumns;
private boolean includeExcludeColumns = false;
private boolean includeExcludePackageRoutines = false;
private boolean includeInvisibleColumns = true;
private boolean includeTables = true;
private boolean includeEmbeddables = true;
@ -961,6 +962,16 @@ public abstract class AbstractDatabase implements Database {
return includeExcludeColumns;
}
@Override
public final void setIncludeExcludePackageRoutines(boolean includeExcludePackageRoutines) {
this.includeExcludePackageRoutines = includeExcludePackageRoutines;
}
@Override
public final boolean getIncludeExcludePackageRoutines() {
return includeExcludePackageRoutines;
}
@Override
public final void setIncludeInvisibleColumns(boolean includeInvisibleColumns) {
this.includeInvisibleColumns = includeInvisibleColumns;

View File

@ -110,9 +110,8 @@ extends AbstractDefinition {
elements = db.filterExcludeInclude(e);
log.info("Columns fetched", fetchedSize(e, elements));
}
else {
else
elements = e;
}
db.sort(elements);
}

View File

@ -37,6 +37,8 @@
*/
package org.jooq.meta;
import static org.jooq.meta.AbstractDatabase.fetchedSize;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@ -74,7 +76,15 @@ public abstract class AbstractPackageDefinition extends AbstractDefinition imple
if (getDatabase().getIncludePackageRoutines()) {
try {
routines = getRoutines0();
List<RoutineDefinition> r = getRoutines0();
// [#12093] Filter exclude / include also for package routines
if (getDatabase().getIncludeExcludePackageRoutines()) {
routines = getDatabase().filterExcludeInclude(r);
log.info("Columns fetched", fetchedSize(r, routines));
}
else
routines = r;
}
catch (Exception e) {
log.error("Error while initialising package", e);

View File

@ -467,6 +467,18 @@ public interface Database extends AutoCloseable {
*/
boolean getIncludeExcludeColumns();
/**
* Indicate whether include / exclude regular expression shall also match
* package routines.
*/
void setIncludeExcludePackageRoutines(boolean includeExcludePackageRoutines);
/**
* Indicate whether include / exclude regular expression shall also match
* package routines.
*/
boolean getIncludeExcludePackageRoutines();
/**
* whether foreign key relationships should be included.
*/

View File

@ -51,6 +51,8 @@ public class Database implements Serializable, XMLAppendable
protected String excludes = "";
@XmlElement(defaultValue = "false")
protected Boolean includeExcludeColumns = false;
@XmlElement(defaultValue = "false")
protected Boolean includeExcludePackageRoutines = false;
@XmlElement(defaultValue = "true")
protected Boolean includeTables = true;
@XmlElement(defaultValue = "true")
@ -439,6 +441,30 @@ public class Database implements Serializable, XMLAppendable
this.includeExcludeColumns = value;
}
/**
* This flag indicates whether include / exclude patterns should also match routines within packages.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isIncludeExcludePackageRoutines() {
return includeExcludePackageRoutines;
}
/**
* Sets the value of the includeExcludePackageRoutines property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setIncludeExcludePackageRoutines(Boolean value) {
this.includeExcludePackageRoutines = value;
}
/**
* This flag indicates whether tables should be included in output produced by this database
*
@ -1885,6 +1911,11 @@ public class Database implements Serializable, XMLAppendable
return this;
}
public Database withIncludeExcludePackageRoutines(Boolean value) {
setIncludeExcludePackageRoutines(value);
return this;
}
public Database withIncludeTables(Boolean value) {
setIncludeTables(value);
return this;
@ -2463,6 +2494,7 @@ public class Database implements Serializable, XMLAppendable
builder.append("includes", includes);
builder.append("excludes", excludes);
builder.append("includeExcludeColumns", includeExcludeColumns);
builder.append("includeExcludePackageRoutines", includeExcludePackageRoutines);
builder.append("includeTables", includeTables);
builder.append("includeEmbeddables", includeEmbeddables);
builder.append("includeRoutines", includeRoutines);
@ -2603,6 +2635,15 @@ public class Database implements Serializable, XMLAppendable
return false;
}
}
if (includeExcludePackageRoutines == null) {
if (other.includeExcludePackageRoutines!= null) {
return false;
}
} else {
if (!includeExcludePackageRoutines.equals(other.includeExcludePackageRoutines)) {
return false;
}
}
if (includeTables == null) {
if (other.includeTables!= null) {
return false;
@ -3121,6 +3162,7 @@ public class Database implements Serializable, XMLAppendable
result = ((prime*result)+((includes == null)? 0 :includes.hashCode()));
result = ((prime*result)+((excludes == null)? 0 :excludes.hashCode()));
result = ((prime*result)+((includeExcludeColumns == null)? 0 :includeExcludeColumns.hashCode()));
result = ((prime*result)+((includeExcludePackageRoutines == null)? 0 :includeExcludePackageRoutines.hashCode()));
result = ((prime*result)+((includeTables == null)? 0 :includeTables.hashCode()));
result = ((prime*result)+((includeEmbeddables == null)? 0 :includeEmbeddables.hashCode()));
result = ((prime*result)+((includeRoutines == null)? 0 :includeRoutines.hashCode()));

View File

@ -581,6 +581,10 @@ Excludes match before includes, i.e. excludes have a higher priority.]]></jxb:ja
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This flag indicates whether include / exclude patterns should also match columns within tables.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="includeExcludePackageRoutines" type="boolean" default="false" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This flag indicates whether include / exclude patterns should also match routines within packages.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="includeTables" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This flag indicates whether tables should be included in output produced by this database]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>