/**
  * Task copy: Field_analyte_location
  * Fetches the related Field_analyte_location for the
  * original task and creates the relation with the new
  * Task created in "copyTaskWithDependencies"
  */
 public static function copyTaskFieldAnalyteLocation($caller, $source_task_id, $target_task_id)
 {
     $falDAO = new \Applications\PMTool\Models\Dao\Field_analyte_location();
     $falDAO->setTask_id($source_task_id);
     $dal = $caller->managers()->getManagerOf("Task");
     $allFals = $dal->selectMany($falDAO, "task_id");
     if (count($allFals) > 0) {
         //fals found, loop and remap with the new task id
         foreach ($allFals as $fal) {
             $falDAO = null;
             $falDAO = new \Applications\PMTool\Models\Dao\Field_analyte_location();
             $falDAO->setTask_id($target_task_id);
             $falDAO->setField_analyte_id($fal->field_analyte_id());
             $falDAO->setLocation_id($fal->location_id());
             //Save
             $dal->add($falDAO);
         }
     }
 }
 /**
  * Fetches the relationship between location and analyte
  * for the passed Task and Analyte Type, along with the 
  * result if any (Only valid for field_analyte_location)
  */
 public static function GetFieldDataMatrixForTaskWithResult($caller, $task_id)
 {
     $id_map = array();
     $fmatrix_result_data = array();
     //FIELD Analyte
     $matrixDAO = new \Applications\PMTool\Models\Dao\Field_analyte_location();
     $matrixDAO->setTask_id($task_id);
     $dal = $caller->managers()->getManagerOf("FieldLabAnalyte");
     $relation_data = $dal->selectMany($matrixDAO, "task_id");
     if (!empty($relation_data) && is_array($relation_data)) {
         foreach ($relation_data as $relation) {
             $id_str = $relation->location_id() . '_' . $relation->field_analyte_id();
             array_push($id_map, $id_str);
             array_push($fmatrix_result_data, $relation->field_analyte_location_result());
         }
     }
     return array('id_map' => $id_map, 'result_map' => $fmatrix_result_data);
 }