public function run()
{
if (!file_exists($this->config->projects_root . '/projects/' . $this->config->project . '/config.ini')) {
throw new NoSuchProject($this->config->project);
}
$files = glob($this->exakatDir . '/*.csv');
foreach ($files as $file) {
unlink($file);
}
$this->checkTokenLimit();
$this->id0 = $this->addAtom('Project');
$this->setAtom($this->id0, array('code' => 'Whole', 'fullcode' => $this->config->project, 'line' => -1, 'token' => 'T_WHOLE'));
if (static::$client === null) {
static::$client = new CypherG3();
// static::$client = new GremlinServerNeo4j();
}
$this->datastore->cleanTable('tokenCounts');
if ($filename = $this->config->filename) {
if (!is_file($filename)) {
throw new MustBeAFile($filename);
}
if ($this->processFile($filename)) {
$this->saveFiles();
$this->saveDefinitions();
}
} elseif ($dirName = $this->config->dirname) {
if (!is_dir($dirName)) {
throw new MustBeADir($dirName);
}
$this->processDir($dirName);
} elseif (($project = $this->config->project) !== 'default') {
$this->processProject($project);
} else {
throw new NoFileToProcess($filename);
}
static::$client->finalize();
$this->datastore->addRow('hash', array('status' => 'Load'));
$loadFinal = new LoadFinal($this->gremlin, $this->config, self::IS_SUBTASK);
$loadFinal->run();
}
public function run() { $project = 'test'; // Check for requested file if (!empty($this->config->filename) && !file_exists($this->config->filename)) { throw new NoSuchFile($this->config->filename); } elseif (!empty($this->config->dirname) && !file_exists($this->config->dirname)) { throw new NoSuchDir($this->config->filename); } // Check for requested analyze $analyzer = $this->config->program; if (Analyzer::getClass($analyzer)) { $analyzers_class = array($analyzer); } else { $r = Analyzer::getSuggestionClass($analyzer); if (count($r) > 0) { echo 'did you mean : ', implode(', ', str_replace('_', '/', $r)), "\n"; } throw new NoSuchAnalyzer($analyzer); } display("Cleaning DB\n"); $clean = new CleanDb($this->gremlin, $this->config, Tasks::IS_SUBTASK); $clean->run(); $load = new Load($this->gremlin, $this->config, Tasks::IS_SUBTASK); $load->run(); unset($load); display("Project loaded\n"); $analyze = new Analyze($this->gremlin, $this->config, Tasks::IS_SUBTASK); $analyze->run(); unset($analyze); $results = new Results($this->gremlin, $this->config, Tasks::IS_SUBTASK); $results->run(); unset($results); display("Analyzed project\n"); }