Skip to content

Commit c222df2

Browse files
Update validate LST States GUID (#1865)
* Update validate LST States GUID * Add comment
1 parent a0be64c commit c222df2

File tree

1 file changed

+16
-8
lines changed
  • java/bundles/org.eclipse.set.feature.plazmodel/src/org/eclipse/set/feature/plazmodel/check

1 file changed

+16
-8
lines changed

java/bundles/org.eclipse.set.feature.plazmodel/src/org/eclipse/set/feature/plazmodel/check/GuidStateUnique.xtend

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import org.eclipse.set.ppmodel.extensions.PlanProSchnittstelleExtensions
1515
import org.osgi.service.component.annotations.Component
1616

1717
import static extension org.eclipse.set.ppmodel.extensions.PlanungEinzelExtensions.*
18-
import static extension org.eclipse.set.ppmodel.extensions.utils.IterableExtensions.*
1918

2019
/**
21-
* Checks if GUIDs of LST states are unique
20+
* Checks if GUIDs of LST states are unique.
21+
* The LST states in a Subwork can have same GUID
2222
*/
2323
@Component(immediate=true)
2424
class GuidStateUnique implements PlazCheck {
@@ -27,14 +27,22 @@ class GuidStateUnique implements PlazCheck {
2727
val planungGruppe = PlanProSchnittstelleExtensions.getLSTPlanungGruppe(
2828
modelSession.planProSchnittstelle)
2929
if (planungGruppe.present) {
30-
return planungGruppe.get.flatMap [
30+
// Grouped the LST states by GUID
31+
val sameGUIDStates = planungGruppe.get.flatMap [
3132
#[LSTPlanungEinzel?.LSTZustandStart,
3233
LSTPlanungEinzel?.LSTZustandZiel]
33-
].notDistinctBy[identitaet?.wert].map [
34+
].groupBy[identitaet?.wert]
35+
// Filter the same guid states, which states empty or the states in same subwork
36+
return sameGUIDStates.filter [ guid, states |
37+
!states.nullOrEmpty && (states.size > 2 || states.map [
38+
eContainer
39+
].toSet.size > 1)
40+
].values.flatten.map [
3441
val err = PlazFactory.eINSTANCE.createPlazError
35-
err.message = transformErrorMsg(Map.of("GUID", identitaet?.wert))
42+
err.message = transformErrorMsg(
43+
Map.of("GUID", identitaet?.wert))
3644
err.type = checkType
37-
err.object = it?.identitaet
45+
err.object = identitaet
3846
return err
3947
].toList
4048
}
@@ -44,11 +52,11 @@ class GuidStateUnique implements PlazCheck {
4452
override checkType() {
4553
return "GUID-Zustände"
4654
}
47-
55+
4856
override getDescription() {
4957
return "Die GUIDs aller Zustände sind eindeutig."
5058
}
51-
59+
5260
override getGeneralErrMsg() {
5361
return "Die GUID des Zustands {GUID} ist nicht eindeutig!"
5462
}

0 commit comments

Comments
 (0)