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 @@ -145,14 +145,19 @@ class FootnoteTransformation {
// Determine Footnotes for Ssks Table
private def dispatch Iterable<Footnote> getReferenceFootnotes(
Signal_Signalbegriff signalBegriff) {
val prefix = signalBegriff.prefix
val signalBegriffFootnotes = signalBegriff?.IDBearbeitungsvermerk?.map [
createFootnote(signalBegriff)
]?.filterNull
val objectStateNote = #[
signalBegriff?.transformObjectStateEnum?.
createFootnote(signalBegriff)].filterNull
return #[signalBegriffFootnotes, objectStateNote].filterNull.flatten.
toList.withPrefix(signalBegriff.prefix)
val begriffFootnotesWithPrefix = signalBegriffFootnotes.
withPrefix('''«prefix.key»«IF prefix.value !== null» «prefix.value»«ENDIF»''')
val objectStateNoteWithPrefix = objectStateNote.
withPrefix('''«prefix.key»«IF prefix.value !== null» («prefix.value»)«ENDIF»''')
return #[begriffFootnotesWithPrefix, objectStateNoteWithPrefix].
filterNull.flatten
}

// Determine Footnotes for Sskw Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package org.eclipse.set.model.tablemodel.extensions

import com.google.common.base.Strings
import com.google.common.html.HtmlEscapers
import java.util.HashSet
import java.util.List
import java.util.function.BiFunction
import java.util.function.Function
import org.eclipse.set.model.planpro.Basisobjekte.Bearbeitungsvermerk
Expand All @@ -31,7 +33,6 @@ import static org.eclipse.set.model.tablemodel.extensions.Utils.*

import static extension org.eclipse.set.model.tablemodel.extensions.TableCellExtensions.*
import static extension org.eclipse.set.utils.StringExtensions.*
import java.util.List

/**
* Extensions for {@link CellContent}.
Expand Down Expand Up @@ -125,8 +126,8 @@ class CellContentExtensions {
static def dispatch String getRichTextValueWithFootnotes(
StringCellContent content, SimpleFootnoteContainer fc) {
val footnoteText = fc.footnotes.map [
'''*«getFootnoteNumber(content, it.bearbeitungsvermerk)»'''
].iterableToString(FOOTNOTE_SEPARATOR)
getFootnoteNumber(content, it.bearbeitungsvermerk)
].toSet.sort.map['''*«it»'''].iterableToString(FOOTNOTE_SEPARATOR)

if (footnoteText != "")
return '''<p style="text-align:«content.textAlign»">«content.valueFormat» «footnoteText»</p>'''
Expand All @@ -153,8 +154,7 @@ class CellContentExtensions {
getCompareValueFormat(
mark, '''*«getFootnoteNumber(content, text)»''')
]
)

).toSet
result = result + #[footnotes.iterableToString(FOOTNOTE_SEPARATOR)]

return '''<p style="text-align:«content.textAlign»">«
Expand Down Expand Up @@ -337,13 +337,15 @@ class CellContentExtensions {
BiFunction<Bearbeitungsvermerk, T, U> postFormatter
) {
formatCompareContent(
(content.oldFootnotes.footnotes + content.unchangedFootnotes.footnotes).map[bearbeitungsvermerk],
(content.newFootnotes.footnotes + content.unchangedFootnotes.footnotes).map[bearbeitungsvermerk],
(content.oldFootnotes.footnotes +
content.unchangedFootnotes.footnotes).map[bearbeitungsvermerk],
(content.newFootnotes.footnotes +
content.unchangedFootnotes.footnotes).map[bearbeitungsvermerk],
oldFormatter,
commonFormatter,
newFormatter,
postFormatter,
[it?.bearbeitungsvermerkAllg?.kommentar?.wert]
[getFootnoteNumber(content, it)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort footnote by index number

)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.set.core.services.Services;
import org.eclipse.set.core.services.enumtranslation.EnumTranslationService;
import org.eclipse.set.model.planpro.BasisTypen.BasisTypenFactory;
Expand All @@ -41,6 +42,7 @@
import org.eclipse.set.model.tablemodel.TablemodelFactory;
import org.eclipse.set.ppmodel.extensions.SignalRahmenExtensions;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Pair;

import com.google.common.collect.Streams;

Expand Down Expand Up @@ -256,7 +258,8 @@ public static String getPrefix(final Signal_Rahmen signalRahmen) {
final List<String> signalBegriffe = Streams
.stream(SignalRahmenExtensions
.getSignalbegriffe(signalRahmen))
.map(signalBegriff -> getPrefix(signalBegriff, false))
.map(signalBegriff -> getPrefix(signalBegriff, false)
.getKey())
.filter(Objects::nonNull)
.collect(Collectors.toSet())
.stream()
Expand All @@ -275,28 +278,40 @@ public static String getPrefix(final Signal_Rahmen signalRahmen) {
*
* @param signalBegriff
* the signal begriff for which the prefix shall be generated
* @return the prefix or null if not possible to create prefix
* @return the signalbegriff name and the symbol
*/
public static String getPrefix(final Signal_Signalbegriff signalBegriff) {
public static Pair<String, String> getPrefix(
final Signal_Signalbegriff signalBegriff) {
return getPrefix(signalBegriff, true);
}

private static String getPrefix(final Signal_Signalbegriff signalBegriff,
private static Pair<String, String> getPrefix(
final Signal_Signalbegriff signalBegriff,
final boolean withSymbol) {
if (signalBegriff == null
|| signalBegriff.getSignalbegriffID() == null) {
return null;
}
final Signalbegriff_ID_TypeClass signalBegriffId = signalBegriff
.getSignalbegriffID();
// TODO: Properly determine name of Signalbegriff_ID
final String prefix = signalBegriffId.getClass()
.getSimpleName()
.replace("Impl", ""); //$NON-NLS-1$ //$NON-NLS-2$
final String prefix = getSignalBregiffIDName(signalBegriffId)
.replace("_", " ");//$NON-NLS-1$ //$NON-NLS-2$
if (withSymbol && signalBegriffId.getSymbol() != null) {
return prefix + " " + signalBegriffId.getSymbol(); //$NON-NLS-1$
return new Pair<>(prefix, signalBegriffId.getSymbol());
}
return new Pair<>(prefix, null);
}

private static String getSignalBregiffIDName(
final Signalbegriff_ID_TypeClass signalBegriffId) {
try {
return signalBegriffId.eClass()
.getEAnnotation(ExtendedMetaData.ANNOTATION_URI)
.getDetails()
.get("name"); //$NON-NLS-1$
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name of SignalBegriff_ID is in Annotation

} catch (final Exception e) {
return signalBegriffId.eClass().getName();
}
return prefix;
}

/**
Expand All @@ -311,12 +326,12 @@ private static String getPrefix(final Signal_Signalbegriff signalBegriff,
* if no prefix should be added
* @return the extended footnotes
*/
public static List<Footnote> withPrefix(final List<Footnote> footnotes,
final String prefix) {
public static Iterable<Footnote> withPrefix(
final Iterable<Footnote> footnotes, final String prefix) {
if (prefix == null) {
return footnotes;
}
return footnotes.stream().map(footnote -> {
return Streams.stream(footnotes).map(footnote -> {
final Bearbeitungsvermerk bearbeitungsvermerk = createBearbeitungsvermerkWithoutGuid(
prefix + ": " //$NON-NLS-1$
+ footnote.getBearbeitungsvermerk()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class TableExtensions {
// sort new and common together by text, then append old entries
val footnotes = (common + newF).sortBy[toText] + old.sortBy[toText]

return footnotes.distinctBy[toText -> bearbeitungsvermerk?.identitaet?.wert].indexed.map [
return footnotes.distinctBy[toText].indexed.map [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter the footnote with same content

value.index = key + 1
return value
]
Expand All @@ -484,7 +484,9 @@ class TableExtensions {

static def FootnoteInfo getFootnoteInfo(Table table,
Bearbeitungsvermerk bv) {
return table.allFootnotes.findFirst[bearbeitungsvermerk == bv]
return table.allFootnotes.findFirst[bearbeitungsvermerk?.identitaet?.wert == bv?.identitaet?.wert ||
bv?.bearbeitungsvermerkAllg?.kommentar?.wert == toText
]
}

static def FootnoteInfo getFootnoteInfo(EObject tableContent, Footnote fn) {
Expand Down
Loading