public function testConversion()
 {
     $gen = new Neogen();
     $p = '(person:Person {firstname:firstName, lastname:lastName} *5)-[:WORKS_AT *n..1]->(company:Company {name:company} *10)
     (actor:Person:Actor {name:fullName, birthdate:{dateTimeBetween:["-50 years","-18 years"]}} *10)-[:WORKS_AT {since:{dateTimeBetween:["-5 years","-1 years"]}} *n..1]->(company)';
     $graph = $gen->generateGraphFromCypher($p);
     $converter = new CypherStatementsConverter();
     $converter->convert($graph);
     $client = ClientBuilder::create()->addDefaultLocalConnection()->build();
     $client->sendCypherQuery('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r,n');
     $statements = $converter->getStatements();
     foreach ($statements['constraints'] as $st) {
         $client->sendCypherQuery($st['statement']);
     }
     foreach ($statements['nodes'] as $st) {
         $client->sendCypherQuery($st['statement'], $st['parameters']);
     }
     foreach ($statements['edges'] as $st) {
         if (!isset($st['parameters'])) {
             $parameters = array();
         } else {
             $parameters = $st['parameters'];
         }
         $client->sendCypherQuery($st['statement'], $parameters);
     }
 }
Beispiel #2
0
 public function testLinkedList()
 {
     $gen = new Neogen();
     $p = '(test:Test *5)
     (test)-[:NEXT *1..1]->(test)';
     $graph = $gen->generateGraphFromCypher($p);
 }
Beispiel #3
0
    public function testPatternProcessing1()
    {
        $p = '(p:Product *1)
(cc:ComponentCategory *20)-[:PART_OF {quantity: {randomNumber: [3]}} *n..1]->(p)
(csc:ComponentSubCategory *20)-[:PART_OF {quantity: {randomNumber: [3]}} *n..1]->(cc)
(c:Component {price: {randomNumber: [2]}} *20)-[:PART_OF {quantity: {randomNumber: [3]}} *n..1]->(csc)';
        $gen = new Neogen();
        $schema = $gen->generateGraphFromCypher($p);
        $converter = new CypherStatementsConverter();
        $converter->convert($schema);
        $edgesStatements = $converter->getEdgeStatements();
        $this->assertCount(7, $edgesStatements);
        $this->assertCount(4, $converter->getNodeStatements());
    }
 public function testGraphToCypherStatements()
 {
     $gen = new Neogen();
     $p = '(person:Person {firstname:firstName, lastname:lastName} *5)-[:WORKS_AT *n..1]->(company:Company {name:company} *10)
     (actor:Person:Actor {name:fullName, birthdate:{dateTimeBetween:["-50 years","-18 years"]}} *10)-[:WORKS_AT {since:{dateTimeBetween:["-5 years","-1 years"]}} *n..1]->(company)';
     $graph = $gen->generateGraphFromCypher($p);
     $converter = new StandardCypherConverter();
     $converter->convert($graph);
     $file = getcwd() . '/sts.cql';
     $contents = '';
     foreach ($converter->getStatements() as $st) {
         $contents .= $st . "\n";
     }
     file_put_contents($file, $contents);
 }
Beispiel #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $neogen = Neogen::create()->build();
     $yamlParser = $neogen->getParserManager()->getParser('yaml');
     $filePath = getcwd() . '/neogen.yml';
     $schema = $yamlParser->parse($filePath);
     $start = microtime(true);
     $g = $neogen->generateGraph($schema);
     $end = microtime(true);
     print $end - $start;
     echo PHP_EOL;
     $serializer = $neogen->getServiceContainer()->get('neogen.graph_serializer');
     //$json = $serializer->serializeGraphToJson($g);
 }
Beispiel #6
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Neoxygen\Neogen\Neogen;
use Neoxygen\Neogen\Schema\GraphSchemaBuilder;
//gc_disable();
$neogen = Neogen::create()->build();
$gsb = new GraphSchemaBuilder();
$file = __DIR__ . '/neogen.yml';
$p = $neogen->getParserManager()->getParser('YamlParser');
$userSchema = $p->parse($file);
$def = $gsb->buildGraph($userSchema);
$gen = $neogen->getGraphGenerator();
$g = $gen->generateGraph($def);
print_r($g);
 public function setup()
 {
     $this->neogen = Neogen::create()->build();
 }
Beispiel #8
0
 public function testGraphGeneratorIsAvailable()
 {
     $this->assertInstanceOf('Neoxygen\\Neogen\\GraphGenerator\\Generator', $this->neogen->getGraphGenerator());
 }
 private function generateGraph()
 {
     $gen = new Neogen();
     $graph = $gen->generateGraphFromCypher($this->source);
     return $graph;
 }
Beispiel #10
0
 public function loadGraphInDB($pattern)
 {
     $this->clearDB();
     $gen = new Neogen();
     $schema = $gen->generateGraphFromCypher($pattern);
     $converter = new CypherStatementsConverter();
     $converter->convert($schema);
     $statements = $converter->getStatements();
     foreach ($statements as $statement) {
         if (is_array($statement)) {
             foreach ($statement as $st) {
                 $props = isset($st['parameters']) ? $st['parameters'] : array();
                 $this->sendQuery($st['statement'], $props);
             }
         } else {
             $props = isset($statement['parameters']) ? $statement['parameters'] : array();
             $this->sendQuery($statement['statement'], $props);
         }
     }
 }