Quantcast
Channel: PTC Community: Message List
Viewing all articles
Browse latest Browse all 11560

Re: Windchill 10.2 : Cannot find newly added attributes by using attributeContainer.getAttributeDefinitions()

$
0
0

You can try this method

 

/**

           * Method to populate the attribute information for Classification attributes.

           * @param currNode

           * @return

           * @throws RemoteException

           * @throws WTException

           */

          public static Map<String,String> getWCAttribInfo((ClassificationNode currNode) throws RemoteException, WTException

          {

                    Map<String,String> attribInfo = new TreeMap<String,String>();

                    IBAHolder[] ibaHolder = IBAValueHelper.service.refreshAttributeContainer(new IBAHolder[]{(IBAHolder)currNode});

 

                    for (int i=0; i<ibaHolder.length; i++) {

                                // Do something with values[i], such as print it

                                System.out.println("IBAHolder ==============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+ ibaHolder[i] );

                              }

 

                    DefaultAttributeContainer attribContainer = (DefaultAttributeContainer) currNode.getAttributeContainer();

 

//                    System.out.println("attribcontainer ==============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+ attribContainer );

 

//                    DefaultAttributeContainer attribContainer = (DefaultAttributeContainer) ibaHolder[0].getAttributeContainer();

                    System.out.println("attribcontainer ==============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + currNode.getName() + " --> " + attribContainer);

                    if(attribContainer != null)

                    {

                              AttributeDefDefaultView[] attributes = attribContainer.getAttributeDefinitions();

                              System.out.println("No of attributes for this node:  ==============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + attributes.length);

 

                              for(int i=0;i<attributes.length;i++)

                              {

                                        AttributeDefDefaultView attrib = attributes[i];

 

                                        System.out.println("Attribute name: ==============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + attrib.getName());

                                        AbstractValueView[] attribValue = attribContainer.getAttributeValues(attrib);

                                        String strAttribValue = "";          //initialize with a ~

 

                                        if(attribValue != null && attribValue.length > 0)

                                        {

                                                  System.out.println("==============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

                                                  for(int j=0;j<attribValue.length;j++)

                                                  {

                                                            if(j==0)

                                                            {

                                                                      strAttribValue = strAttribValue + IBAValueUtility.getLocalizedIBAValueDisplayString(attribValue[j], Locale.getDefault());

                                                            }

                                                            else

                                                            {

                                                                      strAttribValue = strAttribValue + ";" + IBAValueUtility.getLocalizedIBAValueDisplayString(attribValue[j], Locale.getDefault());

                                                            }

                                                  }

                                                  System.out.println("Attribute value:==============================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + strAttribValue);

                                                  attribInfo.put(attrib.getName(), strAttribValue);

                                        }

//                                        //Moving this line to outside the if block, as the db structure also needs to include the attributes that do not have a value

//                                        //specified..

                                        attribInfo.put(attrib.getName().trim(), strAttribValue.trim());

                              }

                    }

 

 

 

                    return attribInfo;

          }

 

 

 

 

Let me know your results


Viewing all articles
Browse latest Browse all 11560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>