Skip to content

Commit d102053

Browse files
authored
Merge pull request #661 from Systems-Modeling/ST6RI-856
ST6RI-856 isConstant not serialized in XMI for end Usages
2 parents 14d5fef + ae0a1a8 commit d102053

5 files changed

Lines changed: 37 additions & 23 deletions

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
33
* Copyright (c) 2020 California Institute of Technology/Jet Propulsion Laboratory
4-
* Copyright (c) 2020-2023 Model Driven Solutions, Inc.
4+
* Copyright (c) 2020-2025 Model Driven Solutions, Inc.
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Lesser General Public License as published by
@@ -143,11 +143,15 @@ import org.omg.sysml.lang.sysml.FlowUsage
143143
*/
144144
class SysMLValidator extends KerMLValidator {
145145

146+
public static val INVALID_DEFINITION_VARIATION_IS_ABSTRACT = "validateDefinitionVariationIsAbstract"
147+
public static val INVALID_DEFINITION_VARIATION_IS_ABSTRACT_MSG = "A variation must be abstract."
146148
public static val INVALID_DEFINITION_VARIATION_MEMBERSHIP = "validateDefinitionVariationMembership"
147149
public static val INVALID_DEFINITION_VARIATION_MEMBERSHIP_MSG = "An owned usage of a variation must be a variant."
148150
public static val INVALID_DEFINITION_VARIATION_SPECIALIZATION = "validateDefinitionVariationSpecialization"
149151
public static val INVALID_DEFINITION_VARIATION_SPECIALIZATION_MSG = "A variation must not specialize another variation."
150152

153+
public static val INVALID_USAGE_VARIATION_IS_ABSTRACT = "validateUsageVariationIsAbstract"
154+
public static val INVALID_USAGE_VARIATION_IS_ABSTRACT_MSG = "A variation must be abstract."
151155
public static val INVALID_USAGE_VARIATION_MEMBERSHIP = "validateUsageVariationMembership"
152156
public static val INVALID_USAGE_VARIATION_MEMBERSHIP_MSG = "An owned usage of a variation must be a variant."
153157
public static val INVALID_USAGE_VARIATION_SPECIALIZATION = "validateUsageVariationSpecialization"
@@ -476,6 +480,11 @@ class SysMLValidator extends KerMLValidator {
476480
// validateUsageIsReferential is satisfied automatically
477481

478482
if (usage.isVariation) {
483+
// validateUsageVariationIsAbstract
484+
if (!usage.isAbstract) {
485+
error(INVALID_USAGE_VARIATION_IS_ABSTRACT_MSG, usage, null, INVALID_USAGE_VARIATION_IS_ABSTRACT)
486+
}
487+
479488
// validateUsageVariationOwnedFeatureMembership
480489
for (mem: usage.ownedFeatureMembership) {
481490
// NOTE: Need to allow parameters and objectives because they are currently physically inserted by transform implementation.

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

Lines changed: 10 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, 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2021, 2024, 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
@@ -34,4 +34,13 @@ public Definition getTarget() {
3434
return (Definition)super.getTarget();
3535
}
3636

37+
@Override
38+
public void postProcess() {
39+
super.postProcess();
40+
Definition target = getTarget();
41+
if (target.isVariation()) {
42+
target.setIsAbstract(true);
43+
}
44+
}
45+
3746
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021-2024 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
@@ -53,6 +53,15 @@ public Usage getTarget() {
5353

5454
// Post-processing
5555

56+
@Override
57+
public void postProcess () {
58+
super.postProcess();
59+
Usage target = getTarget();
60+
if (target.isVariation()) {
61+
target.setIsAbstract(true);
62+
}
63+
}
64+
5665
@Override
5766
protected void setIsVariableIfConstant() {
5867
}
@@ -197,8 +206,14 @@ protected void computeValueConnector() {
197206
@Override
198207
public void doTransform() {
199208
super.doTransform();
200-
if (UsageUtil.isVariant(getTarget())) {
209+
Usage target = getTarget();
210+
if (UsageUtil.isVariant(target)) {
201211
addImplicitFeaturingTypesIfNecessary();
202212
}
213+
214+
// Note: This cannot be done in postProcess, because of mayTimeVary computation.
215+
if (target.isEnd() && mayTimeVary()) {
216+
target.setIsConstant(true);
217+
}
203218
}
204219
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -784,15 +784,6 @@ public EList<VariantMembership> getVariantMembership() {
784784
return (EList<VariantMembership>)VARIANT_MEMBERSHIP__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false);
785785
}
786786

787-
// Additional Overrides
788-
789-
@Override
790-
public boolean isAbstract() {
791-
return isVariation() || super.isAbstract();
792-
}
793-
794-
//
795-
796787
/**
797788
* <!-- begin-user-doc -->
798789
* <!-- end-user-doc -->

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,21 +1046,11 @@ public boolean isSetIsVariable() {
10461046

10471047
// Additional overrides
10481048

1049-
@Override
1050-
public boolean isAbstract() {
1051-
return isVariation() || super.isAbstract();
1052-
}
1053-
10541049
@Override
10551050
public boolean isComposite() {
10561051
return UsageUtil.isComposite(this, isComposite);
10571052
}
10581053

1059-
@Override
1060-
public boolean isConstant() {
1061-
return isConstant || isEnd() && isMayTimeVary();
1062-
}
1063-
10641054
//
10651055

10661056
/**

0 commit comments

Comments
 (0)