Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private void tableSelectRowHandler(final JumpToTableEvent event) {
*/
protected Table transformToTableModel() {
return tableService.createDiffTable(tableInfo, tableType,
controlAreaIds);
controlAreaIds, true);
}

private void updateTableView(final List<Pt1TableCategory> tableCategories) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ public Map<TableType, Table> compile(final TableInfo tableInfo,
final IModelSession modelSession,
final Set<String> controlAreaIds) {
final Map<TableType, Table> result = new EnumMap<>(TableType.class);
// always recreate tables here (e.g. for exports) but don't update table
// status here as this transformation is only temporary
if (PlanProSchnittstelleExtensions
.isPlanning(modelSession.getPlanProSchnittstelle())) {
Arrays.stream(TableType.values())
.filter(type -> type != TableType.SINGLE)
.forEach(type -> {
final Table table = tableService.createDiffTable(
tableInfo, type, controlAreaIds);
tableInfo, type, controlAreaIds, false);
result.put(type, table);
});
} else {
final Table single = tableService.createDiffTable(tableInfo,
TableType.SINGLE, controlAreaIds);
TableType.SINGLE, controlAreaIds, false);
result.put(TableType.SINGLE, single);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ modelSession, getModelService(tableInfo),

private void saveTableError(final TableInfo tableInfo,
final IModelSession modelSession,
final Collection<TableError> errors) {
final Collection<TableError> errors,
final TableStatus tableStatus) {
final String shortName = getTableNameInfo(tableInfo).getShortName();
final String shortCut = tableInfo.shortcut();

Expand All @@ -311,8 +312,6 @@ private void saveTableError(final TableInfo tableInfo,
// Only considered table in main session
if (modelSession.getToolboxFile()
.getRole() == ToolboxFileRole.SESSION) {
final TableStatus tableStatus = tablesStatus
.computeIfAbsent(tableInfo, k -> new TableStatus());
tableStatus.setContainsErrors(!errors.isEmpty());
}

Expand All @@ -324,7 +323,8 @@ private void saveTableError(final TableInfo tableInfo,
}

private Object loadTransform(final TableInfo tableInfo,
final IModelSession modelSession, final TableType tableType) {
final IModelSession modelSession, final TableType tableType,
final TableStatus tableStatus) {
final PlanPro2TableTransformationService modelService = getModelService(
tableInfo);

Expand All @@ -346,7 +346,8 @@ private Object loadTransform(final TableInfo tableInfo,

// sorting
sortTable(transformedTable, tableInfo, tableType);
saveTableToCache(transformedTable, modelSession, tableInfo);
saveTableToCache(transformedTable, modelSession, tableInfo,
tableStatus);
return transformedTable;
}

Expand Down Expand Up @@ -378,7 +379,7 @@ public String transformToCsv(final TableInfo tableInfo,
final TableType tableType, final IModelSession modelSession,
final Set<String> controlAreas) {
final Table table = transformToTable(tableInfo, tableType, modelSession,
controlAreas);
controlAreas, new TableStatus());
return transformToCsv(table);
}

Expand Down Expand Up @@ -423,13 +424,13 @@ private String transformToCsv(final Table table) {
@Override
public Table transformToTable(final TableInfo tableInfo,
final TableType tableType, final IModelSession modelSession,
final Set<String> controlAreaIds) {
final Set<String> controlAreaIds, final TableStatus tableStatus) {
final Cache cache = getCacheService().getCache(
modelSession.getPlanProSchnittstelle(),
ToolboxConstants.SHORTCUT_TO_TABLE_CACHE_ID);
final Object table = cache.get(tableInfo.shortcut(), () -> {
final Object transformed = loadTransform(tableInfo, modelSession,
tableType);
tableType, tableStatus);
if (transformed != null
&& transformed instanceof final Table transformedTable) {
return transformedTable;
Expand Down Expand Up @@ -461,9 +462,7 @@ public Table transformToTable(final TableInfo tableInfo,
getModelService(tableInfo).addAdditionRow(stateTable, resultTable);
if (modelSession.getToolboxFile()
.getRole() == ToolboxFileRole.SESSION) {
final TableStatus status = tablesStatus.computeIfAbsent(tableInfo,
k -> new TableStatus());
status.setContainsStateChanged(
tableStatus.setContainsStateChanged(
TableServiceUtils.isTableExistChangedCompareContent(
resultTable, CompareStateCellContent.class));
}
Expand Down Expand Up @@ -515,7 +514,8 @@ private void storageFootnotes(final ToolboxFileRole sessionRole,
}

private void saveTableToCache(final Table table,
final IModelSession modelSession, final TableInfo tableInfo) {
final IModelSession modelSession, final TableInfo tableInfo,
final TableStatus tableStatus) {
final String threadName = String.format("%s/saveCache", //$NON-NLS-1$
tableInfo.shortcut());
final PlanPro2TableTransformationService modelService = getModelService(
Expand All @@ -541,7 +541,7 @@ private void saveTableToCache(final Table table,
});

cache.set(tableInfo.shortcut(), table);
saveTableError(tableInfo, modelSession, errors);
saveTableError(tableInfo, modelSession, errors, tableStatus);
};

if (TableService.isTransformComplete(tableInfo,
Expand Down Expand Up @@ -679,7 +679,7 @@ public Map<TableInfo, Table> transformTables(final IProgressMonitor monitor,
monitor.subTask(nameInfo.getFullDisplayName());

final Table table = createDiffTable(tableInfo, tableType,
controlAreaIds);
controlAreaIds, true);
while (!TableService.isTransformComplete(tableInfo, null)) {
Thread.sleep(2000);
}
Expand All @@ -695,15 +695,17 @@ public Map<TableInfo, Table> transformTables(final IProgressMonitor monitor,

@Override
public Table createDiffTable(final TableInfo tableInfo,
final TableType tableType, final Set<String> controlAreaIds) {
final TableType tableType, final Set<String> controlAreaIds,
final boolean updateTableStatus) {
Table mainSessionTable = null;
final TableStatus tableStatus = tablesStatus.computeIfAbsent(tableInfo,
k -> new TableStatus());
tableStatus.reset();
final TableStatus tableStatus = updateTableStatus
? tablesStatus.computeIfAbsent(tableInfo,
k -> new TableStatus())
: new TableStatus();
try {
mainSessionTable = transformToTable(tableInfo, tableType,
sessionService.getLoadedSession(ToolboxFileRole.SESSION),
controlAreaIds);
controlAreaIds, tableStatus);
storageFootnotes(ToolboxFileRole.SESSION, tableInfo,
mainSessionTable);
if (sessionService.getLoadedSession(
Expand Down Expand Up @@ -737,7 +739,7 @@ public Table createDiffTable(final TableInfo tableInfo,
final IModelSession compareSession = sessionService
.getLoadedSession(ToolboxFileRole.COMPARE_PLANNING);
final Table compareSessionTable = transformToTable(tableInfo,
tableType, compareSession, controlAreaIds);
tableType, compareSession, controlAreaIds, tableStatus);
storageFootnotes(ToolboxFileRole.COMPARE_PLANNING, tableInfo,
compareSessionTable);
final Table compareTable = diffServiceMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,14 @@ String transformToCsv(final TableInfo tableInfo, TableType tableType,
* the model session
* @param controlAreaIds
* the list of {@link Stell_Bereich} and the belonging container
* @param tableStatus
* the table status to update when transforming the table
*
* @return the table
*/
Table transformToTable(final TableInfo tableInfo, TableType tableType,
final IModelSession modelSession, Set<String> controlAreaIds);
final IModelSession modelSession, Set<String> controlAreaIds,
final TableStatus tableStatus);

/**
* Transform the selected container and control area to tables model.
Expand Down Expand Up @@ -220,10 +223,12 @@ public static boolean isTransformComplete(final TableInfo tableInfo,
* the table type
* @param controlAreaIds
* the list of {@link Stell_Bereich} and the belonging container
* @param updateTableStatus
* whether to update the table status or not
* @return the compare table
*/
Table createDiffTable(TableInfo tableInfo, TableType tableType,
Set<String> controlAreaIds);
Set<String> controlAreaIds, boolean updateTableStatus);

/**
* Sort the table after transformation.
Expand Down
Loading