public function __construct($result_file, $read_only_result_objects = false)
 {
     $this->save_identifier = $result_file;
     $this->extra_attributes = array();
     $this->systems = array();
     $this->result_objects = array();
     if ($result_file == null) {
         return;
     } else {
         if (is_file($result_file)) {
             $this->file_location = $result_file;
             $result_file = file_get_contents($result_file);
         } else {
             if (!isset($result_file[1024]) && defined('PTS_SAVE_RESULTS_PATH') && is_file(PTS_SAVE_RESULTS_PATH . $result_file . '/composite.xml')) {
                 $this->file_location = PTS_SAVE_RESULTS_PATH . $result_file . '/composite.xml';
                 $result_file = file_get_contents($this->file_location);
             }
         }
     }
     $xml = simplexml_load_string($result_file, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
     if (isset($xml->Generated)) {
         $this->title = self::clean_input($xml->Generated->Title);
         $this->description = self::clean_input($xml->Generated->Description);
         $this->notes = self::clean_input($xml->Generated->Notes);
         $this->internal_tags = self::clean_input($xml->Generated->InternalTags);
         $this->reference_id = self::clean_input($xml->Generated->ReferenceID);
         $this->preset_environment_variables = self::clean_input($xml->Generated->PreSetEnvironmentVariables);
     }
     if (isset($xml->System)) {
         foreach ($xml->System as $s) {
             $system = new pts_result_file_system(self::clean_input($s->Identifier->__toString()), self::clean_input($s->Hardware->__toString()), self::clean_input($s->Software->__toString()), json_decode(self::clean_input($s->JSON), true), self::clean_input($s->User->__toString()), self::clean_input($s->Notes->__toString()), self::clean_input($s->TimeStamp->__toString()), self::clean_input($s->ClientVersion->__toString()));
             array_push($this->systems, $system);
         }
     }
     if (isset($xml->Result)) {
         foreach ($xml->Result as $result) {
             $test_profile = new pts_test_profile($result->Identifier != null ? $result->Identifier->__toString() : null, null, !$read_only_result_objects);
             $test_profile->set_test_title($result->Title->__toString());
             $test_profile->set_version($result->AppVersion->__toString());
             $test_profile->set_result_scale($result->Scale->__toString());
             $test_profile->set_result_proportion($result->Proportion->__toString());
             $test_profile->set_display_format($result->DisplayFormat->__toString());
             $test_result = new pts_test_result($test_profile);
             $test_result->set_used_arguments_description($result->Description->__toString());
             $test_result->set_used_arguments($result->Arguments->__toString());
             $result_buffer = new pts_test_result_buffer();
             foreach ($result->Data->Entry as $entry) {
                 $result_buffer->add_test_result($entry->Identifier->__toString(), $entry->Value->__toString(), $entry->RawString->__toString(), isset($entry->JSON) ? $entry->JSON->__toString() : null);
             }
             $test_result->set_test_result_buffer($result_buffer);
             $this->result_objects[$test_result->get_comparison_hash(true, false)] = $test_result;
         }
     }
     unset($xml);
 }
Пример #2
0
 public static function generate_overview_object(&$overview_table, $overview_type)
 {
     switch ($overview_type) {
         case 'GEOMETRIC_MEAN':
             $title = 'Geometric Mean';
             $math_call = array('pts_math', 'geometric_mean');
             break;
         case 'HARMONIC_MEAN':
             $title = 'Harmonic Mean';
             $math_call = array('pts_math', 'harmonic_mean');
             break;
         case 'AGGREGATE_SUM':
             $title = 'Aggregate Sum';
             $math_call = 'array_sum';
             break;
         default:
             return false;
     }
     $result_buffer = new pts_test_result_buffer();
     if ($overview_table instanceof pts_result_file) {
         list($days_keys1, $days_keys, $shred) = pts_ResultFileTable::result_file_to_result_table($overview_table);
         foreach ($shred as $system_key => &$system) {
             $to_show = array();
             foreach ($system as &$days) {
                 $days = $days->get_value();
             }
             array_push($to_show, pts_math::set_precision(call_user_func($math_call, $system), 2));
             $result_buffer->add_test_result($system_key, implode(',', $to_show), null);
         }
     } else {
         $days_keys = null;
         foreach ($overview_table as $system_key => &$system) {
             if ($days_keys == null) {
                 // TODO: Rather messy and inappropriate way of getting the days keys
                 $days_keys = array_keys($system);
                 break;
             }
         }
         foreach ($overview_table as $system_key => &$system) {
             $to_show = array();
             foreach ($system as &$days) {
                 array_push($to_show, call_user_func($math_call, $days));
             }
             $result_buffer->add_test_result($system_key, implode(',', $to_show), null);
         }
     }
     $test_profile = new pts_test_profile(null, null, false);
     $test_profile->set_test_title($title);
     $test_profile->set_result_scale($title);
     $test_profile->set_display_format('BAR_GRAPH');
     $test_result = new pts_test_result($test_profile);
     $test_result->set_used_arguments_description('Analytical Overview');
     $test_result->set_test_result_buffer($result_buffer);
     return $test_result;
 }
 public function get_result_object(&$result)
 {
     $test_profile = new pts_test_profile($result->Identifier != null ? $result->Identifier->__toString() : null);
     $test_profile->set_test_title($result->Title->__toString());
     $test_profile->set_version($result->AppVersion->__toString());
     $test_profile->set_result_scale($result->Scale->__toString());
     $test_profile->set_result_proportion($result->Proportion->__toString());
     $test_profile->set_display_format($result->DisplayFormat->__toString());
     $test_result = new pts_test_result($test_profile);
     $test_result->set_used_arguments_description($result->Description->__toString());
     $test_result->set_used_arguments($result->Arguments->__toString());
     $result_buffer = new pts_test_result_buffer();
     foreach ($result->Data->Entry as $entry) {
         $result_buffer->add_test_result($entry->Identifier->__toString(), $entry->Value->__toString(), $entry->RawString->__toString(), isset($entry->JSON) ? $entry->JSON->__toString() : null);
     }
     $test_result->set_test_result_buffer($result_buffer);
     return $test_result;
 }