01: package org.netbeans.modules.iep.project.anttasks;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.netbeans.modules.iep.model.IEPModel;
07: import org.netbeans.modules.iep.model.InputOperatorComponent;
08: import org.netbeans.modules.iep.model.OutputOperatorComponent;
09:
10: public class Util {
11:
12: private static final String INPUT_PORT_TYPE = "InputPt";
13: private static final String INPUT_ROLE_NAME = "InputRn";
14: private static final String INPUT_PARTNER_LINK = "InputPl";
15: private static String NAME_KEY = "name";
16:
17: public static List<PortMapEntry> generatePortMapEntryList(
18: IEPModel model, String tns) throws Exception {
19: List<PortMapEntry> pmeList = new ArrayList<PortMapEntry>();
20:
21: List<InputOperatorComponent> inList = model.getInputList();
22: List<OutputOperatorComponent> outList = model.getOutputList();
23: if (inList.size() > 0) {
24: String partnerLink = tns + ":" + INPUT_PARTNER_LINK;
25: String portType = tns + ":" + INPUT_PORT_TYPE;
26: PortMapEntry pme = new PortMapEntry(partnerLink, portType,
27: PortMapEntry.MY_ROLE, INPUT_ROLE_NAME);
28: pmeList.add(pme);
29: }
30: for (int i = 0, I = outList.size(); i < I; i++) {
31: OutputOperatorComponent op = outList.get(i);
32: String name = op.getProperty(NAME_KEY).getValue();
33: name = NameUtil.makeJavaId(name);
34: String partnerLink = tns + ":" + getOutputPartnerLink(name);
35: String portType = tns + ":" + getOutputPortType(name);
36: String roleName = getOutputRoleName(name);
37: PortMapEntry pme = new PortMapEntry(partnerLink, portType,
38: PortMapEntry.PARTNER_ROLE, roleName);
39: pmeList.add(pme);
40: }
41: return pmeList;
42: }
43:
44: private static String getOutputPartnerLink(String opJName) {
45: return "OutputPl_" + opJName;
46: }
47:
48: private static String getOutputPortType(String opJName) {
49: return "OutputPt_" + opJName;
50: }
51:
52: private static String getOutputRoleName(String opJName) {
53: return "OutputRn_" + opJName;
54: }
55:
56: }
|