Skip to content
Open
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 @@ -45,4 +45,5 @@ TableExportPart_ExportButton=Export des Dokumentensatz durchführen

TableTransform_Error=Fehler bei Tabellengenerierung
TableTransform_ComparePlanError_Msg=Es gibt Fehler bei der Tabellengenerierung der Vergleichsplanung. Es wird nur die Tabelle der Originalplanung angezeigt.
TableTransform_Error_Msg=Es gibt Fehler bei der Tabellengenerierung. Die Table kann nicht vollständig darstellen
TableTransform_Error_Msg=Es gibt Fehler bei der Tabellengenerierung. Die Table kann nicht vollständig darstellen
TableTransform_Sort_Error=Die Sortierung der Tabelle ist nicht erfolgreich
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,21 @@ protected void createView(final Composite parent) {
if (table == null) {
return;
}
subcribeTriggerResortEvent();
final TableStatus status = tableService
.getTablesStatus(tableInfo.category())
.getOrDefault(tableInfo, null);
if (status == null || status.isNonTransformable()) {
subcribeTriggerResortEvent();
if (status == null) {
getDialogService().error(getToolboxShell(),
messages.TableTransform_Error_Msg);
} else if (status.isNonTransformable()) {
getDialogService().error(getToolboxShell(),
messages.TableTransform_Error,
messages.TableTransform_Error_Msg,
status.getTransformException().get());
} else if (!status.isSortSuccess()) {
getDialogService().openInformation(getToolboxShell(),
getViewTitle(), messages.TableTransform_Sort_Error);
}

final ColumnDescriptor rootColumnDescriptor = table
Expand Down Expand Up @@ -901,7 +909,8 @@ private void subcribeTriggerResortEvent() {
.getRowGroupComparator(tableInfo, tableType);
if (table != null
&& comparator instanceof final TableRowGroupComparator rowGroupComparator) {
// This is new instance of Comparator, therefore need call sort here
// This is new instance of Comparator, therefore need call sort
// here
// to determine the waiting on another service criterion
ECollections.sort(table.getTablecontent().getRowgroups(),
rowGroupComparator);
Expand Down Expand Up @@ -936,6 +945,10 @@ private void subcribeTriggerResortEvent() {
natTable.refresh();
}
}));
if (!rowGroupComparator.getCriterionsException().isEmpty()) {
getDialogService().openInformation(getToolboxShell(),
getViewTitle(), messages.TableTransform_Sort_Error);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ private Object loadTransform(final TableInfo tableInfo,
}

// sorting
sortTable(transformedTable, tableInfo, tableType);
saveTableToCache(transformedTable, modelSession, tableInfo,
tableStatus);
return transformedTable;
Expand Down Expand Up @@ -471,7 +470,6 @@ modelSession, getModelService(tableInfo),
.orElse(Collections.emptyList())
.isEmpty());
}
sortTable(resultTable, tableInfo, tableType);

return resultTable;
}
Expand Down Expand Up @@ -621,6 +619,16 @@ public void updateTable(final BasePart tablePart,
throw new RuntimeException(e);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
transformTableThreads.stream()
.map(t -> getTableInfo(t.getKey()))
.filter(tableInfo -> {
final TableStatus status = tablesStatus
.get(tableInfo);
return !status.isSortSuccess()
|| status.getTransformException()
.isPresent();
});
}
}
}
Expand Down Expand Up @@ -667,7 +675,6 @@ private IRunnableWithProgress createProgressMonitor() {
// stop progress
monitor.done();
logger.info("ProgressMonitorDialog done."); //$NON-NLS-1$

};
}

Expand Down Expand Up @@ -714,6 +721,7 @@ public Table createDiffTable(final TableInfo tableInfo,
controlAreaIds, tableStatus);
storageFootnotes(ToolboxFileRole.SESSION, tableInfo,
mainSessionTable);
sortTable(mainSessionTable, tableInfo, tableType);
if (sessionService.getLoadedSession(
ToolboxFileRole.COMPARE_PLANNING) == null) {
tableStatus.setEmpty(
Expand All @@ -728,7 +736,7 @@ public Table createDiffTable(final TableInfo tableInfo,
} catch (final Exception e) {
logger.error("Transformation Error: {} : {}", //$NON-NLS-1$
tableInfo.shortcut(), e.getMessage());
tableStatus.setErrorMessages(e.getMessage());
tableStatus.setTransformException(e);
broker.post(Events.TABLEERROR_CHANGED, null);
// Give empty table back
return createEmptyTable(tableInfo);
Expand Down Expand Up @@ -771,10 +779,14 @@ public Table createDiffTable(final TableInfo tableInfo,

@Override
public void sortTable(final Table table, final TableInfo tableInfo,
final TableType tableType) {
final Comparator<RowGroup> comparator = getModelService(tableInfo)
.getRowGroupComparator(tableType);
ECollections.sort(table.getTablecontent().getRowgroups(), comparator);
final TableType tableTypes) {
final TableRowGroupComparator rowGroupComparator = getRowGroupComparator(
tableInfo, tableTypes);
ECollections.sort(table.getTablecontent().getRowgroups(),
rowGroupComparator);
tablesStatus.get(tableInfo)
.setSortSuccess(
rowGroupComparator.getCriterionsException().isEmpty());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ public class Messages {
*/
public String TableTransform_Error;

/**
* Die Sortierung der Tabelle ist nicht erfolgreich
*/
public String TableTransform_Sort_Error;

/**
* Es gibt Fehler bei der Tabellengenerierung der Vergleichsplanung. Es wird
* nur die Tabelle der Originalplanung angezeigt.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public class TableStatus {
private boolean containsErrors;
private boolean containsStateChanged;
private boolean containsPlanChanged;
private Optional<String> errorMessages;
private Optional<Exception> transformException;
private boolean isEmpty;
private boolean sortSuccess;

/**
*
Expand All @@ -38,7 +39,7 @@ public void reset() {
containsErrors = false;
containsPlanChanged = false;
containsStateChanged = false;
errorMessages = Optional.empty();
transformException = Optional.empty();
isEmpty = false;
}

Expand Down Expand Up @@ -91,15 +92,22 @@ public void setContainsPlanChanged(final boolean containsPlanChanged) {
* @return true, if table non transformable
*/
public boolean isNonTransformable() {
return errorMessages.isPresent();
return transformException.isPresent();
}

/**
* @param errorMessages
* the error messages by table transformation
* @param e
* the exception by table transformation
*/
public void setErrorMessages(final String errorMessages) {
this.errorMessages = Optional.ofNullable(errorMessages);
public void setTransformException(final Exception e) {
this.transformException = Optional.ofNullable(e);
}

/**
* @return the exception by table transformation
*/
public Optional<Exception> getTransformException() {
return transformException;
}

/**
Expand All @@ -116,4 +124,19 @@ public boolean isEmpty() {
public void setEmpty(final boolean value) {
isEmpty = value;
}

/**
* @return the sort exception
*/
public boolean isSortSuccess() {
return sortSuccess;
}

/**
* @param sortSuccess
* the sort
*/
public void setSortSuccess(final boolean sortSuccess) {
this.sortSuccess = sortSuccess;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,19 @@ private int compareRouteAndKm(final Punkt_Objekt first,
.getStreckeAndKm(second);
final Set<String> firstRouten = firstStreckeAndKm.stream()
.map(Pair::getKey)
.filter(value -> !value.isEmpty())
// Compare only to fourth character
.map(value -> value.substring(0, 4))
.map(value -> value.length() > 4 //
? value.substring(0, 4) //
: value)
.collect(Collectors.toSet());
final Set<String> secondRouten = secondStreckeAndKm.stream()
.map(Pair::getKey)
.filter(value -> !value.isEmpty())
// Compare only to fourth character
.map(value -> value.substring(0, 4))
.map(value -> value.length() > 4 //
? value.substring(0, 4) //
: value)
.collect(Collectors.toSet());
final int compareRouten = numericComparator.compareCell(firstRouten,
secondRouten);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
package org.eclipse.set.utils.table.sorting;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import org.eclipse.nebula.widgets.nattable.sort.SortDirectionEnum;
Expand Down Expand Up @@ -42,8 +44,18 @@ public static ComparatorBuilder builder(final TableType tableType) {
private final List<Comparator<TableRow>> criteria = Lists.newLinkedList();
private final TableType tableType;

private final Map<Comparator<TableRow>, Exception> criterionsException;

/**
* @return the exception during comparator
*/
public Map<Comparator<TableRow>, Exception> getCriterionsException() {
return criterionsException;
}

private TableRowGroupComparator(final TableType tableType) {
this.tableType = tableType;
this.criterionsException = new HashMap<>();
}

/**
Expand Down Expand Up @@ -108,10 +120,16 @@ public int compare(final RowGroup group1, final RowGroup group2) {
*/
public int compare(final TableRow row1, final TableRow row2) {
for (final Comparator<TableRow> criterion : criteria) {
final int result = criterion.compare(row1, row2);
if (result != 0) {
return result;
try {
final int result = criterion.compare(row1, row2);
if (result != 0) {
return result;
}
} catch (final Exception e) {
criterionsException.put(criterion, e);
continue;
}

}
return 0;
}
Expand Down
Loading