public function callback($headers, $requestBody) { $jobID = $headers["Proxy-Transaction-Id"]; $contentItemURI = $headers["Content-Item-Id"]; $this->logger->trace("A message has been received" . " [ jobId :: {$jobID} ][ contentItemURI :: {$contentItemURI} ]" . " [ requestBody :: {$requestBody} ]."); // get the posts for the specified job ID. $posts = $this->jobService->getPostByJobID($jobID); // exit if the job ID does NOT exist. if (0 === count($posts)) { $this->logger->error("No job found for id [ jobID :: {$jobID} ]" . "[ posts :: " . var_export($posts, true) . " ]."); echo "No job found for id [ jobID :: {$jobID} ]" . "[ posts :: " . var_export($posts, true) . " ]."; return; } // get the post ID. $postID = $posts[0]->ID; $this->logger->trace("A post was found [ postID :: {$postID} ]" . "[ jobID :: {$jobID} ]."); $this->logger->trace("Removing existing enhancements [ postID :: {$postID} ]."); $this->tripleStoreService->query("DELETE { ?s ?p ?o }\n WHERE {\n ?s a fise:Enhancement .\n ?s wordlift:postID \"{$postID}\" .\n ?s ?p ?o .\n }"); $index = $this->triplesUtils->getIndexFromData($requestBody); $newIndex = $this->triplesUtils->bNodesToMD5($index); $this->changeSetService->applyChanges($newIndex, $this->changeCreator, false, "analysis"); if (!empty($contentItemURI)) { $this->logger->trace("Setting the postID on the enhancements" . " [ postID :: {$postID} ]."); $this->tripleStoreService->query("INSERT INTO <> { ?subject wordlift:postID \"{$postID}\" }\n WHERE { ?subject a fise:Enhancement .\n ?subject fise:extracted-from {$contentItemURI} }"); } $this->logger->trace("Setting the job to completed" . " [ postID :: {$postID} ][ jobID :: {$jobID} ]."); $this->jobService->setJob($postID, $jobID, WordLift_JobService::COMPLETED); echo "Data load completed successfully."; return WordPress_AjaxProxy::CALLBACK_RETURN_NULL; }
public function updateJob($jobID, $jobState) { $this->logger->trace("[ jobID :: {$jobID} ][ jobState :: {$jobState} ]."); $posts = $this->jobService->getPostByJobID($jobID); if (0 === count($posts)) { return WordPress_AjaxProxy::CALLBACK_RETURN_ERROR; } $this->jobService->setJob($posts[0]->ID, $jobID, $jobState); return $this->getJob(NULL, $posts[0]->ID); }