-
Notifications
You must be signed in to change notification settings - Fork 85
/
GetISScopeInsertActors__Lib.java
53 lines (48 loc) · 2.45 KB
/
GetISScopeInsertActors__Lib.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
/*******************************************************************************
* 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.sirius.analysis.queries.interactionServices;
import static org.polarsys.capella.common.helpers.cache.ModelCache.getCache;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.polarsys.capella.common.libraries.ILibraryManager;
import org.polarsys.capella.common.libraries.IModel;
import org.polarsys.capella.common.libraries.manager.LibraryManagerExt;
import org.polarsys.capella.common.queries.AbstractQuery;
import org.polarsys.capella.common.queries.ExtendingQuery;
import org.polarsys.capella.common.queries.interpretor.QueryInterpretor;
import org.polarsys.capella.common.queries.queryContext.IQueryContext;
import org.polarsys.capella.core.data.cs.Component;
import org.polarsys.capella.core.libraries.model.CapellaModel;
import org.polarsys.capella.core.libraries.queries.QueryExt;
import org.polarsys.capella.core.model.helpers.ComponentExt;
import org.polarsys.capella.core.model.helpers.queries.QueryIdentifierConstants;
@ExtendingQuery (extendingQuery = GetISScopeInsertActors.class)
public class GetISScopeInsertActors__Lib extends AbstractQuery {
@Override
public List<Object> execute(Object input, IQueryContext context) {
List<Object> result = new ArrayList<Object>();
EObject element = (EObject) input;
IModel currentProject = ILibraryManager.INSTANCE.getModel(element);
Collection<IModel> libraries = LibraryManagerExt.getAllActivesReferences(currentProject);
for (IModel library : libraries) {
EObject correspondingInput = QueryExt.getCorrespondingElementInLibrary(element, (CapellaModel) library);
List<Component> actors = QueryInterpretor.executeQuery(QueryIdentifierConstants.GET_ALL_ACTORS, correspondingInput, context);
for (Component actor : actors) {
result.addAll(getCache(ComponentExt::getRepresentingParts, actor));
}
}
return result;
}
}