private function addAuthorProperty($p, $projectVar, $list, $name = null) { $pIri = new Erfurt_Sparql_Query2_IriRef($p); if ($name == null) { $var = new Erfurt_Sparql_Query2_Var($pIri); } else { $var = new Erfurt_Sparql_Query2_Var($name); } $projectVar = new Erfurt_Sparql_Query2_Var($projectVar->getName() . substr(md5($pIri), 0, 5)); //for each property a new author var $authorVar = new Erfurt_Sparql_Query2_Var('author' . substr(md5($pIri), 0, 5)); $versionToProjectTriple = new Erfurt_Sparql_Query2_Triple($projectVar, new Erfurt_Sparql_Query2_IriRef(self::EXTENSION_RELEASE_PROPERTY), $list->getResourceVar()); $projectToAuthorTriple = new Erfurt_Sparql_Query2_Triple($projectVar, new Erfurt_Sparql_Query2_IriRef(self::EXTENSION_AUTHOR_PROPERTY), $authorVar); $authorPropertyTriple = new Erfurt_Sparql_Query2_Triple($authorVar, $pIri, $var); $list->addShownPropertyCustom(array($versionToProjectTriple, $projectToAuthorTriple, $authorPropertyTriple), $var); }
public function variable() { $value = null; $v = null; try { // Sparql10.g:277:5: (v= VAR1 | v= VAR2 ) $alt52 = 2; $LA52_0 = $this->input->LA(1); if ($LA52_0 == $this->getToken('VAR1')) { $alt52 = 1; } else { if ($LA52_0 == $this->getToken('VAR2')) { $alt52 = 2; } else { $nvae = new NoViableAltException("", 52, 0, $this->input); throw $nvae; } } switch ($alt52) { case 1: $v = $this->match($this->input, $this->getToken('VAR1'), self::$FOLLOW_VAR1_in_variable1686); $vartype = "?"; break; case 2: $v = $this->match($this->input, $this->getToken('VAR2'), self::$FOLLOW_VAR2_in_variable1698); $vartype = "\$"; break; } $value = new Erfurt_Sparql_Query2_Var($v != null ? $v->getText() : null); $value->setVarLabelType($vartype); } catch (RecognitionException $re) { $this->reportError($re); $this->recover($this->input, $re); } catch (Exception $e) { throw $e; } return $value; }
public function testExtraction() { $this->assertTrue(Erfurt_Sparql_Query2_Var::extractName('http://example.com/foaf/bob') == "bob"); $this->assertTrue(Erfurt_Sparql_Query2_Var::extractName('http://example.com/foaf#bob') == "bob"); $this->assertTrue(Erfurt_Sparql_Query2_Var::extractName('http://example.com/foaf/bob/') == "bob"); }