static function createForRequest($data)
 {
     $obj = new Entity_SolrUpdateDocument();
     $obj->initializeObject($data);
     $requiredFields = array("workspace", "document");
     $obj->validateRequiredFields($requiredFields);
     return $obj;
 }
Esempio n. 2
0
 /**
  * Update the information of the specified applications in Solr
  *
  * @param array $aaAPPUIDs
  *          Array of arrays of App_UID that must be updated,
  *          APP_UID is permitted also
  */
 public function updateApplicationSearchIndex($aaAPPUIDs)
 {
     if (empty($aaAPPUIDs)) {
         return;
     }
     if (!is_array($aaAPPUIDs)) {
         // convert to array
         $APPUID = $aaAPPUIDs;
         $aaAPPUIDs = array();
         $aaAPPUIDs[] = array('APP_UID' => $APPUID);
     }
     // check if index server is available
     if (!$this->isSolrEnabled()) {
         // store update in table and return
         foreach ($aaAPPUIDs as $aAPPUID) {
             $this->applicationChangedUpdateSolrQueue($aAPPUID['APP_UID'], true);
         }
     }
     // create XML document
     $xmlDoc = $this->createSolrXMLDocument($aaAPPUIDs);
     // update document
     $data = array('workspace' => $this->_solrInstance, 'document' => $xmlDoc);
     $oSolrUpdateDocument = Entity_SolrUpdateDocument::createForRequest($data);
     G::LoadClass('searchIndex');
     $oSearchIndex = new BpmnEngine_Services_SearchIndex($this->_solrIsEnabled, $this->_solrHost);
     $oSearchIndex->updateIndexDocument($oSolrUpdateDocument);
     // commit changes
     $oSearchIndex->commitIndexChanges($this->_solrInstance);
 }
Esempio n. 3
0
 /**
  * Update the information of the specified applications in Solr
  *
  * @param array $aaAPPUIDs Array of arrays of App_UID that must be updated,
  *        APP_UID is permitted also
  */
 public function updateApplicationSearchIndex($aaAPPUIDs)
 {
     if (empty($aaAPPUIDs)) {
         return;
     }
     if (!is_array($aaAPPUIDs)) {
         // convert to array
         $APPUID = $aaAPPUIDs;
         $aaAPPUIDs = array();
         $aaAPPUIDs[] = array('APP_UID' => $APPUID);
     }
     // check if index server is available
     if (!$this->isSolrEnabled()) {
         // store update in table and return
         foreach ($aaAPPUIDs as $aAPPUID) {
             $this->applicationChangedUpdateSolrQueue($aAPPUID['APP_UID'], true);
         }
         return;
     }
     if ($this->debug) {
         $this->getApplicationDataDBTime = 0;
         $this->getPreparedApplicationDataDBTime = 0;
         $this->getBuilXMLDocTime = 0;
         $this->beforeCreateSolrXMLDocTime = microtime(true);
     }
     // create XML document
     $xmlDoc = $this->createSolrXMLDocument($aaAPPUIDs);
     if ($this->debug) {
         $this->afterCreateSolrXMLDocTime = microtime(true);
     }
     // update document
     $data = array('workspace' => $this->_solrInstance, 'document' => $xmlDoc);
     $oSolrUpdateDocument = Entity_SolrUpdateDocument::createForRequest($data);
     G::LoadClass('searchIndex');
     $oSearchIndex = new BpmnEngine_Services_SearchIndex($this->_solrIsEnabled, $this->_solrHost);
     try {
         $oSearchIndex->updateIndexDocument($oSolrUpdateDocument);
         if ($this->debug) {
             $this->afterUpdateSolrXMLDocTime = microtime(true);
         }
         // commit changes
         //$oSearchIndex->commitIndexChanges( $this->_solrInstance );
     } catch (Exception $ex) {
         //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, $ex->getMessage());
         fclose($fh);
     }
     if ($this->debug) {
         $fh = fopen("SolrIndexTime.txt", 'a') or die("can't open file to store Solr index time.");
         //fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s \n", gmdate ('H:i:s:u', ($this->afterSolrQueryTime - $this->initTimeAll)), gmdate ('H:i:s:u', ($this->afterDbQueryTime - $this->afterSolrQueryTime)), gmdate ('H:i:s:u', ($this->afterPrepareResultTime - $this->afterDbQueryTime))  ));
         $trunkSize = count($aaAPPUIDs);
         $this->trunkSizeAcumulated += $trunkSize;
         $this->totalTimeAcumulated += $this->afterUpdateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime;
         //Solr App trunk size| Get Data from DB (s)| Prepare DB data (s) | Create XML file (s)| Create XML Document total (s)| Update Solr Document (s)
         fwrite($fh, sprintf("%s|%s|%s|%s|%s|%s|%s|%s\r\n", $this->trunkSizeAcumulated, $this->totalTimeAcumulated, $this->getApplicationDataDBTime, $this->getPreparedApplicationDataDBTime, $this->getBuilXMLDocTime, $this->afterCreateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime, $this->afterUpdateSolrXMLDocTime - $this->afterCreateSolrXMLDocTime, $this->afterUpdateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime));
         fclose($fh);
         /*
                     $this->afterCommitSolrDocTime = microtime( true );
         
                     $fh = fopen( "SolrIndexTime.txt", 'a' ) or die( "can't open file to store Solr index time." );
                     //fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s \n", gmdate ('H:i:s:u', ($this->afterSolrQueryTime - $this->initTimeAll)), gmdate ('H:i:s:u', ($this->afterDbQueryTime - $this->afterSolrQueryTime)), gmdate ('H:i:s:u', ($this->afterPrepareResultTime - $this->afterDbQueryTime))  ));
                     fwrite( $fh, sprintf( "Solr Create XML Document time: %s Update Solr Document time: %s Commit Solr Changes time: %s Total:%s \r\n", ($this->afterCreateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime), ($this->afterUpdateSolrXMLDocTime - $this->afterCreateSolrXMLDocTime), ($this->afterCommitSolrDocTime - $this->afterUpdateSolrXMLDocTime), ($this->afterCommitSolrDocTime - $this->beforeCreateSolrXMLDocTime) ) );
                     fclose( $fh );*/
     }
 }
Esempio n. 4
0
 /**
  * Update the information of the specified applications in Solr
  *
  * @param array $aaAPPUIDs
  *          Array of arrays of App_UID that must be updated,
  *          APP_UID is permitted also
  */
 public function updateApplicationSearchIndex($aaAPPUIDs, $saveDBRecord = false)
 {
     if (empty($aaAPPUIDs)) {
         return;
     }
     if ($this->debug) {
         //show app to reindex
         var_dump($aaAPPUIDs);
     }
     if (!is_array($aaAPPUIDs)) {
         // convert to array
         $APPUID = $aaAPPUIDs;
         $aaAPPUIDs = array();
         $aaAPPUIDs[] = array('APP_UID' => $APPUID);
     }
     if ($this->debug) {
         //show app to reindex
         var_dump($aaAPPUIDs);
     }
     try {
         // check if index server is available
         /*
               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'], true);
                   }
                   return;  
                 }
                 
               }*/
         if ($this->debug) {
             $this->getApplicationDataDBTime = 0;
             $this->getPreparedApplicationDataDBTime = 0;
             $this->getBuilXMLDocTime = 0;
             $this->afterUpdateSolrXMLDocTime = 0;
             $this->beforeCreateSolrXMLDocTime = microtime(true);
         }
         // create XML document
         $xmlDoc = $this->createSolrXMLDocument($aaAPPUIDs);
         if ($this->debug) {
             $this->afterCreateSolrXMLDocTime = microtime(true);
         }
         // update document
         $data = array('workspace' => $this->_solrInstance, 'document' => $xmlDoc);
         $oSolrUpdateDocument = Entity_SolrUpdateDocument::createForRequest($data);
         G::LoadClass('searchIndex');
         $oSearchIndex = new BpmnEngine_Services_SearchIndex($this->_solrIsEnabled, $this->_solrHost);
         $oSearchIndex->updateIndexDocument($oSolrUpdateDocument);
         if ($this->debug) {
             $this->afterUpdateSolrXMLDocTime = microtime(true);
         }
         // commit changes no required because of the commitwithin option
         //$oSearchIndex->commitIndexChanges ($this->_solrInstance);
         //change status in db to indexed
         if ($saveDBRecord) {
             foreach ($aaAPPUIDs as $aAPPUID) {
                 $this->applicationChangedUpdateSolrQueue($aAPPUID['APP_UID'], 0);
             }
         }
     } catch (Exception $ex) {
         //echo $ex->getMessage();
         //echo $ex->getTraceAsString();
         $appuidsString = " ";
         //register all the appuids that can't be indexed
         foreach ($aaAPPUIDs as $aAPPUID) {
             $this->applicationChangedUpdateSolrQueue($aAPPUID['APP_UID'], true);
             $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);
     }
     if ($this->debug) {
         //$this->afterCommitSolrDocTime = microtime (true);
         $fh = fopen("SolrIndexTime.txt", 'a') or die("can't open file to store Solr index time.");
         //fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s \n", gmdate ('H:i:s:u', ($this->afterSolrQueryTime - $this->initTimeAll)), gmdate ('H:i:s:u', ($this->afterDbQueryTime - $this->afterSolrQueryTime)), gmdate ('H:i:s:u', ($this->afterPrepareResultTime - $this->afterDbQueryTime))  ));
         $trunkSize = count($aaAPPUIDs);
         $this->trunkSizeAcumulated += $trunkSize;
         $this->totalTimeAcumulated += $this->afterUpdateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime;
         //Solr App trunk size| Get Data from DB (s)| Prepare DB data (s) | Create XML file (s)| Create XML Document total (s)| Update Solr Document (s)
         fwrite($fh, sprintf("%s|%s|%s|%s|%s|%s|%s|%s\r\n", $this->trunkSizeAcumulated, $this->totalTimeAcumulated, $this->getApplicationDataDBTime, $this->getPreparedApplicationDataDBTime, $this->getBuilXMLDocTime, $this->afterCreateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime, $this->afterUpdateSolrXMLDocTime - $this->afterCreateSolrXMLDocTime, $this->afterUpdateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime));
         fclose($fh);
         /*
               fwrite($fh, sprintf("Solr App trunk size: %s => Create XML Document total (s): %s, Update Solr Document (s): %s, Total (s):%s \r\n", 
                 $trunkSize, ($this->afterCreateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime), ($this->afterUpdateSolrXMLDocTime - $this->afterCreateSolrXMLDocTime), 
                 ($this->afterUpdateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime)));
               fclose($fh);
               $fh = fopen("SolrIndexTime.txt", 'a') or die("can't open file to store Solr index time.");
               fwrite($fh, sprintf("APP range => Get Data from DB (s): %s, Prepare DB data (s): %s, Create XML file(s): %s \r\n", 
                 $this->getApplicationDataDBTime, $this->getPreparedApplicationDataDBTime, $this->getBuilXMLDocTime ));
               fclose($fh);*/
     }
 }