private Object[] getCuttableElements(NonRootModelElement rto) { List<Object> elements = new ArrayList<Object>(); if (rto instanceof InterfaceReference_c) { // need to include self and the parent component elements.add(rto.getFirstParentComponent()); // and add the provision or requirement Provision_c pro = Provision_c.getOneC_POnR4009((InterfaceReference_c) rto); Requirement_c req = Requirement_c.getOneC_ROnR4009((InterfaceReference_c) rto); if (pro != null) { elements.add(pro); } else { elements.add(req); } } if (rto instanceof Port_c) { // need to include self and the parent component elements.add(rto.getFirstParentComponent()); // and add the provision or requirement Provision_c pro = Provision_c.getOneC_POnR4009(InterfaceReference_c.getOneC_IROnR4016((Port_c) rto)); Requirement_c req = Requirement_c.getOneC_ROnR4009(InterfaceReference_c.getOneC_IROnR4016((Port_c) rto)); if (pro != null) { elements.add(pro); } else { elements.add(req); } } else if (rto instanceof ExecutableProperty_c) { // need to cut the interface Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) rto); elements.add(iface); } else { elements.add(getSelectableElement(rto)); } return elements.toArray(); }
private void populateInterfaceOperationInstances( Component_c comp, String portName, boolean Required) { Port_c[] ports = Port_c.getManyC_POsOnR4010(comp); for (int i = 0; i < ports.length; ++i) { if (ports[i].getName().equalsIgnoreCase(portName)) { // BirdgePoint support only single interface reference for a // port // so select One interface reference only InterfaceReference_c intRef = InterfaceReference_c.getOneC_IROnR4016(ports[i]); Requirement_c req = Requirement_c.getOneC_ROnR4009(intRef); Provision_c prov = Provision_c.getOneC_POnR4009(intRef); String[] interfaceOperations; if (req != null && Required) { // Required Interface RequiredExecutableProperty_c[] REPs = RequiredExecutableProperty_c.getManySPR_REPsOnR4500(req); for (int j = 0; j < funcs.length; ++j) { class ReqOperation_test1_c implements ClassQueryInterface_c { ReqOperation_test1_c(String p) { m_p = p; } private String m_p; public boolean evaluate(Object inst) { RequiredOperation_c selected = (RequiredOperation_c) inst; return selected.getName().equals(m_p); } } RequiredOperation_c testOpr = RequiredOperation_c.getOneSPR_ROOnR4502(REPs, new ReqOperation_test1_c(funcs[j])); if (testOpr != null) { if (m_testReqOpr[j] == null) { m_testReqOpr[j] = testOpr; } } else fail("Missing Interface Operation " + m_testReqOpr[j]); // $NON-NLS-1$ } return; } else if (prov != null && !Required) { // Provided Interface ProvidedExecutableProperty_c[] PEPs = ProvidedExecutableProperty_c.getManySPR_PEPsOnR4501(prov); for (int j = 0; j < funcs.length; ++j) { class ProvOperation_test1_c implements ClassQueryInterface_c { ProvOperation_test1_c(String p) { m_p = p; } private String m_p; public boolean evaluate(Object inst) { ProvidedOperation_c selected = (ProvidedOperation_c) inst; return selected.getName().equals(m_p); } } ProvidedOperation_c testOpr = ProvidedOperation_c.getOneSPR_POOnR4503(PEPs, new ProvOperation_test1_c(funcs[j])); if (testOpr != null) { if (m_testProvOpr[j] == null) { m_testProvOpr[j] = testOpr; } } else fail("Missing Interface Operation " + m_testReqOpr[j]); // $NON-NLS-1$ } return; } else { fail( "Port" + portName + "is defined as" + (Required ? "Provided" : "Required") + "interface."); //$NON-NLS-1$ } } } fail("Can not find port " + portName); // $NON-NLS-1$ }