Exemple #1
0
 public function createBatchCreatorSoftwareAgent()
 {
     if (!\MongoDB\SoftwareAgent::find('batchcreator')) {
         $softwareAgent = new \MongoDB\SoftwareAgent();
         $softwareAgent->_id = "batchcreator";
         $softwareAgent->label = "This component is used for creating batches with units etc.";
         $softwareAgent->save();
     }
 }
Exemple #2
0
 public static function boot()
 {
     parent::boot();
     static::saving(function ($job) {
         \Log::debug('Clearing jobCache and mainSearchFilters.');
         \MongoDB\Temp::whereIn('_id', ['mainSearchFilters', 'jobCache', $job->_id])->forceDelete();
     });
     static::creating(function ($job) {
         try {
             if (!SoftwareAgent::find('jobcreator')) {
                 $softwareAgent = new SoftwareAgent();
                 $softwareAgent->_id = 'jobcreator';
                 $softwareAgent->label = "Job creation";
             }
             if (!isset($job->projectedCost) and !isset($job->iamemptyjob)) {
                 $reward = $job->jobConfiguration->content['reward'];
                 $workerunitsPerUnit = intval($job->jobConfiguration->content['workerunitsPerUnit']);
                 $unitsPerTask = intval($job->jobConfiguration->content['unitsPerTask']);
                 $unitsCount = count($job->batch->wasDerivedFrom);
                 if (!$unitsPerTask) {
                     $projectedCost = 0;
                 } else {
                     $projectedCost = round($reward / $unitsPerTask * ($unitsCount * $workerunitsPerUnit), 2);
                 }
                 $job->expectedWorkerunitsCount = $unitsCount * $job->jobConfiguration->content['workerunitsPerUnit'];
                 $job->projectedCost = $projectedCost;
             }
             $job->unitsCount = count($job->batch->wasDerivedFrom);
             $job->latestMetrics = 0;
             $job->workerunitsCount = 0;
             $job->completion = 0.0;
             // 0.00-1.00
             if (!isset($job->activity_id)) {
                 $activity = new Activity();
                 $activity->label = "Job is uploaded to crowdsourcing platform.";
                 $activity->softwareAgent_id = 'jobcreator';
                 // TODO: JOB softwareAgent_id = $platform. Does this need to be the same?
                 $activity->save();
                 $job->activity_id = $activity->_id;
             }
         } catch (Exception $e) {
             // Something went wrong with creating the Entity
             $job->forceDelete();
             throw $e;
         }
         Log::debug("Saved entity {$job->_id} with activity {$job->activity_id}.");
     });
 }
Exemple #3
0
 public function createOpenimagesVideoDescriptionExtractorSoftwareAgent()
 {
     if (!\MongoDB\SoftwareAgent::find('videodescriptiongetter')) {
         $softwareAgent = new \MongoDB\SoftwareAgent();
         $softwareAgent->_id = "videodescriptiongetter";
         $softwareAgent->label = "This component is used for getting the videos description from openimages.nl and storing them as documents within MongoDB";
         $softwareAgent->save();
     }
 }
 public function createSoftwareAgent()
 {
     try {
         if (!\MongoDB\SoftwareAgent::find('relexstructurer')) {
             $this->softwareAgent->_id = "relexstructurer";
             $this->softwareAgent->label = "This component (pre)processes chang documents into structured relex documents";
             $this->softwareAgent->save();
         }
     } catch (Exception $e) {
         $this->status['error']['relexstructurer'] = $e->getMessage();
     }
 }
 public function createVideoSegmentingSoftwareAgent()
 {
     if (!\MongoDB\SoftwareAgent::find('videosegmenting')) {
         $softwareAgent = new \MongoDB\SoftwareAgent();
         $softwareAgent->_id = "videosegmenting";
         $softwareAgent->label = "This component (pre)processes video documents by splitting the video into segments";
         $softwareAgent->save();
     }
 }
 public function createNamedEntitiesExtractionDBpediaSpotlightApiSoftwareAgent()
 {
     if (!\MongoDB\SoftwareAgent::find('dbpediaspotlightextractor')) {
         $softwareAgent = new \MongoDB\SoftwareAgent();
         $softwareAgent->_id = "dbpediaspotlightextractor";
         $softwareAgent->label = "This component uses the DBpediaSpotlight API in order to extract named entities from video metadata description";
         $softwareAgent->save();
     }
 }
Exemple #7
0
 public function createPostSoftwareAgent($data)
 {
     if (isset($data['softwareAgent_id'])) {
         if (!\MongoDB\SoftwareAgent::find($data['softwareAgent_id'])) {
             $softwareAgent = new \MongoDB\SoftwareAgent();
             $softwareAgent->_id = strtolower($data['softwareAgent_id']);
             if (isset($data['softwareAgent_label'])) {
                 $softwareAgent->label = $data['softwareAgent_label'];
             }
             $softwareAgent->save();
         }
         return true;
     }
     throw new Exception("Error creating SoftwareAgent");
 }