Browse Source
* commit '249f552c4b3eff636e841b9d8da918025efe1417': REPORT-133888 - 【fr-fbp回归】文件数据集excel只能被选一次 REPORT-133863 【fr-fbp回归】数据字典获取数据库字段空白 REPORT-133186 【fr-fbp回归】【数据集】fbp设计器远程设计,新建mysql数据连接,开启SSL通道后读不到CA证书 REPORT-133186 【fr-fbp回归】【数据集】fbp设计器远程设计,新建mysql数据连接,开启SSL通道后读不到CA证书 REPORT-133110 【fr-fbp回归】【FR图表】区域地图-类型-地图边界,地理信息和自定义图片无法选中并展开选择子层级内容 缩放以及事件不响应 REPORT-132393 & REPORT-133561 fix:NewUI 修复图标问题&图表区域遗漏翻新布局 fix: 回退调整滚动条的代码 REPORT-132393 & REPORT-133561 fix:NewUI 修复图标问题&图表区域遗漏翻新布局 fix: 解决代码规范问题 REPORT-132393 & REPORT-133561 fix:NewUI 修复图标问题&图表区域遗漏翻新布局 REPORT-127437 fix: newui 视觉修复 REPORT-133442 【fr-fbp回归】【数据集】数据连接驱动选择自定义,保存后二次编辑,仍选择默认驱动fbp/feature
superman
4 months ago
65 changed files with 951 additions and 333 deletions
@ -0,0 +1,198 @@
|
||||
package com.fr.design.data.datapane.preview; |
||||
|
||||
import com.fr.base.DataSetProcessors; |
||||
import com.fr.base.Parameter; |
||||
import com.fr.base.ParameterHelper; |
||||
import com.fr.base.ParameterTypeHandler; |
||||
import com.fr.base.StoreProcedureParameter; |
||||
import com.fr.base.TableData; |
||||
import com.fr.data.impl.Connection; |
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.data.impl.NameDatabaseConnection; |
||||
import com.fr.data.impl.storeproc.StoreProcedure; |
||||
import com.fr.decision.fun.UniversalServerTableDataProvider; |
||||
import com.fr.decision.webservice.bean.dataset.ParameterBean; |
||||
import com.fr.decision.webservice.bean.dataset.ParameterExternal; |
||||
import com.fr.decision.webservice.bean.dataset.SQLDataSetBean; |
||||
import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; |
||||
import com.fr.decision.webservice.bean.dataset.StoreProcedureBean; |
||||
import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.SQLDataSetProcessor; |
||||
import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.StoreProcedureProcessor; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.general.sql.SqlUtils; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.security.encryption.transmission.TransmissionEncryptionManager; |
||||
import com.fr.stable.ParameterProvider; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.workspace.server.repository.connection.ConnectionRepository; |
||||
import com.fr.workspace.server.repository.tabledata.DataEncryptionHelper; |
||||
import com.fr.workspace.server.repository.tabledata.TableDataRepository; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 数据集bean工具类 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/8/9 |
||||
*/ |
||||
public class TableDataBeanHelper { |
||||
|
||||
/** |
||||
* 获取服务器数据集 |
||||
*/ |
||||
public static Map<String, TableData> getServerTableDatas() { |
||||
final List<ServerDataSetBean> beans = TableDataRepository.getInstance().getAllTableData(); |
||||
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll()); |
||||
final Map<String, TableData> tableDataMap = new HashMap<>(); |
||||
try { |
||||
TransmissionEncryptionManager.setTransEncryptionLevel(1); |
||||
for (ServerDataSetBean bean : beans) { |
||||
tableDataMap.put(bean.getDatasetName() , TableDataBeanHelper.getTableDataSet(connectionMap, bean.getDatasetType(), bean.getDatasetData())); |
||||
} |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} finally { |
||||
TransmissionEncryptionManager.removeTransEncryptionLevel(); |
||||
} |
||||
return tableDataMap; |
||||
} |
||||
|
||||
/** |
||||
* 根据序列化数据生成tabledata |
||||
*/ |
||||
public static TableData getTableDataSet(Map<String, Connection> connectionMap, String type, String tableDataSetData) throws Exception { |
||||
if (DataSetProcessors.getProcessors().containsKey(type)) { |
||||
if (StringUtils.equals(SQLDataSetProcessor.TYPE, type)) { |
||||
return deserialize4SQL(connectionMap, null, new JSONObject(tableDataSetData)); |
||||
} else if (StringUtils.equals(StoreProcedureProcessor.TYPE, type)) { |
||||
return deserialize4Procedure(connectionMap, null, new JSONObject(tableDataSetData)); |
||||
} else { |
||||
UniversalServerTableDataProvider processor = DataSetProcessors.getProcessors().get(type); |
||||
return (TableData) processor.deserialize(null, new JSONObject(tableDataSetData)); |
||||
} |
||||
|
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private static TableData deserialize4Procedure(Map<String, Connection> connectionMap, DBTableData oldDataSet, JSONObject object) { |
||||
StoreProcedure storeProcedure = new StoreProcedure(); |
||||
StoreProcedureBean bean = object.mapTo(StoreProcedureBean.class); |
||||
storeProcedure.setShare(bean.isShare()); |
||||
storeProcedure.setMaxMemRowCount(bean.getMaxMemRowCount()); |
||||
storeProcedure.setQuery(bean.getQuery()); |
||||
if (StringUtils.isNotEmpty(bean.getDatabase())) { |
||||
Connection connection = connectionMap.get(bean.getDatabase()); |
||||
if (connection != null) { |
||||
storeProcedure.setDatabaseConnection(new NameDatabaseConnection(bean.getDatabase())); |
||||
} else { |
||||
FineLoggerFactory.getLogger().info("not find conn by {}", bean.getDatabase()); |
||||
} |
||||
} |
||||
Parameter[] parameters = new Parameter[bean.getParameters().size()]; |
||||
for (int i = 0; i < parameters.length; i++) { |
||||
ParameterBean parameterBean = bean.getParameters().get(i); |
||||
parameters[i] = (Parameter) ParameterTypeHandler.getInstance().parseParameter(parameterBean, new Parameter(parameterBean.getName())); |
||||
} |
||||
List<ParameterExternal> externals = bean.getStoreProcedureParameterBeanList(); |
||||
StoreProcedureParameter[] procedureParameters = new StoreProcedureParameter[bean.getParameters().size()]; |
||||
for (int i = 0; i < procedureParameters.length; i++) { |
||||
StoreProcedureParameter storeProcedureParameter = new StoreProcedureParameter(); |
||||
storeProcedureParameter.setName(parameters[i].getName()); |
||||
storeProcedureParameter.setValue(parameters[i].getValue()); |
||||
storeProcedureParameter.setSchema(externals.get(i).getSchema()); |
||||
storeProcedureParameter.setType(externals.get(i).getTypeInt()); |
||||
procedureParameters[i] = storeProcedureParameter; |
||||
} |
||||
storeProcedure.setParameters(procedureParameters); |
||||
return storeProcedure; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取服务器数据集传输的bean |
||||
*/ |
||||
public static ServerDataSetBean getServerDataSetBean(String name, TableData tableData) { |
||||
for (UniversalServerTableDataProvider processor : DataSetProcessors.getProcessors().values()) { |
||||
if (SQLDataSetProcessor.KEY.classForTableData() == tableData.getClass()) { |
||||
return serialize4SQL(name, tableData); |
||||
} else if (processor.classForTableData() == tableData.getClass()) { |
||||
ServerDataSetBean bean = new ServerDataSetBean(); |
||||
try { |
||||
bean.setDatasetData(processor.serialize(tableData).toString()); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
bean.setDatasetData(StringUtils.EMPTY); |
||||
} |
||||
bean.setDatasetName(name); |
||||
bean.setDatasetId(name); |
||||
bean.setDatasetType(processor.nameForTableData()); |
||||
return bean; |
||||
} |
||||
} |
||||
return new ServerDataSetBean(name); |
||||
} |
||||
|
||||
private static ServerDataSetBean serialize4SQL(String name, TableData tableData) { |
||||
ServerDataSetBean bean = new ServerDataSetBean(); |
||||
try { |
||||
bean.setDatasetData(serialize4SQL0((DBTableData) tableData).toString()); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
bean.setDatasetData(StringUtils.EMPTY); |
||||
} |
||||
bean.setDatasetName(name); |
||||
bean.setDatasetId(name); |
||||
bean.setDatasetType(SQLDataSetProcessor.KEY.nameForTableData()); |
||||
return bean; |
||||
} |
||||
|
||||
private static Object serialize4SQL0(DBTableData dataSet) { |
||||
SQLDataSetBean bean = new SQLDataSetBean(); |
||||
if (dataSet.getDatabase() instanceof NameDatabaseConnection) { |
||||
bean.setDatabase(((NameDatabaseConnection) dataSet.getDatabase()).getName()); |
||||
} |
||||
bean.setQuery(DataEncryptionHelper.encrypt(dataSet.getQuery())); |
||||
List<ParameterBean> parameterBeans = new ArrayList<>(); |
||||
ParameterProvider[] parameters = dataSet.getParameters(Calculator.createCalculator()); |
||||
for (ParameterProvider parameter : parameters) { |
||||
parameterBeans.add(new ParameterBean(parameter.getValue().getClass().getSimpleName(), parameter.getName(), GeneralUtils.objectToString(parameter.getValue()))); |
||||
} |
||||
bean.setParameters(parameterBeans); |
||||
return JSONObject.mapFrom(bean); |
||||
} |
||||
|
||||
|
||||
private static TableData deserialize4SQL(Map<String, Connection> connectionMap, DBTableData oldDataSet, JSONObject object) { |
||||
DBTableData tableData = new DBTableData(); |
||||
SQLDataSetBean bean = object.mapTo(SQLDataSetBean.class); |
||||
tableData.setQuery(DataEncryptionHelper.decrypt(bean.getQuery())); |
||||
Connection connection = connectionMap.get(bean.getDatabase()); |
||||
if (connection != null) { |
||||
tableData.setDatabase(new NameDatabaseConnection(bean.getDatabase())); |
||||
} else { |
||||
FineLoggerFactory.getLogger().info("not find conn by {}", bean.getDatabase()); |
||||
} |
||||
String sql = SqlUtils.clearSqlComments(DataEncryptionHelper.decrypt(bean.getQuery())); |
||||
Parameter[] parameters = new Parameter[bean.getParameters().size()]; |
||||
for (int i = 0; i < parameters.length; i++) { |
||||
ParameterBean parameterBean = bean.getParameters().get(i); |
||||
parameters[i] = (Parameter) ParameterTypeHandler.getInstance().parseParameter(parameterBean, new Parameter(parameterBean.getName())); |
||||
} |
||||
tableData.setParameters(ParameterHelper.analyzeAndUnionSameParameters(new String[]{sql}, parameters)); |
||||
if (oldDataSet != null) { |
||||
tableData.setMaxMemRowCount(oldDataSet.getMaxMemRowCount()); |
||||
tableData.setPageQuerySql(oldDataSet.getPageQuerySql()); |
||||
tableData.setShare(oldDataSet.isShare()); |
||||
tableData.setDataQueryProcessor(oldDataSet.getDataQueryProcessor()); |
||||
} |
||||
return tableData; |
||||
} |
||||
} |
@ -0,0 +1,167 @@
|
||||
package com.fr.file; |
||||
|
||||
import com.fr.decision.webservice.bean.entry.FileNodeBean; |
||||
import com.fr.file.filetree.FileNode; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.CoreConstants; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.project.ProjectConstants; |
||||
import com.fr.workspace.server.repository.tabledata.TableDataRepository; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* CA证书文件相关 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/9/8 |
||||
*/ |
||||
public class FileCAFILE extends FileNodeFILE{ |
||||
public static final String ROOT = ProjectConstants.CERTIFICATES_DIRECTORY; |
||||
private List<FileCAFILE> children = new ArrayList<>(); |
||||
private boolean builded = false; |
||||
private String id = StringUtils.EMPTY; |
||||
|
||||
public FileCAFILE(FileNode node) { |
||||
super(node); |
||||
} |
||||
|
||||
public FileCAFILE(FileNode node, boolean builded, String id) { |
||||
super(node); |
||||
this.builded = builded; |
||||
this.id = id; |
||||
} |
||||
|
||||
/** |
||||
* 添加子 |
||||
*/ |
||||
private void addChild(FileCAFILE file) { |
||||
children.add(file); |
||||
} |
||||
|
||||
public List<FileCAFILE> getChildren() { |
||||
return children; |
||||
} |
||||
|
||||
public void setChildren(List<FileCAFILE> children) { |
||||
this.children = children; |
||||
} |
||||
|
||||
public boolean isBuilded() { |
||||
return builded; |
||||
} |
||||
|
||||
public void setBuilded(boolean builded) { |
||||
this.builded = builded; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
@Override |
||||
public FILE[] listFiles() { |
||||
|
||||
if (ComparatorUtils.equals(node, null)) { |
||||
node = new FileNode(CoreConstants.SEPARATOR, true); |
||||
} |
||||
if (!node.isDirectory()) { |
||||
return new FILE[]{this}; |
||||
} |
||||
try { |
||||
FileCAFILE root = null; |
||||
if (!this.builded) { |
||||
root = buildTree(); |
||||
FileCAFILE dataFILE = root.getFileCAFILE(this.id); |
||||
this.setChildren(dataFILE.getChildren()); |
||||
this.builded = true; |
||||
} |
||||
return this.getChildren().toArray(new FILE[0]); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
return new FILE[0]; |
||||
} |
||||
} |
||||
|
||||
private List<FileNodeBean> getBeans() { |
||||
try { |
||||
return TableDataRepository.getInstance().getCertificatesFile(StringUtils.EMPTY); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 递归获取指定id的文件 |
||||
*/ |
||||
public FileCAFILE getFileCAFILE(String id) { |
||||
if (StringUtils.equals(this.id, id) || StringUtils.equals(StableUtils.pathJoin(this.id, StringUtils.EMPTY), id)) { |
||||
return this; |
||||
} |
||||
for (FileCAFILE file : getChildren()) { |
||||
return file.getFileCAFILE(id); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private FileCAFILE buildTree() { |
||||
List<FileNodeBean> beans = getBeans(); |
||||
Map<String, FileCAFILE> tree = new HashMap<>(); |
||||
FileCAFILE root = null; |
||||
// id , 父
|
||||
for (FileNodeBean bean : beans) { |
||||
FileNode fileNode = new FileNode(); |
||||
fileNode.setEnvPath(bean.getPath()); |
||||
fileNode.setDirectory(bean.getIsParent()); |
||||
tree.putIfAbsent(bean.getId(), new FileCAFILE(fileNode, true, bean.getId())); |
||||
if (StringUtils.isEmpty(bean.getpId())) { |
||||
root = tree.get(bean.getId()); |
||||
} else { |
||||
tree.putIfAbsent(bean.getpId(), createParent(bean.getpId(), beans)); |
||||
FileCAFILE file = tree.get(bean.getpId()); |
||||
if (file != null) { |
||||
file.addChild(tree.get(bean.getId())); |
||||
} |
||||
} |
||||
} |
||||
for (Map.Entry<String, FileCAFILE> entry : tree.entrySet()) { |
||||
if (entry.getKey().endsWith(ROOT)) { |
||||
root = entry.getValue(); |
||||
root.setId(StableUtils.pathJoin(ProjectConstants.RESOURCES_NAME, ProjectConstants.CERTIFICATES_DIRECTORY)); |
||||
break; |
||||
} |
||||
} |
||||
return root; |
||||
} |
||||
|
||||
private FileCAFILE createParent(String s, List<FileNodeBean> beans) { |
||||
for (FileNodeBean bean : beans) { |
||||
if (StringUtils.equals(bean.getId(), s)) { |
||||
FileNode fileNode = new FileNode(); |
||||
fileNode.setEnvPath(bean.getPath()); |
||||
fileNode.setDirectory(bean.getIsParent()); |
||||
return new FileCAFILE(fileNode, true, bean.getId()); |
||||
} |
||||
} |
||||
FileNode fileNode = new FileNode(); |
||||
fileNode.setEnvPath(s); |
||||
fileNode.setDirectory(true); |
||||
return new FileCAFILE(fileNode, true, ROOT); |
||||
} |
||||
|
||||
@Override |
||||
public String prefix() { |
||||
return FILEFactory.FILE_CA_PREFIX; |
||||
} |
||||
|
||||
} |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.0 KiB |
Loading…
Reference in new issue