Skip to content

Commit

Permalink
#2607 SystemEngineeringExt.getSystemEngineering now applies on Extens…
Browse files Browse the repository at this point in the history
…ibleElement

SystemEngineeringExt.getSystemEngineering used to apply on CapellaElement, but it is required to apply
on ExtensibleElement to be compatible with viewpoints

Change-Id: Ie59232acafef9c2a47eafd8deeb21bcdc1d858f1
Signed-off-by: Erwann Traisnel <[email protected]>
  • Loading branch information
etraisnel2 authored and pdulth committed Mar 2, 2023
1 parent 7f2b29c commit b29c388
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.polarsys.capella.core.data.sharedmodel.SharedPkg;
import org.polarsys.capella.core.model.helpers.query.CapellaQueries;
import org.polarsys.capella.core.model.utils.CollectionExt;
import org.polarsys.kitalpha.emde.model.ExtensibleElement;

/**
* SystemEngineering helpers
Expand Down Expand Up @@ -781,7 +782,7 @@ public static Component getSystem(SystemEngineering currentElement) {
return null;
}

public static SystemEngineering getSystemEngineering(CapellaElement currentElement) {
public static SystemEngineering getSystemEngineering(ExtensibleElement currentElement) {
SystemEngineering sysEng = CapellaQueries.getInstance().getRootQueries().getSystemEngineering(currentElement);
return sysEng;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import org.polarsys.capella.core.data.capellamodeller.Project;
import org.polarsys.capella.core.data.capellamodeller.SystemEngineering;
import org.polarsys.capella.common.data.modellingcore.ModelElement;
import org.polarsys.kitalpha.emde.model.ExtensibleElement;

/**
* Root queries for the Sys & Soft models.
Expand All @@ -27,7 +27,7 @@ public interface IRootQueries {
* @param modelElement a business element
* @return the system engineering (or null if it does not exist)
*/
SystemEngineering getSystemEngineering(ModelElement modelElement);
SystemEngineering getSystemEngineering(ExtensibleElement modelElement);

public Project getProject(ModelElement modelElement);
public Project getProject(ExtensibleElement modelElement);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,47 @@

package org.polarsys.capella.core.model.helpers.query.impl;

import org.polarsys.capella.common.data.modellingcore.ModelElement;
import org.polarsys.capella.core.data.capellamodeller.Project;
import org.polarsys.capella.core.data.capellamodeller.SystemEngineering;
import org.polarsys.capella.core.model.helpers.query.IRootQueries;
import org.polarsys.capella.common.data.modellingcore.ModelElement;
import org.polarsys.kitalpha.emde.model.ExtensibleElement;

public class RootQueries implements IRootQueries {
/**
* Get the system engineering element.
* @see org.polarsys.capella.core.model.helpers.query.IRootQueries#getSystemEngineering()
* @param modelElement a business element
*/
public SystemEngineering getSystemEngineering(ModelElement modelElement) {
public SystemEngineering getSystemEngineering(ExtensibleElement modelElement) {
return (SystemEngineering) getSystemEngineeringRecursively(modelElement);
}

private ModelElement getSystemEngineeringRecursively(ModelElement modelElement) {
private ModelElement getSystemEngineeringRecursively(ExtensibleElement modelElement) {
ModelElement result;
if (null == modelElement) {
result = null;
} else if (modelElement instanceof SystemEngineering) {
result = modelElement;
result = (ModelElement) modelElement;
} else {
ModelElement container = (ModelElement) modelElement.eContainer();
ExtensibleElement container = (ExtensibleElement) modelElement.eContainer();
result = getSystemEngineeringRecursively(container);
}
return result;
}

public Project getProject(ModelElement modelElement) {
public Project getProject(ExtensibleElement modelElement) {
return (Project) getProjectRecursively(modelElement);
}

private ModelElement getProjectRecursively(ModelElement modelElement) {
private ModelElement getProjectRecursively(ExtensibleElement modelElement) {
ModelElement result;
if (null == modelElement) {
result = null;
} else if (modelElement instanceof Project) {
result = modelElement;
result = (ModelElement) modelElement;
} else {
ModelElement container = (ModelElement) modelElement.eContainer();
ExtensibleElement container = (ExtensibleElement) modelElement.eContainer();
result = getProjectRecursively(container);
}
return result;
Expand Down

0 comments on commit b29c388

Please sign in to comment.