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
2121
2222package 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 ;
2724import org .omg .sysml .lang .sysml .OccurrenceUsage ;
2825import org .omg .sysml .lang .sysml .PortionKind ;
29- import org .omg .sysml .lang .sysml .SysMLPackage ;
30- import org .omg .sysml .lang .sysml .Type ;
3126
3227public 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}
0 commit comments