Skip to content

Commit f020c1c

Browse files
committed
SYSML2_-158 Implemented semantic/validation constraints per resolution.
1 parent 0759b0f commit f020c1c

8 files changed

Lines changed: 42 additions & 51 deletions

File tree

org.omg.kerml.expressions.xtext/src/org/omg/kerml/expressions/xtext/KerMLExpressions.xtext

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2018-2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2018-2025 Model Driven Solutions, Inc.
44
* Copyright (c) 2018 IncQuery Labs Ltd.
55
* Copyright (c) 2019 Maplesoft (Waterloo Maple, Inc.)
66
* Copyright (c) 2019 Mgnite Inc.

org.omg.kerml.xtext/src/org/omg/kerml/xtext/KerML.xtext

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2018-2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2018-2025 Model Driven Solutions, Inc.
44
* Copyright (c) 2018 IncQuery Labs Ltd.
55
* Copyright (c) 2019 Maplesoft (Waterloo Maple, Inc.)
66
* Copyright (c) 2019 Mgnite Inc.

org.omg.sysml.xtext/src/org/omg/sysml/xtext/SysML.xtext

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2018-2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2018-2025 Model Driven Solutions, Inc.
44
* Copyright (c) 2018 IncQuery Labs Ltd.
55
* Copyright (c) 2019 Maplesoft (Waterloo Maple, Inc.)
66
* Copyright (c) 2019 Mgnite Inc.

org.omg.sysml.xtext/src/org/omg/sysml/xtext/validation/SysMLValidator.xtend

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,16 @@ class SysMLValidator extends KerMLValidator {
174174
public static val INVALID_EVENT_OCCURRENCE_USAGE_REFERENCE = "validateEventOccurrenceUsageReferent"
175175
public static val INVALID_EVENT_OCCURRENCE_USAGE_REFERENCE_MSG = "Must reference an occurrence."
176176

177-
public static val INVALID_OCCURRENCE_DEFINITION_LIFE_CLASS = "validateOccurrenceDefinitionLifeClass"
178-
public static val INVALID_OCCURRENCE_DEFINITION_LIFE_CLASS_MSG_1 = "Must have exactly one LifeClass."
179-
public static val INVALID_OCCURRENCE_DEFINITION_LIFE_CLASS_MSG_2 = "Must not have a LifeClass."
180-
181177
public static val INVALID_OCCURRENCE_USAGE_TYPE = "validateOccurrenceUsageType_"
182178
public static val INVALID_OCCURRENCE_USAGE_TYPE_MSG = "An occurrence must be typed by occurrence definitions."
183179
public static val INVALID_OCCURRENCE_USAGE_INDIVIDUAL_DEFINITION = "validateOccurrenceUsageIndividualDefinition"
184180
public static val INVALID_OCCURRENCE_USAGE_INDIVIDUAL_DEFINITION_MSG = "At most one individual definition is allowed."
185181
public static val INVALID_OCCURRENCE_USAGE_INDIVIDUAL_USAGE = "validateOccurrenceUsageIndividualUsage"
186182
public static val INVALID_OCCURRENCE_USAGE_INDIVIDUAL_USAGE_MSG = "An individual must be typed by one individual definition."
183+
public static val INVALID_OCCURRENCE_USAGE_IS_PORTION = "validateOccurrenceUsageIsPortion"
184+
public static val INVALID_OCCURRENCE_USAGE_IS_PORTION_MSG = "Must be a portion."
185+
public static val INVALID_OCCURRENCE_USAGE_PORTION_KIND = "validateOccurrenceUsageIsPortion"
186+
public static val INVALID_OCCURRENCE_USAGE_PORTION_KIND_MSG = "Must be owned by an occurrence definition or usage."
187187

188188
public static val INVALID_ITEM_DEFINITION_SPECIALIZATION = "validateClassSpecialization"
189189
public static val INVALID_ITEM_DEFINITION_SPECIALIZATION_MSG = "Cannot specialize attribute definition"
@@ -577,6 +577,17 @@ class SysMLValidator extends KerMLValidator {
577577
} else if (usg.isIndividual && nIndividualDefs != 1) {
578578
error (INVALID_OCCURRENCE_USAGE_INDIVIDUAL_USAGE_MSG, SysMLPackage.eINSTANCE.occurrenceUsage_OccurrenceDefinition, INVALID_OCCURRENCE_USAGE_INDIVIDUAL_USAGE)
579579
}
580+
581+
// validateOccurrenceUsageIsPortion
582+
if (usg.isIndividual && !usg.isPortion) {
583+
error(INVALID_OCCURRENCE_USAGE_IS_PORTION_MSG, usg, null, INVALID_OCCURRENCE_USAGE_IS_PORTION_MSG)
584+
}
585+
586+
// validateOccurrenceUsagePortionKind
587+
val owningType = usg.owningType;
588+
if (usg.portionKind === null && !(owningType instanceof OccurrenceDefinition || owningType instanceof OccurrenceUsage )) {
589+
error(INVALID_OCCURRENCE_USAGE_PORTION_KIND_MSG, usg, null, INVALID_OCCURRENCE_USAGE_PORTION_KIND_MSG)
590+
}
580591

581592
}
582593

org.omg.sysml/src/org/omg/sysml/adapter/OccurrenceDefinitionAdapter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021 Model Driven Solutions, Inc.
3+
* Copyright (c) 2021, 2025 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -33,5 +33,10 @@ public OccurrenceDefinitionAdapter(OccurrenceDefinition element) {
3333
public OccurrenceDefinition getTarget() {
3434
return (OccurrenceDefinition)super.getTarget();
3535
}
36+
37+
protected String getDefaultSupertype() {
38+
return getTarget().isIndividual()? getDefaultSupertype("life"):
39+
getDefaultSupertype("base");
40+
}
3641

3742
}
Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021, 2023-2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2021, 2023-2025 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -21,13 +21,8 @@
2121

2222
package org.omg.sysml.adapter;
2323

24-
import org.eclipse.emf.common.util.EList;
25-
import org.omg.sysml.lang.sysml.FeatureTyping;
26-
import org.omg.sysml.lang.sysml.OccurrenceDefinition;
2724
import org.omg.sysml.lang.sysml.OccurrenceUsage;
2825
import org.omg.sysml.lang.sysml.PortionKind;
29-
import org.omg.sysml.lang.sysml.SysMLPackage;
30-
import org.omg.sysml.lang.sysml.Type;
3126

3227
public class OccurrenceUsageAdapter extends UsageAdapter {
3328

@@ -39,6 +34,20 @@ public OccurrenceUsageAdapter(OccurrenceUsage element) {
3934
public OccurrenceUsage getTarget() {
4035
return (OccurrenceUsage)super.getTarget();
4136
}
37+
38+
// Post-processing
39+
40+
@Override
41+
public void postProcess() {
42+
super.postProcess();
43+
44+
OccurrenceUsage self = getTarget();
45+
if (self.getPortionKind() != null) {
46+
self.setIsPortion(true);
47+
}
48+
}
49+
50+
// Implicit Generalization
4251

4352
@Override
4453
public void addDefaultGeneralType() {
@@ -66,39 +75,4 @@ protected boolean isSuboccurrence() {
6675
protected String getDefaultSupertype() {
6776
return getDefaultSupertype("base");
6877
}
69-
70-
protected void addOccurrenceTyping() {
71-
OccurrenceUsage target = getTarget();
72-
Type owningType = target.getOwningType();
73-
if (target.getPortionKind() != null && target.getOwnedTyping().isEmpty()) {
74-
if (owningType instanceof OccurrenceDefinition) {
75-
addImplicitGeneralType(SysMLPackage.eINSTANCE.getFeatureTyping(), owningType);
76-
} else if (owningType instanceof OccurrenceUsage) {
77-
addImplicitGeneralType(SysMLPackage.eINSTANCE.getSubsetting(), owningType);
78-
}
79-
}
80-
}
81-
82-
protected void addOccurrenceFeaturing() {
83-
OccurrenceUsage target = getTarget();
84-
if (target.getPortionKind() != null) {
85-
EList<Type> featuringTypes = target.getFeaturingType();
86-
target.getOwnedTyping().stream().
87-
map(FeatureTyping::getType).
88-
filter(OccurrenceDefinition.class::isInstance).
89-
forEach(type->{
90-
if (!(featuringTypes.contains(type))) {
91-
addFeaturingType(type);
92-
}
93-
});
94-
}
95-
}
96-
97-
@Override
98-
public void computeImplicitGeneralTypes() {
99-
addOccurrenceTyping();
100-
addOccurrenceFeaturing();
101-
super.computeImplicitGeneralTypes();
102-
}
103-
10478
}

org.omg.sysml/src/org/omg/sysml/util/ImplicitGeneralizationMap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ protected ImplicitGeneralizationMap() {
271271
put(MergeNodeImpl.class, "subaction", "Actions::Action::merges");
272272

273273
put(OccurrenceDefinitionImpl.class, "base", "Occurrences::Occurrence");
274+
put(OccurrenceDefinitionImpl.class, "life", "Occurrences::Life");
274275
put(OccurrenceUsageImpl.class, "base", "Occurrences::occurrences");
275276
put(OccurrenceUsageImpl.class, "timeslice", "Occurrences::Occurrence::timeSlices");
276277
put(OccurrenceUsageImpl.class, "snapshot", "Occurrences::Occurrence::snapshots");

org.omg.sysml/syntax-gen/org/omg/sysml/lang/sysml/impl/FlowUsageImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ public class FlowUsageImpl extends ConnectorAsUsageImpl implements FlowUsage {
103103
* <!-- begin-user-doc -->
104104
* <!-- end-user-doc -->
105105
* @see #getPortionKind()
106-
* @generated
106+
* @generated NOT
107107
* @ordered
108108
*/
109-
protected static final PortionKind PORTION_KIND_EDEFAULT = PortionKind.TIMESLICE;
109+
protected static final PortionKind PORTION_KIND_EDEFAULT = null;
110110
/**
111111
* The cached value of the '{@link #getPortionKind() <em>Portion Kind</em>}' attribute.
112112
* <!-- begin-user-doc -->

0 commit comments

Comments
 (0)