예제 #1
0
 public function run()
 {
     $neo4j_config = \Config::get('database.connections.neo4j');
     // Create an admin user
     $client = new Everyman\Neo4j\Client($neo4j_config['host'], $neo4j_config['port']);
     $client->getTransport()->setAuth($neo4j_config['username'], $neo4j_config['password']);
     foreach ($this->listNames as $listName) {
         $labels = [$client->makeLabel('E32'), $client->makeLabel('AuthorityDocument'), $client->makeLabel('MEDEA_NODE')];
         $nameLabel = $client->makeLabel($listName);
         $labels[] = $nameLabel;
         // Avoid duplicates
         $duplicates = $nameLabel->getNodes();
         foreach ($duplicates as $duplicate) {
             $relationships = $duplicate->getRelationships();
             foreach ($relationships as $rel) {
                 $rel->delete();
             }
             $this->command->info("Found duplicate for {$listName}, deleting it first in order to reseed.");
             $duplicate->delete();
         }
         $node = $client->makeNode();
         $node->save();
         $node->addLabels($labels);
         $functionName = 'get' . $listName;
         $node->setProperty('values', $this->{$functionName}());
         $node->save();
         $this->command->info("Seeded node, {$listName}");
     }
 }
예제 #2
0
 private function getPersonLabel()
 {
     $neo4j_config = \Config::get('database.connections.neo4j');
     // Create an admin
     $client = new Client($neo4j_config['host'], $neo4j_config['port']);
     $client->getTransport()->setAuth($neo4j_config['username'], $neo4j_config['password']);
     // Set a label configured client, equivalent of only returning a certain eloquent model
     return $client->makeLabel('E21');
 }
예제 #3
0
 public function getAllDonatur()
 {
     $client = new Client(HelperController::getHost(), HelperController::getPort());
     $client->getTransport()->setAuth(HelperController::getUserNeo4j(), HelperController::getPassNeo4j());
     $label = $client->makeLabel(HelperController::getLabelDonatur());
     $nodes = $label->getNodes();
     $status = 'success';
     $result = array();
     $properties = array();
     foreach ($nodes as $node) {
         $properties['id'] = $node->getId();
         $properties['properties'] = $node->getProperties();
         array_push($result, $properties);
     }
     return response()->json(array('status' => $status, 'data' => $result));
 }
예제 #4
0
 public function index()
 {
     // $client = new Client('localhost', 7474);
     // $client->getTransport()
     //   ->setAuth('neo4j', 'soulmate');
     $client = new Client('localhost', 7474);
     $client->getTransport()->setAuth('neo4j', 'neo4j');
     $label = $client->makeLabel('Muzakki');
     $nodes = $label->getNodes();
     $status = 'success';
     $result = array();
     $properties = array();
     foreach ($nodes as $node) {
         $properties['id'] = $node->getId();
         $properties['properties'] = $node->getProperties();
         array_push($result, $properties);
     }
     return response()->json(array('status' => $status, 'data' => $result));
 }
예제 #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $neo4j_config = \Config::get('database.connections.neo4j');
     // Create an admin
     $client = new Everyman\Neo4j\Client($neo4j_config['host'], $neo4j_config['port']);
     $client->getTransport()->setAuth($neo4j_config['username'], $neo4j_config['password']);
     // Check if the admin user already exists, if not create one.
     // Use the Person label, as described by the vocabulary the MEDEA project handles
     // Get the Person label
     $label = $client->makeLabel('Person');
     // Get all of the Person node with the admin email
     $nodes = $label->getNodes("email", "*****@*****.**");
     if ($nodes->count() == 0) {
         $users = new UserRepository();
         $admin = ['firstName' => 'Medea', 'lastName' => 'Admin', 'password' => 'foobar', 'email' => '*****@*****.**', 'verified' => true, 'description' => 'Dit is de generieke admin user van het MEDEA platform.', 'personType' => ['detectorist', 'validator', 'administrator', 'registrator', 'onderzoeker', 'vondstexpert'], 'showContactInfo' => 'never', 'passContactInfoToAgency' => false];
         $users->store($admin);
         $this->command->info("An admin user was created.");
     } else {
         $this->command->info("The admin user already exists.");
     }
     // Seed the values in the lists of MEDEA
     $this->call(ListValueSeeder::class);
 }