You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.9 KiB
53 lines
1.9 KiB
/* |
|
* Copyright (C), 2015-2019 |
|
* FileName: JSONExportOperate |
|
* Author: Louis |
|
* Date: 2019/8/29 16:24 |
|
* Description: JSONExportOperate |
|
* History: |
|
* <author> <time> <version> <desc> |
|
*/ |
|
package com.fr.plugin.tabledataservice.toolbar; |
|
|
|
import com.fanruan.api.i18n.I18nKit; |
|
import com.fanruan.api.log.LogKit; |
|
import com.fr.general.DeclareRecordType; |
|
import com.fr.io.collection.ExportCollection; |
|
import com.fr.plugin.context.PluginContexts; |
|
import com.fr.plugin.tabledataservice.exporter.JSONExporter; |
|
import com.fr.web.core.ReportSessionIDInfor; |
|
import com.fr.web.core.reserve.DefaultOperate; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
/** |
|
* 〈Function Description〉<br> |
|
* 〈JSONExportOperate〉 |
|
* |
|
* @author fr.open |
|
* @since 1.0.0 |
|
*/ |
|
public class JSONExportOperate extends DefaultOperate { |
|
@Override |
|
public void setContent(HttpServletRequest req, HttpServletResponse res, String fileName, boolean isEmbed) { |
|
if (!PluginContexts.currentContext().isAvailable()) { |
|
LogKit.error(I18nKit.getLocText("Plugin-tabledataservice_Licence_Expired")); |
|
return; |
|
} |
|
res.setContentType("application/octet-stream"); |
|
res.setHeader("extension", "json"); |
|
res.setHeader("Content-disposition", "attachment; filename=" + fileName + ".json"); |
|
} |
|
|
|
@Override |
|
public ExportCollection createCollection(HttpServletRequest req, HttpServletResponse res, ReportSessionIDInfor sessionIDInfor, String fileName) { |
|
if (!PluginContexts.currentContext().isAvailable()) { |
|
return ExportCollection.create(); |
|
} |
|
ExportCollection collection = ExportCollection.create(); |
|
collection.setExporter(new JSONExporter()); |
|
collection.setRecordType(DeclareRecordType.EXPORT_TYPE_CSV); |
|
return collection; |
|
} |
|
} |