Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ssks exception not show in OverviewTable #1161

Merged
merged 2 commits into from
Dec 12, 2024
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 @@ -134,7 +134,9 @@ import static extension org.eclipse.set.ppmodel.extensions.utils.CacheUtils.*
import static extension org.eclipse.set.ppmodel.extensions.utils.IterableExtensions.*
import static extension org.eclipse.set.utils.math.BigDecimalExtensions.*
import static extension org.eclipse.set.utils.math.DoubleExtensions.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableRowExtensions.*
import org.eclipse.set.core.services.Services
import org.eclipse.set.utils.table.TableError

/**
* Table transformation for a Signaltabelle (Ssks).
Expand Down Expand Up @@ -175,7 +177,7 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
override transformTableContent(MultiContainer_AttributeGroup container,
TMFactory factory, Stell_Bereich controlArea) {
// iterate signal-wise
val waitingFileSideDistanceSignal = newHashMap
val waitingFillSideDistanceSignal = newHashMap
for (Signal signal : container?.signal?.filter[isPlanningObject].
filterObjectsInControlArea(controlArea).filter[ssksSignal]) {
if (Thread.currentThread.interrupted) {
Expand Down Expand Up @@ -352,38 +354,46 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator {
[CellContentExtensions.HOURGLASS_ICON]
)
]
waitingFileSideDistanceSignal.put(row, signal)
waitingFillSideDistanceSignal.put(row, signal)
} else {
val abstandMastmitteLinks = new HashSet<Pair<String, String>>
val abstandMastmitteRechts = new HashSet<Pair<String, String>>
try {
val abstandMastmitteLinks = new HashSet<Pair<String, String>>
val abstandMastmitteRechts = new HashSet<Pair<String, String>>

signal.initAbstandMastmitte(signal.signalRahmen,
abstandMastmitteLinks, abstandMastmitteRechts);
signal.initAbstandMastmitte(signal.signalRahmen,
abstandMastmitteLinks,
abstandMastmitteRechts);

fillIterable(
row,
cols.getColumn(Mastmitte_Links),
signal,
[
abstandMastmitteLinks.map [
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null,
[toString]
)
fillIterable(
row,
cols.getColumn(Mastmitte_Links),
signal,
[
abstandMastmitteLinks.map [
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null,
[toString]
)

fillIterable(
row,
cols.getColumn(Mastmitte_Rechts),
signal,
[
abstandMastmitteRechts.map [
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null
)
fillIterable(
row,
cols.getColumn(Mastmitte_Rechts),
signal,
[
abstandMastmitteRechts.map [
'''«key»«IF value !== null» («value»)«ENDIF»'''
]
],
null
)
} catch (Exception e) {
handleFillingException(e, row,
cols.getColumn(Mastmitte_Links))
handleFillingException(e, row,
cols.getColumn(Mastmitte_Rechts))
}
}

// L: Ssks.Standortmerkmale.Sichtbarkeit.Soll
Expand Down Expand Up @@ -905,8 +915,26 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)
}
}
val changeProperties = newArrayList
waitingFileSideDistanceSignal.forEach [ row, signal |
row.refillSideDistance(signal, changeProperties)
waitingFillSideDistanceSignal.forEach [ row, signal |
try {
row.refillSideDistance(signal, changeProperties)
} catch (Exception e) {
val errorMsg = e.createErrorMsg(row)
tableErrors.add(
new TableError(
row.group.leadingObject?.identitaet?.wert,
signal.identitaet.wert, "", errorMsg, row))
val containerType = signal.container.containerType
changeProperties.add(
new Pt1TableChangeProperties(containerType, row,
cols.getColumn(Mastmitte_Links), List.of('''«ERROR_PREFIX»«errorMsg»'''),
ITERABLE_FILLING_SEPARATOR))
changeProperties.add(
new Pt1TableChangeProperties(containerType, row,
cols.getColumn(Mastmitte_Rechts), List.of('''«ERROR_PREFIX»«errorMsg»'''),
ITERABLE_FILLING_SEPARATOR))
}

]
val updateValuesEvent = new TableDataChangeEvent(
tableShortCut.toLowerCase, changeProperties)
Expand Down Expand Up @@ -941,7 +969,7 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)
List<Signal_Rahmen> signalRahmen,
Set<Pair<String, String>> abstandMastmitteLinks,
Set<Pair<String, String>> abstandMastmitteRechts
) {
) throws NullPointerException, IllegalArgumentException, RuntimeException {
signalRahmen.map [
signalBefestigungIterator.findFirst [
signalBefestigungAllg.befestigungArt.wert ==
Expand All @@ -951,27 +979,17 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)
]
].filterNull.map[singlePoints].flatten.toSet.forEach [ p |
if (p?.seitlicherAbstand?.wert === null) {
val exception = new NullPointerException(
throw new NullPointerException(
"The Signal_Befestigung haven't seitlicherAbstand")
abstandMastmitteLinks.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
abstandMastmitteRechts.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
return
}
val seitlicherAbstand = Math.round(p.seitlicherAbstand.wert.doubleValue * 1000)
val seitlicherAbstand = Math.round(
p.seitlicherAbstand.wert.doubleValue * 1000)
val wirkrichtung = p.wirkrichtung.wert
val distanceFromPoint = MAX_OPOSIDE_DISTANCE -
Math.abs(seitlicherAbstand)
if (wirkrichtung !== ENUM_WIRKRICHTUNG_IN &&
wirkrichtung !== ENUM_WIRKRICHTUNG_GEGEN) {
val exception = new IllegalArgumentException(
"The Signal_Befestigung have Illegal Wirkrichtung")
abstandMastmitteLinks.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
abstandMastmitteRechts.add(
exception.createErrorMsg(signal.identitaet.wert) -> null)
return
throw new IllegalArgumentException('''The Signal_Befestigung have Illegal Wirkrichtung: «wirkrichtung»''')
}
val isLeftsideOfTrack = (wirkrichtung === ENUM_WIRKRICHTUNG_IN) ===
(seitlicherAbstand >= 0)
Expand All @@ -984,6 +1002,7 @@ class .simpleName»: «e.message» - failed to transform table contents''', e)
perpendicularRotation, distanceFromPoint / 1000)
} catch (Exception e) {
LOGGER.error(e.message)
throw new RuntimeException(e)
}
val distanceBetweenTracks = opposideSideDistance > 0
? (Math.abs(seitlicherAbstand) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ public Map<String, Collection<TableError>> getTableErrors(
.map(cacheKey -> (List<TableError>) cache
.getIfPresent(cacheKey.getValue()))
.filter(Objects::nonNull).toList();
if (!tableErrors.isEmpty()) {
if (!tableErrors.isEmpty() || Thread.getAllStackTraces()
.keySet().stream()
.anyMatch(thread -> thread.getName().toLowerCase()
.startsWith(
tableInfo.shortcut().toLowerCase()))) {
map.put(tableInfo.shortcut(), tableErrors.stream()
.flatMap(List::stream).toList());
}
Expand Down Expand Up @@ -432,9 +436,18 @@ public Table transformToTable(final String elementId,
for (final Pair<String, String> cacheKey : cacheKeys) {
final String areaId = cacheKey.getKey();
final String areaCacheKey = cacheKey.getValue();
final Table table = (Table) cache.get(areaCacheKey,
() -> loadTransform(shortCut, tableType, modelSession,
areaId, areaCacheKey));
Table table = (Table) cache.getIfPresent(areaCacheKey);

if (table == null) {
table = (Table) loadTransform(shortCut, tableType, modelSession,
areaId, areaCacheKey);
// Not storage table, when table isn't complete transform
if (Thread.getAllStackTraces().keySet().stream()
.noneMatch(thread -> thread.getName().toLowerCase()
.startsWith(shortCut))) {
cache.set(areaCacheKey, table);
}
}
if (resultTable == null) {
resultTable = EcoreUtil.copy(table);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.slf4j.LoggerFactory
import static extension com.google.common.base.Throwables.*
import static extension org.eclipse.set.model.tablemodel.extensions.TableRowExtensions.*
import static extension org.eclipse.set.ppmodel.extensions.utils.Debug.*
import org.eclipse.set.model.planpro.Basisobjekte.Ur_Objekt

/**
* Provides common functions for table transformations.
Expand All @@ -40,7 +39,7 @@ abstract class AbstractTableModelTransformator<T> implements TableModelTransform
/**
* constant prefix for cells that show errors
*/
static final String ERROR_PREFIX = "Error: ";
protected static final String ERROR_PREFIX = "Error: ";

static val Logger logger = LoggerFactory.getLogger(
typeof(AbstractTableModelTransformator))
Expand Down Expand Up @@ -529,7 +528,7 @@ abstract class AbstractTableModelTransformator<T> implements TableModelTransform
* @returns the leading object identifier of the given row which is either the value of the first cell
* or the GUID of the leading object entity if the first cell is empty or shows an error
*/
def private getLeadingObjectIdentifier(TableRow row, String guid) {
def String getLeadingObjectIdentifier(TableRow row, String guid) {
var firstCellValue = row.getPlainStringValue(0)
if (firstCellValue === null || firstCellValue.startsWith(ERROR_PREFIX)) {
return guid
Expand Down Expand Up @@ -568,7 +567,7 @@ abstract class AbstractTableModelTransformator<T> implements TableModelTransform
String leadingObjectGuid
) {
var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObjectGuid»"'''
return '''«ERROR_PREFIX»«errorMsg»'''
return errorMsg
}


Expand Down
Loading