job:  #5005  Provide PropertyDescriptor class name to test generation.

.//========================================================================
.//
.//File:      $RCSfile: create_view_test.arc,v $
.//Version:   $Revision: 1.47 $
.//Modified:  $Date: 2013/05/12 22:30:18 $
.//
.//(c) Copyright 2006-2014 by Mentor Graphics Corp. All rights reserved.
.//
.//========================================================================
.// Licensed under the Apache License, Version 2.0 (the "License"); you may not
.// use this file except in compliance with the License.  You may obtain a copy
.// of the License at
.//
.//       http://www.apache.org/licenses/LICENSE-2.0
.//
.// Unless required by applicable law or agreed to in writing, software
.// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
.// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
.// License for the specific language governing permissions and limitations under
.// the License.
.//========================================================================
.//
.invoke arc_env = GET_ENV_VAR( "PTC_MC_ARC_DIR" )
.assign mc_archetypes = arc_env.result
.if ( mc_archetypes == "" )
  .print "\nERROR: Environment variable PTC_MC_ARC_DIR not set."
  .exit 100
.end if
.//
.include "${mc_archetypes}/arch_utils.inc"
.function get_ref_value
  .param inst_ref child_node   .// T_TNS
  .param string child_var_name
  .//
  .if ( child_node.Key_Lett == "R_REL" )
            "R$${${child_var_name}.Numb}" },
  .elif ( child_node.Key_Lett == "O_IOBJ" )
    ..select one obj related by O_IOBJclass->O_OBJ[R101]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "SM_ASM" )
            "$${O_OBJclass.Name}" },
  .elif ( child_node.Key_Lett == "SM_ISM" )
            "$${O_OBJclass.Name}" },
  .elif ( child_node.Key_Lett == "SM_PEVT" )
     ..assign result = SM_PEVTclass.localEventMning;
     ..if(result == "")
       ..assign result = "test_poly"
     ..end if
            "$${result}" },
  .elif(child_node.Key_Lett == "SM_NLEVT")
            "test_sm::B Class" },
  .elif(child_node.Key_Lett == "SM_TXN")
            "test_sm::B Class" },
  .elif ( child_node.Key_Lett == "O_RTIDA" )
     ..select one cia related by O_RTIDAclass->O_OIDA[R110]
     ..select one assoc related by O_RTIDAclass->R_RTO[R110]->R_OIR[R203]->R_REL[R201]
     ..assign attrName = cia.localAttributeName;
     ..if(attrName == "")
       ..assign attrName = "id"
     ..end if
     ..assign result = attrName + " {R"
     ..assign result = result + "$${assoc.Numb}"
     ..assign result = result + "}"
            "$${result}" },
  .elif ( child_node.Key_Lett == "SM_SM" )
    ..select one obj related by SM_SMclass->SM_ISM[R517]->O_OBJ[R518]
    ..if ( not_empty obj )
            "$${obj.Name}" },
    ..else
      ..select one obj related by SM_SMclass->SM_ASM[R517]->O_OBJ[R519]
            "$${obj.Name}" },
    ..end if
  .elif ( child_node.Key_Lett == "SM_SUPDT")
    ..select many edi_set related by ${child_var_name}->SM_SDI[R522]->SM_EVTDI[R522];
    ..assign result = "("
    ..assign first = true
    ..for each edi in edi_set
      ..if ( not first )
        ..assign result = result + ","
      ..end if
      ..assign result = result + edi.Name
      ..assign first = false
    ..end for
            "$${result}" + ")" },
  .elif ( child_node.Key_Lett == "SM_EVT" )
    ..select any smsevt from instances of SM_SEVT where ((selected.SMevt_ID == SM_EVTclass.SMevt_ID) and (selected.SM_ID == SM_EVTclass.SM_ID) and (selected.SMspd_ID == SM_EVTclass.SMspd_ID))
    ..select one nlevt related by smsevt->SM_NLEVT[R526]
    ..if(not_empty nlevt)
      ..select one smpevt related by nlevt->SM_PEVT[R527]
      ..select any smevt from instances of SM_EVT where ((selected.SMevt_ID == smpevt.SMevt_ID) and (selected.SM_ID == smpevt.SM_ID) and (selected.SMspd_ID == smpevt.SMspd_ID))
      ..select one obj related by smevt->SM_SM[R502]->SM_ISM[R517]->O_OBJ[R518]
            "$${SM_EVTclass.Mning}::$${obj.Name}" },
    ..else
      ..select one obj related by SM_EVTclass->SM_SM[R502]->SM_ISM[R517]->O_OBJ[R518]
      ..if ( not_empty obj )
            "$${SM_EVTclass.Drv_Lbl}: $${SM_EVTclass.Mning}" },
      ..else
        ..select one obj related by SM_EVTclass->SM_SM[R502]->SM_ASM[R517]->O_OBJ[R519]
            "$${SM_EVTclass.Drv_Lbl}: $${SM_EVTclass.Mning}" },
      ..end if
    ..end if
  .elif ( child_node.Key_Lett == "SM_SEME" )
            "State Event Matrix Entry (test_poly::B Class)" },
  .elif ( child_node.Key_Lett == "SM_ACT" )
      ..select one state related by SM_ACTclass->SM_AH[R514]->SM_MOAH[R513]->SM_STATE[R511]
      ..if(empty state)
            "Transition Action" },
      ..else
            "State Action" },
      ..end if
  .elif ( child_node.Key_Lett == "O_ID" )
      ..assign id_val = O_IDclass.Oid_ID + 1
              "*$${id_val}" },
  .elif ( child_node.Key_Lett == "S_CDT" )
      ..select one dt related by S_CDTclass->S_DT[R17]
            "$${dt.Name}" },
  .elif ( child_node.Key_Lett == "S_EEEVT" )
      ..select one ee related by S_EEEVTclass->S_EE[R10]
            "$${ee.Name}.$${S_EEEVTclass.Drv_Lbl}" },
  .elif ( child_node.Key_Lett == "R_PART" )
      ..select one obj related by R_PARTclass->R_RTO[R204]->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "R_FORM" )
      ..select one obj related by R_FORMclass->R_RGO[R205]->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "SM_CH" )
      ..select one smsevt related by SM_CHclass->SM_SEME[R504]->SM_SEVT[R503]
      ..select any evt from instances of SM_EVT where ((selected.SMevt_ID == smsevt.SMevt_ID) and (selected.SM_ID == smsevt.SM_ID) and (selected.SMspd_ID == smsevt.SMspd_ID))
      ..select one state related by SM_CHclass->SM_SEME[R504]->SM_STATE[R503]
            "$${evt.Drv_Lbl}/$${state.Name}" },
  .elif ( child_node.Key_Lett == "R_CONE" )
      ..select one obj related by R_CONEclass->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "R_COTH" )
      ..select one obj related by R_COTHclass->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "SM_SDI" )
      ..select one edi related by SM_SDIclass->SM_EVTDI[R522]
            "$${edi.Name}" },
  .elif ( child_node.Key_Lett == "S_UDT" )
  	..select any dt related by S_UDTclass->S_DT[R17]
  			"$${dt.Name}" },
  .elif ( child_node.Key_Lett == "S_SDT" )
  	..select any dt related by S_SDTclass->S_DT[R17]
  			"$${dt.Name}" },
  .elif ( child_node.Key_Lett == "S_EDT" )
  	..select any dt related by S_EDTclass->S_DT[R17]
  			"$${dt.Name}" },
  .elif(((child_node.Key_Lett == "SQ_CP") or (child_node.Key_Lett == "MSG_A")) or (child_node.Key_Lett == "SQ_AV"))
    				"$${${child_var_name}.InformalName}" },
  .elif((child_node.Key_Lett == "MSG_SM") or (child_node.Key_Lett == "MSG_AM"))
        "$${${child_var_name}.InformalName}" },
  .elif(child_node.Key_Lett == "MSG_ISM")
    ..select one sm related by ${child_var_name}->MSG_SM[R1020]
        "$${sm.InformalName}" },
  .elif(child_node.Key_Lett == "MSG_IAM")
    ..select one am related by ${child_var_name}->MSG_AM[R1019]
        "$${am.InformalName}" },
  .elif ( child_node.Key_Lett == "A_FJ" )
  			"$${${child_var_name}.GuardCondition}" },
  .elif ( child_node.Key_Lett == "A_DM" )
  			"$${${child_var_name}.DecisionInput}" },
  .elif ( child_node.Key_Lett == "A_E" )
  			"$${${child_var_name}.Guard}" },
  .else
            "$${${child_var_name}.Name}" },
  .end if
.end function
.function generateTestCase
  .param String kl
  .assign attr_result = true
  .if(kl == "S_EEDI")
    .assign attr_result = false
  .elif(kl == "CP_CP")
    .assign attr_result = false
  .elif(kl == "C_SF")
    .assign attr_result = false
  .elif(kl == "O_OIDA")
    .assign attr_result = false
  .elif(kl == "EP_PKG")
    .assign attr_result = false
  .elif(kl == "IP_IP")
    .assign attr_result = false
  .elif(kl == "C_C")
    .assign attr_result = false
  .elif(kl == "CL_IP")
    .assign attr_result = false
  .elif(kl == "CL_IR")
    .assign attr_result = false
  .elif(kl == "C_I")
    .assign attr_result = false
  .elif(kl == "C_P")
    .assign attr_result = false
  .elif(kl == "C_R")
    .assign attr_result = false
  .elif(kl == "C_AS")
    .assign attr_result = false
  .elif(kl == "C_IO")
    .assign attr_result = false
  .elif(kl == "C_DG")
    .assign attr_result = false
  .elif(kl == "C_PO")
    .assign attr_result = false
  .elif(kl == "C_PP")
    .assign attr_result = false
  .elif(kl == "CL_IC")
    .assign attr_result = false
  .elif(kl == "SPR_RO")
    .assign attr_result = false
  .elif(kl == "SPR_PO")
    .assign attr_result = false
  .elif(kl == "SPR_RS")
    .assign attr_result = false
  .elif(kl == "SPR_PS")
    .assign attr_result = false
  .elif(kl == "I_INS")
    .assign attr_result = false
  .elif(kl == "I_AVL")
    .assign attr_result = false
  .elif(kl == "I_EVI")
    .assign attr_result = false
  .elif(kl == "RV_RVL")
    .assign attr_result = false
  .elif(kl == "I_EXE")
    .assign attr_result = false
  .elif(kl == "I_LIP")
    .assign attr_result = false
  .elif(kl == "CSME_CIE")
    .assign attr_result = false
  .elif(kl == "SM_CRTXN")
    .assign attr_result = false
   .elif(kl == "CL_POR")
    .assign attr_result = false
  .elif(kl == "SM_STATE")
    .// Test case commented out, see DEI 8588
    .assign attr_result = false
  .elif(kl == "SM_TXN")
    .// Test case commented out, see DEI 8588
    .assign attr_result = false
.// START: dts0100656086
  .elif(kl == "S_DOM")
    .assign attr_result = false
  .elif(kl == "S_SS")
    .assign attr_result = false
  .elif(kl == "O_OBJ")
    .assign attr_result = false
  .elif(kl == "O_TFR")
    .assign attr_result = false
  .elif(kl == "O_TPARM")
    .assign attr_result = false
  .elif(kl == "SM_ISM")
    .assign attr_result = false
  .elif(kl == "SM_EVT")
    .assign attr_result = false
  .elif(kl == "SM_EVTDI")
    .assign attr_result = false
  .elif(kl == "O_ATTR")
    .assign attr_result = false
  .elif(kl == "O_REF")
    .assign attr_result = false
  .elif(kl == "SM_SEME")
    .assign attr_result = false
  .elif(kl == "S_DPK")
    .assign attr_result = false
  .elif(kl == "SQ_CIP")
    .assign attr_result = false
  .elif(kl == "SQ_CP")
    .assign attr_result = false
  .elif(kl == "SQ_PP")
    .assign attr_result = false
  .elif(kl == "S_FPK")
    .assign attr_result = false
  .elif(kl == "S_EEPK")
    .assign attr_result = false
  .elif(kl == "SQ_S")
    .assign attr_result = false
  .elif(kl == "SQ_FPP")
    .assign attr_result = false
  .elif(kl == "COMM_COMM")
    .assign attr_result = false
  .elif(kl == "UC_UCC")
    .assign attr_result = false
  .elif(kl == "A_A")
    .assign attr_result = false
.// END: dts0100656086
  .end if
.end function
.//
.assign path = "org/xtuml/bp/ui/properties/test"
.assign class_name = "PropertiesViewTest"
//======================================================================
//
// File: ${path}/${class_name}.java
//
// WARNING:      Do not edit this generated file
// Generated by: ${info.arch_file_name}
// Version:      $$Revision: 1.47 $$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
//
// This class is responsible for determing the dependency between
// classes for displaying property changes.
//
package org.xtuml.bp.ui.properties.test;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.junit.Test;
import org.xtuml.bp.core.*;
import org.xtuml.bp.core.common.ClassQueryInterface_c;
import org.xtuml.bp.test.common.BaseTest;
import org.xtuml.bp.ui.properties.*;

public class ${class_name} extends BaseTest
{
    public ${class_name}() {
        super(null, null);
    }
.select many node_set from instances of T_TNS
.for each node in node_set
  .invoke generateTestCase = generateTestCase(node.Key_Lett);
  .if(generateTestCase.result)
    .select any meta_model_obj from instances of O_OBJ where (selected.Key_Lett == node.Key_Lett)
    .invoke formatted_name = get_class_name(meta_model_obj)
    .invoke gia = get_instance_accessor(meta_model_obj)
    @Test
	public void test$r{meta_model_obj.Name}_$r{node.CategoryName}Properties() throws Exception
    {
    .if ( node.Key_Lett == "S_SYS" )
       .// the SystemModel instances are in the default model root
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(Ooaofooa.getDefaultInstance());
    .elif ( node.Key_Lett == "S_DT" )
       .// the instances are loaded in a different order, so search for specific data type
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(Ooaofooa.getDefaultInstance(), new ClassQueryInterface_c() {
            public boolean evaluate(Object candidate) {
                ${formatted_name.body} selected = (${formatted_name.body}) candidate;
                return selected.getName().equals("void");
            }
        });
	.elif(node.Key_Lett == "O_OBJ")
	ModelClass_c inst = ModelClass_c.ModelClassInstance(modelRoot);
	.elif(node.Key_Lett == "SM_STATE")
		StateMachineState_c inst = StateMachineState_c
				..StateMachineStateInstance(modelRoot, new ClassQueryInterface_c() {

					@Override
					public boolean evaluate(Object candidate) {
								ModelClass_c clazz = ModelClass_c
										..getOneO_OBJOnR518(InstanceStateMachine_c
												..getOneSM_ISMOnR517(StateMachine_c
														..getOneSM_SMOnR501((StateMachineState_c) candidate)));
								if(clazz != null && clazz.getName().equals("C class"))
									return true;
								return false;
					}
				});
    .elif((node.Key_Lett == "S_UDT") or (node.Key_Lett == "S_CDT"))
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(Ooaofooa.getDefaultInstance());
    .else
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(modelRoot);
    .end if
        $r{node.CategoryName}${meta_model_obj.Key_Lett}PropertySource ps = new $r{node.categoryName}${meta_model_obj.Key_Lett}PropertySource(inst);
        IPropertyDescriptor [] pd_set = ps.getPropertyDescriptors();
        for ( int i = 0; i < ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}.length; ++i )
        {
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][0], pd_set[i].getClass().getName() );
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1], pd_set[i].getId() );
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][2], pd_set[i].getDisplayName() );
    .select any descrip_attr related by meta_model_obj->O_ATTR[R102] where (selected.name == "Descrip")
    .select any act_attr related by meta_model_obj->O_ATTR[R102] where (selected.name == "Action_Semantics")
    .if ( (not_empty descrip_attr) and (not_empty act_attr) )
            if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Descrip"))
            {
                assertEquals( inst.getDescrip().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Action_Semantics"))
            {
                assertEquals( inst.getAction_semantics().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else
            {
                assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
            }
    .elif ( not_empty descrip_attr )
            if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Descrip"))
            {
                assertEquals( inst.getDescrip().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else
            {
                assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
            }
    .elif ( not_empty act_attr )
            if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Action_Semantics"))
            {
                assertEquals( inst.getAction_semantics().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else
            {
                assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
            }
     .else
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
     .end if
        }
    }
  .end if .// ( node.Key_Lett != "S_EEDI" )
.end for
}
.emit to file "src/${path}/${class_name}.java"
.//
.// Now generate the archetype that will generate the test data!
.//
//======================================================================
//
// File: ${path}/${class_name}Data.java
//
// WARNING:      Do not edit this generated file
// Generated by: $${info.arch_file_name}
// Version:      $$$$Revision: 1.47 $$$$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
///
// This class is responsible for determing the dependency between
// classes for displaying property changes.
//
package org.xtuml.bp.ui.properties.test;

import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

import org.xtuml.bp.ui.properties.ActivityPropertyDescriptor;
import org.xtuml.bp.ui.properties.BooleanPropertyDescriptor;
import org.xtuml.bp.ui.properties.DescriptionPropertyDescriptor;
import org.xtuml.bp.ui.properties.DimensionsPropertyDescriptor;
import org.xtuml.bp.ui.properties.ChooserPropertyDescriptor;
import org.xtuml.bp.ui.properties.EnumPropertyDescriptor;
import org.xtuml.bp.ui.properties.IntegerPropertyDescriptor;
import org.xtuml.bp.ui.properties.ConstantValuePropertyDescriptor;
import org.xtuml.bp.ui.properties.TypeDefinitionPropertyDescriptor;
import org.xtuml.bp.ui.properties.RangeValuePropertyDescriptor.java;

public class ${class_name}Data
{
.for each node in node_set
  .select any meta_model_obj from instances of O_OBJ where (selected.Key_Lett == node.Key_Lett)
  .assign mm_obj_var = "${meta_model_obj.Key_Lett}class"
  .invoke generateTestCase = generateTestCase(node.Key_Lett);
  .if(generateTestCase.result)
	public static final String[][] $r{meta_model_obj.Name}_$r{node.CategoryName} =
      {
    .select many attr_set related by meta_model_obj->O_ATTR[R102]
  .if(node.Key_Lett == "S_DT")
  ..select any ${mm_obj_var} from instances of ${meta_model_obj.Key_Lett} where (selected.Name == "void")
  .elif(node.Key_Lett == "S_UDT")
  ..select any dt from instances of S_DT where (selected.Name == "date")
  ..select one ${mm_obj_var} related by dt->S_UDT[R17];
  .elif(node.Key_Lett == "SM_STATE")
  ..select any cclass from instances of O_OBJ where (selected.Name == "C class")
  ..select any ${mm_obj_var} related by cclass->SM_ISM[R518]->SM_SM[R517]->SM_STATE[R501]
  .else
  ..select any ${mm_obj_var} from instances of ${meta_model_obj.Key_Lett}
  .end if
  .// if the test being generated is for datatype packages
  .// there will be two instances, one for the system level dts and one
  .// for the domain level dts
  .// here we need to use the second as it is the instance that the
  .// test is expecting
  .if(node.Key_Lett == "S_DPK")
  ..select many ${mm_obj_var}s from instances of ${meta_model_obj.Key_Lett}
  ..for each mobj in ${mm_obj_var}s
    ..if(last ${mm_obj_var}s)
      ..assign ${mm_obj_var} = mobj
    ..end if
  ..end for
  .end if
  ..print "Generating class ${meta_model_obj.Name} for $r{node.CategoryName}"
    .for each attr in attr_set
      .if(("$l{attr.Descrip:In Properties}" == "true") or ("$l{attr.Descrip:In Properties}" == ""))
        .select one dt related by attr->S_DT[R114]
        .select one edt related by dt->S_EDT[R17]
        .select one rattr related by attr->O_RATTR[R106]
        .if (((dt.Name != "unique_id") and (empty rattr)) and ("$l{attr.Descrip:User_Visible}" != "false"))
			{
          .assign readonly = "$l{attr.Descrip:readonly}"
          .select one dbattr related by attr->O_BATTR[R106]->O_DBATTR[R107]
          .if ( ((not_empty dbattr) or (readonly == "true")) and (attr.Name != "Action_Semantics") )
            .if ( ("${attr.Descrip:enum0}" == "") and (empty edt) )
                PropertyDescriptor.class.getName(),
            .else
                EnumPropertyDescriptor.class.getName(),
            .end if
          .else
            .if (dt.Name == "boolean" )
               BooleanPropertyDescriptor.class.getName(),
            .elif ((dt.Name == "integer") or (not_empty edt))
              .if ( ("${attr.Descrip:enum0}" == "") and (empty edt) )
               IntegerPropertyDescriptor.class.getName(),
              .else
                EnumPropertyDescriptor.class.getName(),
              .end if
            .elif (dt.Name == "string" )
              .if (attr.Name == "Descrip" )
               DescriptionPropertyDescriptor.class.getName(),
              .elif ( attr.Name == "Action_Semantics" )
               ActivityPropertyDescriptor.class.getName(),
              .elif (( attr.Name == "Dimensions" ) or ( attr.Name == "Return_Dimensions"))
               DimensionsPropertyDescriptor.class.getName(),
              .elif (( attr.Name == "Value" ) and ( node.Key_Lett == "CNST_LSC"))
               ConstantValuePropertyDescriptor.class.getName(),
              .elif (node.Key_Lett == "S_RANGE")
               RangeValuePropertyDescriptor.class.getName(),
              .else
               .//
               .// The default datatype package "Datatypes" has a read-only
               .// name attribute.
               .// This corresponds to the 'canRename' special case in
               .// BuildPropertySource.arc
                 .if ( (meta_model_obj.Key_Lett == "S_DPK") and (attr.Name == "Name") )
               PropertyDescriptor.class.getName(),
                 .else
                   .if(attr.Name == "Definition")
               TypeDefinitionPropertyDescriptor.class.getName(),
                   .else
               TextPropertyDescriptor.class.getName(),
                   .end if
              .end if
            .end if
          .end if
        .end if
				"${attr.Name}",
				"${attr.Descrip:Full Name}",
        .if (attr.Name == "Descrip" )
				"" },
        .elif ( attr.Name == "Action_Semantics" )
				"" },
        .else
          .if ( dt.Name == "boolean" )
            .if((meta_model_obj.Key_Lett == "S_EE") and (attr.Name == "isRealized"))
				"true" },
            .else
				"$$l{${mm_obj_var}.${attr.Name}}" },
		    .end if
		  .elif ( ("${attr.Descrip:enum0}" != "") or (not_empty edt) )
            .if ( attr.Name == "Is_Lbl_U" )
				EnumRangeTest.${meta_model_obj.Key_Lett}_${attr.name}_vals[$${${mm_obj_var}.${attr.Name}}] },
		    .else
				EnumRangeTest.${attr.name}_vals[$${${mm_obj_var}.${attr.Name}}] },
            .end if
          .else
              .if(node.Key_Lett == "SM_NLEVT")
                .if(attr.Name == "Name")
        ..select one smpevt related by ${mm_obj_var}->SM_PEVT[R527]
        ..select any smevt from instances of SM_EVT where ((selected.SMevt_ID == smpevt.SMevt_ID) and (selected.SM_ID == smpevt.SM_ID) and (selected.SMspd_ID == smpevt.SMspd_ID))
        ..select one polyClass related by smevt->SM_SM[R502]->SM_ISM[R517]->O_OBJ[R518]
        ..select any smsevt from instances of SM_SEVT where ((selected.SMevt_ID == ${mm_obj_var}.SMevt_ID) and (selected.SM_ID == ${mm_obj_var}.SM_ID) and (selected.SMspd_ID == ${mm_obj_var}.SMspd_ID))
        ..select any evt from instances of SM_EVT where ((selected.SMevt_ID == smsevt.SMevt_ID) and (selected.SM_ID == smsevt.SM_ID) and (selected.SMspd_ID == smsevt.SMspd_ID))
				"$${evt.Mning}::$${polyClass.Name}" },
                .end if
              .else
				"$${${mm_obj_var}.${attr.Name}}" },
				      .end if
            .end if
          .end if
        .end if
      .end if
    .end for
    .//
    .//  Now do the referential attributes
    .//
    .select many child_specs related by node->T_TPS[R1000] where (selected.ExcludedFromProperties == false)
    .for each child in child_specs
      .select one child_node related by child->T_TNS[R1001]
      .select any child_class from instances of O_OBJ where (selected.Key_Lett == child_node.Key_Lett)
      .assign child_var_name = "${child_class.Key_Lett}class"
  ..select many ${child_var_name}_set related by ${mm_obj_var}${child.ParentChildRelChain}
  ..assign count = 0
.//
  	  .if ((((node.Key_Lett == "S_CDT") or ( node.Key_Lett == "S_UDT")) or (node.Key_Lett == "S_SDT")) and ((child_node.Key_Lett == "S_DT") and (child.NameOnly == "")) )
    //Skipping special case for core data types and user data types.
      .elif ( (node.Key_Lett == "CNST_CSP") and (child_node.Key_Lett == "CNST_LSC") )
    //Skipping special case for constants
  	  .elif (node.Key_Lett == "S_SYS")
    //Skipping special case for System Model
  	 .else
.//
  ..for each ${child_var_name} in ${child_var_name}_set
     	.if ( (child_node.Key_Lett == "S_DT") and (node.Key_Lett != "S_EDT"))
            { ChooserPropertyDescriptor.class.getName(),
            "$r{child_node.CategoryName}",
      .else
            { PropertyDescriptor.class.getName(),
            "$r{child_node.CategoryName}$r{child.NameOnly}.$${count}",
      .end if
      .if ( child.NameOnly != "" )
            "${child.NameOnly}",
      .else
            "${child_class.name}",
      .end if
      .invoke grv = get_ref_value( child_node, child_var_name )
${grv.body}\
    ..assign count = count + 1
  ..end for
  	  .end if
    .end for
      };
  .end if   .// not S_EEDI
.end for
}
..emit to file "src/${path}/${class_name}Data.java"
.emit to file "arc/create_view_test_data.arc"

.//========================================================================
.//
.//File:      $RCSfile: create_view_test.arc,v $
.//Version:   $Revision: 1.47 $
.//Modified:  $Date: 2013/05/12 22:30:18 $
.//
.//(c) Copyright 2006-2014 by Mentor Graphics Corp. All rights reserved.
.//
.//========================================================================
.// Licensed under the Apache License, Version 2.0 (the "License"); you may not
.// use this file except in compliance with the License.  You may obtain a copy
.// of the License at
.//
.//       http://www.apache.org/licenses/LICENSE-2.0
.//
.// Unless required by applicable law or agreed to in writing, software
.// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
.// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
.// License for the specific language governing permissions and limitations under
.// the License.
.//========================================================================
.//
.invoke arc_env = GET_ENV_VAR( "PTC_MC_ARC_DIR" )
.assign mc_archetypes = arc_env.result
.if ( mc_archetypes == "" )
  .print "\nERROR: Environment variable PTC_MC_ARC_DIR not set."
  .exit 100
.end if
.//
.include "${mc_archetypes}/arch_utils.inc"
.function get_ref_value
  .param inst_ref child_node   .// T_TNS
  .param string child_var_name
  .//
  .if ( child_node.Key_Lett == "R_REL" )
            "R$${${child_var_name}.Numb}" },
  .elif ( child_node.Key_Lett == "O_IOBJ" )
    ..select one obj related by O_IOBJclass->O_OBJ[R101]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "SM_ASM" )
            "$${O_OBJclass.Name}" },
  .elif ( child_node.Key_Lett == "SM_ISM" )
            "$${O_OBJclass.Name}" },
  .elif ( child_node.Key_Lett == "SM_PEVT" )
     ..assign result = SM_PEVTclass.localEventMning;
     ..if(result == "")
       ..assign result = "test_poly"
     ..end if
            "$${result}" },
  .elif(child_node.Key_Lett == "SM_NLEVT")
            "test_sm::B Class" },
  .elif(child_node.Key_Lett == "SM_TXN")
            "test_sm::B Class" },
  .elif ( child_node.Key_Lett == "O_RTIDA" )
     ..select one cia related by O_RTIDAclass->O_OIDA[R110]
     ..select one assoc related by O_RTIDAclass->R_RTO[R110]->R_OIR[R203]->R_REL[R201]
     ..assign attrName = cia.localAttributeName;
     ..if(attrName == "")
       ..assign attrName = "id"
     ..end if
     ..assign result = attrName + " {R"
     ..assign result = result + "$${assoc.Numb}"
     ..assign result = result + "}"
            "$${result}" },
  .elif ( child_node.Key_Lett == "SM_SM" )
    ..select one obj related by SM_SMclass->SM_ISM[R517]->O_OBJ[R518]
    ..if ( not_empty obj )
            "$${obj.Name}" },
    ..else
      ..select one obj related by SM_SMclass->SM_ASM[R517]->O_OBJ[R519]
            "$${obj.Name}" },
    ..end if
  .elif ( child_node.Key_Lett == "SM_SUPDT")
    ..select many edi_set related by ${child_var_name}->SM_SDI[R522]->SM_EVTDI[R522];
    ..assign result = "("
    ..assign first = true
    ..for each edi in edi_set
      ..if ( not first )
        ..assign result = result + ","
      ..end if
      ..assign result = result + edi.Name
      ..assign first = false
    ..end for
            "$${result}" + ")" },
  .elif ( child_node.Key_Lett == "SM_EVT" )
    ..select any smsevt from instances of SM_SEVT where ((selected.SMevt_ID == SM_EVTclass.SMevt_ID) and (selected.SM_ID == SM_EVTclass.SM_ID) and (selected.SMspd_ID == SM_EVTclass.SMspd_ID))
    ..select one nlevt related by smsevt->SM_NLEVT[R526]
    ..if(not_empty nlevt)
      ..select one smpevt related by nlevt->SM_PEVT[R527]
      ..select any smevt from instances of SM_EVT where ((selected.SMevt_ID == smpevt.SMevt_ID) and (selected.SM_ID == smpevt.SM_ID) and (selected.SMspd_ID == smpevt.SMspd_ID))
      ..select one obj related by smevt->SM_SM[R502]->SM_ISM[R517]->O_OBJ[R518]
            "$${SM_EVTclass.Mning}::$${obj.Name}" },
    ..else
      ..select one obj related by SM_EVTclass->SM_SM[R502]->SM_ISM[R517]->O_OBJ[R518]
      ..if ( not_empty obj )
            "$${SM_EVTclass.Drv_Lbl}: $${SM_EVTclass.Mning}" },
      ..else
        ..select one obj related by SM_EVTclass->SM_SM[R502]->SM_ASM[R517]->O_OBJ[R519]
            "$${SM_EVTclass.Drv_Lbl}: $${SM_EVTclass.Mning}" },
      ..end if
    ..end if
  .elif ( child_node.Key_Lett == "SM_SEME" )
            "State Event Matrix Entry (test_poly::B Class)" },
  .elif ( child_node.Key_Lett == "SM_ACT" )
      ..select one state related by SM_ACTclass->SM_AH[R514]->SM_MOAH[R513]->SM_STATE[R511]
      ..if(empty state)
            "Transition Action" },
      ..else
            "State Action" },
      ..end if
  .elif ( child_node.Key_Lett == "O_ID" )
      ..assign id_val = O_IDclass.Oid_ID + 1
              "*$${id_val}" },
  .elif ( child_node.Key_Lett == "S_CDT" )
      ..select one dt related by S_CDTclass->S_DT[R17]
            "$${dt.Name}" },
  .elif ( child_node.Key_Lett == "S_EEEVT" )
      ..select one ee related by S_EEEVTclass->S_EE[R10]
            "$${ee.Name}.$${S_EEEVTclass.Drv_Lbl}" },
  .elif ( child_node.Key_Lett == "R_PART" )
      ..select one obj related by R_PARTclass->R_RTO[R204]->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "R_FORM" )
      ..select one obj related by R_FORMclass->R_RGO[R205]->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "SM_CH" )
      ..select one smsevt related by SM_CHclass->SM_SEME[R504]->SM_SEVT[R503]
      ..select any evt from instances of SM_EVT where ((selected.SMevt_ID == smsevt.SMevt_ID) and (selected.SM_ID == smsevt.SM_ID) and (selected.SMspd_ID == smsevt.SMspd_ID))
      ..select one state related by SM_CHclass->SM_SEME[R504]->SM_STATE[R503]
            "$${evt.Drv_Lbl}/$${state.Name}" },
  .elif ( child_node.Key_Lett == "R_CONE" )
      ..select one obj related by R_CONEclass->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "R_COTH" )
      ..select one obj related by R_COTHclass->R_OIR[R203]->O_OBJ[R201]
            "$${obj.Name}" },
  .elif ( child_node.Key_Lett == "SM_SDI" )
      ..select one edi related by SM_SDIclass->SM_EVTDI[R522]
            "$${edi.Name}" },
  .elif ( child_node.Key_Lett == "S_UDT" )
  	..select any dt related by S_UDTclass->S_DT[R17]
  			"$${dt.Name}" },
  .elif ( child_node.Key_Lett == "S_SDT" )
  	..select any dt related by S_SDTclass->S_DT[R17]
  			"$${dt.Name}" },
  .elif ( child_node.Key_Lett == "S_EDT" )
  	..select any dt related by S_EDTclass->S_DT[R17]
  			"$${dt.Name}" },
  .elif(((child_node.Key_Lett == "SQ_CP") or (child_node.Key_Lett == "MSG_A")) or (child_node.Key_Lett == "SQ_AV"))
    				"$${${child_var_name}.InformalName}" },
  .elif((child_node.Key_Lett == "MSG_SM") or (child_node.Key_Lett == "MSG_AM"))
        "$${${child_var_name}.InformalName}" },
  .elif(child_node.Key_Lett == "MSG_ISM")
    ..select one sm related by ${child_var_name}->MSG_SM[R1020]
        "$${sm.InformalName}" },
  .elif(child_node.Key_Lett == "MSG_IAM")
    ..select one am related by ${child_var_name}->MSG_AM[R1019]
        "$${am.InformalName}" },
  .elif ( child_node.Key_Lett == "A_FJ" )
  			"$${${child_var_name}.GuardCondition}" },
  .elif ( child_node.Key_Lett == "A_DM" )
  			"$${${child_var_name}.DecisionInput}" },
  .elif ( child_node.Key_Lett == "A_E" )
  			"$${${child_var_name}.Guard}" },
  .else
            "$${${child_var_name}.Name}" },
  .end if
.end function
.function generateTestCase
  .param String kl
  .assign attr_result = true
  .if(kl == "S_EEDI")
    .assign attr_result = false
  .elif(kl == "CP_CP")
    .assign attr_result = false
  .elif(kl == "C_SF")
    .assign attr_result = false
  .elif(kl == "O_OIDA")
    .assign attr_result = false
  .elif(kl == "EP_PKG")
    .assign attr_result = false
  .elif(kl == "IP_IP")
    .assign attr_result = false
  .elif(kl == "C_C")
    .assign attr_result = false
  .elif(kl == "CL_IP")
    .assign attr_result = false
  .elif(kl == "CL_IR")
    .assign attr_result = false
  .elif(kl == "C_I")
    .assign attr_result = false
  .elif(kl == "C_P")
    .assign attr_result = false
  .elif(kl == "C_R")
    .assign attr_result = false
  .elif(kl == "C_AS")
    .assign attr_result = false
  .elif(kl == "C_IO")
    .assign attr_result = false
  .elif(kl == "C_DG")
    .assign attr_result = false
  .elif(kl == "C_PO")
    .assign attr_result = false
  .elif(kl == "C_PP")
    .assign attr_result = false
  .elif(kl == "CL_IC")
    .assign attr_result = false
  .elif(kl == "SPR_RO")
    .assign attr_result = false
  .elif(kl == "SPR_PO")
    .assign attr_result = false
  .elif(kl == "SPR_RS")
    .assign attr_result = false
  .elif(kl == "SPR_PS")
    .assign attr_result = false
  .elif(kl == "I_INS")
    .assign attr_result = false
  .elif(kl == "I_AVL")
    .assign attr_result = false
  .elif(kl == "I_EVI")
    .assign attr_result = false
  .elif(kl == "RV_RVL")
    .assign attr_result = false
  .elif(kl == "I_EXE")
    .assign attr_result = false
  .elif(kl == "I_LIP")
    .assign attr_result = false
  .elif(kl == "CSME_CIE")
    .assign attr_result = false
  .elif(kl == "SM_CRTXN")
    .assign attr_result = false
   .elif(kl == "CL_POR")
    .assign attr_result = false
  .elif(kl == "SM_STATE")
    .// Test case commented out, see DEI 8588
    .assign attr_result = false
  .elif(kl == "SM_TXN")
    .// Test case commented out, see DEI 8588
    .assign attr_result = false
.// START: dts0100656086
  .elif(kl == "S_DOM")
    .assign attr_result = false
  .elif(kl == "S_SS")
    .assign attr_result = false
  .elif(kl == "O_OBJ")
    .assign attr_result = false
  .elif(kl == "O_TFR")
    .assign attr_result = false
  .elif(kl == "O_TPARM")
    .assign attr_result = false
  .elif(kl == "SM_ISM")
    .assign attr_result = false
  .elif(kl == "SM_EVT")
    .assign attr_result = false
  .elif(kl == "SM_EVTDI")
    .assign attr_result = false
  .elif(kl == "O_ATTR")
    .assign attr_result = false
  .elif(kl == "O_REF")
    .assign attr_result = false
  .elif(kl == "SM_SEME")
    .assign attr_result = false
  .elif(kl == "S_DPK")
    .assign attr_result = false
  .elif(kl == "SQ_CIP")
    .assign attr_result = false
  .elif(kl == "SQ_CP")
    .assign attr_result = false
  .elif(kl == "SQ_PP")
    .assign attr_result = false
  .elif(kl == "S_FPK")
    .assign attr_result = false
  .elif(kl == "S_EEPK")
    .assign attr_result = false
  .elif(kl == "SQ_S")
    .assign attr_result = false
  .elif(kl == "SQ_FPP")
    .assign attr_result = false
  .elif(kl == "COMM_COMM")
    .assign attr_result = false
  .elif(kl == "UC_UCC")
    .assign attr_result = false
  .elif(kl == "A_A")
    .assign attr_result = false
.// END: dts0100656086
  .end if
.end function
.//
.assign path = "org/xtuml/bp/ui/properties/test"
.assign class_name = "PropertiesViewTest"
//======================================================================
//
// File: ${path}/${class_name}.java
//
// WARNING:      Do not edit this generated file
// Generated by: ${info.arch_file_name}
// Version:      $$Revision: 1.47 $$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
//
// This class is responsible for determing the dependency between
// classes for displaying property changes.
//
package org.xtuml.bp.ui.properties.test;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.junit.Test;
import org.xtuml.bp.core.*;
import org.xtuml.bp.core.common.ClassQueryInterface_c;
import org.xtuml.bp.test.common.BaseTest;
import org.xtuml.bp.ui.properties.*;

public class ${class_name} extends BaseTest
{
    public ${class_name}() {
        super(null, null);
    }
.select many node_set from instances of T_TNS
.for each node in node_set
  .invoke generateTestCase = generateTestCase(node.Key_Lett);
  .if(generateTestCase.result)
    .select any meta_model_obj from instances of O_OBJ where (selected.Key_Lett == node.Key_Lett)
    .invoke formatted_name = get_class_name(meta_model_obj)
    .invoke gia = get_instance_accessor(meta_model_obj)
    @Test
	public void test$r{meta_model_obj.Name}_$r{node.CategoryName}Properties() throws Exception
    {
    .if ( node.Key_Lett == "S_SYS" )
       .// the SystemModel instances are in the default model root
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(Ooaofooa.getDefaultInstance());
    .elif ( node.Key_Lett == "S_DT" )
       .// the instances are loaded in a different order, so search for specific data type
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(Ooaofooa.getDefaultInstance(), new ClassQueryInterface_c() {
            public boolean evaluate(Object candidate) {
                ${formatted_name.body} selected = (${formatted_name.body}) candidate;
                return selected.getName().equals("void");
            }
        });
	.elif(node.Key_Lett == "O_OBJ")
	ModelClass_c inst = ModelClass_c.ModelClassInstance(modelRoot);
	.elif(node.Key_Lett == "SM_STATE")
		StateMachineState_c inst = StateMachineState_c
				..StateMachineStateInstance(modelRoot, new ClassQueryInterface_c() {

					@Override
					public boolean evaluate(Object candidate) {
								ModelClass_c clazz = ModelClass_c
										..getOneO_OBJOnR518(InstanceStateMachine_c
												..getOneSM_ISMOnR517(StateMachine_c
														..getOneSM_SMOnR501((StateMachineState_c) candidate)));
								if(clazz != null && clazz.getName().equals("C class"))
									return true;
								return false;
					}
				});
    .elif((node.Key_Lett == "S_UDT") or (node.Key_Lett == "S_CDT"))
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(Ooaofooa.getDefaultInstance());
    .else
        ${formatted_name.body} inst = ${formatted_name.body}.${gia.body}(modelRoot);
    .end if
        $r{node.CategoryName}${meta_model_obj.Key_Lett}PropertySource ps = new $r{node.categoryName}${meta_model_obj.Key_Lett}PropertySource(inst);
        IPropertyDescriptor [] pd_set = ps.getPropertyDescriptors();
        for ( int i = 0; i < ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}.length; ++i )
        {
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][0], pd_set[i].getClass().getName() );
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1], pd_set[i].getId() );
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][2], pd_set[i].getDisplayName() );
    .select any descrip_attr related by meta_model_obj->O_ATTR[R102] where (selected.name == "Descrip")
    .select any act_attr related by meta_model_obj->O_ATTR[R102] where (selected.name == "Action_Semantics")
    .if ( (not_empty descrip_attr) and (not_empty act_attr) )
            if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Descrip"))
            {
                assertEquals( inst.getDescrip().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Action_Semantics"))
            {
                assertEquals( inst.getAction_semantics().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else
            {
                assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
            }
    .elif ( not_empty descrip_attr )
            if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Descrip"))
            {
                assertEquals( inst.getDescrip().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else
            {
                assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
            }
    .elif ( not_empty act_attr )
            if ( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][1].equals("Action_Semantics"))
            {
                assertEquals( inst.getAction_semantics().replace('\n','/'), ps.getPropertyValue(pd_set[i].getId()));
            }
            else
            {
                assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
            }
     .else
            assertEquals( ${class_name}Data.$r{meta_model_obj.Name}_$r{node.CategoryName}[i][3], ps.getPropertyValue(pd_set[i].getId()).toString());
     .end if
        }
    }
  .end if .// ( node.Key_Lett != "S_EEDI" )
.end for
}
.emit to file "src/${path}/${class_name}.java"
.//
.// Now generate the archetype that will generate the test data!
.//
//======================================================================
//
// File: ${path}/${class_name}Data.java
//
// WARNING:      Do not edit this generated file
// Generated by: $${info.arch_file_name}
// Version:      $$$$Revision: 1.47 $$$$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
///
// This class is responsible for determing the dependency between
// classes for displaying property changes.
//
package org.xtuml.bp.ui.properties.test;

import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

import org.xtuml.bp.ui.properties.ActivityPropertyDescriptor;
import org.xtuml.bp.ui.properties.BooleanPropertyDescriptor;
import org.xtuml.bp.ui.properties.DescriptionPropertyDescriptor;
import org.xtuml.bp.ui.properties.DimensionsPropertyDescriptor;
import org.xtuml.bp.ui.properties.ChooserPropertyDescriptor;
import org.xtuml.bp.ui.properties.EnumPropertyDescriptor;
import org.xtuml.bp.ui.properties.IntegerPropertyDescriptor;
import org.xtuml.bp.ui.properties.ConstantValuePropertyDescriptor;
import org.xtuml.bp.ui.properties.TypeDefinitionPropertyDescriptor;

public class ${class_name}Data
{
.for each node in node_set
  .select any meta_model_obj from instances of O_OBJ where (selected.Key_Lett == node.Key_Lett)
  .assign mm_obj_var = "${meta_model_obj.Key_Lett}class"
  .invoke generateTestCase = generateTestCase(node.Key_Lett);
  .if(generateTestCase.result)
	public static final String[][] $r{meta_model_obj.Name}_$r{node.CategoryName} =
      {
    .select many attr_set related by meta_model_obj->O_ATTR[R102]
  .if(node.Key_Lett == "S_DT")
  ..select any ${mm_obj_var} from instances of ${meta_model_obj.Key_Lett} where (selected.Name == "void")
  .elif(node.Key_Lett == "S_UDT")
  ..select any dt from instances of S_DT where (selected.Name == "date")
  ..select one ${mm_obj_var} related by dt->S_UDT[R17];
  .elif(node.Key_Lett == "SM_STATE")
  ..select any cclass from instances of O_OBJ where (selected.Name == "C class")
  ..select any ${mm_obj_var} related by cclass->SM_ISM[R518]->SM_SM[R517]->SM_STATE[R501]
  .else
  ..select any ${mm_obj_var} from instances of ${meta_model_obj.Key_Lett}
  .end if
  .// if the test being generated is for datatype packages
  .// there will be two instances, one for the system level dts and one
  .// for the domain level dts
  .// here we need to use the second as it is the instance that the
  .// test is expecting
  .if(node.Key_Lett == "S_DPK")
  ..select many ${mm_obj_var}s from instances of ${meta_model_obj.Key_Lett}
  ..for each mobj in ${mm_obj_var}s
    ..if(last ${mm_obj_var}s)
      ..assign ${mm_obj_var} = mobj
    ..end if
  ..end for
  .end if
  ..print "Generating class ${meta_model_obj.Name} for $r{node.CategoryName}"
    .for each attr in attr_set
      .if(("$l{attr.Descrip:In Properties}" == "true") or ("$l{attr.Descrip:In Properties}" == ""))
        .select one dt related by attr->S_DT[R114]
        .select one edt related by dt->S_EDT[R17]
        .select one rattr related by attr->O_RATTR[R106]
        .if (((dt.Name != "unique_id") and (empty rattr)) and ("$l{attr.Descrip:User_Visible}" != "false"))
			{
          .assign readonly = "$l{attr.Descrip:readonly}"
          .select one dbattr related by attr->O_BATTR[R106]->O_DBATTR[R107]
          .if ( ((not_empty dbattr) or (readonly == "true")) and (attr.Name != "Action_Semantics") )
            .if ( ("${attr.Descrip:enum0}" == "") and (empty edt) )
                PropertyDescriptor.class.getName(),
            .else
                EnumPropertyDescriptor.class.getName(),
            .end if
          .else
            .if (dt.Name == "boolean" )
               BooleanPropertyDescriptor.class.getName(),
            .elif ((dt.Name == "integer") or (not_empty edt))
              .if ( ("${attr.Descrip:enum0}" == "") and (empty edt) )
               IntegerPropertyDescriptor.class.getName(),
              .else
                EnumPropertyDescriptor.class.getName(),
              .end if
            .elif (dt.Name == "string" )
              .if (attr.Name == "Descrip" )
               DescriptionPropertyDescriptor.class.getName(),
              .elif ( attr.Name == "Action_Semantics" )
               ActivityPropertyDescriptor.class.getName(),
              .elif (( attr.Name == "Dimensions" ) or ( attr.Name == "Return_Dimensions"))
               DimensionsPropertyDescriptor.class.getName(),
              .elif (( attr.Name == "Value" ) and ( node.Key_Lett == "CNST_LSC"))
               ConstantValuePropertyDescriptor.class.getName(),
              .else
               .//
               .// The default datatype package "Datatypes" has a read-only
               .// name attribute.
               .// This corresponds to the 'canRename' special case in
               .// BuildPropertySource.arc
                 .if ( (meta_model_obj.Key_Lett == "S_DPK") and (attr.Name == "Name") )
               PropertyDescriptor.class.getName(),
                 .else
                   .if(attr.Name == "Definition")
               TypeDefinitionPropertyDescriptor.class.getName(),
                   .else
               TextPropertyDescriptor.class.getName(),
                   .end if
              .end if
            .end if
          .end if
        .end if
				"${attr.Name}",
				"${attr.Descrip:Full Name}",
        .if (attr.Name == "Descrip" )
				"" },
        .elif ( attr.Name == "Action_Semantics" )
				"" },
        .else
          .if ( dt.Name == "boolean" )
            .if((meta_model_obj.Key_Lett == "S_EE") and (attr.Name == "isRealized"))
				"true" },
            .else
				"$$l{${mm_obj_var}.${attr.Name}}" },
		    .end if
		  .elif ( ("${attr.Descrip:enum0}" != "") or (not_empty edt) )
            .if ( attr.Name == "Is_Lbl_U" )
				EnumRangeTest.${meta_model_obj.Key_Lett}_${attr.name}_vals[$${${mm_obj_var}.${attr.Name}}] },
		    .else
				EnumRangeTest.${attr.name}_vals[$${${mm_obj_var}.${attr.Name}}] },
            .end if
          .else
              .if(node.Key_Lett == "SM_NLEVT")
                .if(attr.Name == "Name")
        ..select one smpevt related by ${mm_obj_var}->SM_PEVT[R527]
        ..select any smevt from instances of SM_EVT where ((selected.SMevt_ID == smpevt.SMevt_ID) and (selected.SM_ID == smpevt.SM_ID) and (selected.SMspd_ID == smpevt.SMspd_ID))
        ..select one polyClass related by smevt->SM_SM[R502]->SM_ISM[R517]->O_OBJ[R518]
        ..select any smsevt from instances of SM_SEVT where ((selected.SMevt_ID == ${mm_obj_var}.SMevt_ID) and (selected.SM_ID == ${mm_obj_var}.SM_ID) and (selected.SMspd_ID == ${mm_obj_var}.SMspd_ID))
        ..select any evt from instances of SM_EVT where ((selected.SMevt_ID == smsevt.SMevt_ID) and (selected.SM_ID == smsevt.SM_ID) and (selected.SMspd_ID == smsevt.SMspd_ID))
				"$${evt.Mning}::$${polyClass.Name}" },
                .end if
              .else
				"$${${mm_obj_var}.${attr.Name}}" },
				      .end if
            .end if
          .end if
        .end if
      .end if
    .end for
    .//
    .//  Now do the referential attributes
    .//
    .select many child_specs related by node->T_TPS[R1000] where (selected.ExcludedFromProperties == false)
    .for each child in child_specs
      .select one child_node related by child->T_TNS[R1001]
      .select any child_class from instances of O_OBJ where (selected.Key_Lett == child_node.Key_Lett)
      .assign child_var_name = "${child_class.Key_Lett}class"
  ..select many ${child_var_name}_set related by ${mm_obj_var}${child.ParentChildRelChain}
  ..assign count = 0
.//
  	  .if ((((node.Key_Lett == "S_CDT") or ( node.Key_Lett == "S_UDT")) or (node.Key_Lett == "S_SDT")) and ((child_node.Key_Lett == "S_DT") and (child.NameOnly == "")) )
    //Skipping special case for core data types and user data types.
      .elif ( (node.Key_Lett == "CNST_CSP") and (child_node.Key_Lett == "CNST_LSC") )
    //Skipping special case for constants
  	  .elif (node.Key_Lett == "S_SYS")
    //Skipping special case for System Model
  	 .else
.//
  ..for each ${child_var_name} in ${child_var_name}_set
     	.if ( (child_node.Key_Lett == "S_DT") and (node.Key_Lett != "S_EDT"))
            { ChooserPropertyDescriptor.class.getName(),
            "$r{child_node.CategoryName}",
      .else
            { PropertyDescriptor.class.getName(),
            "$r{child_node.CategoryName}$r{child.NameOnly}.$${count}",
      .end if
      .if ( child.NameOnly != "" )
            "${child.NameOnly}",
      .else
            "${child_class.name}",
      .end if
      .invoke grv = get_ref_value( child_node, child_var_name )
${grv.body}\
    ..assign count = count + 1
  ..end for
  	  .end if
    .end for
      };
  .end if   .// not S_EEDI
.end for
}
..emit to file "src/${path}/${class_name}Data.java"
.emit to file "arc/create_view_test_data.arc"


job #8442 - Move nested for loop out to be a sibling for loop.  The nested loop did not need to be nested, and in fact, was not being processed because the set of elements in the outer loop was being processed in a different order than old generator.  When I move the loop out, the generated code is identical between new and old generator.

.//=====================================================================
.//
.// File:      $RCSfile: create_modeladapter_java.arc,v $
.// Version:   $Revision: 1.20 $
.// Modified:  $Date: 2013/01/17 03:28:52 $
.//
.// (c) Copyright 2004-2014 by Mentor Graphics Corp. All rights reserved.
.//
.//=====================================================================
.// Licensed under the Apache License, Version 2.0 (the "License"); you may not
.// use this file except in compliance with the License.  You may obtain a copy
.// of the License at
.//
.//      http://www.apache.org/licenses/LICENSE-2.0
.//
.// Unless required by applicable law or agreed to in writing, software
.// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
.// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
.// License for the specific language governing permissions and limitations under
.// the License.
.//=====================================================================
.//
.// This archetype is responsible for creating the ModelAdapter.java
.// file for org.xtuml.bp.ui.text.
.//
.// Get the file contents
.//
.invoke arc_env = GET_ENV_VAR( "PTC_MC_ARC_DIR" )
.assign mc_archetypes = arc_env.result
.if ( mc_archetypes == "" )
  .print "\nERROR: Environment variable PTC_MC_ARC_DIR not set."
  .exit 100
.end if
.//
.include "${mc_archetypes}/arch_utils.inc"
.include "arc/create_util.inc"
.//
.assign core_package = "org.xtuml.bp.core"
.assign path = "org.xtuml.bp.ui.text"
.//
.invoke result = get_editor_obj_set()
.assign dsc_obj_set = result.dsc_obj_set
.assign oal_obj_set = result.oal_obj_set
.assign both_obj_set = result.both_obj_set
.assign both_source_set = result.dsc_source_set | result.oal_source_set
.assign all_set = both_obj_set | both_source_set
.assign oal_set = result.oal_source_set | oal_obj_set
.invoke result = get_model_adapter_class_name()
.assign modelAdapterClass = result.class_name
.invoke result = get_test_class_name()
.assign interfacename = result.body
.//
//======================================================================
//
// File: ${path}/${modelAdapterClass}.java
//
// WARNING:      Do not edit this generated file
// Generated by: ${info.arch_file_name}
// Version:      $$Revision: 1.20 $$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
//
// This class handles the input to the Description and Activity
// text editors.
//
package ${path};
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;

import org.xtuml.bp.core.*;
import org.xtuml.bp.core.common.*;
import org.xtuml.bp.core.inspector.IModelClassInspector;
import org.xtuml.bp.core.inspector.ModelInspector;

public class ${modelAdapterClass}
{
  private ${modelAdapterClass}() {};
  protected static String getName(Object input) {
	String result = ""; //$$NON-NLS-1$$
	Class inputClass = input.getClass();
	Class[] type = new Class[0];
	Method getName = null;
	try {
		getName = inputClass.getMethod("Get_label", type); //$$NON-NLS-1$$
	} catch (NoSuchMethodException e1) {
			try {
		getName = inputClass.getMethod("getName", type); //$$NON-NLS-1$$
			} catch (NoSuchMethodException e2) {
		// There is no accessor, try an explicit operation . . .
		try {
			getName = inputClass.getMethod("Get_name", type); //$$NON-NLS-1$$
				} catch (NoSuchMethodException e3) {
					TextPlugin.logError("Class does not implement any name accessor", e3); //$$NON-NLS-1$$
		}
	    }
    }
    if ( getName != null )
    {
		try {
		  Object[] args = new Object[0];
		  result = (String) getName.invoke(input, args);
		} catch (InvocationTargetException e) {
		  TextPlugin.logError("Invocation Target exception in getName", e); //$$NON-NLS-1$$
		} catch (IllegalAccessException e) {
          TextPlugin.logError("Illegal Access exception in getName", e); //$$NON-NLS-1$$
		}
        return result;
	}
	else
	{
	  return null;
	}
  }

  public static interface IModelElementAdapter {
	public ModelElementID createModelElementID(NonRootModelElement modelElement);
	public NonRootModelElement resolveModelElement(ModelElementID modelElementID);
    public String getName(NonRootModelElement modelElement);
  }

  static Map adapterRegistry = new HashMap();

  public static IModelElementAdapter getModelElementAdapter(NonRootModelElement modelElement){
    if (modelElement == null){
        throw new IllegalArgumentException("modelElement cannot be null"); //$$NON-NLS-1$$
    }
    return getModelElementAdapter(modelElement.getClass().getName());
  }

  public static IModelElementAdapter getModelElementAdapter(String type){
    return (IModelElementAdapter)adapterRegistry.get(type);
  }

  static{
.for each obj in all_set
  .invoke result = get_class_name(obj)
  .assign classname = result.body
    adapterRegistry.put("${core_package}.${classname}", new ${classname}Adapter()); //$$NON-NLS-1$$
.end for
  }

.for each obj in all_set
  .invoke result = get_class_name(obj)
  .assign classname = result.body
  .invoke result = get_query_class_name(obj)
  .assign testclass = result.body
  .invoke result = get_test_class_name()
  .assign interfacename = result.body
  .invoke result = get_instance_accessor(obj)
  .assign instancename = result.body
  .invoke result = get_id_attr_set(obj)
  .assign id_attr_set = result.attr_set

  public static final class ${classname}Adapter implements IModelElementAdapter{
    public ModelElementID createModelElementID(NonRootModelElement modelElement){
       if(!(modelElement instanceof ${classname})){
         throw new IllegalArgumentException("Model element is not of type ${classname}"); //$$NON-NLS-1$$
       }

       ModelElementID id = (new ${testclass}((${classname})modelElement)).createModelElementID();
       id.modelElement = modelElement;
       id.modelRoot = (Ooaofooa)(modelElement.getModelRoot());
       // update the cached name
       id.getLastValidName();
       return id;
    }

    public NonRootModelElement resolveModelElement(ModelElementID modelElementID){
        if(!"${core_package}.${classname}".equals(modelElementID.getType())){ //$$NON-NLS-1$$
          throw new IllegalArgumentException("Given ModelElementID does not represent type ${classname}" ); //$$NON-NLS-1$$
        }

        Ooaofooa modelRoot = Ooaofooa.getInstance(modelElementID.getModelRootID(), false);
        if(modelRoot == null){
             return null;
        }

        String componentPath = modelElementID.getComponentPath();
        if(componentPath != null){
            IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(componentPath));
            try {
                // if the resource tree isn't locked, then we can do a refresh
                // the resource tree has locking conflicts during unit tests,
                // so only check this if we are running a unit test
                if ( !ResourcesPlugin.getWorkspace().isTreeLocked()) {
                    f.refreshLocal(0, new NullProgressMonitor());
                }
            } catch (CoreException e) {
                TextPlugin.logError("Unable to refresh component file", e);
            }
            if (!f.exists())
            {
                return null;
            }
            else
            {
                PersistenceManager.getDefaultInstance().loadAndFinishComponent(componentPath);
                PersistableModelComponent pmc = PersistenceManager.findComponent(new Path(componentPath));
                if (pmc == null) {
                    return null;
                }
            }
        }
        return ${classname}.${instancename}(modelRoot, new ${testclass}(modelElementID));
    }

	.assign found = false
	.assign is_oal = false;
	.select many attr_set related by obj->O_ATTR[R102]
    .select any attr from instances of O_ATTR where (false)
	.for each attr in attr_set
	  .if ("$l{attr.name}" == "name")
	    .assign found = true
	    .break for
	  .end if
	.end for
	.for each oal in oal_set
	  .if ( obj.Key_Lett == oal.Key_Lett)
	  	.assign is_oal = true;
	  .end if
	.end for
	.if (not found )
	private static String m_getNameValid = "no"; //$$NON-NLS-1$$
	.end if
	public final String getName(NonRootModelElement modelElement)
	{
	  if(modelElement == null){
	    return "${obj.Name}";
	  }
	  if(!(modelElement instanceof ${classname})){
	    throw new IllegalArgumentException("argument should be instanceof ${classname}"); //$$NON-NLS-1$$
	  }
	  ${classname} obj = (${classname})modelElement;
	.if (found)
	  .if (is_oal)
		try{
	  	ModelInspector inspector = new ModelInspector();
		IModelClassInspector elementInspector = inspector.getInspector(obj .getClass());
			NonRootModelElement parent = (NonRootModelElement) elementInspector .getParent(obj);
	    .if (((obj.Key_Lett == "SPR_RO") or (obj.Key_Lett == "SPR_RS")) or ((obj.Key_Lett == "SPR_PO") or (obj.Key_Lett == "SPR_PS")) )
	    .// return the Port as parent instead of interface reference for interface operations and signals instead of Interface Reference
	    	elementInspector = inspector.getInspector(parent.getClass());
			parent = (NonRootModelElement) elementInspector .getParent(parent);
		.end if
	    return parent.getName() + "::" + obj.get$cr{attr.name}(); //$$NON-NLS-1$$
		}catch(Exception e){
			return obj.get$cr{attr.name}(); //  Return the element name if the parent element is not found
		}
	  .else
	  return obj.get$cr{attr.name}(); //$$NON-NLS-1$$
	  .end if
	.else
	  if ( m_getNameValid != null && m_getNameValid.equals("no") ) //$$NON-NLS-1$$
	  {
	    m_getNameValid = ModelAdapter.getName( obj );
	    if ( m_getNameValid != null )
		  m_getNameValid = "yes"; //$$NON-NLS-1$$
	  }
	  if ( m_getNameValid != null && m_getNameValid.equals("yes") ) //$$NON-NLS-1$$
	  .if (is_oal)
	  	{
	  	try{
	  	ModelInspector inspector = new ModelInspector();
		IModelClassInspector elementInspector = inspector.getInspector(obj .getClass());
		NonRootModelElement parent = (NonRootModelElement) elementInspector .getParent(obj);
	    .if (obj.Key_Lett == "SM_TXN")
	    	.// Return the model class as parent for transition
	    	elementInspector = inspector.getInspector(parent.getClass());
			parent = (NonRootModelElement) elementInspector .getParent(parent);
	    .end if
	    return parent.getName() + "::" + ModelAdapter.getName( obj ); //$$NON-NLS-1$$
	    }catch(Exception e){
			return ModelAdapter.getName( obj ); //  Return the element name if the parent element is not found
		}
		}
	  .else
	    return ModelAdapter.getName( obj );
	  .end if
	  else
	    return "UNKNOWN";
	.end if
	}
  }

  public static final class ${testclass}
    implements ${interfacename}
  {
    private final static String type = "${core_package}.${classname}"; //$$NON-NLS-1$$
    private String modelRootID = null;
    private String componentPath;
  .for each attr in id_attr_set
    .invoke result = get_core_datatype(attr)
    .assign cdt = result.cdt
    .if (cdt.core_typ == 2)
    private long $cr{attr.name} = 0;
    .elif (cdt.core_typ == 5)
    private UUID $cr{attr.name} = IdAssigner.NULL_UUID;
    .elif (cdt.core_typ == 4)
    private String $cr{attr.name} = ""; //$$NON-NLS-1$$
    .else
      .print "Invalid datatype for attribute ${obj.name}.${attr.name}"
    private Xxxxxx $cr{attr.name};
    .end if
  .end for
    public ${testclass}(${classname} inst)
    {
      modelRootID = inst.getModelRoot().getId();
      componentPath = inst.getContent();
  .for each attr in id_attr_set
      .select one rattr related by attr->O_RATTR[R106]
      .if(not_empty rattr)
         $cr{attr.name} = inst.get$cr{attr.name}();
         if(IdAssigner.NULL_UUID.equals($cr{attr.name}))
         {
            $cr{attr.name} = inst.get$cr{attr.name}CachedValue();
         }
      .else
        $cr{attr.name} = inst.get$cr{attr.name}();
      .end if
  .end for
    }
    public ${testclass}(ModelElementID set)
    {
      if (set.getType().equals(type))
      {
        modelRootID = set.getModelRootID();
  .assign index = -1
  .for each attr in id_attr_set
    .assign index = index + 1
    .invoke result = get_core_datatype(attr)
    .assign cdt = result.cdt
    .if (cdt.core_typ == 2)
        $cr{attr.name} = Long.parseLong(set.getId(${index}));
    .elif (cdt.core_typ == 5)
        $cr{attr.name} = UUID.fromString(set.getId(${index}));
    .elif (cdt.core_typ == 4)
        $cr{attr.name} = set.getId(${index};
    .else
        $cr{attr.name} = (Xxxxxx)set.getId(${index});
    .end if
  .end for
      }else{
        throw new IllegalArgumentException("Mis type argument"); //$$NON-NLS-1$$
      }
    }
    public ModelElementID createModelElementID()
    {
  .assign count = cardinality id_attr_set
      ModelElementID id = new ModelElementID(modelRootID, type, componentPath);
  .for each attr in id_attr_set
    .invoke result = get_core_datatype(attr)
    .assign cdt = result.cdt
    .if (cdt.core_typ == 4)
      id.add($cr{attr.name});
    .else
      id.add(String.valueOf($cr{attr.name}));
    .end if
  .end for
      return id;
    }
    public boolean evaluate(Object inst)
    {
      ${classname} candidate = (${classname}) inst;
      return\
  .assign sep = "   "
  .for each attr in id_attr_set
        .invoke ibaaui = is_base_attribute_a_unique_id(attr)
        .if (ibaaui.is_unique_id)
        ${sep}candidate.get$cr{attr.name}().equals($cr{attr.name})\
        .else
        ${sep}candidate.get$cr{attr.name}() == $cr{attr.name}\
        .end if
    .assign sep = "&& "
  .end for
;
    }
  }
.end for
}
.emit to file "src/org/xtuml/bp/ui/text/ModelAdapter.java"
.//

.//=====================================================================
.//
.// File:      $RCSfile: create_modeladapter_java.arc,v $
.// Version:   $Revision: 1.20 $
.// Modified:  $Date: 2013/01/17 03:28:52 $
.//
.// (c) Copyright 2004-2014 by Mentor Graphics Corp. All rights reserved.
.//
.//=====================================================================
.// Licensed under the Apache License, Version 2.0 (the "License"); you may not
.// use this file except in compliance with the License.  You may obtain a copy
.// of the License at
.//
.//      http://www.apache.org/licenses/LICENSE-2.0
.//
.// Unless required by applicable law or agreed to in writing, software
.// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
.// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
.// License for the specific language governing permissions and limitations under
.// the License.
.//=====================================================================
.//
.// This archetype is responsible for creating the ModelAdapter.java
.// file for org.xtuml.bp.ui.text.
.//
.// Get the file contents
.//
.invoke arc_env = GET_ENV_VAR( "PTC_MC_ARC_DIR" )
.assign mc_archetypes = arc_env.result
.if ( mc_archetypes == "" )
  .print "\nERROR: Environment variable PTC_MC_ARC_DIR not set."
  .exit 100
.end if
.//
.include "${mc_archetypes}/arch_utils.inc"
.include "arc/create_util.inc"
.//
.assign core_package = "org.xtuml.bp.core"
.assign path = "org.xtuml.bp.ui.text"
.//
.invoke result = get_editor_obj_set()
.assign dsc_obj_set = result.dsc_obj_set
.assign oal_obj_set = result.oal_obj_set
.assign both_obj_set = result.both_obj_set
.assign both_source_set = result.dsc_source_set | result.oal_source_set
.assign all_set = both_obj_set | both_source_set
.assign oal_set = result.oal_source_set | oal_obj_set
.invoke result = get_model_adapter_class_name()
.assign modelAdapterClass = result.class_name
.invoke result = get_test_class_name()
.assign interfacename = result.body
.//
//======================================================================
//
// File: ${path}/${modelAdapterClass}.java
//
// WARNING:      Do not edit this generated file
// Generated by: ${info.arch_file_name}
// Version:      $$Revision: 1.20 $$
//
// (c) Copyright 2004-2014 by Mentor Graphics Corp.  All rights reserved.
//
//======================================================================
//
// This class handles the input to the Description and Activity
// text editors.
//
package ${path};
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;

import org.xtuml.bp.core.*;
import org.xtuml.bp.core.common.*;
import org.xtuml.bp.core.inspector.IModelClassInspector;
import org.xtuml.bp.core.inspector.ModelInspector;

public class ${modelAdapterClass}
{
  private ${modelAdapterClass}() {};
  protected static String getName(Object input) {
	String result = ""; //$$NON-NLS-1$$
	Class inputClass = input.getClass();
	Class[] type = new Class[0];
	Method getName = null;
	try {
		getName = inputClass.getMethod("Get_label", type); //$$NON-NLS-1$$
	} catch (NoSuchMethodException e1) {
			try {
		getName = inputClass.getMethod("getName", type); //$$NON-NLS-1$$
			} catch (NoSuchMethodException e2) {
		// There is no accessor, try an explicit operation . . .
		try {
			getName = inputClass.getMethod("Get_name", type); //$$NON-NLS-1$$
				} catch (NoSuchMethodException e3) {
					TextPlugin.logError("Class does not implement any name accessor", e3); //$$NON-NLS-1$$
		}
	    }
    }
    if ( getName != null )
    {
		try {
		  Object[] args = new Object[0];
		  result = (String) getName.invoke(input, args);
		} catch (InvocationTargetException e) {
		  TextPlugin.logError("Invocation Target exception in getName", e); //$$NON-NLS-1$$
		} catch (IllegalAccessException e) {
          TextPlugin.logError("Illegal Access exception in getName", e); //$$NON-NLS-1$$
		}
        return result;
	}
	else
	{
	  return null;
	}
  }

  public static interface IModelElementAdapter {
	public ModelElementID createModelElementID(NonRootModelElement modelElement);
	public NonRootModelElement resolveModelElement(ModelElementID modelElementID);
    public String getName(NonRootModelElement modelElement);
  }

  static Map adapterRegistry = new HashMap();

  public static IModelElementAdapter getModelElementAdapter(NonRootModelElement modelElement){
    if (modelElement == null){
        throw new IllegalArgumentException("modelElement cannot be null"); //$$NON-NLS-1$$
    }
    return getModelElementAdapter(modelElement.getClass().getName());
  }

  public static IModelElementAdapter getModelElementAdapter(String type){
    return (IModelElementAdapter)adapterRegistry.get(type);
  }

  static{
.for each obj in all_set
  .invoke result = get_class_name(obj)
  .assign classname = result.body
    adapterRegistry.put("${core_package}.${classname}", new ${classname}Adapter()); //$$NON-NLS-1$$
.end for
  }

.for each obj in all_set
  .invoke result = get_class_name(obj)
  .assign classname = result.body
  .invoke result = get_query_class_name(obj)
  .assign testclass = result.body
  .invoke result = get_test_class_name()
  .assign interfacename = result.body
  .invoke result = get_instance_accessor(obj)
  .assign instancename = result.body
  .invoke result = get_id_attr_set(obj)
  .assign id_attr_set = result.attr_set

  public static final class ${classname}Adapter implements IModelElementAdapter{
    public ModelElementID createModelElementID(NonRootModelElement modelElement){
       if(!(modelElement instanceof ${classname})){
         throw new IllegalArgumentException("Model element is not of type ${classname}"); //$$NON-NLS-1$$
       }

       ModelElementID id = (new ${testclass}((${classname})modelElement)).createModelElementID();
       id.modelElement = modelElement;
       id.modelRoot = (Ooaofooa)(modelElement.getModelRoot());
       // update the cached name
       id.getLastValidName();
       return id;
    }

    public NonRootModelElement resolveModelElement(ModelElementID modelElementID){
        if(!"${core_package}.${classname}".equals(modelElementID.getType())){ //$$NON-NLS-1$$
          throw new IllegalArgumentException("Given ModelElementID does not represent type ${classname}" ); //$$NON-NLS-1$$
        }

        Ooaofooa modelRoot = Ooaofooa.getInstance(modelElementID.getModelRootID(), false);
        if(modelRoot == null){
             return null;
        }

        String componentPath = modelElementID.getComponentPath();
        if(componentPath != null){
            IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(componentPath));
            try {
                // if the resource tree isn't locked, then we can do a refresh
                // the resource tree has locking conflicts during unit tests,
                // so only check this if we are running a unit test
                if ( !ResourcesPlugin.getWorkspace().isTreeLocked()) {
                    f.refreshLocal(0, new NullProgressMonitor());
                }
            } catch (CoreException e) {
                TextPlugin.logError("Unable to refresh component file", e);
            }
            if (!f.exists())
            {
                return null;
            }
            else
            {
                PersistenceManager.getDefaultInstance().loadAndFinishComponent(componentPath);
                PersistableModelComponent pmc = PersistenceManager.findComponent(new Path(componentPath));
                if (pmc == null) {
                    return null;
                }
            }
        }
        return ${classname}.${instancename}(modelRoot, new ${testclass}(modelElementID));
    }

	.assign found = false
	.assign is_oal = false;
	.select many attr_set related by obj->O_ATTR[R102]
    .select any attr from instances of O_ATTR where (false)
	.for each attr in attr_set
	  .if ("$l{attr.name}" == "name")
	    .assign found = true
	    .break for
	  .end if
	  .for each oal in oal_set
	  	.if ( obj.Key_Lett == oal.Key_Lett)
	  		.assign is_oal = true;
	  	.end if
	  .end for
	.end for
	.if (not found )
	private static String m_getNameValid = "no"; //$$NON-NLS-1$$
	.end if
	public final String getName(NonRootModelElement modelElement)
	{
	  if(modelElement == null){
	    return "${obj.Name}";
	  }
	  if(!(modelElement instanceof ${classname})){
	    throw new IllegalArgumentException("argument should be instanceof ${classname}"); //$$NON-NLS-1$$
	  }
	  ${classname} obj = (${classname})modelElement;
	.if (found)
	  .if (is_oal)
		try{
	  	ModelInspector inspector = new ModelInspector();
		IModelClassInspector elementInspector = inspector.getInspector(obj .getClass());
			NonRootModelElement parent = (NonRootModelElement) elementInspector .getParent(obj);
	    .if (((obj.Key_Lett == "SPR_RO") or (obj.Key_Lett == "SPR_RS")) or ((obj.Key_Lett == "SPR_PO") or (obj.Key_Lett == "SPR_PS")) )
	    .// return the Port as parent instead of interface reference for interface operations and signals instead of Interface Reference
	    	elementInspector = inspector.getInspector(parent.getClass());
			parent = (NonRootModelElement) elementInspector .getParent(parent);
		.end if
	    return parent.getName() + "::" + obj.get$cr{attr.name}(); //$$NON-NLS-1$$
		}catch(Exception e){
			return obj.get$cr{attr.name}(); //  Return the element name if the parent element is not found
		}
	  .else
	  return obj.get$cr{attr.name}(); //$$NON-NLS-1$$
	  .end if
	.else
	  if ( m_getNameValid != null && m_getNameValid.equals("no") ) //$$NON-NLS-1$$
	  {
	    m_getNameValid = ModelAdapter.getName( obj );
	    if ( m_getNameValid != null )
		  m_getNameValid = "yes"; //$$NON-NLS-1$$
	  }
	  if ( m_getNameValid != null && m_getNameValid.equals("yes") ) //$$NON-NLS-1$$
	  .if (is_oal)
	  	{
	  	try{
	  	ModelInspector inspector = new ModelInspector();
		IModelClassInspector elementInspector = inspector.getInspector(obj .getClass());
		NonRootModelElement parent = (NonRootModelElement) elementInspector .getParent(obj);
	    .if (obj.Key_Lett == "SM_TXN")
	    	.// Return the model class as parent for transition
	    	elementInspector = inspector.getInspector(parent.getClass());
			parent = (NonRootModelElement) elementInspector .getParent(parent);
	    .end if
	    return parent.getName() + "::" + ModelAdapter.getName( obj ); //$$NON-NLS-1$$
	    }catch(Exception e){
			return ModelAdapter.getName( obj ); //  Return the element name if the parent element is not found
		}
		}
	  .else
	    return ModelAdapter.getName( obj );
	  .end if
	  else
	    return "UNKNOWN";
	.end if
	}
  }

  public static final class ${testclass}
    implements ${interfacename}
  {
    private final static String type = "${core_package}.${classname}"; //$$NON-NLS-1$$
    private String modelRootID = null;
    private String componentPath;
  .for each attr in id_attr_set
    .invoke result = get_core_datatype(attr)
    .assign cdt = result.cdt
    .if (cdt.core_typ == 2)
    private long $cr{attr.name} = 0;
    .elif (cdt.core_typ == 5)
    private UUID $cr{attr.name} = IdAssigner.NULL_UUID;
    .elif (cdt.core_typ == 4)
    private String $cr{attr.name} = ""; //$$NON-NLS-1$$
    .else
      .print "Invalid datatype for attribute ${obj.name}.${attr.name}"
    private Xxxxxx $cr{attr.name};
    .end if
  .end for
    public ${testclass}(${classname} inst)
    {
      modelRootID = inst.getModelRoot().getId();
      componentPath = inst.getContent();
  .for each attr in id_attr_set
      .select one rattr related by attr->O_RATTR[R106]
      .if(not_empty rattr)
         $cr{attr.name} = inst.get$cr{attr.name}();
         if(IdAssigner.NULL_UUID.equals($cr{attr.name}))
         {
            $cr{attr.name} = inst.get$cr{attr.name}CachedValue();
         }
      .else
        $cr{attr.name} = inst.get$cr{attr.name}();
      .end if
  .end for
    }
    public ${testclass}(ModelElementID set)
    {
      if (set.getType().equals(type))
      {
        modelRootID = set.getModelRootID();
  .assign index = -1
  .for each attr in id_attr_set
    .assign index = index + 1
    .invoke result = get_core_datatype(attr)
    .assign cdt = result.cdt
    .if (cdt.core_typ == 2)
        $cr{attr.name} = Long.parseLong(set.getId(${index}));
    .elif (cdt.core_typ == 5)
        $cr{attr.name} = UUID.fromString(set.getId(${index}));
    .elif (cdt.core_typ == 4)
        $cr{attr.name} = set.getId(${index};
    .else
        $cr{attr.name} = (Xxxxxx)set.getId(${index});
    .end if
  .end for
      }else{
        throw new IllegalArgumentException("Mis type argument"); //$$NON-NLS-1$$
      }
    }
    public ModelElementID createModelElementID()
    {
  .assign count = cardinality id_attr_set
      ModelElementID id = new ModelElementID(modelRootID, type, componentPath);
  .for each attr in id_attr_set
    .invoke result = get_core_datatype(attr)
    .assign cdt = result.cdt
    .if (cdt.core_typ == 4)   .// string
      id.add($cr{attr.name});
    .else
      id.add(String.valueOf($cr{attr.name}));
    .end if
  .end for
      return id;
    }
    public boolean evaluate(Object inst)
    {
      ${classname} candidate = (${classname}) inst;
      return\
  .assign sep = "   "
  .for each attr in id_attr_set
        .invoke ibaaui = is_base_attribute_a_unique_id(attr)
        .if (ibaaui.is_unique_id)
        ${sep}candidate.get$cr{attr.name}().equals($cr{attr.name})\
        .else
        ${sep}candidate.get$cr{attr.name}() == $cr{attr.name}\
        .end if
    .assign sep = "&& "
  .end for
;
    }
  }
.end for
}
.emit to file "src/org/xtuml/bp/ui/text/ModelAdapter.java"
.//