Example #1
0
 private function createTermImportResultContentPreview($termImportName)
 {
     $result = "__NOTOC__\n";
     $result .= "==== Import summary ====";
     $result .= "\nTerm Import definition: [[belongsToTermImport::TermImport:" . $termImportName . "|" . $termImportName . "]]" . " [[belongsToTermImportWithLabel::" . $termImportName . "| ]]";
     $result .= "\nImport date: [[hasImportDate::";
     $result .= $this->getDateString() . "]]";
     $result .= "\nResult: Some errors occured.[[wasImportedSuccessfully::false| ]] (Check [[Special:Gardening]] if Term Import is finished.)";
     $result .= "\n==== Added terms ====\n";
     $result .= "{{#ask: [[WasAddedDuringTermImport::TermImport:" . $termImportName . "/" . $this->getDateString() . "]]| format=ul}}";
     $result .= "\n==== Updated terms ====\n";
     $result .= "{{#ask: [[WasUpdatedDuringTermImport::TermImport:" . $termImportName . "/" . $this->getDateString() . "]]| format=ul}}";
     $result .= "\n==== Ignored terms ====\n";
     $result .= "{{#ask: [[IgnoredDuringTermImport::TermImport:" . $termImportName . "/" . $this->getDateString() . "]]| format=ul}}";
     $result .= "\n[[Category:TermImportRun]]";
     $timeInTitle = $this->getDateString();
     smwf_om_EditArticle("TermImport:" . $termImportName . "/" . $timeInTitle, 'TermImportBot', $result, '');
     //smwf_om_TouchArticle("TermImport:".$termImportName."/".$timeInTitle);
     smwf_om_TouchArticle("TermImport:" . $termImportName);
 }
Example #2
0
function smwf_ti_createTIArticle($moduleConfig, $sourceConfig, $mappingConfig, $conflictConfig, $inputConfig, $importSetConfig, $termImportName, $updatePolicy, $edit)
{
    $title = Title::newFromText("TermImport:" . $termImportName);
    if ($title->exists() && $edit == "false") {
        return '<?xml version="1.0"?>
	 			<ReturnValue xmlns="http://www.ontoprise.de/smwplus#">
	 		    <value>falseTIN</value>
	 		    <message>' . wfMsg('smw_ti_def_allready_exists') . '</message>
	 			</ReturnValue >';
    }
    $moduleConfig = str_replace('<?xml version="1.0"?>', "", $moduleConfig);
    $moduleConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $moduleConfig);
    $moduleConfig = trim($moduleConfig);
    $sourceConfig = str_replace('<?xml version="1.0"?>', "", $sourceConfig);
    $sourceConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $sourceConfig);
    $sourceConfig = trim($sourceConfig);
    $mappingConfig = str_replace('<?xml version="1.0"?>', "", $mappingConfig);
    $mappingConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $mappingConfig);
    $mappingConfig = trim($mappingConfig);
    $conflictConfig = str_replace('<?xml version="1.0"?>', "", $conflictConfig);
    $conflictConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $conflictConfig);
    $conflictConfig = trim($conflictConfig);
    $inputConfig = str_replace('<?xml version="1.0"?>', "", $inputConfig);
    $inputConfig = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $inputConfig);
    $inputConfig = trim($inputConfig);
    $updatePolicy = str_replace('<?xml version="1.0"?>', "", $updatePolicy);
    $updatePolicy = str_replace(' xmlns="http://www.ontoprise.de/smwplus#"', "", $updatePolicy);
    $updatePolicy = trim($updatePolicy);
    $importSetConfig = str_replace('<?xml version="1.0"?>', "", $importSetConfig);
    $importSetConfig = str_replace(' XMLNS="http://www.ontoprise.de/smwplus#"', "", $importSetConfig);
    $importSetConfig = str_replace('IMPORTSETS>', "ImportSets>", $importSetConfig);
    $importSetConfig = str_replace('IMPORTSET>', "ImportSet>", $importSetConfig);
    $importSetConfig = str_replace('NAME>', "Name>", $importSetConfig);
    $importSetConfig = trim($importSetConfig);
    $tiConfig = "<ImportSettings>" . $moduleConfig . $sourceConfig . $mappingConfig . $conflictConfig . $inputConfig . $importSetConfig . $updatePolicy . "</ImportSettings>";
    //pretty print
    $xml = explode("\n", preg_replace('/>\\s*</', ">\n<", $tiConfig));
    $tiConfig = implode("\n", $xml);
    $articleContent = $tiConfig;
    $articleContent .= "\n==== Last runs of this Term Import ====\n";
    $articleContent .= "{{#ask: [[belongsToTermImportWithLabel::" . $termImportName . "]]" . "\n| format=ul | limit=10 | sort=hasImportDate | order=descending}}";
    $articleContent .= "\n[[Category:TermImport]]";
    $result = smwf_om_EditArticle('TermImport:' . $termImportName, 'TermImportBot', $articleContent, '');
    $temp = $result;
    $result = explode(",", $result);
    $result = trim($result[0]);
    if ($result !== "true") {
        return '<?xml version="1.0"?>
	 			<ReturnValue xmlns="http://www.ontoprise.de/smwplus#">
	 		    <value>falseTIN</value>
	 		    <message>' . wfMsg('smw_ti_def_not_creatable') . '</message>
	 			</ReturnValue >';
    }
    smwf_om_TouchArticle("TermImport:" . $termImportName);
    return true;
}
/**
 * this method is called after step 3 (specify ws-name)
 *
 * @param string $name name of the webservice
 * @param string $wwsd the wwsd which was created
 * @return string error/ok signals if the wwsd could be validated
 */
function smwf_ws_processStep6($name, $wwsd, $user, $wsSyntax)
{
    global $wgHooks;
    $wgHooks['ArticleSaveComplete'][] = 'WebServiceManager::articleSavedHook';
    //$editResult = explode(",", smwf_om_EditArticle("webservice:".$name, $user, $wwsd.$wsSyntax, ""));
    $editResult = explode(",", smwf_om_EditArticle("webservice:" . $name, $user, $wwsd, ""));
    if ($editResult[0]) {
        $ws = WebService::newFromWWSD($name, $wwsd);
        if (is_array($ws)) {
            return "isa " . implode(";", $ws);
        } else {
            //$res = $ws->validateWWSD();
            // $res = $ws->store();
            // if(!$res){
            //	return "error";
            //}
            return smwf_om_TouchArticle("webservice:" . $name);
        }
    } else {
        return "false done";
    }
}
 public function doNotTestPriorityComputation()
 {
     smwf_om_EditArticle('QRCQueryArticle1', 'PHPUnit', $this->queryArticle1Version2, '');
     $request = json_encode(array('debug' => true));
     $response = smwf_qc_getQueryIds($request);
     $response = json_decode($response);
     $qrcStore = SMWQRCStore::getInstance()->getDB();
     $qId = $response->queryIds[0];
     $queryData = $qrcStore->getQueryData($qId);
     $this->assertEquals($queryData['priority'], SMWQRCPriorityCalculator::getInstance()->computeQueryUpdatePriority($queryData['lastUpdate'], $queryData['accessFrequency'], $queryData['invalidationFrequency']));
     $rememberedPriority = $queryData['priority'];
     $article = Article::newFromID(Title::newFromText('QRCQueryArticle1')->getArticleID());
     $content = $article->getContent();
     global $wgParser;
     $pOpts = new ParserOptions();
     $result = $wgParser->parse($content, Title::newFromText('QRCQueryArticle1'), $pOpts)->getText();
     $queryData = $qrcStore->getQueryData($qId);
     $this->assertEquals($queryData['priority'], SMWQRCPriorityCalculator::getInstance()->computeQueryUpdatePriority($queryData['lastUpdate'], $queryData['accessFrequency'], $queryData['invalidationFrequency']));
     $this->assertNotEquals($rememberedPriority, $queryData['priority']);
     $rememberedPriority = $queryData['priority'];
     global $wgTitle;
     $wgTitle = Title::newFromText('QRCDataArticle1');
     smwf_om_EditArticle('QRCDataArticle1', 'PHPUnit', '', '');
     $queryData = $qrcStore->getQueryData($qId);
     $this->assertEquals($queryData['priority'], SMWQRCPriorityCalculator::getInstance()->computeQueryUpdatePriority($queryData['lastUpdate'], $queryData['accessFrequency'], $queryData['invalidationFrequency']));
     $this->assertNotEquals($rememberedPriority, $queryData['priority']);
     $request = json_encode(array('debug' => true, 'queryId' => $qId));
     $response = smwf_qc_updateQuery($request);
     $response = json_decode($response);
     $queryData = $qrcStore->getQueryData($qId);
     $this->assertEquals($queryData['priority'], SMWQRCPriorityCalculator::getInstance()->computeQueryUpdatePriority($queryData['lastUpdate'], $queryData['accessFrequency'], $queryData['invalidationFrequency']));
     $this->assertNotEquals($rememberedPriority, $queryData['priority']);
 }
 public function createMergeResultArticle()
 {
     $dateString = $this->getDateString();
     $title = $this->title . "/WUM " . $dateString;
     $result = "\n==Merge Result==";
     $result .= "\n* Merged article was: [[merged article was::" . $this->title . "]]";
     $result .= "\n* Has merge date: [[has merge date::" . $dateString . "]]";
     $result .= "\n* Was merged successfully: [[was merged successfully::";
     if (count($this->unresolvedTableReplacements) == 0) {
         $result .= "true]]";
     } else {
         $result .= "false]]";
         $result .= "\n===Occured merge faults===";
         foreach ($this->unresolvedTableReplacements as $utr) {
             $result .= "\n====Table: " . str_replace("##", "; ", $utr->getFingerprint()) . "====";
             $result .= "\n<pre>" . $utr->getOriginalText() . "</pre>";
         }
     }
     $result .= "\n\n[[Category:WUMergeReport]]";
     smwf_om_EditArticle($title, 'WUM', $result, '');
 }