new cli argument "-deletion-schemamapping"

This commit is contained in:
Ralf Wisser
2019-11-06 09:40:10 +01:00
parent eac5f3fc4b
commit c779e6a0bf
6 changed files with 490 additions and 54 deletions
@@ -99,12 +99,15 @@ public class CommandLine {
@Option(name="-where",usage="subject condition", metaVar="SQL-expression")
public String where = null;
@Option(name="-schemamapping",usage="schema map", metaVar="schema-in-model=schema-in-db[','x=y]*")
@Option(name="-schemamapping",usage="schema mapping", metaVar="schema-in-model=schema-in-db[','x=y]*")
public String rawschemamapping = null;
@Option(name="-source-schemamapping",usage="source schema map", metaVar="<from>=<to>[','<from>=<to>]*")
@Option(name="-source-schemamapping",usage="source schema mapping", metaVar="<from>=<to>[','<from>=<to>]*")
public String rawsourceschemamapping = null;
@Option(name="-deletion-schemamapping",usage="deletion schema mapping", metaVar="<from>=<to>[','<from>=<to>]*")
public String rawdeletionschemamapping = null;
@Option(name="-parameters",usage="parameters", metaVar="<parameter>=<value>[';'<parameter>=<value>]*")
public String parameters = null;
@@ -69,6 +69,7 @@ public class ExecutionContext {
this.analyseView = other.analyseView;
this.rawschemamapping = other.rawschemamapping;
this.rawsourceschemamapping = other.rawsourceschemamapping;
this.rawdeletionschemamapping = other.rawdeletionschemamapping;
this.parameters = copy(other.parameters);
this.numberOfThreads = other.numberOfThreads;
this.numberOfEntities = other.numberOfEntities;
@@ -685,6 +686,34 @@ public class ExecutionContext {
return sourceSchemaMapping;
}
private Map<String, String> deletionSchemaMapping;
/**
* @param deletionSchemaMapping the sourceSchemaMapping to set
*/
public void setDeletionSchemaMapping(Map<String, String> deletionSchemaMapping) {
this.deletionSchemaMapping = deletionSchemaMapping;
}
public Map<String, String> getDeletionSchemaMapping() {
if (deletionSchemaMapping == null) {
deletionSchemaMapping = new HashMap<String, String>();
String rawmapping = rawdeletionschemamapping;
if (rawmapping == null) {
rawmapping = rawsourceschemamapping;
}
if (rawmapping != null) {
for (String item: rawmapping.split(",")) {
String[] fromTo = (" " + item + " ").split("=");
if (fromTo.length == 2) {
deletionSchemaMapping.put(fromTo[0].trim(), fromTo[1].trim());
}
}
}
}
return deletionSchemaMapping;
}
private ScriptFormat scriptFormat;
/**
@@ -816,6 +845,9 @@ public class ExecutionContext {
// source schema map
private String rawsourceschemamapping = null;
// source schema map
private String rawdeletionschemamapping = null;
// parameters
private Map<String, String> parameters = null;
@@ -939,6 +971,7 @@ public class ExecutionContext {
analyseView = commandLine.analyseView;
rawschemamapping = commandLine.rawschemamapping;
rawsourceschemamapping = commandLine.rawsourceschemamapping;
rawdeletionschemamapping = commandLine.rawdeletionschemamapping;
rawparameters = commandLine.parameters;
numberOfThreads = commandLine.numberOfThreads;
numberOfEntities = commandLine.numberOfEntities;
@@ -213,7 +213,7 @@ public class DeletionTransformer extends AbstractResultSetReader {
*/
private String qualifiedTableName(Table t) {
String schema = t.getOriginalSchema("");
String mappedSchema = executionContext.getSourceSchemaMapping().get(schema);
String mappedSchema = executionContext.getDeletionSchemaMapping().get(schema);
if (mappedSchema != null) {
schema = mappedSchema;
}
@@ -397,7 +397,7 @@ public class UpdateTransformer extends AbstractResultSetReader {
*/
private String qualifiedTableName(Table t) {
String schema = t.getOriginalSchema("");
String mappedSchema = inSourceSchema? executionContext.getSourceSchemaMapping().get(schema) : executionContext.getSchemaMapping().get(schema);
String mappedSchema = inSourceSchema? executionContext.getDeletionSchemaMapping().get(schema) : executionContext.getSchemaMapping().get(schema);
if (mappedSchema != null) {
schema = mappedSchema;
}
+156 -19
View File
@@ -78,22 +78,12 @@
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="82" gridWidth="2" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="1" gridY="82" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel18">
<Properties>
<Property name="text" type="java.lang.String" value=" Read from schema " noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel19">
<Properties>
<Property name="text" type="java.lang.String" value=" " noResource="true"/>
@@ -116,25 +106,59 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="schemaMappingPanel">
<Container class="javax.swing.JPanel" name="sourceSchemaMappingLabelPanel">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="80" gridWidth="2" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="82" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel13">
<Component class="javax.swing.JLabel" name="jLabel33">
<Properties>
<Property name="text" type="java.lang.String" value=" Insert rows from schema " noResource="true"/>
<Property name="text" type="java.lang.String" value=" Read rows" noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel34">
<Properties>
<Property name="text" type="java.lang.String" value=" " noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel42">
<Properties>
<Property name="text" type="java.lang.String" value=" from schema..." noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="4" insetsRight="0" anchor="18" weightX="0.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="schemaMappingPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="84" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="text" type="java.lang.String" value=" " noResource="true"/>
@@ -157,6 +181,109 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="schemaMappingLabelPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="84" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel36">
<Properties>
<Property name="text" type="java.lang.String" value=" Insert rows" noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel37">
<Properties>
<Property name="text" type="java.lang.String" value=" " noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel43">
<Properties>
<Property name="text" type="java.lang.String" value=" into schema... " noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="4" insetsRight="0" anchor="11" weightX="0.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="deleteSchemaMappingPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="86" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel31">
<Properties>
<Property name="text" type="java.lang.String" value=" " noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="deleteSchemaMappingLabelPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="86" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel39">
<Properties>
<Property name="text" type="java.lang.String" value=" Delete rows" noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel40">
<Properties>
<Property name="text" type="java.lang.String" value=" " noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel44">
<Properties>
<Property name="text" type="java.lang.String" value=" from schema..." noResource="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="4" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JTextField" name="where">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
@@ -520,7 +647,7 @@
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="85" gridWidth="4" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
<GridBagConstraints gridX="0" gridY="95" gridWidth="4" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
@@ -848,7 +975,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@@ -858,7 +985,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@@ -1023,6 +1150,16 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value=" "/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="94" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
+294 -31
View File
@@ -119,7 +119,12 @@ public abstract class ExportDialog extends javax.swing.JDialog {
* Source-schema mapping fields.
*/
private Map<String, JTextField> sourceSchemaMappingFields = new HashMap<String, JTextField>();
/**
* Delete-schema mapping fields.
*/
private Map<String, JTextField> deleteSchemaMappingFields = new HashMap<String, JTextField>();
/**
* The form field setting.
*/
@@ -304,10 +309,20 @@ public abstract class ExportDialog extends javax.swing.JDialog {
if ((!ScriptFormat.SQL.equals(scriptFormat)) && (!ScriptFormat.INTRA_DATABASE.equals(scriptFormat)) && (!ScriptFormat.DBUNIT_FLAT_XML.equals(scriptFormat)) && !ScriptFormat.LIQUIBASE_XML.equals(scriptFormat)) {
schemaMappingPanel.setVisible(false);
schemaMappingLabelPanel.setVisible(false);
} else {
schemaMappingPanel.setVisible(true);
schemaMappingLabelPanel.setVisible(true);
initSchemaMapping(dataModel, fields, defaults);
}
if ((!ScriptFormat.SQL.equals(scriptFormat)) && (!ScriptFormat.DBUNIT_FLAT_XML.equals(scriptFormat)) && !ScriptFormat.LIQUIBASE_XML.equals(scriptFormat)) {
deleteSchemaMappingPanel.setVisible(false);
deleteSchemaMappingLabelPanel.setVisible(false);
} else {
deleteSchemaMappingPanel.setVisible(true);
deleteSchemaMappingLabelPanel.setVisible(true);
initDeleteSchemaMapping(dataModel, fields, defaults);
}
initSourceSchemaMapping(dataModel, fields, defaults);
initIsolationLevel(session);
initScopeButtons(session);
@@ -655,6 +670,9 @@ public abstract class ExportDialog extends javax.swing.JDialog {
private void updateCLIArea() {
explain.setEnabled(!scopeLocal.isSelected());
for (JTextField cb: deleteSchemaMappingFields.values()) {
cb.setEnabled(delete.isVisible() && delete.getText().trim().length() > 0);
}
List<String> args = new ArrayList<String>(initialArgs);
if (args.size() > 0) {
@@ -692,6 +710,101 @@ public abstract class ExportDialog extends javax.swing.JDialog {
updateCLIArea();
}
/**
* Initializes the delete-schema mapping panel.
*
* @param dataModel the data model
* @param fields to put newly created text fields into
* @param defaults to put default values for newly created text fields into
*/
private void initDeleteSchemaMapping(DataModel dataModel, Map<String, JComponent> fields, Map<JTextField, String> defaults) {
Set<String> distinctSchemas = new HashSet<String>();
Set<String> relevantSchemas = getRelevantSchemas(true);
for (Table table: dataModel.getTables()) {
String schema = table.getOriginalSchema(DEFAULT_SCHEMA);
if (relevantSchemas.contains(schema.equals(DEFAULT_SCHEMA)? "" : schema)) {
distinctSchemas.add(schema);
}
}
List<String> sortedSchemaList = new ArrayList<String>(distinctSchemas);
Collections.sort(sortedSchemaList);
boolean simplified = sortedSchemaList.size() == 1;
if (simplified) {
deleteSchemaMappingPanel.setVisible(false);
deleteSchemaMappingLabelPanel.setVisible(false);
}
int y = 0;
for (String schema: sortedSchemaList) {
JLabel b = new JLabel(" instead of ");
java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = y;
if (simplified) {
b.setText(" Delete from schema ");
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 86;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add(b, gridBagConstraints);
} else {
deleteSchemaMappingPanel.add(b, gridBagConstraints);
}
JComboBox cb = new JComboBox();
cb.setMaximumRowCount(20);
JComponent ccb = cb;
cb.setModel(new DefaultComboBoxModel(schemaComboboxModel));
cb.setEditable(true);
cb.setSelectedItem(schema);
JTextField c;
try {
c = (JTextField) cb.getEditor().getEditorComponent();
} catch (ClassCastException e) {
c = new JTextField(schema);
ccb = c;
}
c.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
updateCLIArea();
}
@Override
public void insertUpdate(DocumentEvent e) {
updateCLIArea();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateCLIArea();
}
});
fields.put("delschema-" + schema, c);
defaults.put(c, schema);
deleteSchemaMappingFields.put(schema, c);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = y;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
if (simplified) {
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 86;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
jPanel1.add(ccb, gridBagConstraints);
} else {
deleteSchemaMappingPanel.add(ccb, gridBagConstraints);
}
JLabel a = new JLabel(schema);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = y;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
deleteSchemaMappingPanel.add(a, gridBagConstraints);
y++;
}
}
/**
* Initializes the schema mapping panel.
*
@@ -716,19 +829,20 @@ public abstract class ExportDialog extends javax.swing.JDialog {
boolean simplified = sortedSchemaList.size() == 1;
if (simplified) {
schemaMappingPanel.setVisible(false);
schemaMappingLabelPanel.setVisible(false);
}
int y = 0;
for (String schema: sortedSchemaList) {
JLabel a = new JLabel(schema + " into ");
JLabel a = new JLabel(" instead of " + schema);
java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = y;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
if (simplified) {
a.setText(" Target schema ");
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 80;
gridBagConstraints.gridy = 84;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add(a, gridBagConstraints);
} else {
@@ -766,12 +880,12 @@ public abstract class ExportDialog extends javax.swing.JDialog {
schemaMappingFields.put(schema, c);
schemaMappingLabels.put(schema, a);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = y;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
if (simplified) {
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 80;
gridBagConstraints.gridy = 84;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
jPanel1.add(ccb, gridBagConstraints);
@@ -781,7 +895,7 @@ public abstract class ExportDialog extends javax.swing.JDialog {
y++;
}
}
/**
* Initializes the source schema mapping panel.
*
@@ -806,11 +920,12 @@ public abstract class ExportDialog extends javax.swing.JDialog {
boolean simplified = sortedSchemaList.size() == 1;
if (simplified) {
sourceSchemaMappingPanel.setVisible(false);
sourceSchemaMappingLabelPanel.setVisible(false);
}
int y = 0;
for (String schema: sortedSchemaList) {
JLabel b = new JLabel(" instead of ");
JLabel b = new JLabel(" instead of ");
java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = y;
@@ -820,10 +935,6 @@ public abstract class ExportDialog extends javax.swing.JDialog {
gridBagConstraints.gridy = 82;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add(b, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 83;
jPanel1.add(new JLabel(" "), gridBagConstraints);
} else {
sourceSchemaMappingPanel.add(b, gridBagConstraints);
}
@@ -854,7 +965,7 @@ public abstract class ExportDialog extends javax.swing.JDialog {
updateCLIArea();
}
});
// fields.put("srcschema-" + schema, c);
fields.put("srcschema-" + schema, c);
defaults.put(c, schema);
sourceSchemaMappingFields.put(schema, c);
gridBagConstraints = new java.awt.GridBagConstraints();
@@ -894,13 +1005,25 @@ public abstract class ExportDialog extends javax.swing.JDialog {
jPanel6 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
sourceSchemaMappingPanel = new javax.swing.JPanel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
sourceSchemaMappingLabelPanel = new javax.swing.JPanel();
jLabel33 = new javax.swing.JLabel();
jLabel34 = new javax.swing.JLabel();
jLabel42 = new javax.swing.JLabel();
schemaMappingPanel = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
schemaMappingLabelPanel = new javax.swing.JPanel();
jLabel36 = new javax.swing.JLabel();
jLabel37 = new javax.swing.JLabel();
jLabel43 = new javax.swing.JLabel();
deleteSchemaMappingPanel = new javax.swing.JPanel();
jLabel31 = new javax.swing.JLabel();
deleteSchemaMappingLabelPanel = new javax.swing.JPanel();
jLabel39 = new javax.swing.JLabel();
jLabel40 = new javax.swing.JLabel();
jLabel44 = new javax.swing.JLabel();
where = new javax.swing.JTextField();
exportLabel = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
@@ -967,6 +1090,7 @@ public abstract class ExportDialog extends javax.swing.JDialog {
transactional = new javax.swing.JCheckBox();
independentWorkingTables = new javax.swing.JCheckBox();
orderByPKCheckbox = new javax.swing.JCheckBox();
jLabel13 = new javax.swing.JLabel();
jPanel7 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
@@ -988,12 +1112,6 @@ public abstract class ExportDialog extends javax.swing.JDialog {
sourceSchemaMappingPanel.setLayout(new java.awt.GridBagLayout());
jLabel18.setText(" Read from schema "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
sourceSchemaMappingPanel.add(jLabel18, gridBagConstraints);
jLabel19.setText(" "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
@@ -1009,19 +1127,43 @@ public abstract class ExportDialog extends javax.swing.JDialog {
sourceSchemaMappingPanel.add(jLabel20, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 82;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(sourceSchemaMappingPanel, gridBagConstraints);
schemaMappingPanel.setLayout(new java.awt.GridBagLayout());
sourceSchemaMappingLabelPanel.setLayout(new java.awt.GridBagLayout());
jLabel13.setText(" Insert rows from schema "); // NOI18N
jLabel33.setText(" Read rows"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
schemaMappingPanel.add(jLabel13, gridBagConstraints);
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
sourceSchemaMappingLabelPanel.add(jLabel33, gridBagConstraints);
jLabel34.setText(" "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
sourceSchemaMappingLabelPanel.add(jLabel34, gridBagConstraints);
jLabel42.setText(" from schema..."); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
sourceSchemaMappingLabelPanel.add(jLabel42, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 82;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(sourceSchemaMappingLabelPanel, gridBagConstraints);
schemaMappingPanel.setLayout(new java.awt.GridBagLayout());
jLabel14.setText(" "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
@@ -1038,12 +1180,89 @@ public abstract class ExportDialog extends javax.swing.JDialog {
schemaMappingPanel.add(jLabel15, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 80;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 84;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(schemaMappingPanel, gridBagConstraints);
schemaMappingLabelPanel.setLayout(new java.awt.GridBagLayout());
jLabel36.setText(" Insert rows"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
schemaMappingLabelPanel.add(jLabel36, gridBagConstraints);
jLabel37.setText(" "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
schemaMappingLabelPanel.add(jLabel37, gridBagConstraints);
jLabel43.setText(" into schema... "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
schemaMappingLabelPanel.add(jLabel43, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 84;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(schemaMappingLabelPanel, gridBagConstraints);
deleteSchemaMappingPanel.setLayout(new java.awt.GridBagLayout());
jLabel31.setText(" "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
deleteSchemaMappingPanel.add(jLabel31, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 86;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(deleteSchemaMappingPanel, gridBagConstraints);
deleteSchemaMappingLabelPanel.setLayout(new java.awt.GridBagLayout());
jLabel39.setText(" Delete rows"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
deleteSchemaMappingLabelPanel.add(jLabel39, gridBagConstraints);
jLabel40.setText(" "); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
deleteSchemaMappingLabelPanel.add(jLabel40, gridBagConstraints);
jLabel44.setText(" from schema..."); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
deleteSchemaMappingLabelPanel.add(jLabel44, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 86;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(deleteSchemaMappingLabelPanel, gridBagConstraints);
where.setMaximumSize(new java.awt.Dimension(300, 2147483647));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
@@ -1368,7 +1587,7 @@ public abstract class ExportDialog extends javax.swing.JDialog {
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 85;
gridBagConstraints.gridy = 95;
gridBagConstraints.gridwidth = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
@@ -1537,6 +1756,7 @@ public abstract class ExportDialog extends javax.swing.JDialog {
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
iFMTPanel.add(jLabel29, gridBagConstraints);
jLabel30.setText(" mapping table schema "); // NOI18N
@@ -1545,6 +1765,7 @@ public abstract class ExportDialog extends javax.swing.JDialog {
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
iFMTPanel.add(jLabel30, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
@@ -1667,6 +1888,12 @@ public abstract class ExportDialog extends javax.swing.JDialog {
gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 0);
jPanel1.add(orderByPKCheckbox, gridBagConstraints);
jLabel13.setText(" ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 94;
jPanel1.add(jLabel13, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
@@ -1758,6 +1985,11 @@ public abstract class ExportDialog extends javax.swing.JDialog {
f.setText(DEFAULT_SCHEMA);
}
}
for (JTextField f: deleteSchemaMappingFields.values()) {
if (f.getText().trim().length() == 0) {
f.setText(DEFAULT_SCHEMA);
}
}
theSettings.save(settingsContext, settingsContextSecondaryKey);
boolean err = false;
@@ -2126,6 +2358,24 @@ public abstract class ExportDialog extends javax.swing.JDialog {
args.add(sourceSchemaMapping.toString());
}
if (delete.isVisible() && delete.getText().trim().length() > 0) {
StringBuilder deleteSchemaMapping = new StringBuilder();
for (String schema: deleteSchemaMappingFields.keySet()) {
String to = deleteSchemaMappingFields.get(schema).getText().trim();
if (to.equals(DEFAULT_SCHEMA)) {
to = "";
}
if (deleteSchemaMapping.length() > 0) {
deleteSchemaMapping.append(",");
}
deleteSchemaMapping.append((schema.equals(DEFAULT_SCHEMA)? "" : schema) + "=" + to);
}
if (deleteSchemaMapping.length() > 0) {
args.add("-deletion-schemamapping");
args.add(deleteSchemaMapping.toString());
}
}
args.add("-scope");
args.add(getTemporaryTableScope().toString());
@@ -2244,6 +2494,8 @@ public abstract class ExportDialog extends javax.swing.JDialog {
public javax.swing.JCheckBox confirmInsert;
private javax.swing.JButton copyButton;
private javax.swing.JTextField delete;
private javax.swing.JPanel deleteSchemaMappingLabelPanel;
private javax.swing.JPanel deleteSchemaMappingPanel;
public javax.swing.JCheckBox explain;
private javax.swing.JLabel exportLabel;
private javax.swing.JPanel iFMTPanel;
@@ -2263,7 +2515,6 @@ public abstract class ExportDialog extends javax.swing.JDialog {
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
@@ -2277,7 +2528,17 @@ public abstract class ExportDialog extends javax.swing.JDialog {
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel33;
private javax.swing.JLabel jLabel34;
private javax.swing.JLabel jLabel36;
private javax.swing.JLabel jLabel37;
private javax.swing.JLabel jLabel39;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel40;
private javax.swing.JLabel jLabel42;
private javax.swing.JLabel jLabel43;
private javax.swing.JLabel jLabel44;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
@@ -2298,11 +2559,13 @@ public abstract class ExportDialog extends javax.swing.JDialog {
private javax.swing.JLabel placeholder;
private javax.swing.JLabel placeholder1;
private javax.swing.JTextField rowsPerThread;
private javax.swing.JPanel schemaMappingLabelPanel;
private javax.swing.JPanel schemaMappingPanel;
private javax.swing.JRadioButton scopeGlobal;
private javax.swing.JRadioButton scopeLocal;
private javax.swing.JRadioButton scopeSession;
private javax.swing.JCheckBox sortedCheckBox;
public javax.swing.JPanel sourceSchemaMappingLabelPanel;
public javax.swing.JPanel sourceSchemaMappingPanel;
private javax.swing.JLabel subjectTable;
private javax.swing.JComboBox targetDBMSComboBox;