/** * Converts site.super[{user}] value from MongoId to string. * * @return void */ public function down() { $db = \DB::getMongoDB(); $sites = new MongoCollection($db, 'site'); $sitesCursor = $sites->find([], ['super' => true]); foreach ($sitesCursor as $site) { foreach ($site['super'] as $key => $supers) { $sites->update(['_id' => $site['_id']], ['$set' => ["super.{$key}.user" => (string) $supers['user']]], ['multiple' => true]); } } }
/** * Convert foreign id values from MongoId to string. * * @return void */ public function down() { // The Client model has a mutator that converts lrs_id from string to MongoId, // so the Mongo classes are used to directly modify the client collection. $db = \DB::getMongoDB(); $clients = new MongoCollection($db, 'client'); $lrsIds = $clients->aggregateCursor([['$group' => ['_id' => '$lrs_id']]]); foreach ($lrsIds as $lrsId) { $clients->update(['lrs_id' => $lrsId['_id']], ['$set' => ['lrs_id' => (string) $lrsId['_id']]], ['multiple' => true]); } echo 'Foreign id values in client collection converted from MongoId to string.' . PHP_EOL; }
/** * Removes documents from the client collection that have * an lrs_id that does not exist in the lrs collection. * * @return void */ public function up() { $db = \DB::getMongoDB(); $clients = new MongoCollection($db, 'client'); $lrss = new MongoCollection($db, 'lrs'); $clientCursor = $clients->find([], ['lrs_id' => true]); foreach ($clientCursor as $client) { $count = $lrss->count(['_id' => $client['lrs_id']]); if ($count == 0) { $clients->remove(['_id' => $client['_id']]); } } }
public function down() { $db = \DB::getMongoDB(); Lrs::get()->each(function (Lrs $lrs) use($db) { $users = $lrs->getAttribute('users'); foreach ($users as &$user) { $user['_id'] = (string) $user['_id']; } $lrs->setAttribute('users', $users); $lrs->owner_id = (string) $lrs->owner_id; $lrs->save(); echo 'IDs for lrs collection "' . $lrs->title . '" converted to strings.' . PHP_EOL; }); }
public function down() { $db = \DB::getMongoDB(); Lrs::get()->each(function (Lrs $lrs) use($db) { $convertToString = function ($value) { return (string) $value; }; $this->changeForeignKey($db->statements, 'lrs_id', 'lrs._id', $lrs->_id, $convertToString); $this->changeForeignKey($db->documentapi, 'lrs_id', 'lrs', $lrs->_id, $convertToString); $this->changeForeignKey($db->reports, 'lrs_id', 'lrs', $lrs->_id, $convertToString); $this->changeForeignKey($db->exports, 'lrs_id', 'lrs', $lrs->_id, $convertToString); $lrs->owner = ['_id' => $convertToString($lrs->owner_id)]; $lrs->save(); echo 'Models for "' . $lrs->title . '" converted.' . PHP_EOL; }); echo 'All finished, hopefully!' . PHP_EOL; }
public function getNear($country, $zip) { $zip = strtoupper($zip); $country = strtoupper($country); $cacheKey = $this->key->ofType('placeNear')->inCountry($country)->forCode($zip)->generate(); if ($this->cache->has($cacheKey)) { return $this->cache->get($cacheKey); } else { $placeKey = $this->key->ofType("placeByName")->forCode($zip)->inCountry($country)->generate(); if ($this->cache->has($placeKey)) { $place = $this->cache->get($placeKey); } else { $place = $this->places->where('post code', $zip)->where('country abbreviation', $country)->get()->first(); } $mongo = \DB::getMongoDB(); $places = $mongo->selectCollection('nearby')->aggregate([['$geoNear' => ['near' => [floatval($place->longitude), floatval($place->latitude)], 'spherical' => true, 'limit' => 30, 'distanceField' => 'distance', 'distanceMultiplier' => 3959]]]); return $this->places->hydrate($places['result']); } }
/** * Run the migrations. * * @return void */ public function up() { $db = \DB::getMongoDB(); $indexOptions = ['background' => 1, 'socketTimeoutMS' => -1]; $statements = new MongoCollection($db, 'statements'); $statements->createIndex(['statement.id' => 1, 'lrs_id' => 1], $indexOptions); $statements->createIndex(['statement.actor.mbox' => 1], $indexOptions); $statements->createIndex(['stored' => 1], $indexOptions); $statements->createIndex(['timestamp' => 1], $indexOptions); $statements->createIndex(['active' => 1], $indexOptions); $statements->createIndex(['voided' => 1], $indexOptions); $statements->createIndex(['lrs_id' => 1], $indexOptions); $statements->createIndex(['lrs_id' => 1, 'active' => -1, 'voided' => 1], $indexOptions); $statements->createIndex(['lrs_id' => 1, 'statement.actor.account.name' => 1, 'statement.actor.account.homePage' => 1], $indexOptions); $statements->createIndex(['lrs_id' => 1, 'statement.actor.mbox' => 1], $indexOptions); $statements->createIndex(['lrs_id' => 1, 'statement.verb.id' => 1], $indexOptions); $statements->createIndex(['lrs_id' => 1, 'statement.object.id' => 1], $indexOptions); $statements->createIndex(['lrs_id' => 1, 'stored' => -1], $indexOptions); $statements->createIndex(['lrs_id' => 1, 'timestamp' => -1], $indexOptions); }
/** * Reverse the migrations. * * @return void */ public function down() { $db = \DB::getMongoDB(); $statementsCollection = new MongoCollection($db, 'statements'); $statementsCollection->deleteIndex('stored'); $statementsCollection->deleteIndex(['lrs_id' => 1, 'stored' => -1]); $statementsCollection->update([], ['$unset' => ["stored" => ""]], ['multiple' => true]); $statementsCursor = $statementsCollection->find(); $remaining = $statementsCursor->count(); print $remaining . ' statements total' . PHP_EOL; $maxBatchSize = 10000; while ($statementsCursor->hasNext()) { $batch = new MongoUpdateBatch($statementsCollection); $batchSize = 0; $shouldExecute = false; while ($batchSize < $maxBatchSize && $statementsCursor->hasNext()) { $batchSize++; $statement = $statementsCursor->next(); if (isset($statement['refs'])) { $query = ['q' => ['_id' => $statement['_id']], 'u' => ['$set' => []], 'multi' => false, 'upsert' => false]; foreach ($statement['refs'] as $key => $refStatement) { if (isset($refStatement['timestamp']) && $refStatement['timestamp'] instanceof MongoDate) { $query['u']['$set']['refs.' . $key . '.timestamp'] = date('Y-m-d\\TH:i:s.uP', $refStatement['timestamp']->sec); } if (isset($refStatement['stored']) && $refStatement['stored'] instanceof MongoDate) { $query['u']['$set']['refs.' . $key . '.stored'] = date('Y-m-d\\TH:i:s.uP', $refStatement['stored']->sec); } } if (!empty($query['u']['$set'])) { $batch->add((object) $query); $shouldExecute = true; } } } if ($shouldExecute) { $batch->execute(); } $remaining -= $batchSize; print $remaining . ' remaining' . PHP_EOL; } }
public function testDb() { $this->assertInstanceOf('MongoDB', DB::getMongoDB()); }
/** * Destroys the model with the given ID and options. * @param String $id ID to match. * @param [String => Mixed] $opts * @return Boolean */ public function destroy($id, array $opts) { $client = $this->show($id, $opts); \DB::getMongoDB()->oauth_clients->remove(['client_id' => $client->api['basic_key']]); if ($this->where($opts)->count() < 2) { $this->store(['authority' => ['name' => 'Must have client', 'mbox' => 'mailto:hello@learninglocker.net']], $opts); } return parent::destroy($id, $opts); }
public function getMapreduceworker() { $db = \DB::getMongoDB(); $db->execute('loadServerScripts'); // $map = new \MongoCode("function() {\r\n var key = this['crowdAgent_id'];\r\n\r\n var annVects = this.annotationVector;\r\n\t\t\t\t\t\t\tvar contr = this.contradiction;\r\n for (iterMTasks in annVects){\r\n var annVector = annVects[iterMTasks];\r\n var unit_id = this['unit_id'] + '/' + iterMTasks;\r\n if (units_to_remove.indexOf(unit_id) == -1) {\r\n var value = { 'workerunits' : [{ unit_id:unit_id , vector:annVector, count:1, contradiction:contr}]};\r\n emit(key, value);\r\n }\r\n }\r\n }"); $reduce = new \MongoCode("function(key, units) {\r\n var uniqueUnits = {};\r\n var contradictions = {};\r\n var freqUnits = {};\r\n for (iterUnit in units) {\r\n workerunits = units[iterUnit]['workerunits'];\r\n for (iterWorker in workerunits) {\r\n unit_id = workerunits[iterWorker]['unit_id'];\r\n if(unit_id in uniqueUnits) {\r\n for (annKey in workerunits[iterWorker]['vector']) {\r\n uniqueUnits[unit_id][annKey] += workerunits[iterWorker]['vector'][annKey];\r\n\t\t\t\t\t\t}\r\n freqUnits[unit_id] += workerunits[iterWorker]['count'];\r\n\t\t\t\t\t contradictions[unit_id] = workerunits[iterWorker]['contradiction'];\r\n\t\t\t\t\t} else {\r\n uniqueUnits[unit_id] = workerunits[iterWorker]['vector'];\r\n freqUnits[unit_id] = workerunits[iterWorker]['count'];\r\n\t\t\t\t\t\tcontradictions[unit_id] = workerunits[iterWorker]['contradiction'];\r\n }\r\n }\r\n }\r\n var result = { 'workerunits' :[]};\r\n for (unit_id in uniqueUnits) {\r\n var unitInfo = {};\r\n unitInfo['unit_id'] = unit_id;\r\n unitInfo['contradiction'] = contradictions[unit_id];\r\n unitInfo['vector'] = uniqueUnits[unit_id];\r\n unitInfo['count'] = freqUnits[unit_id];\r\n result.workerunits.push(unitInfo);\r\n }\r\n\r\n return result;\r\n }"); $scope = array(); $aggregateOperators = $this->processAggregateInput(Input::all()); if (array_key_exists('unit_id', $aggregateOperators['$match'])) { ksort($aggregateOperators['$match']['unit_id']['$nin']); } if (array_key_exists('unit_id', $aggregateOperators['$match'])) { $scope = $aggregateOperators['$match']['unit_id']['$nin']; } $sales = $db->command(array("mapreduce" => "entities", "map" => $map, "reduce" => $reduce, "scope" => array('units_to_remove' => array_flatten($scope)), "query" => $aggregateOperators['$match'], "out" => array("inline" => 1))); return $sales; }
public function setup() { parent::setup(); \DB::getMongoDB()->oauth_clients->insert(['client_id' => $this->ll_client->api['basic_key'], 'client_secret' => $this->ll_client->api['basic_secret'], 'redirect_uri' => 'http://www.example.com/']); }
public function down() { DB::getMongoDB()->oauth_clients->remove([]); }
public static function createJobCache() { \Session::flash('rawArray', 1); $db = \DB::getMongoDB(); $db = $db->temp; $result = Entity::where('type', 'job')->with('hasConfiguration')->get()->toArray(); if (count($result) > 0) { try { Temp::where('type', 'job')->forceDelete(); $db->batchInsert($result, array('continueOnError' => true)); } catch (Exception $e) { // ContinueOnError will still throw an exception on duplication, even though it continues, so we just move on. } } \Session::forget('rawArray'); }
public function __construct() { $this->db = \DB::getMongoDB(); }
function createStatisticsForMetadatadescriptionCache($id) { set_time_limit(5200); \Session::flash('rawArray', 1); $db = \DB::getMongoDB(); $db = $db->entities; $result = \MongoDB\Entity::where('_id', $id)->get()->toArray(); // dd($result); foreach ($result as &$parent) { $children = \MongoDB\Entity::whereIn('parents', [$id])->where('content.features.cleanedUpEntities', 'exists', true)->where("documentType", '!=', "annotatedmetadatadescription")->get(['content.features'])->toArray(); // dd($children); $eventChildren = \MongoDB\Entity::whereIn('parents', [$id])->where('content.automatedEvents', 'exists', true)->get(['content.automatedEvents'])->toArray(); $parent['content']['features'] = array(); $parent['content']['features']['cleanedUpEntities'] = array(); $parent['content']['features']['automatedEvents'] = array(); $parent['content']['features']['topics'] = array(); $parent['content']['features']['people'] = array(); $parent['content']['features']['time'] = array(); $parent['content']['features']['location'] = array(); $parent['content']['features']['other'] = array(); $parent['annotations'] = array(); $parent['annotations']['statistics'] = array(); $parent['annotations']['features'] = array(); $parent['annotations']['statistics']['majvoting'] = array(); $parent['annotations']['statistics']["crowdtruthmetrics"] = array(); $parent['annotations']['features']['cleanedUpEntities'] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"] = array(); $parent['annotations']['statistics']["crowdtruthmetrics"]["cleanedUpEntities"] = array(); $parent['annotations']['features']['topics'] = array(); foreach ($children as $child) { if (isset($child["content"]["features"]["topics"])) { $parent['annotations']['features']['topics'] = $child["content"]["features"]["topics"]; $parent['content']['features']['topics'] = $child["content"]["features"]["topics"]; } } foreach ($eventChildren as $child) { if (isset($child["content"]["automatedEvents"])) { $parent['annotations']['automatedEvents'] = $child["content"]["automatedEvents"]; $parent['content']['features']['automatedEvents'] = $child["content"]["automatedEvents"]; } } foreach ($children as $child) { if (!empty($child['content']['features']['cleanedUpEntities'])) { foreach ($child['content']['features']['cleanedUpEntities'] as $childKey => $childValue) { $found = false; foreach ($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"] as $parentKey => $parentValue) { if (strtolower($childValue["label"]) == strtolower($parentValue["label"]) && intval($childValue["startOffset"]) == intval($parentValue["startOffset"]) && intval($childValue["endOffset"]) == intval($parentValue["endOffset"])) { $found = true; array_push($parent['annotations']["features"]["cleanedUpEntities"][$parentKey]["extractors"], $childValue["provenance"]); array_push($parent['content']["features"]["cleanedUpEntities"][$parentKey]["extractors"], $childValue["provenance"]); array_push($parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["extractors"], $childValue["provenance"]); $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"] += 1; $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["relevanceScore"]["value"] = $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"] / 6; $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["extractors"][$childValue["provenance"]] = $childValue["confidence"]; $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["value"] = max($parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["extractors"]); $noConf = 0; foreach ($parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["extractors"] as $confKey => $confVal) { if ($confVal != null) { $noConf++; } } if ($noConf != 0) { $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["mean"] = array_sum($parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["extractors"]) / $noConf; $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["stddev"] = $this->stats_stddev_func($parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["extractors"]); $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["mse"] = pow($parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["stddev"], 2) / $noConf; } else { $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["mean"] = $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["value"]; $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["stddev"] = $this->stats_stddev_func($parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["confidence"]["extractors"]); $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["mse"] = pow($parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["clarity"]["stddev"], 2); } foreach ($childValue["types"] as $keyType => $valueType) { $foundType = false; foreach ($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"] as $parentTypeKey => $parentTypeValue) { if ($parentTypeKey == strtolower($valueType["typeURI"])) { if (!in_array($childValue["provenance"], $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][$parentTypeKey]["extractors"])) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][$parentTypeKey]["count"] += 1; array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][$parentTypeKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][$parentTypeKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][$parentTypeKey]["count"] / $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundType = true; } else { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][$parentTypeKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][$parentTypeKey]["count"] / $parent['annotations']["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } if ($foundType == true) { break; } } if ($foundType == false) { if ($valueType["typeURI"] != null) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][strtolower($valueType["typeURI"])] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][strtolower($valueType["typeURI"])]["count"] = 1; $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][strtolower($valueType["typeURI"])]["extractors"] = array(); array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][strtolower($valueType["typeURI"])]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][strtolower($valueType["typeURI"])]["relevanceScore"] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerType"][strtolower($valueType["typeURI"])]["relevanceScore"]["value"] = 1 / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } } $foundResource = false; foreach ($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"] as $parentResourceKey => $parentResourceValue) { if (strtolower($parentResourceKey) == strtolower($valueType["entityURI"])) { if (!in_array($childValue["provenance"], $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$parentResourceKey]["extractors"])) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$parentResourceKey]["count"] += 1; array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$parentResourceKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$parentResourceKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$parentResourceKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundResource = true; } else { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$parentResourceKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$parentResourceKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } if ($foundResource == true) { break; } } if ($foundResource == false) { if ($valueType["entityURI"] != null) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$valueType["entityURI"]] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$valueType["entityURI"]]["count"] = 1; $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$valueType["entityURI"]]["extractors"] = array(); array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$valueType["entityURI"]]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$valueType["entityURI"]]["relevanceScore"] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsPerResource"][$valueType["entityURI"]]["relevanceScore"]["value"] = 1 / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } } $foundLabelTypePair = false; $tempTypeValue = ""; if ($valueType["typeURI"] != null) { $tempTypeValue = strtolower($valueType["typeURI"]); } foreach ($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"] as $parentLabelTypeKey => $parentLabelTypeValue) { if (strtolower($parentLabelTypeKey) == strtolower($childValue["label"] . "-" . $tempTypeValue)) { if (!in_array($childValue["provenance"], $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$parentLabelTypeKey]["extractors"])) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$parentLabelTypeKey]["count"] += 1; array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$parentLabelTypeKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$parentLabelTypeKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$parentLabelTypeKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundLabelTypePair = true; } else { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$parentLabelTypeKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$parentLabelTypeKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } if ($foundLabelTypePair == true) { break; } } if ($foundLabelTypePair == false) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$childValue["label"] . "-" . $tempTypeValue] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$childValue["label"] . "-" . $tempTypeValue]["count"] = 1; $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$childValue["label"] . "-" . $tempTypeValue]["extractors"] = array(); array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$childValue["label"] . "-" . $tempTypeValue]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$childValue["label"] . "-" . $tempTypeValue]["relevanceScore"] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypePair"][$childValue["label"] . "-" . $tempTypeValue]["relevanceScore"]["value"] = 1 / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundLabelResourcePair = false; $tempResourceValue = ""; if ($valueType["entityURI"] != null) { $tempResourceValue = $valueType["entityURI"]; } foreach ($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"] as $parentLabelResourceKey => $parentLabelResourceValue) { if (strtolower($parentLabelResourceKey) == strtolower($childValue["label"] . "-" . $tempResourceValue)) { if (!in_array($childValue["provenance"], $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["extractors"])) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["count"] += 1; array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundLabelResourcePair = true; } else { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } if ($foundLabelResourcePair == true) { break; } } if ($foundLabelResourcePair == false) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["count"] = 1; $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["extractors"] = array(); array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["relevanceScore"] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelResourcePair"][$parentLabelResourceKey]["relevanceScore"]["value"] = 1 / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundTypeResourcePair = false; $tempTypeValue = ""; $tempResourceValue = ""; if ($valueType["entityURI"] != null) { $tempResourceValue = $valueType["entityURI"]; } if ($valueType["typeURI"] != null) { $tempTypeValue = $valueType["typeURI"]; } foreach ($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"] as $parentLabelTypeKey => $parentLabelTypeValue) { if (strtolower($parentLabelTypeKey) == strtolower($tempTypeValue . "-" . $tempResourceValue)) { if (!in_array($childValue["provenance"], $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["extractors"])) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["count"] += 1; array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundTypeResourcePair = true; } else { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } if ($foundTypeResourcePair == true) { break; } } if ($foundTypeResourcePair == false) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["count"] = 1; $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["extractors"] = array(); array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["relevanceScore"] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsTypeResourcePair"][$parentLabelTypeKey]["relevanceScore"]["value"] = 1 / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundLabelTypeResourcePair = false; foreach ($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"] as $parentLabelTypeResourceKey => $parentLabelTypeResourceValue) { if (strtolower($parentLabelTypeResourceKey) == strtolower($childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue)) { if (!in_array($childValue["provenance"], $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["extractors"])) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["count"] += 1; array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } $foundLabelTypeResourcePair = true; } else { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["relevanceScore"]["value"] = $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["count"] / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } if ($foundLabelTypeResourcePair == true) { break; } } if ($foundLabelTypeResourcePair == false) { $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["count"] = 1; $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["extractors"] = array(); array_push($parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["extractors"], $childValue["provenance"]); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["relevanceScore"] = array(); $parent['annotations']['statistics']['majvoting']["cleanedUpEntities"][$parentKey]["noExtractorsLabelTypeResourcePair"][$parentLabelTypeResourceKey]["relevanceScore"]["value"] = 1 / $parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"][$parentKey]["noExtractorsPerLabel"]["count"]; } } } if ($found == true) { break; } // break; } if ($found == false) { $extractedEntity = array(); $extractedEntity["label"] = $childValue["label"]; $extractedEntity["startOffset"] = intval($childValue["startOffset"]); $extractedEntity["endOffset"] = intval($childValue["endOffset"]); $extractedEntity["extractors"] = array(); array_push($extractedEntity["extractors"], $childValue["provenance"]); $newEntity = array(); $newEntity["label"] = $childValue["label"]; $newEntity["startOffset"] = $childValue["startOffset"]; $newEntity["endOffset"] = $childValue["endOffset"]; $newEntity["noExtractorsPerLabel"] = array(); $newEntity["noExtractorsPerLabel"]["extractors"] = array(); array_push($newEntity["noExtractorsPerLabel"]["extractors"], $childValue["provenance"]); $newEntity["noExtractorsPerLabel"]["count"] = 1; $newEntity["noExtractorsPerLabel"]["relevanceScore"] = array(); $newEntity["noExtractorsPerLabel"]["relevanceScore"]["value"] = 1 / 6; $newEntity["confidence"] = array(); $newEntity["confidence"]["extractors"] = array(); $newEntity["confidence"]["extractors"][$childValue["provenance"]] = $childValue["confidence"]; $newEntity["confidence"]["value"] = $childValue["confidence"]; $newEntity["clarity"] = array(); $newEntity["clarity"]["mean"] = $childValue["confidence"]; $newEntity["clarity"]["stddev"] = $this->stats_stddev_func($newEntity["confidence"]["extractors"]); $newEntity["clarity"]["mse"] = pow($newEntity["clarity"]["stddev"], 2) / 1; $newEntity["noExtractorsPerType"] = array(); $newEntity["noExtractorsPerResource"] = array(); $newEntity["noExtractorsLabelTypePair"] = array(); $newEntity["noExtractorsLabelResourcePair"] = array(); $newEntity["noExtractorsTypeResourcePair"] = array(); $newEntity["noExtractorsLabelTypeResourcePair"] = array(); foreach ($childValue["types"] as $keyType => $valueType) { if ($valueType["typeURI"] != null || $valueType["typeURI"] != "") { $newEntity["noExtractorsPerType"][strtolower($valueType["typeURI"])] = array(); $newEntity["noExtractorsPerType"][strtolower($valueType["typeURI"])]["count"] = 1; $newEntity["noExtractorsPerType"][strtolower($valueType["typeURI"])]["extractors"] = array(); array_push($newEntity["noExtractorsPerType"][strtolower($valueType["typeURI"])]["extractors"], $childValue["provenance"]); $newEntity["noExtractorsPerType"][strtolower($valueType["typeURI"])]["relevanceScore"] = array(); $newEntity["noExtractorsPerType"][strtolower($valueType["typeURI"])]["relevanceScore"]["value"] = 1; } if ($valueType["entityURI"] != null) { $newEntity["noExtractorsPerResource"][$valueType["entityURI"]] = array(); $newEntity["noExtractorsPerResource"][$valueType["entityURI"]]["count"] = 1; $newEntity["noExtractorsPerResource"][$valueType["entityURI"]]["extractors"] = array(); array_push($newEntity["noExtractorsPerResource"][$valueType["entityURI"]]["extractors"], $childValue["provenance"]); $newEntity["noExtractorsPerResource"][$valueType["entityURI"]]["relevanceScore"] = array(); $newEntity["noExtractorsPerResource"][$valueType["entityURI"]]["relevanceScore"]["value"] = 1; } $tempTypeValue = ""; if ($valueType["typeURI"] != null || $valueType["typeURI"] != "") { $tempTypeValue = strtolower($valueType["typeURI"]); } if (!array_key_exists($childValue["label"] . "-" . strtolower($tempTypeValue), $newEntity["noExtractorsLabelTypePair"])) { $newEntity["noExtractorsLabelTypePair"][$childValue["label"] . "-" . strtolower($tempTypeValue)] = array(); $newEntity["noExtractorsLabelTypePair"][$childValue["label"] . "-" . strtolower($tempTypeValue)]["count"] = 1; $newEntity["noExtractorsLabelTypePair"][$childValue["label"] . "-" . strtolower($tempTypeValue)]["extractors"] = array(); array_push($newEntity["noExtractorsLabelTypePair"][$childValue["label"] . "-" . strtolower($tempTypeValue)]["extractors"], $childValue["provenance"]); $newEntity["noExtractorsLabelTypePair"][$childValue["label"] . "-" . strtolower($tempTypeValue)]["relevanceScore"] = array(); $newEntity["noExtractorsLabelTypePair"][$childValue["label"] . "-" . strtolower($tempTypeValue)]["relevanceScore"]["value"] = 1; } $tempResourceValue = ""; if ($valueType["entityURI"] != null || $valueType["typeURI"] != "") { $tempResourceValue = $valueType["entityURI"]; } if (!array_key_exists($childValue["label"] . "-" . $tempResourceValue, $newEntity["noExtractorsLabelResourcePair"])) { $newEntity["noExtractorsLabelResourcePair"][$childValue["label"] . "-" . $tempResourceValue] = array(); $newEntity["noExtractorsLabelResourcePair"][$childValue["label"] . "-" . $tempResourceValue]["count"] = 1; $newEntity["noExtractorsLabelResourcePair"][$childValue["label"] . "-" . $tempResourceValue]["extractors"] = array(); array_push($newEntity["noExtractorsLabelResourcePair"][$childValue["label"] . "-" . $tempResourceValue]["extractors"], $childValue["provenance"]); $newEntity["noExtractorsLabelResourcePair"][$childValue["label"] . "-" . $tempResourceValue]["relevanceScore"] = array(); $newEntity["noExtractorsLabelResourcePair"][$childValue["label"] . "-" . $tempResourceValue]["relevanceScore"]["value"] = 1; } if (!array_key_exists($tempTypeValue . "-" . $tempResourceValue, $newEntity["noExtractorsTypeResourcePair"])) { $newEntity["noExtractorsTypeResourcePair"][$tempTypeValue . "-" . $tempResourceValue] = array(); $newEntity["noExtractorsTypeResourcePair"][$tempTypeValue . "-" . $tempResourceValue]["count"] = 1; $newEntity["noExtractorsTypeResourcePair"][$tempTypeValue . "-" . $tempResourceValue]["extractors"] = array(); array_push($newEntity["noExtractorsTypeResourcePair"][$tempTypeValue . "-" . $tempResourceValue]["extractors"], $childValue["provenance"]); $newEntity["noExtractorsTypeResourcePair"][$tempTypeValue . "-" . $tempResourceValue]["relevanceScore"] = array(); $newEntity["noExtractorsTypeResourcePair"][$tempTypeValue . "-" . $tempResourceValue]["relevanceScore"]["value"] = 1; } if (!array_key_exists($childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue, $newEntity["noExtractorsLabelTypeResourcePair"])) { $newEntity["noExtractorsLabelTypeResourcePair"][$childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue] = array(); $newEntity["noExtractorsLabelTypeResourcePair"][$childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue]["count"] = 1; $newEntity["noExtractorsLabelTypeResourcePair"][$childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue]["extractors"] = array(); array_push($newEntity["noExtractorsLabelTypeResourcePair"][$childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue]["extractors"], $childValue["provenance"]); $newEntity["noExtractorsLabelTypeResourcePair"][$childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue]["relevanceScore"] = array(); $newEntity["noExtractorsLabelTypeResourcePair"][$childValue["label"] . "-" . $tempTypeValue . "-" . $tempResourceValue]["relevanceScore"]["value"] = 1; } } array_push($parent['annotations']['statistics']['majvoting']['cleanedUpEntities'], $newEntity); array_push($parent['annotations']['features']['cleanedUpEntities'], $extractedEntity); array_push($parent['content']['features']['cleanedUpEntities'], $extractedEntity); // dd($parent['annotations']['features']['cleanedUpEntities']); } } } } foreach ($parent["annotations"]["statistics"]["majvoting"]["cleanedUpEntities"] as $ent) { $foundP = false; $foundL = false; $foundT = false; $foundO = false; $types = array_keys($ent["noExtractorsPerType"]); if (count($types) == 0) { $newOther = array(); $newOther["label"] = $ent["label"]; $newOther["startOffset"] = $ent["startOffset"]; $newOther["endOffset"] = $ent["endOffset"]; array_push($parent['content']['features']['other'], $newOther); continue; } foreach ($types as $type) { if (stripos($type, "person") || stripos($type, "agent") || stripos($type, "organization")) { if ($foundP == true) { continue; } $foundP = true; $newPeople = array(); $newPeople["label"] = $ent["label"]; $newPeople["startOffset"] = $ent["startOffset"]; $newPeople["endOffset"] = $ent["endOffset"]; array_push($parent['content']['features']['people'], $newPeople); } else { if (stripos($type, "place") || stripos($type, "settlement") || stripos($type, "country") || stripos($type, "city") || stripos($type, "location") || stripos($type, "land")) { if ($foundL == true) { continue; } $foundL = true; $newLocation = array(); $newLocation["label"] = $ent["label"]; $newLocation["startOffset"] = $ent["startOffset"]; $newLocation["endOffset"] = $ent["endOffset"]; array_push($parent['content']['features']['location'], $newLocation); } else { if (stripos($type, "time") || stripos($type, "period") || stripos($type, "year") || stripos($type, "date")) { if ($foundT == true) { continue; } $foundT = true; $newTime = array(); $newTime["label"] = $ent["label"]; $newTime["startOffset"] = $ent["startOffset"]; $newTime["endOffset"] = $ent["endOffset"]; array_push($parent['content']['features']['time'], $newTime); } else { if ($foundO == true) { continue; } $foundO = true; $newOther = array(); $newOther["label"] = $ent["label"]; $newOther["startOffset"] = $ent["startOffset"]; $newOther["endOffset"] = $ent["endOffset"]; array_push($parent['content']['features']['other'], $newOther); } } } } } $parent['content']['otherCount'] = count($parent['content']['features']['other']); $parent['content']['peopleCount'] = count($parent['content']['features']['people']); $parent['content']['timeCount'] = count($parent['content']['features']['time']); $parent['content']['locationCount'] = count($parent['content']['features']['location']); $parent['content']['automatedEventsCount'] = count($parent['content']['features']['automatedEvents']); $words = explode(" ", $parent["content"]["description"]); $parent["wordCount"] = count($words); $parent["totalNoOfFeatures"] = count($parent["content"]["features"]["cleanedUpEntities"]) + count($parent["content"]["features"]["automatedEvents"]); // $content = $result["content"]; // $content["features"] = $parent['annotations']['features']; // $result["content"] = $content; // $result["annotations"] = $parent['annotations']; // dd($result); try { \MongoDB\Entity::where('_id', '=', $id)->forceDelete(); // \MongoDB\Entity::insert($result); // $result->save(); $db->batchInsert($result, array('continueOnError' => true)); } catch (Exception $e) { // ContinueOnError will still throw an exception on duplication, even though it continues, so we just move on. } } \Session::forget('rawArray'); // dd("done"); }
protected function setDB() { $this->db = \DB::getMongoDB(); }
public function setUp() { parent::setUp(); // reset MongoDB database before any test DB::getMongoDB()->drop(); }
/** * Delete the model from the database. * * @return bool|null * @throws \Exception */ public function delete() { \DB::getMongoDB()->oauth_clients->remove(['client_id' => $this->api['basic_key']]); parent::delete(); }