コード例 #1
0
 public function anyView()
 {
     $jobArray = explode(',', Input::get('jobs'));
     $colors = array();
     $jobsInfo = array();
     for ($iter = 0; $iter < count($jobArray); ++$iter) {
         $jobID = $jobArray[$iter];
         $jobsInfo[$jobID] = \MongoDB\Entity::find($jobID);
         $color = AnalyticsController::$colorList[$iter % count(AnalyticsController::$colorList)];
         $jobsInfo[$jobID]['color'] = $color;
         $colors[$jobID] = $color;
     }
     return View::make('analytics.jobview')->with('jobConfigurations', $jobsInfo)->with('jobIDs', $jobArray)->with('jobColors', $colors);
 }
コード例 #2
0
ファイル: Entity.php プロジェクト: harixxy/CrowdTruth
 /**
  * Verify Entity has all required properties (as defined by the Data Model)
  * See https://docs.google.com/document/d/11H-jbLWXEv-ha-LBm8SZJ78rJ4L3N6GSt8NkGqxl-W8/edit
  * 
  * @param $entity the Entity object.
  */
 public static function validateEntity($entity)
 {
     // TODO: remove this block of code -- it is NOT Entity's responsibility to ensure
     // a project is set -- this should be passed (or inherited) where entity is created.
     // Check entity has been assigned a project
     if ($entity->project == null) {
         // Use same project as parent Entity
         $entParent = Entity::find($entity->parents[0]);
         $entity->project = $entParent->project;
     }
     // All json documents must have: _id, updated_at, created_at. These are
     // automatically generated by MongoDB
     // Entities must also have: documentType, activity_id, softwareAgent_id, project, user_id
     $checkFor = ["documentType", "activity_id", "softwareAgent_id", "project", "user_id"];
     foreach ($checkFor as $field) {
         if (is_null($entity->{$field})) {
             throw new \Exception('Entity does not comply with data model! -- ' . $field . ' missing');
         }
     }
     $entity->documentType = strtolower($entity->documentType);
 }