示例#1
0
 private NonRootModelElement getElement(String key, Class<?> elementType, boolean nonDefault) {
   NonRootModelElement element = null;
   String name = elementType.getSimpleName();
   if (key.startsWith("A")) {
     name = name + "_RTO";
   } else {
     name = name + "_RGO";
   }
   if (elementType == ImportedReference_c.class) {
     // name will match RTO
     name = "InterfaceReference_c_RTO";
   }
   if (elementType == PortReference_c.class && rto instanceof Port_c) {
     name = "Port_c_RTO";
   }
   if (elementType == InterfaceReference_c.class && rto instanceof Port_c) {
     // name will match RTO
     name = "PortReference_c_RTO";
   }
   if (elementType == InterfaceReference_c.class && rto instanceof Interface_c) {
     // name will match RTO
     name = "Interface_c_RTO";
   }
   if (elementType == ComponentReference_c.class) {
     // name will match RTO
     name = "Component_c_RTO";
   }
   if (elementType == ProvidedExecutableProperty_c.class) {
     // need to locate the Provided Operation
     elementType = ProvidedOperation_c.class;
     // also the name will be ExecutableProperty_c_RTO
     name = "ExecutableProperty_c_RTO";
   }
   if (elementType == RequiredExecutableProperty_c.class) {
     // need to locate the Provided Operation
     elementType = RequiredOperation_c.class;
     // also the name will be ExecutableProperty_c_RTO
     name = "ExecutableProperty_c_RTO";
   }
   if (nonDefault) {
     name = name + "_ND";
   }
   Ooaofooa[] instances = Ooaofooa.getInstances();
   for (Ooaofooa ooa : instances) {
     InstanceList list = ooa.getInstanceList(elementType);
     for (Object elem : list) {
       NonRootModelElement test = (NonRootModelElement) elem;
       if (test.isProxy()) {
         continue;
       }
       if (test.getName().contains(name) && (!nonDefault && !test.getName().contains("ND"))) {
         element = test;
         break;
       }
       if (test.getName().contains(name) && (nonDefault && test.getName().contains("ND"))) {
         element = test;
         break;
       }
     }
     if (element != null) {
       break;
     }
   }
   if (elementType == ProvidedOperation_c.class) {
     return ProvidedExecutableProperty_c.getOneSPR_PEPOnR4503((ProvidedOperation_c) element);
   }
   if (elementType == RequiredOperation_c.class) {
     return RequiredExecutableProperty_c.getOneSPR_REPOnR4502((RequiredOperation_c) element);
   }
   assertNotNull(
       "Missing test element with details : Type->" + elementType + " Name->" + name, element);
   return element;
 }