|
|
@@ -28,24 +28,24 @@ import org.yakindu.sct.model.sgraph.Vertex;
|
|
|
/**
|
|
|
*
|
|
|
* All validation contraints for the meta model elements {@link Region}
|
|
|
+ *
|
|
|
+ *
|
|
|
*
|
|
|
*/
|
|
|
public class RegionValidator extends AbstractSGraphValidator {
|
|
|
|
|
|
|
|
|
- private static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_MSG = "The region can't be entered using the shallow history. Add a default entry node.";
|
|
|
- public static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_CODE = "entry.region.default";
|
|
|
+ private static final String REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_MSG = "The region can't be entered using the shallow history. Add a default entry node.";
|
|
|
+ public static final String REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_CODE = "region.RequiresDefaultEntryIfEnteredByShallowHistory";
|
|
|
|
|
|
private static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_MSG = "The region can't be entered using the shallow history. Add a transition from default entry to a state.";
|
|
|
- public static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE = "entry.in.transition";
|
|
|
-
|
|
|
- private final static String REGION_MULTIPLE_DEFAULT_ENTRIES_MSG = "There are multiple default entry nodes (one without a name and one named 'default') in this region.";
|
|
|
- public final static String REGION_MULTIPLE_DEFAULT_ENTRIES_CODE = "region.duplicate.entry";
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ public static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE = "region.CantBeEnteredUsingShallowHistoryNonConnectedDefaultEntry";
|
|
|
|
|
|
+ /**
|
|
|
+ * TODO: remove second message as this is not required. Every default entry must have a target transition.
|
|
|
+ *
|
|
|
+ * @param e
|
|
|
+ */
|
|
|
@Check(CheckType.FAST)
|
|
|
public void regionCantBeEnteredUsingShallowHistory(Entry e) {
|
|
|
if (e.getKind() == EntryKind.SHALLOW_HISTORY) {
|
|
|
@@ -67,8 +67,8 @@ public class RegionValidator extends AbstractSGraphValidator {
|
|
|
}
|
|
|
}
|
|
|
if (defaultEntry == null) {
|
|
|
- error(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_MSG, r, null, -1,
|
|
|
- REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_CODE);
|
|
|
+ error(REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_MSG, r, null, -1,
|
|
|
+ REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_CODE);
|
|
|
} else if (defaultEntry.getOutgoingTransitions().size() != 1) {
|
|
|
error(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_MSG, r, null, -1,
|
|
|
REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE);
|
|
|
@@ -79,6 +79,10 @@ public class RegionValidator extends AbstractSGraphValidator {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private final static String REGION_NO_MULTIPLE_DEFAULT_ENTRIES_MSG = "There are multiple default entry nodes (one without a name and one named 'default') in this region.";
|
|
|
+ public final static String REGION_NO_MULTIPLE_DEFAULT_ENTRIES_CODE = "region.NoMultipleDefaultEntries";
|
|
|
+
|
|
|
@Check
|
|
|
public void checkOnlyOneDefaultEntryPermitted(Entry entry) {
|
|
|
Region region = (Region) entry.eContainer();
|
|
|
@@ -88,7 +92,7 @@ public class RegionValidator extends AbstractSGraphValidator {
|
|
|
boolean defaultNamedEntryExists = initialEntires.stream()
|
|
|
.filter(v -> v.getName().trim().equalsIgnoreCase("default")).count() > 0;
|
|
|
if (unamedEntryExists && defaultNamedEntryExists) {
|
|
|
- error(REGION_MULTIPLE_DEFAULT_ENTRIES_MSG, region, null, -1, REGION_MULTIPLE_DEFAULT_ENTRIES_CODE);
|
|
|
+ error(REGION_NO_MULTIPLE_DEFAULT_ENTRIES_MSG, region, null, -1, REGION_NO_MULTIPLE_DEFAULT_ENTRIES_CODE);
|
|
|
}
|
|
|
}
|
|
|
|