コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     //DB::table('Simulation_Needle_Parameter')->delete();
     //DB::table('Simulation_Needle')->delete();
     //DB::table('PointSet')->delete();
     //DB::table('Simulation')->delete();
     $development = Modality::whereName("Development")->first();
     if (!$development) {
         $development = Modality::create(array("Name" => "Development"));
     }
     App::make("SimulationSeeder")->clean();
     //App::make("SimulationSeeder")->deepClean();
     App::make("\\CombinationSeeders\\CombinationSeeder")->clean($this->command);
     DB::table('Parameter_Attribution')->delete();
     DB::table('Numerical_Model_Region')->delete();
     //DB::table('Region')->delete();
     //DB::table('Numerical_Model')->delete();
     DB::table('Numerical_Model_Argument')->delete();
     DB::table('Algorithm_Argument')->delete();
     DB::table('Algorithm')->delete();
     $sP = App::make("ParameterSeeder")->clean();
     DB::table('Combination_Needle')->delete();
     //DB::table('Combination')->delete();
     //DB::table('Protocol')->delete();
     //DB::table('Context')->delete();
     DB::table('Needle_Power_Generator')->delete();
     //DB::table('Needle')->delete();
     //DB::table('Power_Generator')->delete();
     //DB::table('Modality')->delete();
     DB::table('Argument')->delete();
     //DB::table('Parameter')->delete();
     $this->call('ParameterSeeder');
     $this->call('RegionSeeder');
     if (!Config::get('gosmart.context_as_enum')) {
         $this->call('\\ContextSeeders\\ContextSeeder');
     }
     $this->call('\\CombinationSeeders\\CombinationSeeder');
     $developmentModels = $development->NumericalModels;
     $developmentModels->each(function ($m) {
         $m->attribute(['Name' => 'DEVELOPMENT', 'Type' => 'boolean', 'Value' => "true"]);
     });
     $this->call('ValueSeeder');
     $this->call('AlgorithmSeeder');
     //if (Simulation::count() == 0)
     $this->call('SimulationSeeder');
 }
コード例 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (file_exists(public_path() . '/backups')) {
         $backups = array_filter(scandir(public_path() . '/backups'), function ($d) {
             return $d[0] != '.';
         });
     } else {
         $backups = [];
     }
     $preferred_server = Session::get('preferred_server', '');
     if (Input::has('modality')) {
         $simulations = Simulation::where('Power_Generator.Modality_Id', '=', Input::get('modality'))->get();
     } else {
         $simulations = Simulation::all();
     }
     $modalities = Modality::all();
     return View::make('simulations.index', compact('simulations', 'backups', 'preferred_server', 'modalities'));
 }
コード例 #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $algorithmsXmls = File::allFiles(public_path() . '/algorithms');
     foreach ($algorithmsXmls as $algorithmsXml) {
         $dom = new DomDocument();
         $dom->load($algorithmsXml);
         $root = $dom->documentElement;
         $modality = Modality::whereName($root->getAttribute('modality'))->first();
         if (empty($modality)) {
             throw new Exception("Could not find modality! ({$algorithmsXml})");
         }
         $protocolName = $root->getAttribute('protocol');
         $protocol = Protocol::whereName($protocolName)->whereModalityId($modality->Id)->first();
         if (empty($protocol)) {
             \Log::warning("Could not find protocol! ({$algorithmsXml})");
             continue;
         }
         $arguments = [];
         $parameters = [];
         $description = "";
         foreach ($root->childNodes as $node) {
             if (get_class($node) == 'DOMText') {
                 continue;
             }
             switch ($node->nodeName) {
                 case 'arguments':
                     foreach ($node->childNodes as $argument) {
                         if (get_class($argument) == 'DOMText') {
                             continue;
                         }
                         $arguments[] = ['Name' => $argument->getAttribute('name')];
                     }
                     break;
                 case 'parameters':
                     foreach ($node->childNodes as $parameter) {
                         if (get_class($parameter) == 'DOMText') {
                             continue;
                         }
                         $parameters[] = ['Name' => $parameter->getAttribute('name'), 'Type' => $parameter->getAttribute('type'), 'Value' => $parameter->hasAttribute('value') ? $parameter->getAttribute('value') : null];
                     }
                     break;
                 case 'description':
                     $description = $node->textContent;
                     break;
                 default:
                     throw new Exception("Unrecognized entry in algorithm XML - {$node->nodeName}! ({$algorithmsXml})");
             }
         }
         $algorithm = new Algorithm();
         $algorithm->content = $description;
         $resultName = $root->getAttribute('result');
         $resultType = $root->getAttribute('type');
         $result = Parameter::whereName($resultName)->first();
         if (empty($result)) {
             $result = Parameter::create(['Name' => $resultName, 'Type' => $resultType]);
         }
         $algorithm->result()->associate($result);
         $algorithm->protocol()->associate($protocol);
         $algorithm->save();
         foreach ($arguments as $argument) {
             $algorithm->arguments()->attach(Argument::create($argument));
         }
         foreach ($parameters as $parameter) {
             $algorithm->attribute($parameter);
         }
     }
 }
コード例 #4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $combinations = Combination::with('PowerGenerator');
     if (Input::has('Needle_Id')) {
         $combinations = $combinations->join('Combination_Needle', 'Combination_Needle.Combination_Id', '=', 'Combination.Combination_Id');
         $combinations->whereNeedleId(Input::get('Needle_Id'));
     }
     if (Input::has('Numerical_Model_Id')) {
         $combinations->whereNumericalModelId(Input::get('Numerical_Model_Id'));
     }
     if (Input::has('Power_Generator_Id')) {
         $combinations->wherePowerGeneratorId(Input::get('Power_Generator_Id'));
     }
     if (Input::has('Protocol_Id')) {
         $combinations->whereProtocolId(Input::get('Protocol_Id'));
     }
     if (Input::has('Context_Id')) {
         if (Config::get('gosmart.context_as_enum')) {
             $combinations->where(Context::$idField, '=', Input::get('Context_Id'));
         } else {
             $combinations->whereContextId(Input::get('Context_Id'));
         }
     }
     if (Input::has('Modality_Id')) {
         $modality_id = Input::get('Modality_Id');
         $combinations->whereHas('PowerGenerator', function ($query) use($modality_id) {
             $query->whereModalityId($modality_id);
         });
     }
     if (Input::has('output')) {
         switch (Input::get('output')) {
             case 'Needle':
                 $combination = $combinations->join('Combination_Needle', 'Combination_Needle.Combination_Id', '=', 'Combination.Combination_Id');
                 $output_ids = array_unique($combinations->get()->lists('Needle_Id'));
                 return Needle::find($output_ids)->lists('Name', 'Id');
             case 'Combination':
                 return $combinations->get()->lists('asString', 'Combination_Id');
             case 'Protocol':
                 $output_ids = array_unique($combinations->get()->lists('Protocol_Id'));
                 return Protocol::find($output_ids)->lists('Name', 'Id');
             case 'PowerGenerator':
                 $output_ids = array_unique($combinations->get()->lists('Power_Generator_Id'));
                 return PowerGenerator::find($output_ids)->lists('Name', 'Id');
             case 'NumericalModel':
                 $output_ids = array_unique($combinations->get()->lists('Numerical_Model_Id'));
                 return NumericalModel::find($output_ids)->lists('Name', 'Id');
             case 'Context':
                 if (Config::get('gosmart.context_as_enum')) {
                     $output_ids = array_unique($combinations->get()->lists('Context_Id'));
                 } else {
                     $output_ids = array_unique($combinations->get()->lists('OrganType'));
                 }
                 return Context::find($output_ids)->lists('Name', 'Id');
             case 'Modality':
                 $combinations = $combinations->join('Power_Generator', 'Power_Generator.Id', '=', 'Combination.Power_Generator_Id')->select('Power_Generator.Modality_Id AS Modality_Id');
                 $output_ids = array_unique($combinations->get()->lists('Modality_Id'));
                 return Modality::find($output_ids)->lists('Name', 'Id');
         }
         return $combinations;
     }
     $combinations = $combinations->get()->sortBy(function ($c) {
         return $c->Power_Generator->Modality->Name;
     });
     return View::make('combinations.index', compact('combinations'));
 }
コード例 #5
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $modalities = Modality::all()->lists('Name', 'Id');
     return View::make('protocols.create', compact('modalities'));
 }