protected function linkData()
 {
     // use credential to access SPARQL server, if required
     if ($this->username) {
         HttpClient::useIdentity($this->username, $this->password);
     }
     if (!empty($this->endpoint) && !empty($this->constructor)) {
         // create links to data
         $sparql = new SparqlClient($this->endpoint);
         $endpointQuery = $this->templateEngine->setTemplate($this->constructor . ' LIMIT {limit} OFFSET {offset}')->render();
         $this->resultGraph = $sparql->query($endpointQuery);
         // add queryResource to template vars
         $this->templateEngine->addVar('queryResource', $this->endpoint . '?query=' . urlencode($endpointQuery));
         // calculate if hasNextPage according pagingPolicy
         $this->hasNextPage = $this->pagingPolicy == self::AGGRESSIVE ? $this->resultGraph->countTriples() == $this->context->getPageSize() : !$this->resultGraph->isEmpty();
     }
     return $this;
 }