Browse Source
* commit 'fd94ed337cedbe73c6f860dab80977f0398f1b1f': REPORT-130599 【FBP数据源】FR设计器远程66环境,添加文件数据集选择本地文件,预览正常但添加失败 REPORT-130846【NewUI】ComboBox边距调整 REPORT-130846【NewUI】ComboBox边距调整 REPORT-113994 【NewUI】图表遗留问题处理 REPORT-131407 修复数据中心弹窗标题缺失fbp/release
superman
3 months ago
17 changed files with 346 additions and 88 deletions
@ -0,0 +1,52 @@
|
||||
package com.fr.design.data.tabledata; |
||||
|
||||
import com.fanruan.config.impl.data.TableDataConfigProviderFactory; |
||||
import com.fr.decision.webservice.bean.entry.FileNodeBean; |
||||
import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.FileProcessor; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.workspace.server.repository.tabledata.BaseTableDataSource; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* LocalTableDataSource |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/5/29 |
||||
*/ |
||||
public class LocalTableDataSource extends BaseTableDataSource { |
||||
@Override |
||||
public Set<String> getAllNames(String username) { |
||||
Set<String> authServerDataSetNames = new HashSet<>(); |
||||
for (String authServerDataSetName : TableDataConfigProviderFactory.getInstance().getTableDatas().keySet()) { |
||||
authServerDataSetNames.add(authServerDataSetName); |
||||
} |
||||
return authServerDataSetNames; |
||||
} |
||||
|
||||
@Override |
||||
public boolean lock(String str) { |
||||
// 本地默认锁定成功,让其执行后续动作
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean unlock(String str) { |
||||
// 本地默认解锁成功
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isLock(String str) { |
||||
// 本地默认未锁定
|
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public List<FileNodeBean> getFileList(String fileType) { |
||||
return FileProcessor.KEY.getFileList(fileType, StringUtils.EMPTY); |
||||
} |
||||
} |
@ -0,0 +1,169 @@
|
||||
package com.fr.file; |
||||
|
||||
import com.fr.decision.webservice.bean.entry.FileNodeBean; |
||||
import com.fr.file.filetree.FileNode; |
||||
import com.fr.file.filter.FILEFilter; |
||||
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.workspace.server.repository.tabledata.TableDataRepository; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* FileDataFILE |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/8/20 |
||||
*/ |
||||
public class FileDataFILE extends FileNodeFILE{ |
||||
public static final String FILE_DATASET_NAME = "file_dataset"; |
||||
public static final String TXT = "txt"; |
||||
public static final String XML = "xml"; |
||||
public static final String EXCEL = "excel"; |
||||
private List<FileDataFILE> children = new ArrayList<>(); |
||||
private boolean builded = false; |
||||
private String id = StringUtils.EMPTY; |
||||
private String type = "txt"; |
||||
|
||||
public FileDataFILE(FileNode node) { |
||||
super(node); |
||||
} |
||||
|
||||
public FileDataFILE(FileNode node, boolean builded, String id) { |
||||
super(node); |
||||
this.builded = builded; |
||||
this.id = id; |
||||
} |
||||
|
||||
private void addChild(FileDataFILE file) { |
||||
children.add(file); |
||||
} |
||||
|
||||
public List<FileDataFILE> getChildren() { |
||||
return children; |
||||
} |
||||
|
||||
public void setChildren(List<FileDataFILE> 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; |
||||
} |
||||
|
||||
public String getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(String type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
@Override |
||||
public FILE[] listFiles() { |
||||
|
||||
if (ComparatorUtils.equals(node, null)) { |
||||
node = new FileNode(CoreConstants.SEPARATOR, true); |
||||
} |
||||
if (!node.isDirectory()) { |
||||
return new FILE[]{this}; |
||||
} |
||||
try { |
||||
FileDataFILE root = null; |
||||
if (!this.builded) { |
||||
root = buildTree(); |
||||
FileDataFILE dataFILE = root.getFileDataFILE(this.id); |
||||
this.setChildren(dataFILE.getChildren()); |
||||
this.setType(dataFILE.getType()); |
||||
this.builded = true; |
||||
} |
||||
return this.getChildren().toArray(new FILE[0]); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
return new FILE[0]; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public String prefix() { |
||||
return FILEFactory.FILE_DATA_PREFIX; |
||||
} |
||||
|
||||
public FileDataFILE getFileDataFILE(String id) { |
||||
if (StringUtils.equals(this.id, id) || StringUtils.equals(StableUtils.pathJoin(this.id, StringUtils.EMPTY), id)) { |
||||
return this; |
||||
} |
||||
for (FileDataFILE file : getChildren()) { |
||||
return file.getFileDataFILE(id); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private FileDataFILE buildTree() { |
||||
List<FileNodeBean> beans = TableDataRepository.getInstance().getFileList(type); |
||||
Map<String, FileDataFILE> tree = new HashMap<>(); |
||||
FileDataFILE root = null; |
||||
// id , 父
|
||||
for (FileNodeBean bean : beans) { |
||||
FileNode fileNode = new FileNode(); |
||||
fileNode.setEnvPath(bean.getPath()); |
||||
fileNode.setDirectory(bean.getIsParent()); |
||||
tree.putIfAbsent(bean.getId(), new FileDataFILE(fileNode, true, bean.getId())); |
||||
if (StringUtils.isEmpty(bean.getpId())) { |
||||
root = tree.get(bean.getId()); |
||||
} else { |
||||
tree.putIfAbsent(bean.getpId(), createParent(bean.getpId(), beans)); |
||||
FileDataFILE file = tree.get(bean.getpId()); |
||||
if (file != null) { |
||||
file.addChild(tree.get(bean.getId())); |
||||
} |
||||
} |
||||
} |
||||
return root; |
||||
} |
||||
|
||||
private FileDataFILE 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 FileDataFILE(fileNode, true, bean.getId()); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取类型 |
||||
*/ |
||||
public static String parseType(FILEFilter filter) { |
||||
if (filter.getDescription().contains("xls")) { |
||||
return EXCEL; |
||||
} else if (filter.getDescription().contains("xml")) { |
||||
return XML; |
||||
} else { |
||||
return TXT; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue