diff --git a/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend b/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend index b980d6ef1..35417b186 100644 --- a/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend +++ b/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend @@ -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). @@ -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) { @@ -352,38 +354,46 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator { [CellContentExtensions.HOURGLASS_ICON] ) ] - waitingFileSideDistanceSignal.put(row, signal) + waitingFillSideDistanceSignal.put(row, signal) } else { - val abstandMastmitteLinks = new HashSet> - val abstandMastmitteRechts = new HashSet> + try { + val abstandMastmitteLinks = new HashSet> + val abstandMastmitteRechts = new HashSet> - 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 @@ -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) @@ -941,7 +969,7 @@ class .simpleName»: «e.message» - failed to transform table contents''', e) List signalRahmen, Set> abstandMastmitteLinks, Set> abstandMastmitteRechts - ) { + ) throws NullPointerException, IllegalArgumentException, RuntimeException { signalRahmen.map [ signalBefestigungIterator.findFirst [ signalBefestigungAllg.befestigungArt.wert == @@ -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) @@ -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) + diff --git a/java/bundles/org.eclipse.set.feature.table/src/org/eclipse/set/feature/table/internal/TableServiceImpl.java b/java/bundles/org.eclipse.set.feature.table/src/org/eclipse/set/feature/table/internal/TableServiceImpl.java index dc9a07b3a..4e0edf9c4 100644 --- a/java/bundles/org.eclipse.set.feature.table/src/org/eclipse/set/feature/table/internal/TableServiceImpl.java +++ b/java/bundles/org.eclipse.set.feature.table/src/org/eclipse/set/feature/table/internal/TableServiceImpl.java @@ -236,7 +236,11 @@ public Map> getTableErrors( .map(cacheKey -> (List) 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()); } @@ -432,9 +436,18 @@ public Table transformToTable(final String elementId, for (final Pair 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 { diff --git a/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend b/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend index dadd461d5..14073d9a4 100644 --- a/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend +++ b/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend @@ -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. @@ -40,7 +39,7 @@ abstract class AbstractTableModelTransformator 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)) @@ -529,7 +528,7 @@ abstract class AbstractTableModelTransformator 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 @@ -568,7 +567,7 @@ abstract class AbstractTableModelTransformator implements TableModelTransform String leadingObjectGuid ) { var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObjectGuid»"''' - return '''«ERROR_PREFIX»«errorMsg»''' + return errorMsg }