Wednesday, 14 December 2016

SOA Service Client : Object Property Policy

How to set Object Property Policy ?

Object Property policy indicates the list of attributes to be loaded when object is fetched from Teamcenter

private static void setObjectPropertyPolicy()
{
      List<String> lAttributes = new ArrayList<String>();
      //lAttributes.add( "object_name" );
      lAttributes.add( "object_string" );// it will load only this attribute so it saves time and memory
     //Eg: if we try to get object_name it will return error
     // bcz way set object_string in setObjectPropertyPolicy to load

     String strTcSource = "RevisionRule";
    try
    {
      String[] attributeArray = lAttributes.toArray(); 


     ObjectPropertyPolicy objectPropertyPolicy = new ObjectPropertyPolicy();
     PolicyType policyType = 
     new PolicyType( strTcSource, attributeArray);   //strTcSource-> Business object name //attributeArray->Array of attributes to be loaded to save time
     objectPropertyPolicy.addType( policyType );        

     SessionService sessionService = SessionService.getService( connection );

     sessionService.setObjectPropertyPolicy( objectPropertyPolicy );
   } 
  catch (Exception e)
  {
    e.printStackTrace();
  }  
}
Explanation : Important API 
ObjectPropertyPolicy objectPropertyPolicy = new ObjectPropertyPolicy(); 
PolicyType policyType = new PolicyType( strTcSource, attributeArray); objectPropertyPolicy.addType( policyType ); 
sessionService.setObjectPropertyPolicy( objectPropertyPolicy );

2 comments:

  1. Thanks for taking time to share this post. It is really useful. Continue sharing more like this.
    Regards,
    Python Training in Chennai

    ReplyDelete
  2. I am happy that its helping you.I will continue sharing more article

    ReplyDelete