public function prepareQuery()
{
// @doc This is when the object is a placeholder for others.
if (count($this->methods) <= 1) {
return true;
}
if (substr($this->methods[1], 0, 9) == 'hasLabel(') {
$first = array_shift($this->methods);
$query = implode('.', $this->methods);
$query = 'g.V().' . $first . '.groupCount("processed").by(count()).' . $query;
unset($this->methods[1]);
} elseif (substr($this->methods[1], 0, 39) == 'where( __.in("ANALYZED").has("analyzer"') {
$first = array_shift($this->methods);
// remove first
$init = array_shift($this->methods);
// remove first
preg_match('#"([^"\\/]+?/[^"]+?)"#', $init, $r);
$query = implode('.', $this->methods);
$query = 'g.V().hasLabel("Analysis").has("analyzer", "' . $r[1] . '").out("ANALYZED").as("first").groupCount("processed").by(count()).' . $query;
unset($this->methods[1]);
} else {
die('No optimization : gremlin query in analyzer should have use g.V. ! ' . $this->methods[1]);
}
// search what ? All ?
$query = <<<GREMLIN
{$query}
GREMLIN;
$query .= '.where( __.in("ANALYZED").has("analyzer", "' . $this->analyzerQuoted . '").count().is(eq(0)) ).groupCount("total").by(count()).addE("ANALYZED").from(g.V(' . $this->analyzerId . ')).cap("processed", "total")
// Query (#' . (count($this->queries) + 1) . ') for ' . $this->analyzerQuoted . '
// php ' . $this->config->executable . " analyze -p " . $this->config->project . ' -P ' . $this->analyzerQuoted . " -v\n";
$this->queries[] = $query;
$this->queriesArguments[] = $this->arguments;
// initializing a new query
return $this->initNewQuery();
}