public function doBuildQuery(array $values) { $query = DQ::create()->from('Imports i')->where('i.state != ?', 'deleted')->andWhere('i.format = ?', 'taxon'); $this->addShowFinishedColumnQuery($query, 'is_finished', $values['show_finished']); if ($values['filename']) { $query->addWhere('i.filename LIKE \'%' . $values['filename'] . '%\''); } if ($values['state']) { $query->addWhere('i.state = ?', $values['state']); } if (!$this->options['user']->isA(Users::ADMIN)) { $query->addWhere('i.user_ref = ?', $this->options['user']->getId()); } return $query; }
public function doBuildQuery(array $values) { $query = DQ::create()->select('ig_ref, expedition_ref, expedition_name, ig_num')->from('IgsSearch')->orderBy('ig_ref, expedition_name')->andWhere('expedition_ref != 0')->groupby('ig_ref, expedition_ref, expedition_name, ig_num'); if ($values['ig_ref']) { $query->addWhere('ig_ref = ?', $values['ig_ref']); if ($values['expedition_name']) { $this->addNamingColumnQuery($query, 'expeditions', 'expedition_name_indexed', $values['expedition_name'], null, 'expedition_name_indexed'); } } else { if (!$values['expedition_name']) { $query->addWhere('ig_ref = ?', $values['ig_ref']); } else { $this->addNamingColumnQuery($query, 'expeditions', 'expedition_name_indexed', $values['expedition_name'], null, 'expedition_name_indexed'); } } return $query; }
public function doBuildQuery(array $values) { $query = DQ::create()->from('Imports i')->innerJoin("i.Collections")->where('i.state != ?', 'deleted')->andWhere('i.format = ?', 'abcd'); $this->addShowFinishedColumnQuery($query, 'is_finished', $values['show_finished']); if ($values['collection_ref'] != 0) { $query->addWhere('i.collection_ref = ?', $values['collection_ref']); } if ($values['filename']) { $query->addWhere('i.filename LIKE \'%' . $values['filename'] . '%\''); } if ($values['state']) { $query->addWhere('i.state = ?', $values['state']); } // here, add where clause to look for import file only where the user have right on collection $query->andWhereIn('collection_ref', array_keys(Doctrine::getTable('Collections')->getAllAvailableCollectionsFor($this->options['user']))); return $query; }
public function doBuildQuery(array $values) { $this->encoding_collection = $this->getCollectionWithRights($this->options['user'], true); $query = DQ::create()->select('s.*, gtu_location[0] as latitude, gtu_location[1] as longitude, (collection_ref in (' . implode(',', $this->encoding_collection) . ')) as has_encoding_rights')->from('Specimens s'); if ($values['with_multimedia']) { $query->where("EXISTS (select m.id from multimedia m where m.referenced_relation = 'specimens' AND m.record_id = s.id)"); } $this->options['query'] = $query; $query = parent::doBuildQuery($values); $this->cols = $this->getCollectionWithRights($this->options['user']); if (!empty($values['collection_ref'])) { $this->cols = array_intersect($values['collection_ref'], $this->cols); } $query->andwhereIn('collection_ref ', $this->cols); if (!empty($values['specimen_status'])) { $query->andwhere('specimen_status = ?', $values['specimen_status']); } if ($values['count_operator'] != '' && $values['count'] != '') { if ($values['count_operator'] == 'e') { $query->andwhere('specimen_count_max = ?', $values['count']); } if ($values['count_operator'] == 'l') { $query->andwhere('specimen_count_max <= ?', $values['count']); } if ($values['count_operator'] == 'g') { $query->andwhere('specimen_count_min >= ?', $values['count']); } } if ($values['people_ref'] != '') { $this->addPeopleSearchColumnQuery($query, $values['people_ref'], $values['role_ref']); } if ($values['acquisition_category'] != '') { $query->andWhere('acquisition_category = ?', $values['acquisition_category']); } if ($values['taxon_level_ref'] != '') { $query->andWhere('taxon_level_ref = ?', intval($values['taxon_level_ref'])); } if ($values['chrono_level_ref'] != '') { $query->andWhere('chrono_level_ref = ?', intval($values['chrono_level_ref'])); } if ($values['litho_level_ref'] != '') { $query->andWhere('litho_level_ref = ?', intval($values['litho_level_ref'])); } if ($values['lithology_level_ref'] != '') { $query->andWhere('lithology_level_ref = ?', intval($values['lithology_level_ref'])); } if ($values['mineral_level_ref'] != '') { $query->andWhere('mineral_level_ref = ?', intval($values['mineral_level_ref'])); } $this->addLatLonColumnQuery($query, $values); $this->addNamingColumnQuery($query, 'expeditions', 'expedition_name_indexed', $values['expedition_name'], 's', 'expedition_name_indexed'); $this->addNamingColumnQuery($query, 'taxonomy', 'taxon_name_indexed', $values['taxon_name'], 's', 'taxon_name_indexed'); $this->addNamingColumnQuery($query, 'chronostratigraphy', 'chrono_name_indexed', $values['chrono_name'], 's', 'chrono_name_indexed'); $this->addNamingColumnQuery($query, 'lithostratigraphy', 'litho_name_indexed', $values['litho_name'], 's', 'litho_name_indexed'); $this->addNamingColumnQuery($query, 'lithology', 'lithology_name_indexed', $values['lithology_name'], 's', 'lithology_name_indexed'); $this->addNamingColumnQuery($query, 'mineralogy', 'mineral_name_indexed', $values['mineral_name'], 's', 'mineral_name_indexed'); $this->addPropertiesQuery($query, $values['property_type'], $values['property_applies_to'], $values['property_value_from'], $values['property_value_to'], $values['property_units']); $this->addCommentsQuery($query, $values['comment_notion_concerned'], $values['comment']); $fields = array('gtu_from_date', 'gtu_to_date'); $this->addDateFromToColumnQuery($query, $fields, $values['gtu_from_date'], $values['gtu_to_date']); $this->addDateFromToColumnQuery($query, array('ig_date'), $values['ig_from_date'], $values['ig_to_date']); $this->addDateFromToColumnQuery($query, array('acquisition_date'), $values['acquisition_from_date'], $values['acquisition_to_date']); $this->addCatalogueRelationColumnQuery($query, $values['taxon_item_ref'], $values['taxon_relation'], 'taxonomy', 'taxon', $values['taxon_child_syn_included']); $this->addCatalogueRelationColumnQuery($query, $values['chrono_item_ref'], $values['chrono_relation'], 'chronostratigraphy', 'chrono', $values['chrono_child_syn_included']); $this->addCatalogueRelationColumnQuery($query, $values['litho_item_ref'], $values['litho_relation'], 'lithostratigraphy', 'litho', $values['litho_child_syn_included']); $this->addCatalogueRelationColumnQuery($query, $values['lithology_item_ref'], $values['lithology_relation'], 'lithology', 'lithology', $values['lithology_child_syn_included']); $this->addCatalogueRelationColumnQuery($query, $values['mineral_item_ref'], $values['mineral_relation'], 'mineralogy', 'mineral', $values['mineral_child_syn_included']); $query->limit($this->getCatalogueRecLimits()); return $query; }
/** * Fetch all specimens by an array of ids * @param array $ids Ids of specimen to search * @return Doctrine_collection */ public function getByMultipleIds(array $ids, $user_id = -1, $is_admin = false) { if (empty($ids)) { return $ids; } $q = DQ::create()->from('Specimens s')->wherein('s.id', $ids)->orderBy('s.id'); if (!$is_admin) { $q->andWhere('s.collection_ref in (select fct_search_authorized_encoding_collections(?))', $user_id); } return $q->execute(); }