예제 #1
0
 private void configureRGOReference(NonRootModelElement rgo, NonRootModelElement rto) {
   TransactionManager manager = TransactionManager.getSingleton();
   Transaction transaction = null;
   String association = ElementMap.getAssociationFor(getMethodName().replaceAll("test", ""));
   NonRootModelElement newRto =
       getElement(getMethodName().replaceAll("test", ""), rto.getClass(), true);
   try {
     transaction =
         manager.startTransaction("Adjust RGO", new Ooaofooa[] {Ooaofooa.getDefaultInstance()});
     if (rgo instanceof ProvidedExecutableProperty_c) {
       // need to reassign the provision
       Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) newRto);
       Provision_c provision = Provision_c.getOneC_POnR4501((ProvidedExecutableProperty_c) rgo);
       provision.Unformalize(false);
       provision.Formalize(iface.getId(), false);
       this.rgo = ProvidedExecutableProperty_c.getOneSPR_PEPOnR4501(provision);
     } else if (rgo instanceof RequiredExecutableProperty_c) {
       // need to reassign the requirement
       Interface_c iface = Interface_c.getOneC_IOnR4003((ExecutableProperty_c) newRto);
       Requirement_c requirement =
           Requirement_c.getOneC_ROnR4500((RequiredExecutableProperty_c) rgo);
       requirement.Unformalize(false);
       requirement.Formalize(iface.getId(), false);
       // need to reset the RGO
       this.rgo = RequiredExecutableProperty_c.getOneSPR_REPOnR4500(requirement);
     } else {
       Method getMethod = getAccessorMethod(rgo, rto);
       NonRootModelElement existing =
           (NonRootModelElement) getMethod.invoke(rto, new Object[] {rgo});
       Method method = getUnrelateMethod(association, existing, rgo);
       method.invoke(existing, new Object[] {rgo});
       method = getRelateMethod(association, newRto, rgo);
       method.invoke(newRto, new Object[] {rgo});
     }
   } catch (Exception e) {
     fail(e.getMessage());
     if (transaction != null) {
       manager.cancelTransaction(transaction);
     }
   } finally {
     if (transaction != null) {
       manager.endTransaction(transaction);
       rgoUpdateSuccessful = true;
     }
   }
   BaseTest.dispatchEvents(0);
 }
예제 #2
0
  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$	
  }