Destiny.Lin
2 months ago
3 changed files with 106 additions and 2 deletions
@ -0,0 +1,100 @@
|
||||
package com.fanruan.data; |
||||
|
||||
import com.fanruan.config.impl.data.TableDataConfigProvider; |
||||
import com.fr.base.TableData; |
||||
import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; |
||||
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; |
||||
import com.fr.design.data.datapane.preview.TableDataBeanHelper; |
||||
import com.fr.file.TableDataConfig; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.transaction.Configurations; |
||||
import com.fr.transaction.WorkerAdaptor; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.repository.tabledata.TableDataRepository; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 设计器的TableData配置Wrapper |
||||
* <p>防止底层错误调用</p> |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/10/25 |
||||
*/ |
||||
public class DesignTableDataConfigWrapper implements TableDataConfigProvider { |
||||
@Override |
||||
public Map<String, TableData> getTableDatas() { |
||||
return TableDataConfig.getInstance().getTableDatas(); |
||||
} |
||||
|
||||
@Override |
||||
public void removeTableData(String tableDataName) { |
||||
Configurations.update(new WorkerAdaptor(TableDataConfig.class) { |
||||
@Override |
||||
public void run() { |
||||
TableDataConfig.getInstance().removeTableData(tableDataName); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public TableData getTableData(String name) { |
||||
if (WorkContext.getCurrent().isLocal()) { |
||||
return TableDataConfig.getInstance().getTableData(name); |
||||
} |
||||
ServerDataSetBean bean = TableDataRepository.getInstance().getTableData(name); |
||||
try { |
||||
if (bean == null) { |
||||
return null; |
||||
} |
||||
return TableDataBeanHelper.getTableDataSet(ConnectionInfoBeanHelper.getCurrentConnectionMap(), bean.getDatasetType(), bean.getDatasetData()); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void addTableData(String name, TableData tableData) { |
||||
Configurations.update(new WorkerAdaptor(TableDataConfig.class) { |
||||
@Override |
||||
public void run() { |
||||
TableDataConfig.getInstance().addTableData(name, tableData); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void renameTableData(String oldName, String newName) { |
||||
Configurations.update(new WorkerAdaptor(TableDataConfig.class) { |
||||
@Override |
||||
public void run() { |
||||
TableDataConfig.getInstance().renameTableData(oldName, newName); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void updateTableData(String tableDataName, TableData tableData) { |
||||
Configurations.update(new WorkerAdaptor(TableDataConfig.class) { |
||||
@Override |
||||
public void run() { |
||||
TableDataConfig.getInstance().removeTableData(tableDataName); |
||||
TableDataConfig.getInstance().addTableData(tableDataName, tableData); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public void removeAllTableData() { |
||||
Configurations.update(new WorkerAdaptor(TableDataConfig.class) { |
||||
@Override |
||||
public void run() { |
||||
TableDataConfig.getInstance().removeAllTableData(); |
||||
} |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue