blob: e76e284f6453f613d06162b99d1707e2a6d4009f (
plain) (
blame)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ansgar Radermacher ansgar.radermacher@cea.fr
*
*****************************************************************************/
package org.eclipse.papyrus.qompass.modellibs.core.embeddingrules;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.papyrus.FCM.Connector;
import org.eclipse.papyrus.FCM.util.ConnectorTypeUtil;
import org.eclipse.papyrus.FCM.util.FCMUtil;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.util.UMLUtil;
/**
* Embedding rule
* TODO: currently unused
*
*/
// @unused
public class AccordCall extends ConnectorTypeUtil {
private ConnectableElement clientRole = null;
private ConnectableElement serverRole = null;
private ConnectableElement rtuRole = null;
private ConnectableElement connectorRole = null;
@Override
public FCMUtil.RoleBindingTable getRoleBindings(Connector connector) {
super.getRoleBindings(connector);
clientRole = bindingTable.getRoleKeyByName("client");
serverRole = bindingTable.getRoleKeyByName("server");
rtuRole = bindingTable.getRoleKeyByName("rtu");
connectorRole = bindingTable.getRoleKeyByName("connector");
for (org.eclipse.uml2.uml.ConnectorEnd end : connector.getBase_Connector().getEnds()) {
if (end.getRole() instanceof org.eclipse.uml2.uml.Port) {
org.eclipse.uml2.uml.Port port = (org.eclipse.uml2.uml.Port) end.getRole();
org.eclipse.uml2.uml.Property part = end.getPartWithPort();
if (StereotypeUtil.isApplied(port, org.eclipse.papyrus.FCM.Port.class)) {
org.eclipse.papyrus.FCM.Port fcmPort = UMLUtil.getStereotypeApplication(port, org.eclipse.papyrus.FCM.Port.class);
if (fcmPort.getKind().getBase_Class().getName().equals("UseInterfaceWithRtf")) {
// => elements associated with the connector end play the client role
List<NamedElement> clientActors = new ArrayList<NamedElement>();
clientActors.add(port);
clientActors.add(part);
bindingTable.addEntry(clientRole, clientActors);
}
else if (fcmPort.getKind().getBase_Class().getName().equals("ProvideInterface")) {
// => elements associated with the connector end play the server role
List<NamedElement> serverActors = new ArrayList<NamedElement>();
serverActors.add(port);
serverActors.add(part);
bindingTable.addEntry(serverRole, serverActors);
// the property playing the server role must also play the rtu role
port = ((org.eclipse.uml2.uml.Class) part.getType()).getOwnedPort("rtu", null);
if (port == null) {
if (((org.eclipse.uml2.uml.Class) part.getType()).getInheritedMember("rtu") != null &&
((org.eclipse.uml2.uml.Class) part.getType()).getInheritedMember("rtu") instanceof org.eclipse.uml2.uml.Port) {
port = (org.eclipse.uml2.uml.Port) ((org.eclipse.uml2.uml.Class) part.getType()).getInheritedMember("rtu");
}
else {
System.out.println("Could not find a port rtu on part " + part.getName() + " : " + part.getType());
}
}
if (port != null) {
List<NamedElement> rtuActors = new ArrayList<NamedElement>();
rtuActors.add(port);
rtuActors.add(part);
bindingTable.addEntry(rtuRole, rtuActors);
}
}
}
}
}
List<NamedElement> connectorActors = new ArrayList<NamedElement>();
connectorActors.add(connector.getBase_Connector());
bindingTable.addEntry(connectorRole, connectorActors);
return bindingTable;
}
}
|