Ejemplo n.º 1
0
 /**
  * @since 1.9
  *
  * @param boolean $addJob
  */
 protected function notifyUpdateDispatcher($addJob = true)
 {
     if ($addJob && !$this->hasDiff) {
         ApplicationFactory::getInstance()->newJobFactory()->newUpdateDispatcherJob($this->semanticData->getSubject()->getTitle())->run();
         $this->hasDiff = true;
     }
 }
 /**
  * Updates propertyCounts using the diff ( old SemanticData and new SemanticData for a subject )
  * Old SemanticData is data before the page was edited and new SemanticData is data after edit.
  * new SemanticData is optional sometimes (as for deleting data)
  *
  * @since 1.8
  *
  * @param SemanticData $oldData
  * @param SemanticData or null $newData
  */
 protected function doDiffandUpdateCount($oldData, $newData = null)
 {
     //Update Property Counts
     $updates = array();
     if (!is_null($newData)) {
         foreach ($newData->getProperties() as $diKey => $diProp) {
             $updates[$diKey] = array($diProp, count($newData->getPropertyValues($diProp)));
         }
     }
     foreach ($oldData->getProperties() as $diKey => $diProp) {
         if (array_key_exists($diKey, $updates)) {
             $updates[$diKey][1] = $updates[$diKey][1] - count($oldData->getPropertyValues($diProp));
         } else {
             $updates[$diKey] = array($diProp, -count($oldData->getPropertyValues($diProp)));
         }
     }
     foreach ($updates as $update) {
         if ($update[1] == 0) {
             continue;
         }
         // HOW to do this query using MW functions ??
         /*
         			$dbw->update(
         				'smw_stats',
         				array( 'usage_count' => 'usage_count + '.$update[1] ),
         				array( 'pid' => $this->store->smwIds->getSMWPropertyID( $update[0] ) ),
         				__METHOD__
         			);
         */
         $this->addToUsageCount($this->store->smwIds->getSMWPropertyID($update[0]), $update[1]);
     }
 }