added ignore facet and trim column name options
This commit is contained in:
parent
3834c27c8f
commit
223d16db39
@ -60,6 +60,9 @@ public class SqlCreateBuilder {
|
|||||||
|
|
||||||
JSONArray columnOptionArray = options == null ? null : JSONUtilities.getArray(options, "columns");
|
JSONArray columnOptionArray = options == null ? null : JSONUtilities.getArray(options, "columns");
|
||||||
|
|
||||||
|
final boolean trimColNames = options == null ? true
|
||||||
|
: JSONUtilities.getBoolean(options, "trimColumnNames", false);
|
||||||
|
|
||||||
int count = columnOptionArray.length();
|
int count = columnOptionArray.length();
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
@ -68,8 +71,13 @@ public class SqlCreateBuilder {
|
|||||||
String name = JSONUtilities.getString(columnOptions, "name", null);
|
String name = JSONUtilities.getString(columnOptions, "name", null);
|
||||||
String type = JSONUtilities.getString(columnOptions, "type", "VARCHAR");
|
String type = JSONUtilities.getString(columnOptions, "type", "VARCHAR");
|
||||||
String size = JSONUtilities.getString(columnOptions, "size", "");
|
String size = JSONUtilities.getString(columnOptions, "size", "");
|
||||||
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
if(trimColNames) {
|
||||||
|
createSB.append(name.trim() + " ");
|
||||||
|
}else{
|
||||||
createSB.append(name + " ");
|
createSB.append(name + " ");
|
||||||
|
}
|
||||||
|
|
||||||
if (type.equals("VARCHAR")) {
|
if (type.equals("VARCHAR")) {
|
||||||
if (size.isEmpty()) {
|
if (size.isEmpty()) {
|
||||||
|
@ -278,7 +278,11 @@
|
|||||||
"for-include-structure-checkbox": "Include Schema",
|
"for-include-structure-checkbox": "Include Schema",
|
||||||
"for-include-drop-statement-checkbox": "Include Drop Statement",
|
"for-include-drop-statement-checkbox": "Include Drop Statement",
|
||||||
"for-include-content-checkbox": "Include Content",
|
"for-include-content-checkbox": "Include Content",
|
||||||
"tableNameLabel": "Table Name:"
|
"tableNameLabel": "Table Name:",
|
||||||
|
"sqlExporterTrimColumns": "Trim Column Names",
|
||||||
|
"sqlExporterIgnoreFacets": "Ignore facets and filters and export all rows",
|
||||||
|
"sqlExporterOutputEmptyRows":"Output empty row (i.e. all cells null)"
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
"core-facets": {
|
"core-facets": {
|
||||||
|
@ -51,9 +51,15 @@
|
|||||||
<td colspan="2"><div class="grid-layout layout-tighter layout-full"><table>
|
<td colspan="2"><div class="grid-layout layout-tighter layout-full"><table>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td width="1%"><input type="checkbox" bind="outputEmptyRowsCheckbox" id="$sql-output-empty-rows" /></td>
|
<td width="1%"><input type="checkbox" bind="sqlExportOutputEmptyRowsCheckbox" id="sqlExportOutputEmptyRowsCheckboxId" /></td>
|
||||||
<td width="25%"><label for="$sql-output-empty-rows" bind="or_dialog_outEmptyRow"></label></td>
|
<td width="25%"><label for="sqlExportOutputEmptyRowsCheckbox" bind="sqlExportOutputEmptyRowsLabel"></label></td>
|
||||||
<td width="25%"><div bind="sqlTypeApplyAllDiv" id="sqlTypeApplyAllDivId"></div></td>
|
|
||||||
|
<td width="1%"><input type="checkbox" bind="sqlExportAllRowsCheckbox" id="sqlExportAllRowsCheckboxId" /></td>
|
||||||
|
<td width="25%"><label for="sqlExportAllRowsCheckbox" bind="sqlExportIgnoreFacetsLabel"></label></td>
|
||||||
|
|
||||||
|
<td width="1%"><input type="checkbox" bind="sqlExportTrimAllColumnsCheckbox" id="sqlExportTrimAllColumnsCheckboxId" /></td>
|
||||||
|
<td width="25%"><label for="sqlExportTrimAllColumnsCheckbox" bind="sqlExportTrimAllColumnsLabel"></label></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
</table></div></td>
|
</table></div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -57,7 +57,7 @@ function SqlExporterDialog(options) {
|
|||||||
this._elmts.selectAllButton.html($.i18n._('core-buttons')["select-all"]);
|
this._elmts.selectAllButton.html($.i18n._('core-buttons')["select-all"]);
|
||||||
this._elmts.deselectAllButton.html($.i18n._('core-buttons')["deselect-all"]);
|
this._elmts.deselectAllButton.html($.i18n._('core-buttons')["deselect-all"]);
|
||||||
|
|
||||||
this._elmts.or_dialog_outEmptyRow.html($.i18n._('core-dialogs')["out-empty-row"]);
|
|
||||||
|
|
||||||
this._elmts.downloadPreviewButton.html($.i18n._('core-buttons')["preview"]);
|
this._elmts.downloadPreviewButton.html($.i18n._('core-buttons')["preview"]);
|
||||||
this._elmts.downloadButton.html($.i18n._('core-buttons')["download"]);
|
this._elmts.downloadButton.html($.i18n._('core-buttons')["download"]);
|
||||||
@ -72,6 +72,12 @@ function SqlExporterDialog(options) {
|
|||||||
this._elmts.includeContentLabel.html($.i18n._('core-dialogs')["for-include-content-checkbox"]);
|
this._elmts.includeContentLabel.html($.i18n._('core-dialogs')["for-include-content-checkbox"]);
|
||||||
|
|
||||||
|
|
||||||
|
this._elmts.sqlExportIgnoreFacetsLabel.html($.i18n._('core-dialogs')["sqlExporterIgnoreFacets"]);
|
||||||
|
this._elmts.sqlExportTrimAllColumnsLabel.html($.i18n._('core-dialogs')["sqlExporterTrimColumns"]);
|
||||||
|
this._elmts.sqlExportOutputEmptyRowsLabel.html($.i18n._('core-dialogs')["sqlExporterOutputEmptyRows"]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("#sql-exporter-tabs-content").css("display", "");
|
$("#sql-exporter-tabs-content").css("display", "");
|
||||||
$("#sql-exporter-tabs-download").css("display", "");
|
$("#sql-exporter-tabs-download").css("display", "");
|
||||||
$("#sql-exporter-tabs").tabs();
|
$("#sql-exporter-tabs").tabs();
|
||||||
@ -88,20 +94,29 @@ function SqlExporterDialog(options) {
|
|||||||
var sizeInputName = 'sizeInputRow' + i;
|
var sizeInputName = 'sizeInputRow' + i;
|
||||||
var applyAllBtnName = 'applyAllBtn' + i;
|
var applyAllBtnName = 'applyAllBtn' + i;
|
||||||
|
|
||||||
var arr = [
|
// var arr = [
|
||||||
{val : 'VARCHAR', text: 'VARCHAR'},
|
// {val : 'VARCHAR', text: 'VARCHAR'},
|
||||||
{val : 'TEXT', text: 'TEXT'},
|
// {val : 'TEXT', text: 'TEXT'},
|
||||||
{val : 'INT', text: 'INT'},
|
// {val : 'INT', text: 'INT'},
|
||||||
{val : 'NUMERIC', text: 'NUMERIC'},
|
// {val : 'NUMERIC', text: 'NUMERIC'},
|
||||||
{val : 'CHAR', text: 'CHAR'},
|
// {val : 'CHAR', text: 'CHAR'},
|
||||||
{val : 'DATE', text: 'DATE'},
|
// {val : 'DATE', text: 'DATE'},
|
||||||
{val : 'TIMESTAMP', text: 'TIMESTAMP'}
|
// {val : 'TIMESTAMP', text: 'TIMESTAMP'}
|
||||||
];
|
// ];
|
||||||
|
|
||||||
var sel = $('<select>').appendTo('body');
|
var sel = $('<select>').appendTo('body');
|
||||||
$(arr).each(function() {
|
sel.append($("<option>").attr('value','VARCHAR').text('VARCHAR'));
|
||||||
sel.append($("<option>").attr('value',this.val).text(this.text));
|
sel.append($("<option>").attr('value','TEXT').text('TEXT'));
|
||||||
});
|
sel.append($("<option>").attr('value','INT').text('INT'));
|
||||||
|
sel.append($("<option>").attr('value','NUMERIC').text('NUMERIC'));
|
||||||
|
sel.append($("<option>").attr('value','CHAR').text('CHAR'));
|
||||||
|
sel.append($("<option>").attr('value','DATE').text('DATE'));
|
||||||
|
sel.append($("<option>").attr('value','TIMESTAMP').text('TIMESTAMP'));
|
||||||
|
|
||||||
|
|
||||||
|
// $(arr).each(function() {
|
||||||
|
// sel.append($("<option>").attr('value',this.val).text(this.text));
|
||||||
|
// });
|
||||||
sel.attr('id', selectBoxName);
|
sel.attr('id', selectBoxName);
|
||||||
sel.attr('rowIndex', i);
|
sel.attr('rowIndex', i);
|
||||||
sel.addClass('typeSelectClass');
|
sel.addClass('typeSelectClass');
|
||||||
@ -109,7 +124,7 @@ function SqlExporterDialog(options) {
|
|||||||
|
|
||||||
$(sel).on('change', function() {
|
$(sel).on('change', function() {
|
||||||
var rowIndex = this.getAttribute('rowIndex');
|
var rowIndex = this.getAttribute('rowIndex');
|
||||||
if (this.value == 'VARCHAR' || this.value == 'CHAR' || this.value == 'NUMERIC' || this.value == 'INT') {
|
if (this.value === 'VARCHAR' || this.value === 'CHAR' || this.value === 'NUMERIC' || this.value === 'INT') {
|
||||||
$('#sizeInputRow'+ rowIndex).prop("disabled", false);
|
$('#sizeInputRow'+ rowIndex).prop("disabled", false);
|
||||||
}else{
|
}else{
|
||||||
$('#sizeInputRow'+ rowIndex).val("");
|
$('#sizeInputRow'+ rowIndex).val("");
|
||||||
@ -199,13 +214,13 @@ function SqlExporterDialog(options) {
|
|||||||
|
|
||||||
this._elmts.selectAllButton.click(function() {
|
this._elmts.selectAllButton.click(function() {
|
||||||
$("input:checkbox[class=columnNameCheckboxStyle]").each(function () {
|
$("input:checkbox[class=columnNameCheckboxStyle]").each(function () {
|
||||||
$(this).attr('checked', true)
|
$(this).attr('checked', true);
|
||||||
});
|
});
|
||||||
self._updateOptionCode();
|
self._updateOptionCode();
|
||||||
});
|
});
|
||||||
this._elmts.deselectAllButton.click(function() {
|
this._elmts.deselectAllButton.click(function() {
|
||||||
$("input:checkbox[class=columnNameCheckboxStyle]").each(function () {
|
$("input:checkbox[class=columnNameCheckboxStyle]").each(function () {
|
||||||
$(this).attr('checked', false)
|
$(this).attr('checked', false);
|
||||||
});
|
});
|
||||||
self._updateOptionCode();
|
self._updateOptionCode();
|
||||||
});
|
});
|
||||||
@ -232,7 +247,9 @@ function SqlExporterDialog(options) {
|
|||||||
SqlExporterDialog.prototype._configureUIFromOptionCode = function(options) {
|
SqlExporterDialog.prototype._configureUIFromOptionCode = function(options) {
|
||||||
|
|
||||||
this._elmts.tableNameTextBox.val(theProject.metadata.name);
|
this._elmts.tableNameTextBox.val(theProject.metadata.name);
|
||||||
this._elmts.outputEmptyRowsCheckbox.attr('checked', 'checked');
|
this._elmts.sqlExportOutputEmptyRowsCheckbox.attr('checked', 'checked');
|
||||||
|
this._elmts.sqlExportTrimAllColumnsCheckbox.attr('checked', 'checked');
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -254,7 +271,7 @@ function SqlExporterDialog(options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SqlExporterDialog.prototype._postExport = function(preview) {
|
SqlExporterDialog.prototype._postExport = function(preview) {
|
||||||
// var exportAllRowsCheckbox = this._elmts.exportAllRowsCheckbox[0].checked;
|
var exportAllRowsCheckbox = this._elmts.sqlExportAllRowsCheckbox[0].checked;
|
||||||
var options = this._getOptionCode();
|
var options = this._getOptionCode();
|
||||||
|
|
||||||
if(options.columns == null || options.columns.length == 0){
|
if(options.columns == null || options.columns.length == 0){
|
||||||
@ -272,7 +289,7 @@ function SqlExporterDialog(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// var ext = SqlExporterDialog.formats[format].extension;
|
// var ext = SqlExporterDialog.formats[format].extension;
|
||||||
var form = this._prepareSqlExportRowsForm(format, false, "sql");
|
var form = this._prepareSqlExportRowsForm(format, !exportAllRowsCheckbox, "sql");
|
||||||
$('<input />')
|
$('<input />')
|
||||||
.attr("name", "options")
|
.attr("name", "options")
|
||||||
.attr("value", JSON.stringify(options))
|
.attr("value", JSON.stringify(options))
|
||||||
@ -365,11 +382,12 @@ function SqlExporterDialog(options) {
|
|||||||
options.separator = ';';
|
options.separator = ';';
|
||||||
options.encoding = 'UTF-8';
|
options.encoding = 'UTF-8';
|
||||||
|
|
||||||
options.outputBlankRows = this._elmts.outputEmptyRowsCheckbox[0].checked;
|
options.outputBlankRows = this._elmts.sqlExportOutputEmptyRowsCheckbox[0].checked;
|
||||||
options.includeStructure = this._elmts.includeStructureCheckbox[0].checked;
|
options.includeStructure = this._elmts.includeStructureCheckbox[0].checked;
|
||||||
options.includeDropStatement = this._elmts.includeDropStatementCheckbox[0].checked;
|
options.includeDropStatement = this._elmts.includeDropStatementCheckbox[0].checked;
|
||||||
options.includeContent = this._elmts.includeContentCheckbox[0].checked;
|
options.includeContent = this._elmts.includeContentCheckbox[0].checked;
|
||||||
options.tableName = $.trim(this._elmts.tableNameTextBox.val().replace(/\W/g, ' ')).replace(/\s+/g, '-');
|
options.tableName = $.trim(this._elmts.tableNameTextBox.val().replace(/\W/g, ' ')).replace(/\s+/g, '-');
|
||||||
|
options.trimColumnNames = this._elmts.sqlExportTrimAllColumnsCheckbox[0].checked;
|
||||||
|
|
||||||
|
|
||||||
options.columns = [];
|
options.columns = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user