数据导出添加JSON导出功能

This commit is contained in:
datagear 2019-10-25 21:28:37 +08:00
parent 97714d57f5
commit c8550bbc2c
13 changed files with 703 additions and 5 deletions

View File

@ -39,5 +39,10 @@
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>${javax.json.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,83 @@
/*
* Copyright (c) 2018 datagear.org. All Rights Reserved.
*/
package org.datagear.dataexchange.support;
import java.io.Writer;
import org.datagear.dataexchange.ConnectionFactory;
import org.datagear.dataexchange.DataFormat;
import org.datagear.dataexchange.Query;
import org.datagear.dataexchange.QueryTextDataExport;
import org.datagear.dataexchange.ResourceFactory;
import org.datagear.dataexchange.TextDataExportOption;
/**
* JSON导出
*
* @author datagear@163.com
*
*/
public class JsonDataExport extends QueryTextDataExport
{
private ResourceFactory<Writer> writerFactory;
/**
* {@linkplain JsonDataExportOption#getJsonDataFormat()}{@linkplain JsonDataFormat#TABLE_OBJECT}设置导出表名
*/
private String tableName;
public JsonDataExport()
{
super();
}
public JsonDataExport(ConnectionFactory connectionFactory, DataFormat dataFormat, JsonDataExportOption exportOption,
Query query, ResourceFactory<Writer> writerFactory, String tableName)
{
super(connectionFactory, dataFormat, exportOption, query);
this.tableName = tableName;
this.writerFactory = writerFactory;
}
@Override
public JsonDataExportOption getExportOption()
{
return (JsonDataExportOption) super.getExportOption();
}
@Override
public void setExportOption(TextDataExportOption exportOption)
{
if (!(exportOption instanceof JsonDataExportOption))
throw new IllegalArgumentException();
super.setExportOption(exportOption);
}
public ResourceFactory<Writer> getWriterFactory()
{
return writerFactory;
}
public void setWriterFactory(ResourceFactory<Writer> writerFactory)
{
this.writerFactory = writerFactory;
}
public boolean hasTableName()
{
return (this.tableName != null && !this.tableName.isEmpty());
}
public String getTableName()
{
return tableName;
}
public void setTableName(String tableName)
{
this.tableName = tableName;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
*/
package org.datagear.dataexchange.support;
import org.datagear.dataexchange.TextDataExportOption;
/**
* JSON导出设置项
*
* @author datagear@163.com
*
*/
public class JsonDataExportOption extends TextDataExportOption
{
private static final long serialVersionUID = 1L;
private JsonDataFormat jsonDataFormat = JsonDataFormat.TABLE_OBJECT;
private boolean prettyPrint = true;
public JsonDataExportOption()
{
super();
}
public JsonDataFormat getJsonDataFormat()
{
return jsonDataFormat;
}
public void setJsonDataFormat(JsonDataFormat jsonDataFormat)
{
this.jsonDataFormat = jsonDataFormat;
}
public boolean isPrettyPrint()
{
return prettyPrint;
}
public void setPrettyPrint(boolean prettyPrint)
{
this.prettyPrint = prettyPrint;
}
}

View File

@ -0,0 +1,173 @@
/*
* Copyright (c) 2018 datagear.org. All Rights Reserved.
*/
package org.datagear.dataexchange.support;
import java.io.Writer;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.json.Json;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonGeneratorFactory;
import org.datagear.dataexchange.AbstractDevotedDbInfoAwareDataExchangeService;
import org.datagear.dataexchange.DataExchangeContext;
import org.datagear.dataexchange.DataExchangeException;
import org.datagear.dataexchange.IndexFormatDataExchangeContext;
import org.datagear.dataexchange.RowDataIndex;
import org.datagear.dataexchange.TextDataExportListener;
import org.datagear.dbinfo.ColumnInfo;
import org.datagear.dbinfo.DatabaseInfoResolver;
import org.datagear.util.JdbcUtil;
/**
* JSON导出服务
*
* @author datagear@163.com
*
*/
public class JsonDataExportService extends AbstractDevotedDbInfoAwareDataExchangeService<JsonDataExport>
{
protected static final JsonGeneratorFactory FACTORY = Json.createGeneratorFactory(new HashMap<String, Object>());
protected static JsonGeneratorFactory FACTORY_PRETTY_PRINT = null;
static
{
Map<String, Object> config = new HashMap<String, Object>();
config.put(JsonGenerator.PRETTY_PRINTING, true);
FACTORY_PRETTY_PRINT = Json.createGeneratorFactory(config);
}
public JsonDataExportService()
{
super();
}
public JsonDataExportService(DatabaseInfoResolver databaseInfoResolver)
{
super(databaseInfoResolver);
}
@Override
protected DataExchangeContext createDataExchangeContext(JsonDataExport dataExchange)
{
return IndexFormatDataExchangeContext.valueOf(dataExchange);
}
@Override
protected void exchange(JsonDataExport dataExchange, DataExchangeContext context) throws Throwable
{
IndexFormatDataExchangeContext exportContext = IndexFormatDataExchangeContext.cast(context);
Writer jsonWriter = getResource(dataExchange.getWriterFactory(), exportContext);
Connection cn = context.getConnection();
JdbcUtil.setReadonlyIfSupports(cn, true);
ResultSet rs = dataExchange.getQuery().execute(cn);
List<ColumnInfo> columnInfos = getColumnInfos(cn, rs);
writeRecords(dataExchange, cn, columnInfos, rs, jsonWriter, exportContext);
}
/**
* 写记录
*
* @param dataExchange
* @param cn
* @param columnInfos
* @param rs
* @param out
* @param exportContext
*/
protected void writeRecords(JsonDataExport dataExchange, Connection cn, List<ColumnInfo> columnInfos, ResultSet rs,
Writer out, IndexFormatDataExchangeContext exportContext) throws Throwable
{
TextDataExportListener listener = dataExchange.getListener();
JsonDataExportOption exportOption = dataExchange.getExportOption();
JsonDataFormat jsonDataFormat = exportOption.getJsonDataFormat();
int columnCount = columnInfos.size();
@SuppressWarnings("resource")
JsonGenerator generator = (exportOption.isPrettyPrint() ? FACTORY_PRETTY_PRINT.createGenerator(out)
: FACTORY.createGenerator(out));
if (JsonDataFormat.TABLE_OBJECT.equals(jsonDataFormat))
{
if (!dataExchange.hasTableName())
throw new DataExchangeException("[JsonDataExport.tableName] must be set");
generator.writeStartObject();
generator.writeStartArray(dataExchange.getTableName());
}
else
{
generator.writeStartArray();
}
long row = 0;
while (rs.next())
{
exportContext.setDataIndex(RowDataIndex.valueOf(row));
generator.writeStartObject();
for (int i = 0; i < columnCount; i++)
{
ColumnInfo columnInfo = columnInfos.get(i);
String value = null;
try
{
value = getStringValue(cn, rs, i + 1, columnInfo.getType(), exportContext.getDataFormatContext());
}
catch (Throwable t)
{
if (exportOption.isNullForIllegalColumnValue())
{
value = null;
if (listener != null)
listener.onSetNullTextValue(exportContext.getDataIndex(), columnInfo.getName(),
wrapToDataExchangeException(t));
}
else
throw t;
}
if (value == null)
generator.writeNull(columnInfo.getName());
else
generator.write(columnInfo.getName(), value);
}
generator.writeEnd();
if (listener != null)
listener.onSuccess(exportContext.getDataIndex());
row++;
}
if (JsonDataFormat.TABLE_OBJECT.equals(jsonDataFormat))
{
generator.writeEnd();
generator.writeEnd();
}
else
{
generator.writeEnd();
}
generator.flush();
}
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
*/
/**
*
*/
package org.datagear.dataexchange.support;
/**
* JSON数据格式
*
* @author datagear@163.com
*
*/
public enum JsonDataFormat
{
/** 表对象,格式为:{"table_name" : [{...}, {...}]} */
TABLE_OBJECT,
/** 行数组:格式为:[{...}, {...}] */
ROW_ARRAY
}

View File

@ -58,7 +58,7 @@
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<version>${javax.json.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>

View File

@ -60,6 +60,9 @@ import org.datagear.dataexchange.support.CsvDataExport;
import org.datagear.dataexchange.support.CsvDataImport;
import org.datagear.dataexchange.support.ExcelDataExport;
import org.datagear.dataexchange.support.ExcelDataImport;
import org.datagear.dataexchange.support.JsonDataExport;
import org.datagear.dataexchange.support.JsonDataExportOption;
import org.datagear.dataexchange.support.JsonDataFormat;
import org.datagear.dataexchange.support.SqlDataExport;
import org.datagear.dataexchange.support.SqlDataExportOption;
import org.datagear.dataexchange.support.SqlDataImport;
@ -1020,6 +1023,125 @@ public class DataExchangeController extends AbstractSchemaConnController
return responseEntity;
}
@RequestMapping("/{schemaId}/export/json")
public String exptJson(HttpServletRequest request, HttpServletResponse response,
org.springframework.ui.Model springModel, @PathVariable("schemaId") String schemaId) throws Throwable
{
final User user = WebUtils.getUser(request, response);
new VoidSchemaConnExecutor(request, response, springModel, schemaId, true)
{
@Override
protected void execute(HttpServletRequest request, HttpServletResponse response, Model springModel,
Schema schema) throws Throwable
{
checkReadTableDataPermission(schema, user);
}
}.execute();
DataFormat defaultDataFormat = new DataFormat();
defaultDataFormat.setBinaryFormat("0x" + DataFormatContext.wrapToExpression(DataFormat.BINARY_FORMAT_HEX));
String dataExchangeId = IDUtil.uuid();
springModel.addAttribute("defaultDataFormat", defaultDataFormat);
springModel.addAttribute("dataExchangeId", dataExchangeId);
springModel.addAttribute("dataExchangeChannelId", getDataExchangeChannelId(dataExchangeId));
springModel.addAttribute("availableCharsetNames", getAvailableCharsetNames());
springModel.addAttribute("defaultCharsetName", Charset.defaultCharset().name());
return "/dataexchange/export_json";
}
@RequestMapping(value = "/{schemaId}/export/json/doExport", produces = CONTENT_TYPE_JSON)
@ResponseBody
public ResponseEntity<OperationMessage> exptJsonDoExport(HttpServletRequest request, HttpServletResponse response,
@PathVariable("schemaId") String schemaId, @RequestParam("dataExchangeId") String dataExchangeId,
JsonFileBatchDataExportForm exportForm) throws Exception
{
if (isEmpty(schemaId) || isEmpty(dataExchangeId) || exportForm == null || isEmpty(exportForm.getDataFormat())
|| isEmpty(exportForm.getExportOption()) || isEmpty(exportForm.getFileEncoding())
|| isEmpty(exportForm.getSubDataExchangeIds()) || isEmpty(exportForm.getQueries())
|| isEmpty(exportForm.getFileNames())
|| exportForm.getSubDataExchangeIds().length != exportForm.getQueries().length
|| exportForm.getSubDataExchangeIds().length != exportForm.getFileNames().length)
throw new IllegalInputException();
JsonDataExportOption exportOption = exportForm.getExportOption();
if (JsonDataFormat.TABLE_OBJECT.equals(exportOption.getJsonDataFormat()))
{
if (isEmpty(exportForm.getTableNames())
|| exportForm.getSubDataExchangeIds().length != exportForm.getTableNames().length)
throw new IllegalInputException();
}
final User user = WebUtils.getUser(request, response);
String[] subDataExchangeIds = exportForm.getSubDataExchangeIds();
String[] queries = exportForm.getQueries();
String[] tableNames = exportForm.getTableNames();
String[] fileNames = exportForm.getFileNames();
checkNoEmptyWithElement(subDataExchangeIds);
checkNoEmptyWithElement(queries);
checkNoEmptyWithElement(fileNames);
File directory = getTempDataExchangeDirectory(dataExchangeId, true);
File logDirectory = getTempDataExchangeLogDirectory(dataExchangeId, true);
Schema schema = getSchemaForUserNotNull(user, schemaId);
checkReadTableDataPermission(schema, user);
ConnectionFactory connectionFactory = new DataSourceConnectionFactory(new SchemaDataSource(schema));
String exportChannelId = getDataExchangeChannelId(dataExchangeId);
ServerChannel exportServerChannel = this.dataExchangeCometdService.getChannelWithCreation(exportChannelId);
Locale locale = getLocale(request);
Set<SubDataExchange> subDataExchanges = new HashSet<SubDataExchange>();
for (int i = 0; i < subDataExchangeIds.length; i++)
{
Query query = toQuery(queries[i]);
File file = FileUtil.getFile(directory, fileNames[i]);
ResourceFactory<Writer> writerFactory = FileWriterResourceFactory.valueOf(file,
exportForm.getFileEncoding());
JsonDataExport csvDataExport = new JsonDataExport(connectionFactory, exportForm.getDataFormat(),
exportOption, query, writerFactory, (tableNames == null ? null : tableNames[i]));
CometdSubTextDataExportListener listener = new CometdSubTextDataExportListener(
this.dataExchangeCometdService, exportServerChannel, getMessageSource(), getLocale(request),
subDataExchangeIds[i]);
listener.setLogFile(getTempSubDataExchangeLogFile(logDirectory, subDataExchangeIds[i]));
listener.setSendExchangingMessageInterval(
evalSendDataExchangingMessageInterval(subDataExchangeIds.length, csvDataExport));
csvDataExport.setListener(listener);
SubDataExchange subDataExchange = new SubDataExchange(subDataExchangeIds[i], csvDataExport);
subDataExchanges.add(subDataExchange);
}
BatchDataExchange batchDataExchange = buildBatchDataExchange(connectionFactory, subDataExchanges,
exportServerChannel, locale);
this.dataExchangeService.exchange(batchDataExchange);
BatchDataExchangeInfo batchDataExchangeInfo = new BatchDataExchangeInfo(dataExchangeId, batchDataExchange);
storeBatchDataExchangeInfo(request, batchDataExchangeInfo);
ResponseEntity<OperationMessage> responseEntity = buildOperationMessageSuccessEmptyResponseEntity();
Map<String, String> subDataExchangeFileNameMap = buildSubDataExchangeFileNameMap(subDataExchangeIds, fileNames);
responseEntity.getBody().setData(subDataExchangeFileNameMap);
return responseEntity;
}
@RequestMapping(value = "/{schemaId}/export/download")
@ResponseBody
public void exptDownload(HttpServletRequest request, HttpServletResponse response,
@ -1861,6 +1983,43 @@ public class DataExchangeController extends AbstractSchemaConnController
}
}
public static class JsonFileBatchDataExportForm extends TextFileBatchDataExportForm
{
private static final long serialVersionUID = 1L;
private String[] tableNames;
public JsonFileBatchDataExportForm()
{
super();
}
@Override
public JsonDataExportOption getExportOption()
{
return (JsonDataExportOption) super.getExportOption();
}
@Override
public void setExportOption(TextDataExportOption exportOption)
{
if (!(exportOption instanceof JsonDataExportOption))
throw new IllegalArgumentException();
super.setExportOption(exportOption);
}
public String[] getTableNames()
{
return tableNames;
}
public void setTableNames(String[] tableNames)
{
this.tableNames = tableNames;
}
}
protected static class BatchDataExchangeInfo implements Serializable
{
private static final long serialVersionUID = 1L;

View File

@ -453,6 +453,9 @@
<bean class="org.datagear.dataexchange.support.ExcelDataExportService">
<property name="databaseInfoResolver" ref="databaseInfoResolver" />
</bean>
<bean class="org.datagear.dataexchange.support.JsonDataExportService">
<property name="databaseInfoResolver" ref="databaseInfoResolver" />
</bean>
<bean class="org.datagear.dataexchange.BatchDataExchangeService" destroy-method="shutdown">
<property name="subDataExchangeService" ref="dataExchangeService" />
</bean>

View File

@ -516,10 +516,13 @@ dataExport.dataType.csv=CSV
dataExport.dataType.csv.desc=\u5BFC\u51FA\u4E3A\u9017\u53F7\u5206\u9694\u503C\u6570\u636E
dataExport.dataType.sql=SQL
dataExport.dataType.sql.desc=\u5BFC\u51FA\u4E3ASQL Insert\u8BED\u53E5
dataExport.dataType.json=JSON
dataExport.dataType.json.desc=\u5BFC\u51FA\u4E3AJSON\u683C\u5F0F\u7684\u6570\u636E
dataExport.dataType.excel=Excel
dataExport.dataType.excel.desc=\u5BFC\u51FA\u4E3AExcel\u683C\u5F0F\u7684\u6570\u636E
dataExport.exportCsvData=\u5BFC\u51FACSV\u6570\u636E
dataExport.exportSqlData=\u5BFC\u51FASQL\u6570\u636E
dataExport.exportJsonData=\u5BFC\u51FAJSON\u6570\u636E
dataExport.exportExcelData=\u5BFC\u51FAExcel\u6570\u636E
dataExport.setDataFormat=\u8BBE\u7F6E
dataExport.nullForIllegalColumnValue=\u5217\u503C\u975E\u6CD5\u65F6\u8BBE\u7F6E\u4E3ANULL
@ -534,6 +537,12 @@ dataExport.startExport=\u5F00\u59CB\u5BFC\u51FA
dataExport.finishExport=\u5B8C\u6210\u5BFC\u51FA
dataExport.sqlExportTableName=SQL\u8868\u540D
dataExport.exportCreationSql=\u5BFC\u51FA\u5EFA\u8868\u8BED\u53E5
dataExport.jsonExportTableName=JSON\u8868\u5BF9\u8C61\u540D
dataExport.exportFileFormat=\u5BFC\u51FA\u6587\u4EF6\u683C\u5F0F
dataExport.exportFileFormat.json.TABLE_OBJECT=\u8868\u5BF9\u8C61
dataExport.exportFileFormat.json.TABLE_OBJECT.desc=\u6587\u4EF6\u683C\u5F0F\u4E3A\uFF1A{&quot;table_name&quot; : [{...}, {...}]}
dataExport.exportFileFormat.json.ROW_ARRAY=\u884C\u6570\u7EC4
dataExport.exportFileFormat.json.ROW_ARRAY.desc=\u6587\u4EF6\u683C\u5F0F\u4E3A\uFF1A[{...}, {...}]
#role
role.addRole=\u6DFB\u52A0\u7528\u6237\u7EC4

View File

@ -50,8 +50,18 @@ Schema schema 数据库不允许为null
<div class="form-item">
<div class="form-item-label">&nbsp;</div>
<div class="form-item-value">
<label for="${pageId}-dataType-2"><@spring.message code='dataExport.dataType.excel' /></label>
<input id="${pageId}-dataType-2" type="radio" name="dataType" value="excel" />
<label for="${pageId}-dataType-2"><@spring.message code='dataExport.dataType.json' /></label>
<input id="${pageId}-dataType-2" type="radio" name="dataType" value="json" />
<div class="input-desc minor">
<@spring.message code='dataExport.dataType.json.desc' />
</div>
</div>
</div>
<div class="form-item">
<div class="form-item-label">&nbsp;</div>
<div class="form-item-value">
<label for="${pageId}-dataType-3"><@spring.message code='dataExport.dataType.excel' /></label>
<input id="${pageId}-dataType-3" type="radio" name="dataType" value="excel" />
<div class="input-desc minor">
<@spring.message code='dataExport.dataType.excel.desc' />
</div>

View File

@ -0,0 +1,180 @@
<#include "../include/import_global.ftl">
<#include "../include/html_doctype.ftl">
<#--
Schema schema 数据库不允许为null
-->
<html>
<head>
<#include "../include/html_head.ftl">
<title>
<#include "../include/html_title_app_name.ftl">
<@spring.message code='dataExport.dataExport' />
<@spring.message code='bracketLeft' />
${schema.title?html}
<@spring.message code='bracketRight' />
</title>
</head>
<body class="fill-parent">
<#if !isAjaxRequest>
<div class="fill-parent">
</#if>
<div id="${pageId}" class="page-dataexchange page-dataexport-text page-dataexport-json">
<div class="head">
<@spring.message code='dataExport.exportJsonData' />
</div>
<div class="content">
<form id="${pageId}-form" action="${contextPath}/dataexchange/${schema.id}/export/json/doExport" method="POST">
<input type="hidden" name="dataExchangeId" value="${dataExchangeId}" />
<div class="form-content form-content-wizard">
<h3><@spring.message code='dataExport.setDataFormat' /></h3>
<div>
<#include "include/dataExchange_form_dataFormat_html.ftl">
<div class="form-item">
<div class="form-item-label"><@spring.message code='dataExport.nullForIllegalColumnValue' /></div>
<div class="form-item-value">
<div id="${pageId}-nullForIllegalColumnValue">
<label for="${pageId}-nullForIllegalColumnValue-0"><@spring.message code='yes' /></label>
<input id="${pageId}-nullForIllegalColumnValue-0" type="radio" name="exportOption.nullForIllegalColumnValue" value="true" />
<label for="${pageId}-nullForIllegalColumnValue-1"><@spring.message code='no' /></label>
<input id="${pageId}-nullForIllegalColumnValue-1" type="radio" name="exportOption.nullForIllegalColumnValue" value="false" />
</div>
</div>
</div>
<div class="form-item">
<div class="form-item-label"><@spring.message code='dataExport.exportFileFormat' /></div>
<div class="form-item-value">
<div id="${pageId}-exportFileFormat">
<label for="${pageId}-exportFileFormat-0" title="<@spring.message code='dataExport.exportFileFormat.json.TABLE_OBJECT.desc' />"><@spring.message code='dataExport.exportFileFormat.json.TABLE_OBJECT' /></label>
<input id="${pageId}-exportFileFormat-0" type="radio" name="exportOption.jsonDataFormat" value="TABLE_OBJECT" />
<label for="${pageId}-exportFileFormat-1" title="<@spring.message code='dataExport.exportFileFormat.json.ROW_ARRAY.desc' />"><@spring.message code='dataExport.exportFileFormat.json.ROW_ARRAY' /></label>
<input id="${pageId}-exportFileFormat-1" type="radio" name="exportOption.jsonDataFormat" value="ROW_ARRAY" />
</div>
</div>
</div>
</div>
<h3><@spring.message code='dataExport.selectAndExportData' /></h3>
<div>
<div class="form-item form-item-table-head form-item-add page-status-aware-show edit-status-show">
<div class="form-item-value">
<div id="${pageId}-add-group">
<button type="button" class="table-add-item-button edit-state-aware ui-corner-left"><@spring.message code='add' /></button>
<select id="${pageId}-add-group-select">
<option value="addAll"><@spring.message code='dataExport.addAllTable' /></option>
</select>
</div>
</div>
</div>
<div class="form-item form-item-table-head form-item-progress page-status-aware-show exchange-status-show finish-status-show">
<div class="form-item-value">
<label><@spring.message code='dataExport.exportProgress' /></label>
<div id="${pageId}-progress"></div>
<div id="${pageId}-progress-percent" class="progress-percent"></div>
</div>
</div>
<div class="form-item form-item-table">
<div class="table-operation-wrapper">
<button type="button" class="table-delete-item-button page-status-aware-show edit-status-show"><@spring.message code='delete' /></button>
<button type="button" class="table-cancel-export-button page-status-aware-show exchange-status-show"><@spring.message code='cancel' /></button>
<button type="button" class="table-download-all-button page-status-aware-show finish-status-show" file-name="export_json.zip"><@spring.message code='downloadAll' /></button>
</div>
<div class="file-encoding-wrapper">
<span class="file-encoding-label page-status-aware-enable edit-status-enable">
<@spring.message code='dataExport.exportFileEncoding' />
</span>
<select name="fileEncoding">
<#list availableCharsetNames as item>
<option value="${item}" <#if item == defaultCharsetName>selected="selected"</#if>>${item}</option>
</#list>
</select>
</div>
<div class="table-wrapper minor-dataTable">
<table id="${pageId}-table" width="100%" class="hover stripe"></table>
</div>
</div>
</div>
</div>
</form>
<div class="return-wrapper page-status-aware-show edit-status-show finish-status-show">
<button type="button" class="return-button" return-url="${contextPath}/dataexchange/${schema.id}/export">
<@spring.message code='return' />
</button>
</div>
<div class="restart-wrapper page-status-aware-show finish-status-show">
<button type="button" class="restart-button"><@spring.message code='restart' /></button>
</div>
<div id="${pageId}-exchange-exception-tooltip" title="import tooltip" style="width:0; height:0;"></div>
</div>
<div class="foot">
</div>
</div>
<#if !isAjaxRequest>
</div>
</#if>
<#include "../include/page_js_obj.ftl">
<#include "../include/page_obj_grid.ftl">
<#include "../include/page_obj_cometd.ftl">
<#include "../include/page_obj_format_time.ftl" >
<#include "include/dataExchange_js.ftl" >
<#include "include/dataExport_js.ftl" >
<script type="text/javascript">
(function(po)
{
po.element(".binaryFormatSetButtonHex").attr("value", "0x"+"$"+"{Hex}");
po.postBuildSubDataExchange = function(subDataExchange)
{
subDataExchange.tableName = subDataExchange.query;
};
po.toExportFileName = function(tableName)
{
if(!tableName)
return "";
return $.toValidFileName(tableName)+".json";
};
po.onStepChangedSuper = po.onStepChanged;
po.onStepChanged = function(event, currentIndex, priorIndex)
{
if(currentIndex == 1)
{
var visible = po.element("input[name='exportOption.jsonDataFormat']:checked").val() == "TABLE_OBJECT";
po.getSubDataExchangeDataTable().column(2).visible(visible, false);
}
po.onStepChangedSuper(event, currentIndex, priorIndex);
};
po.dataExportTableColumns.splice(1, 0,
{
title : "<@spring.message code='dataExport.jsonExportTableName' />",
data : "tableName",
render : function(data, type, row, meta)
{
if(!data)
data = "";
return "<input type='text' name='tableNames' value='"+$.escapeHtml(data)+"' class='table-name-input input-in-table ui-widget ui-widget-content' style='width:90%' />";
},
defaultContent: "",
width : "20%"
});
po.cometdInitIfNot();
po.initDataExportSteps();
po.initDataExchangeUIs();
po.initDataExportUIs();
po.element("#${pageId}-exportFileFormat").buttonset();
po.element("#${pageId}-exportFileFormat-0").click();
po.initDataExportDataTable();
po.initDataExchangeActions();
po.initDataExportActions();
po.initDataExportDroppable();
po.updateDataExchangePageStatus("edit");
})
(${pageId});
</script>
</body>
</html>

View File

@ -140,6 +140,12 @@ dataExchange_js.ftl
}
];
po.onStepChanged = function(event, currentIndex, priorIndex)
{
if(currentIndex == 1)
po.adjustDataTable();
};
po.initDataExportSteps = function()
{
po.element(".form-content").steps(
@ -148,8 +154,7 @@ dataExchange_js.ftl
bodyTag: "div",
onStepChanged : function(event, currentIndex, priorIndex)
{
if(currentIndex == 1)
po.adjustDataTable();
po.onStepChanged(event, currentIndex, priorIndex);
},
onFinished : function(event, currentIndex)
{

View File

@ -19,6 +19,7 @@
<slf4j.version>1.7.9</slf4j.version>
<slf4j-log4j12.version>1.7.9</slf4j-log4j12.version>
<log4j.version>1.2.17</log4j.version>
<javax.json.version>1.0.4</javax.json.version>
</properties>
<modules>