title: setting context in odi mapping objects
body: <p>Due to project requirement we need to import the project mappings &amp; other objects from a different server. But we found that all the mapping context becomes undefined.</p>
  
  <p>I am trying to write a groovy program to set the context at a bulk. I have written the below code but somehow the <code>interfaceList</code> is empty and thus unable to perform <code>odiInterface.setOptimizationContext(context);</code>.</p>
  
  <p>Below is my code. For brevity I haven't mentioned the packages stmt.</p>
  
  <pre class="lang-java prettyprint-override"><code>def all the variables like url,driver,schema etc
  def all variables like MasterInfo, auth, transaction, etc 
  
  def OdiContext context = ((IOdiContextFinder) odiInstance.getTransactionalEntityManager().getFinder(OdiContext.class)).findByCode("CTX_ANN1_S4")
  for (p in odiProjectList) {
      if (p.getName() == "PrjDemo_TA") {
          def OdiFolderList = p.getFolders()
          for (f in OdiFolderList) {
              if (f.getName() == "TrgDemoMod_Comn_TA_S4") {
                  // def OdiInterfaceList2 = f.getInterfaces()                
                  // def OdiMappingList = odiInstance.getTransactionalEntityManager().findAll( Mapping.class)
                  def OdiInterfaceList = ((IOdiInterfaceFinder) odiInstance.getTransactionalEntityManager().getFinder(OdiInterface.class)).findByProject(projectCode, folderName)
  
                  for (m in OdiInterfaceList2) {
                      println(m.getName() + "|" + m.getClass()) //+ "|" + m.getParent()   + "|" + m.getFolder() )
                      m.setOptimizationContext(context)
                  }
                  tm.commit(txnStatus)
              }
          }
      }
  }
  
  </code></pre>
  
  <p>The line which initializes <code>OdiInterfaceList</code> is not throwing any error nor populating desired interface lists of all the interfaces within a folder.
  So <code>m.setOptimizationContext(context)</code> is not executed.</p>
  
  <p>If i substitute that line with:</p>
  
  <pre class="lang-java prettyprint-override"><code>def OdiMappingList = odiInstance.getTransactionalEntityManager().findAll( Mapping.class)
  </code></pre>
  
  <p>within a <code>for ... loop</code> i can able to access the mappings but I don't know how to set its context <code>OdiMappingList</code> as <code>setOptimizationContext</code> is an interface's  method.</p>