/**
  * Delete the specified application record from Solr
  *
  * @param string $appUID
  *          Application identifier
  */
 public function deleteApplicationSearchIndex($appUID)
 {
     if (empty($appUID)) {
         return;
     }
     // check if index server is available
     if (!$this->_solrIsEnabled) {
         // store update in table and return
         $this->applicationChangedUpdateSolrQueue($appUID['APP_UID'], 2);
         // delete
         return;
     }
     $idQuery = "APP_UID:" . $appUID;
     G::LoadClass('searchIndex');
     $oSearchIndex = new BpmnEngine_Services_SearchIndex($this->_solrIsEnabled, $this->_solrHost);
     $oSearchIndex->deleteDocumentFromIndex($this->_solrInstance, $idQuery);
     // commit changes
     $oSearchIndex->commitIndexChanges($this->_solrInstance);
 }
 /**
  * Delete the specified application record from Solr
  *
  * @param string $aaAPPUIDs
  *          array of arrays of Application identifiers format:$aaAPPUIDs [] = array ('APP_UID' => '...') 
  */
 public function deleteApplicationSearchIndex($aaAPPUIDs, $saveDBRecord = false)
 {
     if (empty($aaAPPUIDs)) {
         return;
     }
     if (!is_array($aaAPPUIDs)) {
         // convert to array
         $APPUID = $aaAPPUIDs;
         $aaAPPUIDs = array();
         $aaAPPUIDs[] = array('APP_UID' => $APPUID);
     }
     /*
         if ($saveDBRecord) {
           if($this->isSolrEnabled()){
             //store update in table but with status updated
             foreach ($aaAPPUIDs as $aAPPUID) {
               $this->applicationChangedUpdateSolrQueue ($aAPPUID ['APP_UID'], 0);
             }
           }
           else{
             // store update in table and return
             foreach ($aaAPPUIDs as $aAPPUID) {
               $this->applicationChangedUpdateSolrQueue ($aAPPUID ['APP_UID'], 2);
             }
             return;  
           }        
         }*/
     try {
         G::LoadClass('searchIndex');
         $oSearchIndex = new BpmnEngine_Services_SearchIndex($this->_solrIsEnabled, $this->_solrHost);
         foreach ($aaAPPUIDs as $aAPPUID) {
             $idQuery = "APP_UID:" . $aAPPUID['APP_UID'];
             $oSearchIndex->deleteDocumentFromIndex($this->_solrInstance, $idQuery);
         }
         if ($saveDBRecord) {
             foreach ($aaAPPUIDs as $aAPPUID) {
                 $this->applicationChangedUpdateSolrQueue($aAPPUID['APP_UID'], 0);
             }
         }
     } catch (Exception $ex) {
         //register all the appuids that can't be indexed
         $appuidsString = " ";
         foreach ($aaAPPUIDs as $aAPPUID) {
             $this->applicationChangedUpdateSolrQueue($aAPPUID['APP_UID'], 2);
             $appuidsString .= $aAPPUID['APP_UID'] . ", ";
         }
         //print "Excepcion indexing data: " . $ex->getMessage() . "\n"; die;
         $fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
         fwrite($fh, date('Y-m-d H:i:s:u') . ":" . $appuidsString . $ex->getMessage() . "\r\n");
         fclose($fh);
     }
     // commit changes
     //$oSearchIndex->commitIndexChanges ($this->_solrInstance);
 }