private function observationalSearchContainerPopulator($response) { $columns = $response->{'columns'}; $dataList = $response->{'data'}; $container = array(); $headerPositions = array(); $interactions = new SupportedInteractions(); $j = 0; foreach ($columns as $headerTitle) { switch ($headerTitle) { case 'target_taxon_name': $headerPositions['tax'] = $j; break; case 'interaction_type': $headerPositions['interactionType'] = $j; break; case 'latitude': $headerPositions['lat'] = $j; break; case 'longitude': $headerPositions['long'] = $j; break; case 'altitude': $headerPositions['alt'] = $j; break; case 'study_title': $headerPositions['study'] = $j; break; case 'collection_time_in_unix_epoch': $headerPositions['epoch'] = $j; break; case 'tmp_and_unique_source_specimen_id': // note that this id is used to aggregate results. // for eats interaction, the source specimen id is the predator specimen id. $headerPositions['id'] = $j; break; case 'source_specimen_life_stage': $headerPositions['sourceLS'] = $j; break; case 'target_specimen_life_stage': $headerPositions['targetLS'] = $j; break; case 'source_specimen_body_part': $headerPositions['sourceBP'] = $j; break; case 'target_specimen_body_part': $headerPositions['targetBP'] = $j; break; case 'source_specimen_physiological_state': $headerPositions['sourcePS'] = $j; break; case 'target_specimen_physiological_state': $headerPositions['targetPS'] = $j; break; default: #some new header property break; } $j += 1; } if (empty($dataList)) { # if nothng is returned from the rest, dont do anything below this return null; } $interactionType = $dataList[0][$headerPositions['interactionType']]; $target = $interactions->interactionToTarget($interactionType); $source = $interactions->interactionToSource($interactionType); # here we change the words target and source to the real represenation of the name IE pred, prey, host.. or whatever if (in_array($interactionType, $interactions->getSupportedInteractions())) { $headerPositions[$target . 'LS'] = $headerPositions['targetLS']; $headerPositions[$source . 'LS'] = $headerPositions['sourceLS']; $headerPositions[$target . 'BP'] = $headerPositions['targetBP']; $headerPositions[$source . 'BP'] = $headerPositions['sourceBP']; $headerPositions[$target . 'PS'] = $headerPositions['targetPS']; $headerPositions[$source . 'PS'] = $headerPositions['sourcePS']; } else { throw new UnsupportedInteractionTypeException('Interaction type ' . $dataList[0][$headerPositions['interactionType']] . ' is not yet supported!'); } $i = 0; foreach ($dataList as $taxonData) { $container[$i] = array(); $container[$i][0] = $taxonData[$headerPositions['tax']]; #subjectTaxon $container[$i][1] = $taxonData[$headerPositions['lat']]; #latitude $container[$i][2] = $taxonData[$headerPositions['long']]; #longitude $container[$i][3] = $taxonData[$headerPositions['alt']]; #altitude $container[$i][4] = $taxonData[$headerPositions['study']]; #contributor $container[$i][5] = $taxonData[$headerPositions['epoch']]; #unix epoch $container[$i][6] = $taxonData[$headerPositions['id']]; #tmp_and_unique_specimen_id $container[$i][$target . 'LS'] = $taxonData[$headerPositions[$target . 'LS']]; $container[$i][$source . 'LS'] = $taxonData[$headerPositions[$source . 'LS']]; $container[$i][$target . 'BP'] = $taxonData[$headerPositions[$target . 'BP']]; $container[$i][$source . 'BP'] = $taxonData[$headerPositions[$source . 'BP']]; $container[$i][$target . 'PS'] = $taxonData[$headerPositions[$target . 'PS']]; $container[$i][$source . 'PS'] = $taxonData[$headerPositions[$source . 'PS']]; $i += 1; } return $container; }