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; }
<?php const DB_HOST = "localhost"; const DB_NAME = "wordlift_dev"; const DB_USER = "******"; const DB_PASSWORD = "******"; const GRAPH_URI = "http://wordlift.it/graph"; const CHANGE_FORCE = false; const CHANGE_CREATOR = "system7"; include_once "src/main/php/log4php/Logger.php"; include_once "src/test/php/arc2/ARC2.php"; include_once "src/test/TriplesUtils.php"; include_once "src/test/ChangeSetService.php"; include_once "src/main/php/insideout/wordlift/services/TripleStoreService.php"; include_once "src/main/php/insideout/wordlift/services/QueryService.php"; $logger = Logger::getLogger(__CLASS__); $storeService = new WordLift_TripleStoreService(); $storeService->logger = Logger::getLogger("WordLift_TripleStoreService"); $storeService->tablePrefix = "wordlift"; $queryService = new WordLift_QueryService(); $queryService->logger = Logger::getLogger("WordLift_QueryService"); $queryService->storeService = $storeService; $queryService->defaultGraphURI = GRAPH_URI; $triplesUtils = new WordLift_TriplesUtils(); $changeSetService = new WordLift_ChangeSetService(); $changeSetService->queryService = $queryService; $changeSetService->storeService = $storeService; $changeSetService->triplesUtils = $triplesUtils; $index = $triplesUtils->getIndexFromFile("src/test/resources/sample-4.rdf"); $newIndex = $triplesUtils->bNodesToMD5($index); $changeSetService->applyChanges($newIndex, CHANGE_CREATOR, CHANGE_FORCE, $reason = "none given");