aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcong-bang.do2019-05-23 10:57:10 -0400
committercong-bang.do2019-05-27 10:59:38 -0400
commit7694cbe9a0e444420140212ad83a1dface67a369 (patch)
treed73e74af1a6155a6d15c2309d2ef02c881c7cfa2
parentd57e82c80d430965107d354d06471493707a02f9 (diff)
downloadcapella-sss-transition-master.zip
capella-sss-transition-master.tar.gz
capella-sss-transition-master.tar.bz2
[2491] Issue to transit new sub system with referenced data in librariesHEADv1.3.1v1.3.xmaster
- Fixed for multiphase transition SA-LA-PA: -- Make the temporary project referencing the library -- Add the library to both scopes of diffmerge -- Adapt the match policy for handling elements of library Change-Id: I8efd64bfc11477238105e834e7496fd696866e7d Signed-off-by: cong-bang.do <docongbang1993@gmail.com>
-rw-r--r--plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesDiffMergeActivity.java48
-rw-r--r--plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesTransformationActivity.java93
-rw-r--r--plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/diffmerge/MultiphasesMatchPolicy.java136
3 files changed, 196 insertions, 81 deletions
diff --git a/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesDiffMergeActivity.java b/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesDiffMergeActivity.java
index f78f1e3..217ea5c 100644
--- a/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesDiffMergeActivity.java
+++ b/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesDiffMergeActivity.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.polarsys.capella.transition.system2subsystem.multiphases.activities;
+import java.util.Set;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
@@ -18,31 +20,33 @@ import org.polarsys.capella.core.data.fa.FaPackage;
import org.polarsys.capella.core.data.interaction.InteractionPackage;
import org.polarsys.capella.core.model.helpers.naming.NamingConstants;
import org.polarsys.capella.core.transition.common.activities.InitializeDiffMergeFromTransformationActivity;
+import org.polarsys.capella.core.transition.common.constants.ITransitionConstants;
import org.polarsys.capella.core.transition.common.handlers.IHandler;
import org.polarsys.capella.core.transition.common.handlers.merge.IMergeHandler;
import org.polarsys.capella.core.transition.common.handlers.traceability.CompoundTraceabilityHandler;
import org.polarsys.capella.core.transition.common.handlers.traceability.config.ITraceabilityConfiguration;
+import org.polarsys.capella.core.transition.common.merge.scope.ReferenceModelScope;
+import org.polarsys.capella.core.transition.common.merge.scope.TargetModelScope;
import org.polarsys.capella.core.transition.system.handlers.merge.AttributeDescriptionValueFromSource;
import org.polarsys.capella.core.transition.system.handlers.merge.AttributeNameValueFromSource;
import org.polarsys.capella.core.transition.system.handlers.merge.AttributeSummaryValueFromSource;
import org.polarsys.capella.core.transition.system.handlers.merge.CapellaClassFilters;
import org.polarsys.capella.core.transition.system.handlers.merge.RootCategoryFilter;
import org.polarsys.capella.core.transition.system.topdown.handlers.merge.RealizationLinkCategoryFilter;
+import org.polarsys.capella.transition.system2subsystem.constants.ITransitionConstants2;
import org.polarsys.capella.transition.system2subsystem.handlers.filter.UpdateOfCategoryFilter;
import org.polarsys.capella.transition.system2subsystem.multiphases.handlers.traceability.config.MultiphasesSourceConfiguration;
import org.polarsys.capella.transition.system2subsystem.multiphases.handlers.traceability.config.MultiphasesTargetConfiguration;
import org.polarsys.kitalpha.cadence.core.api.parameter.ActivityParameters;
import org.polarsys.kitalpha.transposer.rules.handler.rules.api.IContext;
-
-
/**
*
*/
public class InitializeMultiphasesDiffMergeActivity extends InitializeDiffMergeFromTransformationActivity {
public static final String ID = "org.polarsys.capella.transition.system2subsystem.multiphases.activities.InitializeMultiphasesDiffMergeActivity"; //$NON-NLS-1$
-
+
@Override
protected IHandler createDefaultTraceabilitySourceHandler(IContext context_p) {
ITraceabilityConfiguration configuration = new MultiphasesSourceConfiguration();
@@ -62,10 +66,10 @@ public class InitializeMultiphasesDiffMergeActivity extends InitializeDiffMergeF
CapellaClassFilters.addClassFilters(handler, context);
handler.addCategory(new RootCategoryFilter(context), context);
- handler.addCategory(new AttributeNameValueFromSource(context){
+ handler.addCategory(new AttributeNameValueFromSource(context) {
@Override
public boolean isUpdatableValue(EObject source, EObject target, Object oldValue, Object newValue) {
- if (NamingConstants.CreateLogicalArchCmd_logicalComponent_name.equals(oldValue)){
+ if (NamingConstants.CreateLogicalArchCmd_logicalComponent_name.equals(oldValue)) {
return true;
}
return super.isUpdatableValue(source, target, oldValue, newValue);
@@ -76,7 +80,39 @@ public class InitializeMultiphasesDiffMergeActivity extends InitializeDiffMergeF
handler.addCategory(new RealizationLinkCategoryFilter(context), context);
handler.addCategory(new UpdateOfCategoryFilter(FaPackage.Literals.FUNCTIONAL_CHAIN, context), context);
handler.addCategory(new UpdateOfCategoryFilter(CsPackage.Literals.PHYSICAL_PATH, context), context);
- handler.addCategory(new UpdateOfCategoryFilter(InteractionPackage.Literals.SCENARIO, context), context);
+ handler.addCategory(new UpdateOfCategoryFilter(InteractionPackage.Literals.SCENARIO, context), context);
+
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ protected IStatus initializeReferenceScope(IContext context, ActivityParameters activityParams) {
+ super.initializeReferenceScope(context, activityParams);
+
+ ReferenceModelScope sourceScope = (ReferenceModelScope) context.get(ITransitionConstants2.MERGE_REFERENCE_SCOPE);
+ Set libraries = (Set) context.get(ITransitionConstants2.ROOTS_FOR_LIBRARIES_OF_SOURCE_PROJECT);
+ if (libraries != null && !libraries.isEmpty()) {
+ for (Object library : libraries) {
+ sourceScope.add((EObject) library, true);
+ }
+ }
+ sourceScope.build(getReferenceFilter(context));
+
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ protected IStatus initializeTargetScope(IContext context, ActivityParameters activityParams) {
+ super.initializeTargetScope(context, activityParams);
+
+ TargetModelScope targetScope = (TargetModelScope) context.get(ITransitionConstants.MERGE_TARGET_SCOPE);
+ Set libraries = (Set) context.get(ITransitionConstants2.ROOTS_FOR_LIBRARIES_OF_TARGET_PROJECT);
+ if (libraries instanceof Set) {
+ for (Object library : libraries) {
+ targetScope.add((EObject) library, true);
+ }
+ }
+ targetScope.build(getTargetFilter(context));
return Status.OK_STATUS;
}
diff --git a/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesTransformationActivity.java b/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesTransformationActivity.java
index df0a1b0..52f16f7 100644
--- a/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesTransformationActivity.java
+++ b/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/activities/InitializeMultiphasesTransformationActivity.java
@@ -27,9 +27,9 @@ import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.ui.business.api.viewpoint.ViewpointSelection;
import org.eclipse.ui.statushandlers.StatusManager;
+import org.polarsys.capella.common.libraries.ModelInformation;
import org.polarsys.capella.core.data.capellacore.CapellaElement;
import org.polarsys.capella.core.data.capellamodeller.Project;
-import org.polarsys.capella.core.data.capellamodeller.SystemEngineering;
import org.polarsys.capella.core.model.handler.command.CapellaResourceHelper;
import org.polarsys.capella.core.model.helpers.CapellaElementExt;
import org.polarsys.capella.core.platform.sirius.ui.project.operations.ProjectSessionCreationHelper;
@@ -39,14 +39,15 @@ import org.polarsys.capella.core.transition.common.constants.ITransitionConstant
import org.polarsys.capella.core.transition.common.handlers.IHandler;
import org.polarsys.capella.core.transition.common.handlers.traceability.ITraceabilityHandler;
import org.polarsys.capella.core.transition.common.handlers.traceability.config.ExtendedTraceabilityConfiguration;
-import org.polarsys.capella.core.transition.system.activities.InitializeTransformationActivity;
-import org.polarsys.capella.core.transition.system.handlers.traceability.ReconciliationTraceabilityHandler;
+import org.polarsys.capella.core.transition.system.handlers.traceability.LibraryTraceabilityHandler;
+import org.polarsys.capella.core.transition.system.helpers.ContextHelper;
import org.polarsys.capella.transition.system2subsystem.activities.FinalizeSubsystemTransitionActivity;
+import org.polarsys.capella.transition.system2subsystem.activities.InitializeTransformationActivity;
import org.polarsys.capella.transition.system2subsystem.multiphases.handlers.traceability.config.RecTraceabilityHandler;
import org.polarsys.capella.transition.system2subsystem.multiphases.handlers.traceability.config.SIDTraceabilityHandler;
+import org.polarsys.kitalpha.emde.model.ElementExtension;
import org.polarsys.kitalpha.transposer.rules.handler.rules.api.IContext;
-
public final class InitializeMultiphasesTransformationActivity extends InitializeTransformationActivity {
@Override
@@ -58,63 +59,95 @@ public final class InitializeMultiphasesTransformationActivity extends Initializ
protected String getExtensionIdentifier(IContext context) {
return ISchemaConstants.TRANSFORMATION_TRACEABILITY_CONFIGURATION;
}
-
+
@Override
protected void initHandlers(IContext fContext_p) {
addHandler(fContext_p, new SIDTraceabilityHandler(getIdentifier(fContext_p)));
addHandler(fContext_p, new RecTraceabilityHandler());
+ addHandler(fContext_p, new LibraryTraceabilityHandler());
}
@Override
- public boolean useHandlerForAttachment(EObject source_p, EObject target_p, ITraceabilityHandler handler_p, IContext context_p) {
+ public boolean useHandlerForAttachment(EObject source_p, EObject target_p, ITraceabilityHandler handler_p,
+ IContext context_p) {
+ if (LibraryTraceabilityHandler.isLibraryElement(source_p, context_p)) {
+ return handler_p instanceof LibraryTraceabilityHandler;
+ }
+
if (handler_p instanceof RecTraceabilityHandler) {
return false;
}
return super.useHandlerForAttachment(source_p, target_p, handler_p, context_p);
}
+
+ @Override
+ public boolean useHandlerForSourceElements(EObject source, ITraceabilityHandler handler, IContext context) {
+ if (LibraryTraceabilityHandler.isLibraryElement(source, context)) {
+ return handler instanceof LibraryTraceabilityHandler;
+ }
+ return super.useHandlerForSourceElements(source, handler, context);
+ }
+
+ @Override
+ public boolean useHandlerForTracedElements(EObject source, ITraceabilityHandler handler, IContext context) {
+ if (LibraryTraceabilityHandler.isLibraryElement(source, context)) {
+ return handler instanceof LibraryTraceabilityHandler;
+ }
+ return super.useHandlerForTracedElements(source, handler, context);
+ }
+
};
return new MultiphaseTraceabilityHandler(configuration);
}
- /**
- * Overridden to create a temporary transformation project
- * rather than attaching a new SystemEngineering into the target model.
- */
@Override
- protected EObject createTargetTransformationContainer(Resource targetResource_p, IContext context_p) {
- EObject result = null;
-
- if (context_p.get(ITransitionConstants.DIFFMERGE_DISABLE) == Boolean.TRUE) {
+ protected EObject createTargetTransformationContainer(Resource source, IContext context) {
+ Project targetProject = null;
+ if (context.get(ITransitionConstants.DIFFMERGE_DISABLE) == Boolean.TRUE) {
// elements are created directly in the target model
- Project project = (Project) CapellaElementExt.getRoot((CapellaElement) targetResource_p.getContents().get(0));
- result = project;
+ Project project = (Project) CapellaElementExt.getRoot((CapellaElement) source.getContents().get(0));
+ targetProject = project;
} else {
// Create a temporary project and reload its model through the target editing domain
// The temporary project is removed later in FinalizeSubsystemTransitionActivity
try {
- String temporaryProjectName = getTemporaryProjectName(context_p);
- Session session =
- new ProjectSessionCreationHelper(true, true).createFullProject(temporaryProjectName, null, Collections.<IProject> emptyList(),
- ViewpointSelection.getViewpoints(CapellaResourceHelper.CAPELLA_MODEL_FILE_EXTENSION), new NullProgressMonitor());
+ String temporaryProjectName = getTemporaryProjectName();
+ Session session = new ProjectSessionCreationHelper(true, true).createFullProject(temporaryProjectName, null,
+ Collections.<IProject> emptyList(),
+ ViewpointSelection.getViewpoints(CapellaResourceHelper.CAPELLA_MODEL_FILE_EXTENSION),
+ new NullProgressMonitor());
Project project = SessionHelper.getCapellaProject(session);
session.close(new NullProgressMonitor());
- result =
- ((EditingDomain) context_p.get(ITransitionConstants.TRANSITION_TARGET_EDITING_DOMAIN)).getResourceSet().getEObject(EcoreUtil.getURI(project),
- true);
- context_p.put(FinalizeSubsystemTransitionActivity.PARAM__DELETE_PROJECT, ResourcesPlugin.getWorkspace().getRoot().getProject(temporaryProjectName));
+ targetProject = (Project) ((EditingDomain) context.get(ITransitionConstants.TRANSITION_TARGET_EDITING_DOMAIN))
+ .getResourceSet().getEObject(EcoreUtil.getURI(project), true);
+ context.put(FinalizeSubsystemTransitionActivity.PARAM__DELETE_PROJECT,
+ ResourcesPlugin.getWorkspace().getRoot().getProject(temporaryProjectName));
+
+
+ Project sourceProject = ContextHelper.getSourceProject(context);
+
+ // Copy Library information from source project to target project if any
+ for (ElementExtension extension : sourceProject.getOwnedExtensions()) {
+ if (extension instanceof ModelInformation) {
+ ElementExtension copy = EcoreUtil.copy(extension);
+ targetProject.getOwnedExtensions().add(copy);
+ }
+ }
} catch (InvocationTargetException exception_p) {
- StatusManager.getManager().handle(
- new Status(IStatus.ERROR, org.polarsys.capella.transition.system2subsystem.Activator.PLUGIN_ID, exception_p.getMessage(), exception_p));
+ StatusManager.getManager()
+ .handle(new Status(IStatus.ERROR, org.polarsys.capella.transition.system2subsystem.Activator.PLUGIN_ID,
+ exception_p.getMessage(), exception_p));
} catch (InterruptedException exception_p) {
- StatusManager.getManager().handle(
- new Status(IStatus.ERROR, org.polarsys.capella.transition.system2subsystem.Activator.PLUGIN_ID, exception_p.getMessage(), exception_p));
+ StatusManager.getManager()
+ .handle(new Status(IStatus.ERROR, org.polarsys.capella.transition.system2subsystem.Activator.PLUGIN_ID,
+ exception_p.getMessage(), exception_p));
}
}
- return result;
+ return targetProject;
}
- private String getTemporaryProjectName(IContext context_p) {
+ private String getTemporaryProjectName() {
return "MultiphaseTransformation_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/diffmerge/MultiphasesMatchPolicy.java b/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/diffmerge/MultiphasesMatchPolicy.java
index 6f25f1e..a924c43 100644
--- a/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/diffmerge/MultiphasesMatchPolicy.java
+++ b/plugins/org.polarsys.capella.transition.system2subsystem.multiphases/src/org/polarsys/capella/transition/system2subsystem/multiphases/diffmerge/MultiphasesMatchPolicy.java
@@ -28,6 +28,7 @@ import org.polarsys.capella.common.data.modellingcore.AbstractTrace;
import org.polarsys.capella.common.data.modellingcore.ModelElement;
import org.polarsys.capella.common.helpers.EcoreUtil2;
import org.polarsys.capella.common.libraries.LibrariesPackage;
+import org.polarsys.capella.common.libraries.LibraryReference;
import org.polarsys.capella.core.data.capellacommon.Region;
import org.polarsys.capella.core.data.capellacommon.StateMachine;
import org.polarsys.capella.core.data.capellacore.EnumerationPropertyLiteral;
@@ -36,6 +37,7 @@ import org.polarsys.capella.core.data.capellacore.KeyValue;
import org.polarsys.capella.core.data.capellacore.NamedElement;
import org.polarsys.capella.core.data.capellacore.Type;
import org.polarsys.capella.core.data.capellamodeller.CapellamodellerPackage;
+import org.polarsys.capella.core.data.capellamodeller.Library;
import org.polarsys.capella.core.data.cs.CsPackage;
import org.polarsys.capella.core.data.cs.Part;
import org.polarsys.capella.core.data.ctx.CtxPackage;
@@ -67,20 +69,35 @@ public class MultiphasesMatchPolicy implements IMatchPolicy {
private enum PredefinedType {
- PREDEFINED_DATA_PKG(NamingConstants.PredefinedTypesCmd_predefinedDataTypePkg_name, InformationPackage.Literals.DATA_PKG), PREDEFINED_BOOLEAN(
- NamingConstants.PredefinedTypesCmd_boolean_name, DatatypePackage.Literals.BOOLEAN_TYPE), PREDEFINED_BYTE(NamingConstants.PredefinedTypesCmd_byte_name,
- DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_CHAR(NamingConstants.PredefinedTypesCmd_char_name, DatatypePackage.Literals.STRING_TYPE), PREDEFINED_DOUBLE(
- NamingConstants.PredefinedTypesCmd_double_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_FLOAT(NamingConstants.PredefinedTypesCmd_float_name,
- DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_HEXADECIMAL(NamingConstants.PredefinedTypesCmd_hexadecimal_name,
- DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_INTEGER(NamingConstants.PredefinedTypesCmd_integer_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_LONG(
- NamingConstants.PredefinedTypesCmd_long_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_LONGLONG(
- NamingConstants.PredefinedTypesCmd_longLong_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_SHORT(
- NamingConstants.PredefinedTypesCmd_short_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_STRING(
- NamingConstants.PredefinedTypesCmd_string_name, DatatypePackage.Literals.STRING_TYPE), PREDEFINED_UNSIGNED_INTEGER(
- NamingConstants.PredefinedTypesCmd_unsignedInteger_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_UNSIGNED_SHORT(
- NamingConstants.PredefinedTypesCmd_unsignedShort_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_UNSIGNED_LONG_LONG(
- NamingConstants.PredefinedTypesCmd_unsignedLongLong_name, DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_UNSIGNED_LONG(
- NamingConstants.PredefinedTypesCmd_unsignedLong_name, DatatypePackage.Literals.NUMERIC_TYPE);
+ PREDEFINED_DATA_PKG(NamingConstants.PredefinedTypesCmd_predefinedDataTypePkg_name,
+ InformationPackage.Literals.DATA_PKG), PREDEFINED_BOOLEAN(NamingConstants.PredefinedTypesCmd_boolean_name,
+ DatatypePackage.Literals.BOOLEAN_TYPE), PREDEFINED_BYTE(NamingConstants.PredefinedTypesCmd_byte_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_CHAR(NamingConstants.PredefinedTypesCmd_char_name,
+ DatatypePackage.Literals.STRING_TYPE), PREDEFINED_DOUBLE(
+ NamingConstants.PredefinedTypesCmd_double_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_FLOAT(
+ NamingConstants.PredefinedTypesCmd_float_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_HEXADECIMAL(
+ NamingConstants.PredefinedTypesCmd_hexadecimal_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_INTEGER(
+ NamingConstants.PredefinedTypesCmd_integer_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_LONG(
+ NamingConstants.PredefinedTypesCmd_long_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_LONGLONG(
+ NamingConstants.PredefinedTypesCmd_longLong_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_SHORT(
+ NamingConstants.PredefinedTypesCmd_short_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_STRING(
+ NamingConstants.PredefinedTypesCmd_string_name,
+ DatatypePackage.Literals.STRING_TYPE), PREDEFINED_UNSIGNED_INTEGER(
+ NamingConstants.PredefinedTypesCmd_unsignedInteger_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_UNSIGNED_SHORT(
+ NamingConstants.PredefinedTypesCmd_unsignedShort_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_UNSIGNED_LONG_LONG(
+ NamingConstants.PredefinedTypesCmd_unsignedLongLong_name,
+ DatatypePackage.Literals.NUMERIC_TYPE), PREDEFINED_UNSIGNED_LONG(
+ NamingConstants.PredefinedTypesCmd_unsignedLong_name,
+ DatatypePackage.Literals.NUMERIC_TYPE);
private final String name;
private final EClass type;
@@ -100,7 +117,8 @@ public class MultiphasesMatchPolicy implements IMatchPolicy {
if (result == null) {
if ((e instanceof NumericType) || (e instanceof StringType) || (e instanceof BooleanType)) {
for (PredefinedType key : values()) {
- if (key.name.equals(((NamedElement) e).getName()) && key.type.isInstance(e) && (getPredefinedType(e.eContainer()) == PREDEFINED_DATA_PKG)) {
+ if (key.name.equals(((NamedElement) e).getName()) && key.type.isInstance(e)
+ && (getPredefinedType(e.eContainer()) == PREDEFINED_DATA_PKG)) {
result = key;
}
}
@@ -135,37 +153,46 @@ public class MultiphasesMatchPolicy implements IMatchPolicy {
}
private static boolean isRootFunction(EObject e_p) {
- return (e_p instanceof AbstractFunction) && (EcoreUtil2.getFirstContainer(e_p, FaPackage.Literals.ABSTRACT_FUNCTION) == null);
+ return (e_p instanceof AbstractFunction)
+ && (EcoreUtil2.getFirstContainer(e_p, FaPackage.Literals.ABSTRACT_FUNCTION) == null);
}
}
public MultiphasesMatchPolicy() {
- Collection<ENamedElement> uniqueKeys =
- Arrays.asList(CapellamodellerPackage.Literals.PROJECT, CapellamodellerPackage.Literals.SYSTEM_ENGINEERING, LaPackage.Literals.LOGICAL_ARCHITECTURE, PaPackage.Literals.PHYSICAL_ARCHITECTURE,
- CtxPackage.Literals.SYSTEM_ANALYSIS, OaPackage.Literals.OPERATIONAL_ANALYSIS, EpbsPackage.Literals.EPBS_ARCHITECTURE,
- OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_CONCEPT_PKG, OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_ENTITY_PKG,
- OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_OPERATIONAL_CONTEXT, OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_ROLE_PKG,
- LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_COMPONENT, LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_ACTOR_PKG,
- LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_COMPONENT_PKG, LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_CONTEXT,
- LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_SYSTEM_ANALYSIS_REALIZATIONS, CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_ACTOR_PKG,
- CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_MISSION_PKG, CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_OPERATIONAL_ANALYSIS_REALIZATIONS,
- CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_SYSTEM, CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_SYSTEM_CONTEXT,
- PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_LOGICAL_ARCHITECTURE_REALIZATIONS,
- PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_ACTOR_PKG, PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_COMPONENT,
- PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_COMPONENT_PKG, PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_CONTEXT,
- EpbsPackage.Literals.EPBS_ARCHITECTURE__OWNED_EPBS_CONTEXT, EpbsPackage.Literals.EPBS_ARCHITECTURE__OWNED_CONFIGURATION_ITEM,
- EpbsPackage.Literals.EPBS_ARCHITECTURE__OWNED_PHYSICAL_ARCHITECTURE_REALIZATIONS, CapellamodellerPackage.Literals.PROJECT__OWNED_MODEL_ROOTS,
- LibrariesPackage.Literals.MODEL_INFORMATION);
+ Collection<ENamedElement> uniqueKeys = Arrays.asList(CapellamodellerPackage.Literals.PROJECT,
+ CapellamodellerPackage.Literals.SYSTEM_ENGINEERING, LaPackage.Literals.LOGICAL_ARCHITECTURE,
+ PaPackage.Literals.PHYSICAL_ARCHITECTURE, CtxPackage.Literals.SYSTEM_ANALYSIS,
+ OaPackage.Literals.OPERATIONAL_ANALYSIS, EpbsPackage.Literals.EPBS_ARCHITECTURE,
+ OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_CONCEPT_PKG,
+ OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_ENTITY_PKG,
+ OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_OPERATIONAL_CONTEXT,
+ OaPackage.Literals.OPERATIONAL_ANALYSIS__OWNED_ROLE_PKG,
+ LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_COMPONENT,
+ LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_ACTOR_PKG,
+ LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_COMPONENT_PKG,
+ LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_LOGICAL_CONTEXT,
+ LaPackage.Literals.LOGICAL_ARCHITECTURE__OWNED_SYSTEM_ANALYSIS_REALIZATIONS,
+ CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_ACTOR_PKG, CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_MISSION_PKG,
+ CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_OPERATIONAL_ANALYSIS_REALIZATIONS,
+ CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_SYSTEM, CtxPackage.Literals.SYSTEM_ANALYSIS__OWNED_SYSTEM_CONTEXT,
+ PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_LOGICAL_ARCHITECTURE_REALIZATIONS,
+ PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_ACTOR_PKG,
+ PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_COMPONENT,
+ PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_COMPONENT_PKG,
+ PaPackage.Literals.PHYSICAL_ARCHITECTURE__OWNED_PHYSICAL_CONTEXT,
+ EpbsPackage.Literals.EPBS_ARCHITECTURE__OWNED_EPBS_CONTEXT,
+ EpbsPackage.Literals.EPBS_ARCHITECTURE__OWNED_CONFIGURATION_ITEM,
+ EpbsPackage.Literals.EPBS_ARCHITECTURE__OWNED_PHYSICAL_ARCHITECTURE_REALIZATIONS,
+ CapellamodellerPackage.Literals.PROJECT__OWNED_MODEL_ROOTS, LibrariesPackage.Literals.MODEL_INFORMATION);
for (ENamedElement o : uniqueKeys) {
matchIDs.put(o, EcoreUtil.getURI(o).toString());
}
-
- Collection<EClass> allBlockArchitectures =
- Arrays.asList(OaPackage.Literals.OPERATIONAL_ANALYSIS, CtxPackage.Literals.SYSTEM_ANALYSIS, LaPackage.Literals.LOGICAL_ARCHITECTURE,
- PaPackage.Literals.PHYSICAL_ARCHITECTURE, EpbsPackage.Literals.EPBS_ARCHITECTURE);
+ Collection<EClass> allBlockArchitectures = Arrays.asList(OaPackage.Literals.OPERATIONAL_ANALYSIS,
+ CtxPackage.Literals.SYSTEM_ANALYSIS, LaPackage.Literals.LOGICAL_ARCHITECTURE,
+ PaPackage.Literals.PHYSICAL_ARCHITECTURE, EpbsPackage.Literals.EPBS_ARCHITECTURE);
for (EClass c : allBlockArchitectures) {
@@ -214,7 +241,8 @@ public class MultiphasesMatchPolicy implements IMatchPolicy {
public boolean equals(Object obj) {
boolean result = false;
if (obj.getClass() == Key.class) {
- result = (eContainerClass == ((Key) obj).eContainerClass) && (eContainingFeature == ((Key) obj).eContainingFeature);
+ result = (eContainerClass == ((Key) obj).eContainerClass)
+ && (eContainingFeature == ((Key) obj).eContainingFeature);
}
return result;
}
@@ -231,16 +259,17 @@ public class MultiphasesMatchPolicy implements IMatchPolicy {
String result = null;
// if the element has a non-empty, non-null sid, use this as its match id
- if ((element_p instanceof ModelElement) && (((ModelElement) element_p).getSid() != null) && !((ModelElement) element_p).getSid().isEmpty()) {
+ if ((element_p instanceof ModelElement) && (((ModelElement) element_p).getSid() != null)
+ && !((ModelElement) element_p).getSid().isEmpty()) {
EObject archi = EcoreUtil2.getFirstContainer(element_p, CsPackage.Literals.BLOCK_ARCHITECTURE);
return archi == null ? "" : archi.eClass().getName() + ((ModelElement) element_p).getSid();
}
if ((element_p instanceof AbstractTrace) && (((AbstractTrace) element_p).getSourceElement() != null)
&& (((AbstractTrace) element_p).getTargetElement() != null)) {
- result =
- String.format("t[(%s)%s=>%s]", element_p.eClass().getName(), getMatchID(((AbstractTrace) element_p).getSourceElement(), scope_p),
- getMatchID(((AbstractTrace) element_p).getTargetElement(), scope_p));
+ result = String.format("t[(%s)%s=>%s]", element_p.eClass().getName(),
+ getMatchID(((AbstractTrace) element_p).getSourceElement(), scope_p),
+ getMatchID(((AbstractTrace) element_p).getTargetElement(), scope_p));
}
// otherwise we test for some unique characteristics
@@ -271,25 +300,29 @@ public class MultiphasesMatchPolicy implements IMatchPolicy {
if (element_p instanceof LiteralBooleanValue) {
String parentMatch = getMatchID(element_p.eContainer(), scope_p);
if (parentMatch != null) {
- result = parentMatch + ";" + element_p.eContainingFeature().getName() + "@boolean:" + ((LiteralBooleanValue) element_p).getName();
+ result = parentMatch + ";" + element_p.eContainingFeature().getName() + "@boolean:"
+ + ((LiteralBooleanValue) element_p).getName();
}
}
if (element_p instanceof LiteralStringValue) {
String parentMatch = getMatchID(element_p.eContainer(), scope_p);
if (parentMatch != null) {
- result = parentMatch + ";" + element_p.eContainingFeature().getName() + ";string:" + ((LiteralStringValue) element_p).getName();
+ result = parentMatch + ";" + element_p.eContainingFeature().getName() + ";string:"
+ + ((LiteralStringValue) element_p).getName();
}
}
if (element_p instanceof LiteralNumericValue) {
String parentMatch = getMatchID(element_p.eContainer(), scope_p);
if (parentMatch != null) {
- result = parentMatch + ";" + element_p.eContainingFeature().getName() + ";numeric: " + ((LiteralNumericValue) element_p).getValue();
+ result = parentMatch + ";" + element_p.eContainingFeature().getName() + ";numeric: "
+ + ((LiteralNumericValue) element_p).getValue();
}
}
if (element_p instanceof BinaryExpression) {
String parentMatch = getMatchID(element_p.eContainer(), scope_p);
if (parentMatch != null) {
- result = parentMatch + ";" + (((InternalEObject) element_p.eContainer()).eURIFragmentSegment(element_p.eContainingFeature(), element_p));
+ result = parentMatch + ";" + (((InternalEObject) element_p.eContainer())
+ .eURIFragmentSegment(element_p.eContainingFeature(), element_p));
}
}
if (element_p instanceof EnumerationPropertyLiteral) {
@@ -336,6 +369,19 @@ public class MultiphasesMatchPolicy implements IMatchPolicy {
}
+ if (element_p instanceof LibraryReference) {
+ result = "-LIBRARYREFERENCE-" + ((LibraryReference) element_p).getLibrary().getId();
+ }
+
+ // If the element is in a library.
+ if (element_p.eResource().getContents().get(0) instanceof Library) {
+ if (element_p instanceof ModelElement) {
+ result += "-" + ((ModelElement) element_p).getId();
+ }
+ String libraryName = ((Library) element_p.eResource().getContents().get(0)).getName();
+ result += "-LIBRARY-" + libraryName;
+ }
+
if (result == null) {
result = "UNMATCHABLE-ELEMENT-" + EcoreUtil.getID(element_p);
}