[jOOQ/jOOQ#15335] Support synonym export/import in InformationSchema XML
This commit is contained in:
parent
f9d21eedda
commit
b4ed7a1813
@ -65,6 +65,7 @@ import org.jooq.meta.ParameterDefinition;
|
||||
import org.jooq.meta.RoutineDefinition;
|
||||
import org.jooq.meta.SchemaDefinition;
|
||||
import org.jooq.meta.SequenceDefinition;
|
||||
// ...
|
||||
import org.jooq.meta.TableDefinition;
|
||||
// ...
|
||||
import org.jooq.meta.UniqueKeyDefinition;
|
||||
@ -86,6 +87,7 @@ import org.jooq.util.xml.jaxb.Routine;
|
||||
import org.jooq.util.xml.jaxb.RoutineType;
|
||||
import org.jooq.util.xml.jaxb.Schema;
|
||||
import org.jooq.util.xml.jaxb.Sequence;
|
||||
import org.jooq.util.xml.jaxb.Synonym;
|
||||
import org.jooq.util.xml.jaxb.Table;
|
||||
import org.jooq.util.xml.jaxb.TableConstraint;
|
||||
import org.jooq.util.xml.jaxb.TableType;
|
||||
@ -428,6 +430,20 @@ public class XMLGenerator extends AbstractGenerator {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -805,6 +805,17 @@ fun MutableList<org.jooq.util.xml.jaxb.Trigger>.trigger(block: org.jooq.util.xml
|
||||
add(e)
|
||||
}
|
||||
|
||||
fun InformationSchema.synonyms(block: MutableList<org.jooq.util.xml.jaxb.Synonym>.() -> Unit) {
|
||||
block(synonyms)
|
||||
}
|
||||
|
||||
@JvmName("mutableListSynonym")
|
||||
fun MutableList<org.jooq.util.xml.jaxb.Synonym>.synonym(block: org.jooq.util.xml.jaxb.Synonym.() -> Unit) {
|
||||
val e = org.jooq.util.xml.jaxb.Synonym()
|
||||
block(e)
|
||||
add(e)
|
||||
}
|
||||
|
||||
// [jooq-tools] END [information-schema]
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -100,6 +100,7 @@ import org.jooq.meta.DefaultIndexColumnDefinition;
|
||||
import org.jooq.meta.DefaultRelations;
|
||||
import org.jooq.meta.DefaultSequenceDefinition;
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.meta.DomainDefinition;
|
||||
import org.jooq.meta.EnumDefinition;
|
||||
import org.jooq.meta.IndexColumnDefinition;
|
||||
@ -108,6 +109,7 @@ import org.jooq.meta.PackageDefinition;
|
||||
import org.jooq.meta.RoutineDefinition;
|
||||
import org.jooq.meta.SchemaDefinition;
|
||||
import org.jooq.meta.SequenceDefinition;
|
||||
// ...
|
||||
import org.jooq.meta.TableDefinition;
|
||||
// ...
|
||||
import org.jooq.meta.UDTDefinition;
|
||||
@ -125,6 +127,7 @@ import org.jooq.util.xml.jaxb.ReferentialConstraint;
|
||||
import org.jooq.util.xml.jaxb.Routine;
|
||||
import org.jooq.util.xml.jaxb.Schema;
|
||||
import org.jooq.util.xml.jaxb.Sequence;
|
||||
import org.jooq.util.xml.jaxb.Synonym;
|
||||
import org.jooq.util.xml.jaxb.Table;
|
||||
import org.jooq.util.xml.jaxb.TableConstraint;
|
||||
import org.jooq.util.xml.jaxb.TableConstraintType;
|
||||
@ -625,6 +628,35 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -828,7 +828,7 @@ abstract class AbstractMeta extends AbstractScope implements Meta, Serializable
|
||||
// correct results
|
||||
@Override
|
||||
public /* non-final */ InformationSchema informationSchema() {
|
||||
return InformationSchemaExport.exportCatalogs(configuration(), getCatalogs());
|
||||
return InformationSchemaExport.export(configuration(), this);
|
||||
}
|
||||
|
||||
final Table<?> lookupTable(Table<?> table) {
|
||||
|
||||
@ -59,15 +59,16 @@ import org.jooq.Field;
|
||||
import org.jooq.ForeignKey;
|
||||
import org.jooq.Index;
|
||||
import org.jooq.Key;
|
||||
import org.jooq.Meta;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Qualified;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Sequence;
|
||||
import org.jooq.SortField;
|
||||
import org.jooq.SortOrder;
|
||||
// ...
|
||||
import org.jooq.Table;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.impl.QOM.GenerationOption;
|
||||
import org.jooq.util.xml.jaxb.CheckConstraint;
|
||||
import org.jooq.util.xml.jaxb.Column;
|
||||
import org.jooq.util.xml.jaxb.IndexColumnUsage;
|
||||
@ -139,6 +140,17 @@ final class InformationSchemaExport {
|
||||
exportSequence0(configuration, result, q);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final InformationSchema export(Configuration configuration, Meta meta) {
|
||||
InformationSchema result = exportCatalogs(configuration, meta.getCatalogs());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -165,6 +177,11 @@ final class InformationSchemaExport {
|
||||
|
||||
for (Sequence<?> q : s.getSequences())
|
||||
exportSequence0(configuration, result, q);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,6 +282,43 @@ final class InformationSchemaExport {
|
||||
result.getSequences().add(iq);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static final void exportCatalog0(InformationSchema result, Catalog c) {
|
||||
org.jooq.util.xml.jaxb.Catalog ic = new org.jooq.util.xml.jaxb.Catalog();
|
||||
|
||||
|
||||
@ -80,6 +80,7 @@ import org.jooq.Schema;
|
||||
import org.jooq.Sequence;
|
||||
import org.jooq.SortField;
|
||||
import org.jooq.Statement;
|
||||
// ...
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.TableOptions;
|
||||
@ -129,6 +130,11 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
InformationSchemaMetaImpl(Configuration configuration, InformationSchema source) {
|
||||
super(configuration);
|
||||
|
||||
@ -155,6 +161,11 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
init(source);
|
||||
}
|
||||
|
||||
@ -599,6 +610,48 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -639,6 +692,9 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!errors.isEmpty())
|
||||
throw new IllegalArgumentException(errors.toString());
|
||||
}
|
||||
@ -713,6 +769,18 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -763,6 +831,11 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static final class InformationSchemaTable extends TableImpl<Record> {
|
||||
@ -827,6 +900,20 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
|
||||
* <element name="parameters" type="{http://www.jooq.org/xsd/jooq-meta-3.20.0.xsd}Parameters" minOccurs="0"/>
|
||||
* <element name="element_types" type="{http://www.jooq.org/xsd/jooq-meta-3.20.0.xsd}ElementTypes" minOccurs="0"/>
|
||||
* <element name="triggers" type="{http://www.jooq.org/xsd/jooq-meta-3.20.0.xsd}Triggers" minOccurs="0"/>
|
||||
* <element name="synonyms" type="{http://www.jooq.org/xsd/jooq-meta-3.20.0.xsd}Synonyms" minOccurs="0"/>
|
||||
* </all>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
@ -117,6 +118,9 @@ public class InformationSchema implements Serializable, XMLAppendable
|
||||
@XmlElementWrapper(name = "triggers")
|
||||
@XmlElement(name = "trigger")
|
||||
protected List<Trigger> triggers;
|
||||
@XmlElementWrapper(name = "synonyms")
|
||||
@XmlElement(name = "synonym")
|
||||
protected List<Synonym> synonyms;
|
||||
|
||||
public List<Catalog> getCatalogs() {
|
||||
if (catalogs == null) {
|
||||
@ -316,6 +320,17 @@ public class InformationSchema implements Serializable, XMLAppendable
|
||||
this.triggers = triggers;
|
||||
}
|
||||
|
||||
public List<Synonym> getSynonyms() {
|
||||
if (synonyms == null) {
|
||||
synonyms = new ArrayList<Synonym>();
|
||||
}
|
||||
return synonyms;
|
||||
}
|
||||
|
||||
public void setSynonyms(List<Synonym> synonyms) {
|
||||
this.synonyms = synonyms;
|
||||
}
|
||||
|
||||
public InformationSchema withCatalogs(Catalog... values) {
|
||||
if (values!= null) {
|
||||
for (Catalog value: values) {
|
||||
@ -694,6 +709,27 @@ public class InformationSchema implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public InformationSchema withSynonyms(Synonym... values) {
|
||||
if (values!= null) {
|
||||
for (Synonym value: values) {
|
||||
getSynonyms().add(value);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public InformationSchema withSynonyms(Collection<Synonym> values) {
|
||||
if (values!= null) {
|
||||
getSynonyms().addAll(values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public InformationSchema withSynonyms(List<Synonym> synonyms) {
|
||||
setSynonyms(synonyms);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void appendTo(XMLBuilder builder) {
|
||||
builder.append("catalogs", "catalog", catalogs);
|
||||
@ -714,6 +750,7 @@ public class InformationSchema implements Serializable, XMLAppendable
|
||||
builder.append("parameters", "parameter", parameters);
|
||||
builder.append("element_types", "element_type", elementTypes);
|
||||
builder.append("triggers", "trigger", triggers);
|
||||
builder.append("synonyms", "synonym", synonyms);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -897,6 +934,15 @@ public class InformationSchema implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (synonyms == null) {
|
||||
if (other.synonyms!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!synonyms.equals(other.synonyms)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -922,6 +968,7 @@ public class InformationSchema implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((parameters == null)? 0 :parameters.hashCode()));
|
||||
result = ((prime*result)+((elementTypes == null)? 0 :elementTypes.hashCode()));
|
||||
result = ((prime*result)+((triggers == null)? 0 :triggers.hashCode()));
|
||||
result = ((prime*result)+((synonyms == null)? 0 :synonyms.hashCode()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -181,4 +181,12 @@ public class ObjectFactory {
|
||||
return new Trigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Synonym }
|
||||
*
|
||||
*/
|
||||
public Synonym createSynonym() {
|
||||
return new Synonym();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
<element name="parameters" type="tns:Parameters" minOccurs="0" maxOccurs="1" />
|
||||
<element name="element_types" type="tns:ElementTypes" minOccurs="0" maxOccurs="1" />
|
||||
<element name="triggers" type="tns:Triggers" minOccurs="0" maxOccurs="1" />
|
||||
<element name="synonyms" type="tns:Synonyms" minOccurs="0" maxOccurs="1" />
|
||||
</all>
|
||||
</complexType>
|
||||
</element>
|
||||
@ -400,6 +401,25 @@
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="Synonyms">
|
||||
<sequence>
|
||||
<element name="synonym" type="tns:Synonym" minOccurs="0" maxOccurs="unbounded" />
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="Synonym">
|
||||
<all>
|
||||
<element name="synonym_catalog" type="string" minOccurs="0" maxOccurs="1" />
|
||||
<element name="synonym_schema" type="string" minOccurs="0" maxOccurs="1" />
|
||||
<element name="synonym_name" type="string" minOccurs="1" maxOccurs="1" />
|
||||
<element name="object_catalog" type="string" minOccurs="0" maxOccurs="1" />
|
||||
<element name="object_schema" type="string" minOccurs="0" maxOccurs="1" />
|
||||
<element name="object_name" type="string" minOccurs="1" maxOccurs="1" />
|
||||
<element name="is_public" type="boolean" minOccurs="0" maxOccurs="1" />
|
||||
<element name="comment" type="string" minOccurs="0" maxOccurs="1" />
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<simpleType name="TriggerEventManipulation">
|
||||
<restriction base="string">
|
||||
<enumeration value="INSERT"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user