-
Notifications
You must be signed in to change notification settings - Fork 85
/
PhysicalComponent_deployingPhysicalComponents.java
72 lines (63 loc) · 2.46 KB
/
PhysicalComponent_deployingPhysicalComponents.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*******************************************************************************
* Copyright (c) 2006, 2020 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 static org.polarsys.capella.common.helpers.cache.ModelCache.getCache;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.polarsys.capella.core.data.cs.Component;
import org.polarsys.capella.core.data.cs.DeploymentTarget;
import org.polarsys.capella.core.data.cs.Part;
import org.polarsys.capella.core.data.pa.PhysicalComponent;
import org.polarsys.capella.core.model.helpers.PartExt;
import org.polarsys.capella.common.data.modellingcore.AbstractType;
import org.polarsys.capella.common.data.modellingcore.AbstractTypedElement;
import org.polarsys.capella.common.helpers.query.IQuery;
/**
*
*/
public class PhysicalComponent_deployingPhysicalComponents implements IQuery {
/**
*
*/
public PhysicalComponent_deployingPhysicalComponents() {
// do nothing
}
/**
*
* current.deployingLinks.location
*
* @see org.polarsys.capella.common.helpers.query.IQuery#compute(java.lang.Object)
*/
public List<Object> compute(Object object) {
List<Object> result = new ArrayList<Object>();
if (object instanceof PhysicalComponent) {
PhysicalComponent c = (PhysicalComponent) object;
EList<AbstractTypedElement> abstractTypedElements = c.getAbstractTypedElements();
for (AbstractTypedElement abstractTypedElement : abstractTypedElements) {
if (abstractTypedElement instanceof Part) {
List<DeploymentTarget> deployingElements = getCache(PartExt::getDeployingElements, (Part) abstractTypedElement);
for (DeploymentTarget deploymentTarget : deployingElements) {
if (deploymentTarget instanceof Part) {
AbstractType abstractType = ((Part) deploymentTarget).getAbstractType();
if (null != abstractType && abstractType instanceof Component) {
result.add(abstractType);
}
}
}
}
}
}
return result;
}
}