Teamcenter LOV属性值的设置与获取

1、获取lov方法

public String getRealLoveName(String lovName,String displayName){
     TCComponentListOfValues lov= TCComponentListOfValuesType.findLovByName(lovName);
     if(lov.getListOfValues().getRealValues(displayName)!=NULL){
        return (String)lov.getListOfValues().getRealValue(disPlayValue);
      }
   return displayName;
}

2、.有对象设置LOV属性值:

public static  void  setLovProPerty(TCSession session , String displayname,String prop,TCComponet comp){
try{
     String lov=comp.getTCProPerTy(prop).getDescriptor().getLOV().getProperty("lov_name");
      String trueName= getRealLoveName(lov,displayname);
     if(trueName!=NULL) {
      comp.setProperty(prop,trueName);
    }
catch(TCException e){
     e.prinStackTrace();
  }
}

2.2 二级LOV属性

public static void setSubLovProperty(TCSession session,TCComponent comp,String prop, String disply)

{

     try{

      String lov=comp.getTCProPerTy(prop).getDescriptor().getLOV().getProperty("lov_name");

       Object[][] lovValues=getLovDisplayAndTrueValues(session,lov);

      for(Object[] lovVals:lovValues)

      {

             if(lovVals[2]!=NULL)

             {

                     TCComponentListOfValues  childLov=(TCComponentListOfValues)lovVals[2];

                      ListOfValuesInfo lovInfo=childLov.getListofValues();

                      String[] displayValues=lovInfo.getLOVDisplayValues();

                       Object[] values=lovInfo.getListofValues();

                        for(int i=0,len=values.length;i<len;i++){

                            if(display.equals(displayValues[i])){

                               comp.setProperty(prop,values[i].toString());

                                 return;

                            }

                       }

                   

              }

      }

      }catch(TCException e)

    {

    e.prinStackTrace();

   }


}

 

public static Object[][] getLovDisplayAndTrueValues(TCSession session , String lovName)
 {
try{

   TCComponentListOfValuesType type=(TCComponentListOfValuesType) session.getTypeComponet("ListofValues");

TCComponentListOfValues[] tmpcom= type.find(lovName);

  if(tmpcom.length>0) {

   ListofValuesInfo lovInfo=tmpcom[0].getListofValues();

    String[] displayValues=lovInfo.getLOVDisplayValues();

  Object[] values=lovInfo.getListofValues();

 TCComponentListOfValues listVals=lovInfo.getListofFilters();

   int valueslength =displayValues.length;

 Object[][] value=new Object[valueslength][3];

 for(i=0;i<valueslength ;i++)

{

 value[i][0] =displayValues[i];

 value[i][1]=values[i].toString();

  value[i][2]=listVals[i];

}

 return value;

 }

}

catch(TCException e)

    {

    e.prinStackTrace();

   }

 

}

你可能感兴趣的:(tc二次开发,TC开发资料,tc客户端开发)