|
|
@ -4,8 +4,13 @@ import com.fr.base.TableData; |
|
|
|
import com.fr.base.TableDataBean; |
|
|
|
import com.fr.base.TableDataBean; |
|
|
|
import com.fr.data.MultiResultTableData; |
|
|
|
import com.fr.data.MultiResultTableData; |
|
|
|
import com.fr.data.TableDataSource; |
|
|
|
import com.fr.data.TableDataSource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.DataSetProcessorFactory; |
|
|
|
import com.fr.design.data.BasicTableDataUtils; |
|
|
|
import com.fr.design.data.BasicTableDataUtils; |
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
|
|
|
|
import com.fr.design.data.MapCompareUtils; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.gui.controlpane.JListControlPane; |
|
|
|
import com.fr.design.gui.controlpane.JListControlPane; |
|
|
|
import com.fr.design.gui.controlpane.NameableCreator; |
|
|
|
import com.fr.design.gui.controlpane.NameableCreator; |
|
|
@ -17,22 +22,22 @@ import com.fr.file.TableDataOperatorImpl; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.NameObject; |
|
|
|
import com.fr.general.NameObject; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.rpc.ExceptionHandler; |
|
|
|
|
|
|
|
import com.fr.rpc.RPCInvokerExceptionInfo; |
|
|
|
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.Nameable; |
|
|
|
import com.fr.stable.Nameable; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
import com.fr.stable.core.PropertyChangeAdapter; |
|
|
|
import com.fr.third.org.apache.commons.collections4.MapUtils; |
|
|
|
import com.fr.third.org.apache.commons.collections4.MapUtils; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.server.repository.tabledata.TableDataRepository; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.DefaultListModel; |
|
|
|
import javax.swing.DefaultListModel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
@ -42,7 +47,7 @@ import java.util.Map; |
|
|
|
public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController { |
|
|
|
public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController { |
|
|
|
private boolean isNamePermitted = true; |
|
|
|
private boolean isNamePermitted = true; |
|
|
|
private Map<String, String> dsNameChangedMap = new HashMap<>(); |
|
|
|
private Map<String, String> dsNameChangedMap = new HashMap<>(); |
|
|
|
|
|
|
|
private final Map<String, TableData> populatedTableDataSnapshot = new LinkedHashMap<>(); |
|
|
|
public TableDataPaneListPane() { |
|
|
|
public TableDataPaneListPane() { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
dsNameChangedMap.clear(); |
|
|
|
dsNameChangedMap.clear(); |
|
|
@ -197,7 +202,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void populate(TableDataSource tds) { |
|
|
|
public void populate(TableDataSource tds) { |
|
|
|
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
|
|
|
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
|
|
|
|
|
|
|
populatedTableDataSnapshot.clear(); |
|
|
|
Iterator tableDataNameIterator = tds.getTableDataNameIterator(); |
|
|
|
Iterator tableDataNameIterator = tds.getTableDataNameIterator(); |
|
|
|
while (tableDataNameIterator.hasNext()) { |
|
|
|
while (tableDataNameIterator.hasNext()) { |
|
|
|
String tableDataName = (String) tableDataNameIterator.next(); |
|
|
|
String tableDataName = (String) tableDataNameIterator.next(); |
|
|
@ -205,6 +210,11 @@ public class TableDataPaneListPane extends JListControlPane implements TableData |
|
|
|
|
|
|
|
|
|
|
|
if (tableData != null) { |
|
|
|
if (tableData != null) { |
|
|
|
nameObjectList.add(new NameObject(tableDataName, tableData)); |
|
|
|
nameObjectList.add(new NameObject(tableDataName, tableData)); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
populatedTableDataSnapshot.put(tableDataName, (TableData) tableData.clone()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -233,15 +243,59 @@ public class TableDataPaneListPane extends JListControlPane implements TableData |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void update(Map<String, TableData> tableDataMap) { |
|
|
|
public void update(Map<String, TableData> tableDataMap) { |
|
|
|
List<TableDataBean> tableDataBeans = getUpdateTableDataBeans(); |
|
|
|
Nameable[] res = this.update(); |
|
|
|
try { |
|
|
|
Map<String, TableData> dataMap = new HashMap<>(); |
|
|
|
WorkContext.getCurrent().get(TableDataOperator.class, new ExceptionHandler() { |
|
|
|
Arrays.stream(res).map(n -> (NameObject) n).forEach(no -> dataMap.put(no.getName(), (TableData) no.getObject())); |
|
|
|
@Override |
|
|
|
List<ServerDataSetBean> addDatas = new ArrayList<>(); |
|
|
|
public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) { |
|
|
|
List<ServerDataSetBean> updateDatas = new ArrayList<>(); |
|
|
|
// 走老的方式
|
|
|
|
List<ServerDataSetBean> deleteDatas = new ArrayList<>(); |
|
|
|
return saveByOldWay(tableDataBeans); |
|
|
|
MapCompareUtils.contrastMapEntries(populatedTableDataSnapshot, dataMap, (entryEventKind, s, tabledata) -> { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
switch (entryEventKind) { |
|
|
|
|
|
|
|
case REMOVED: |
|
|
|
|
|
|
|
deleteDatas.add(DataSetProcessorFactory.getServerDataSetBean(s, tabledata)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ADDED: |
|
|
|
|
|
|
|
addDatas.add(DataSetProcessorFactory.getServerDataSetBean(s, tabledata)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case UPDATED: |
|
|
|
|
|
|
|
updateDatas.add(DataSetProcessorFactory.getServerDataSetBean(s, tabledata)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}).saveTableData(new ArrayList<>(tableDataMap.keySet()), tableDataBeans); |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, new MapCompareUtils.UpdateRule<String, TableData>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean needUpdate(TableData origin, TableData tableData) { |
|
|
|
|
|
|
|
return needUpdate0(origin, tableData); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 是否需要更新处理 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean needUpdate0(TableData origin, TableData tableData) { |
|
|
|
|
|
|
|
return !tableData.equals(origin); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
submit(addDatas, updateDatas, deleteDatas); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void submit(List<ServerDataSetBean> addDatas, List<ServerDataSetBean> updateDatas, List<ServerDataSetBean> deleteDatas){ |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
for (ServerDataSetBean bean : addDatas) { |
|
|
|
|
|
|
|
TableDataRepository.getInstance().add(bean); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (ServerDataSetBean bean : updateDatas) { |
|
|
|
|
|
|
|
TableDataRepository.getInstance().update(bean); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (ServerDataSetBean bean : deleteDatas) { |
|
|
|
|
|
|
|
TableDataRepository.getInstance().delete(bean); |
|
|
|
|
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|