-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
225 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ries/src/org/polarsys/capella/core/semantic/queries/basic/queries/PhysicalLinkSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 THALES GLOBAL SERVICES. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.core.semantic.queries.basic.queries; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.polarsys.capella.common.helpers.query.IQuery; | ||
import org.polarsys.capella.core.data.cs.PhysicalLink; | ||
import org.polarsys.capella.core.data.helpers.cs.services.PhysicalLinkExt; | ||
import org.polarsys.capella.core.data.information.Port; | ||
|
||
/** | ||
* return source @Port of a given @PhysicalLink | ||
*/ | ||
public class PhysicalLinkSource implements IQuery { | ||
|
||
@Override | ||
public List<Object> compute(Object object) { | ||
if (object instanceof PhysicalLink) { | ||
PhysicalLink link = (PhysicalLink) object; | ||
Port port = PhysicalLinkExt.getSourcePort(link); | ||
if (null != port) { | ||
return Collections.singletonList(port); | ||
} | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ries/src/org/polarsys/capella/core/semantic/queries/basic/queries/PhysicalLinkTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 THALES GLOBAL SERVICES. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.core.semantic.queries.basic.queries; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.polarsys.capella.common.helpers.query.IQuery; | ||
import org.polarsys.capella.core.data.cs.PhysicalLink; | ||
import org.polarsys.capella.core.data.helpers.cs.services.PhysicalLinkExt; | ||
import org.polarsys.capella.core.data.information.Port; | ||
|
||
/** | ||
* return target @Port of a given @PhysicalLink | ||
*/ | ||
public class PhysicalLinkTarget implements IQuery { | ||
|
||
@Override | ||
public List<Object> compute(Object object) { | ||
if (object instanceof PhysicalLink) { | ||
PhysicalLink link = (PhysicalLink) object; | ||
Port port = PhysicalLinkExt.getTargetPort(link); | ||
if (null != port) { | ||
return Collections.singletonList(port); | ||
} | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...eries/src/org/polarsys/capella/core/semantic/queries/basic/queries/PhysicalPortOwner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 THALES GLOBAL SERVICES. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.core.semantic.queries.basic.queries; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.eclipse.emf.ecore.EObject; | ||
import org.polarsys.capella.common.helpers.query.IQuery; | ||
import org.polarsys.capella.core.data.cs.Component; | ||
import org.polarsys.capella.core.data.cs.PhysicalPort; | ||
|
||
/** | ||
* return container of a @PhysicalPort | ||
*/ | ||
public class PhysicalPortOwner implements IQuery { | ||
|
||
@Override | ||
public List<Object> compute(Object object) { | ||
if (object instanceof PhysicalPort) { | ||
PhysicalPort pp = (PhysicalPort) object; | ||
EObject eContainer = pp.eContainer(); | ||
if (eContainer instanceof Component) { | ||
return Collections.singletonList(eContainer); | ||
} | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...u/src/org/polarsys/capella/test/semantic/queries/ju/testcases/PhysicalLinkSourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 THALES GLOBAL SERVICES. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.test.semantic.queries.ju.testcases; | ||
|
||
import org.polarsys.capella.test.semantic.queries.ju.model.SemanticQueries; | ||
|
||
public class PhysicalLinkSourceTest extends SemanticQueries { | ||
private final String QUERY = "org.polarsys.capella.core.semantic.queries.PhysicalLinkSource"; | ||
|
||
@Override | ||
protected String getQueryCategoryIdentifier() { | ||
return QUERY; | ||
} | ||
|
||
@Override | ||
public void test() throws Exception { | ||
testQueryIncludingItemQueries(PA__PHYSICAL_LINK_1, PA__PHYSICAL_PORT_1, PA__PC1); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...u/src/org/polarsys/capella/test/semantic/queries/ju/testcases/PhysicalLinkTargetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 THALES GLOBAL SERVICES. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.test.semantic.queries.ju.testcases; | ||
|
||
import org.polarsys.capella.test.semantic.queries.ju.model.SemanticQueries; | ||
|
||
public class PhysicalLinkTargetTest extends SemanticQueries { | ||
private final String QUERY = "org.polarsys.capella.core.semantic.queries.PhysicalLinkTarget"; | ||
|
||
@Override | ||
protected String getQueryCategoryIdentifier() { | ||
return QUERY; | ||
} | ||
|
||
@Override | ||
public void test() throws Exception { | ||
testQueryIncludingItemQueries(PA__PHYSICAL_LINK_1, PA__PHYSICAL_PORT_2, PA__PC2); | ||
} | ||
} |