Esempio n. 1
0
 /**
  * Determines if there is any data in the data set that can be visualized by this plugin using the provided settings
  *
  * @param SearchResult $po_data
  * @param array $pa_viz_settings Visualization settings
  *
  * @return bool True if data can be visualized
  */
 public function canHandle($po_data, $pa_viz_settings)
 {
     $vn_cur_pos = $po_data->currentIndex();
     if ($vn_cur_pos < 0) {
         $vn_cur_pos = 0;
     }
     $po_data->seek(0);
     $o_dm = Datamodel::load();
     //
     // Make sure sources actually exist
     //
     $va_sources = $pa_viz_settings['sources'];
     foreach ($va_sources as $vs_source_code => $va_source_info) {
         $va_tmp = explode('.', $va_source_info['data']);
         $t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true);
         if (!($t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true))) {
             unset($va_sources[$vs_source_code]);
             continue;
         }
         if (!$t_instance->hasField($va_tmp[1]) && !$t_instance->hasElement($va_tmp[1])) {
             unset($va_sources[$vs_source_code]);
         }
     }
     $vn_c = 0;
     //
     // Only check the first 10,000 returned rows before giving up, to avoid timeouts
     //
     while ($po_data->nextHit() && $vn_c < 10000) {
         foreach ($va_sources as $vs_source_code => $va_source_info) {
             if (trim($po_data->get($va_source_info['data']))) {
                 $po_data->seek($vn_cur_pos);
                 return true;
             }
         }
         $vn_c++;
     }
     $po_data->seek($vn_cur_pos);
     return false;
 }
Esempio n. 2
0
 /**
  * Export set of records from a given SearchResult object to an array of strings with the individual exports, keyed by primary key.
  * The behavior is tailored towards the needs of the OAIPMHService.
  *
  * @param string $ps_exporter_code defines the exporter to use
  * @param SearchResult $po_result search result as object
  * @param  array $pa_options
  * 		'start' =
  *   	'limit' =
  * @return array exported data
  */
 public static function exportRecordsFromSearchResultToArray($ps_exporter_code, $po_result, $pa_options = null)
 {
     $vn_start = isset($pa_options['start']) ? (int) $pa_options['start'] : 0;
     $vn_limit = isset($pa_options['limit']) ? (int) $pa_options['limit'] : 0;
     ca_data_exporters::$s_exporter_cache = array();
     ca_data_exporters::$s_exporter_item_cache = array();
     require_once __CA_LIB_DIR__ . '/core/Search/SearchResult.php';
     if (!$po_result instanceof SearchResult) {
         return false;
     }
     if (!($t_mapping = ca_data_exporters::loadExporterByCode($ps_exporter_code))) {
         return false;
     }
     if (sizeof(ca_data_exporters::checkMapping($ps_exporter_code)) > 0) {
         return false;
     }
     $t_instance = $t_mapping->getAppDatamodel()->getInstanceByTableNum($t_mapping->get('table_num'));
     if ($vn_start > 0 && $vn_start < $po_result->numHits()) {
         $po_result->seek($vn_start);
     }
     $va_return = array();
     $vn_i = 0;
     while ($po_result->nextHit()) {
         if ($vn_limit && $vn_i >= $vn_limit) {
             break;
         }
         $vn_pk_val = $po_result->get($t_instance->primaryKey());
         $va_return[$vn_pk_val] = ca_data_exporters::exportRecord($ps_exporter_code, $vn_pk_val);
         $vn_i++;
     }
     return $va_return;
 }
Esempio n. 3
0
 /**
  * Determines if there is any data in the data set that can be visualized by this plugin using the provided settings
  *
  * @param SearchResult $po_data
  * @param array $pa_viz_settings Visualization settings
  *
  * @return bool True if data can be visualized
  */
 public function canHandle($po_data, $pa_viz_settings)
 {
     $vn_cur_pos = $po_data->currentIndex();
     if ($vn_cur_pos < 0) {
         $vn_cur_pos = 0;
     }
     $po_data->seek(0);
     $va_sources = $pa_viz_settings['sources'];
     while ($po_data->nextHit()) {
         foreach ($va_sources as $vs_source_code => $va_source_info) {
             if (trim($po_data->get($va_source_info['data']))) {
                 $po_data->seek($vn_cur_pos);
                 return true;
             }
         }
     }
     $po_data->seek($vn_cur_pos);
     return false;
 }
Esempio n. 4
0
 /**
  * Fetched next hit in result set.
  * Overrides SearchResult::nextHit() to implement result filtering
  *
  * @return bool True if next hit was loaded, false if there are no more hits to iterate through
  */
 public function nextHit()
 {
     if ($this->ops_filter_field) {
         while ($vb_r = parent::nextHit()) {
             if (in_array($this->get($this->ops_filter_field), $this->opa_filter_values)) {
                 return $vb_r;
             }
         }
     }
     return parent::nextHit();
 }
 /**
  * Roll up by-user data for return
  *
  * @param SearchResult $qr_res A ca_object_checkouts result set
  * @param string $ps_display_template Optional display template; will be returned in _display key in returned array
  *
  * @return array List of events (checkins, checkouts, etc.)
  */
 private static function _collectCheckoutData($qr_res, $ps_display_template = null)
 {
     $va_checkouts = array();
     if ($qr_res) {
         while ($qr_res->nextHit()) {
             $va_tmp = array('checkout_id' => $qr_res->get('ca_object_checkouts.checkout_id'), 'group_uuid' => $qr_res->get('ca_object_checkouts.group_uuid'), 'object_id' => $qr_res->get('ca_object_checkouts.object_id'), 'created_on' => $qr_res->get('ca_object_checkouts.created_on', array('timeOmit' => true)), 'checkout_date' => $qr_res->get('ca_object_checkouts.checkout_date', array('timeOmit' => true)), 'due_date' => $qr_res->get('ca_object_checkouts.due_date', array('timeOmit' => true)), 'return_date' => $qr_res->get('ca_object_checkouts.return_date', array('timeOmit' => true)), 'checkout_notes' => $qr_res->get('ca_object_checkouts.checkout_notes'));
             if ($ps_display_template) {
                 $va_tmp['_display'] = $qr_res->getWithTemplate($ps_display_template);
             }
             $va_checkouts[] = $va_tmp;
         }
     }
     return $va_checkouts;
 }