Skip to content

Commit

Permalink
eclipse-capella#2607 RootQueries now applies on ExtensibleElement
Browse files Browse the repository at this point in the history
RootQueries 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 committed Mar 1, 2023
1 parent 253f317 commit 29c1753
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
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 29c1753

Please sign in to comment.