diff --git a/application/config/config.php.example b/application/config/config.php.example index b9f40c9d81..b1d37bf378 100644 --- a/application/config/config.php.example +++ b/application/config/config.php.example @@ -133,7 +133,7 @@ $config['modules'] = array MODPATH.'sref_channel_islands', // Jersey and Guernsey grid notations MODPATH.'sref_utm', // UTM grid notation MODPATH.'demo', // Demo and test pages - MODPATH.'data_cleaner' // automatic record checks + MODPATH.'data_cleaner', // automatic record checks MODPATH.'cache_builder', // build a cache for performance reporting MODPATH.'spatial_index_builder', // index of location occurrence overlaps // ,MODPATH.'summary_builder' // build a cache for improving the performance of reporting summary data diff --git a/application/config/version.php b/application/config/version.php index 3237da513c..f0294b2162 100644 --- a/application/config/version.php +++ b/application/config/version.php @@ -31,7 +31,7 @@ * * @var string */ -$config['version'] = '1.57.0'; +$config['version'] = '1.58.0'; /** * Version release date. * diff --git a/application/controllers/licence.php b/application/controllers/licence.php index 8ad577ebf0..5550e30a5a 100644 --- a/application/controllers/licence.php +++ b/application/controllers/licence.php @@ -14,8 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/gpl.html. * - * @package Core - * @subpackage Controllers * @author Indicia Team * @license http://www.gnu.org/licenses/gpl.html GPL * @link https://github.com/Indicia-Team/warehouse @@ -23,9 +21,6 @@ /** * Controller providing CRUD access to the licences list. - * - * @package Core - * @subpackage Controllers */ class Licence_Controller extends Gridview_Base_Controller { @@ -41,7 +36,10 @@ public function __construct() { } /** - * You can only access the list of licences if at least an editor of one website. + * Check if page access authorised. + * + * You can only access the list of licences if at least an editor of one + * website. */ protected function page_authorised() { return $this->auth->logged_in('CoreAdmin') || $this->auth->has_any_website_access('editor'); @@ -50,9 +48,9 @@ protected function page_authorised() { /** * Returns model values ready to load onto a form. * - * Returns an array of all values from this model and its super models ready to be - * loaded into a form. For this controller, we need to also need to flash a warning - * about editing existing licence records. + * Returns an array of all values from this model and its super models ready + * to be loaded into a form. For this controller, we need to also need to + * flash a warning about editing existing licence records. */ protected function getModelValues() { $r = parent::getModelValues(); diff --git a/application/libraries/ATTR_ORM.php b/application/libraries/ATTR_ORM.php index 65c7bf9125..4cc54db828 100644 --- a/application/libraries/ATTR_ORM.php +++ b/application/libraries/ATTR_ORM.php @@ -55,6 +55,8 @@ public function validate(Validation $array, $save = FALSE) { 'description', 'source_id', 'caption_i18n', + 'term_name', + 'term_identifier', ) ); $array->add_rules('caption', 'required'); diff --git a/application/views/custom_attribute/custom_attribute_edit.php b/application/views/custom_attribute/custom_attribute_edit.php index 95a5a7a988..9ad8e89e45 100644 --- a/application/views/custom_attribute/custom_attribute_edit.php +++ b/application/views/custom_attribute/custom_attribute_edit.php @@ -68,6 +68,34 @@ 'helpText' => $helpText, ]); } + if (array_key_exists('term_name', $this->model->as_array())) { + $helpText = << "$model->object_name:term_name", + 'label' => 'Term name', + 'default' => html::initial_value($values, "$model->object_name:term_name"), + 'disabled' => $disabled_input === 'YES' ? 'disabled' : '', + 'helpText' => $helpText, + ]); + } + if (array_key_exists('term_identifier', $this->model->as_array())) { + $helpText = << "$model->object_name:term_identifier", + 'label' => 'Term identifier', + 'default' => html::initial_value($values, "$model->object_name:term_identifier"), + 'disabled' => $disabled_input === 'YES' ? 'disabled' : '', + 'helpText' => $helpText, + 'class' => 'control-width-6', + ]); + } if (array_key_exists('description', $this->model->as_array())) { echo data_entry_helper::textarea([ 'fieldname' => "$model->object_name:description", diff --git a/modules/indicia_setup/db/version_1_58_0/201803261544_attr_dwc.sql b/modules/indicia_setup/db/version_1_58_0/201803261544_attr_dwc.sql new file mode 100644 index 0000000000..a894469d6f --- /dev/null +++ b/modules/indicia_setup/db/version_1_58_0/201803261544_attr_dwc.sql @@ -0,0 +1,76 @@ +ALTER TABLE survey_attributes + ADD COLUMN term_name character varying, + ADD COLUMN term_identifier character varying; +COMMENT ON COLUMN survey_attributes.term_name + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term name. Otherwise ' + 'provide a brief alphanumeric only (with no spaces) version of the attribute name to give it a unique identifier ' + 'within the context of the survey dataset to make it easier to refer to in configuration.'; +COMMENT ON COLUMN survey_attributes.term_identifier + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term identifier, ' + 'typically the URL to the term definition.'; + +ALTER TABLE sample_attributes + ADD COLUMN term_name character varying, + ADD COLUMN term_identifier character varying; +COMMENT ON COLUMN sample_attributes.term_name + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term name. Otherwise ' + 'provide a brief alphanumeric only (with no spaces) version of the attribute name to give it a unique identifier ' + 'within the context of the survey dataset to make it easier to refer to in configuration.'; +COMMENT ON COLUMN sample_attributes.term_identifier + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term identifier, ' + 'typically the URL to the term definition.'; + +ALTER TABLE occurrence_attributes + ADD COLUMN term_name character varying, + ADD COLUMN term_identifier character varying; +COMMENT ON COLUMN occurrence_attributes.term_name + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term name. Otherwise ' + 'provide a brief alphanumeric only (with no spaces) version of the attribute name to give it a unique identifier ' + 'within the context of the survey dataset to make it easier to refer to in configuration.'; +COMMENT ON COLUMN occurrence_attributes.term_identifier + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term identifier, ' + 'typically the URL to the term definition.'; + +ALTER TABLE location_attributes + ADD COLUMN term_name character varying, + ADD COLUMN term_identifier character varying; +COMMENT ON COLUMN location_attributes.term_name + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term name. Otherwise ' + 'provide a brief alphanumeric only (with no spaces) version of the attribute name to give it a unique identifier ' + 'within the context of the survey dataset to make it easier to refer to in configuration.'; +COMMENT ON COLUMN location_attributes.term_identifier + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term identifier, ' + 'typically the URL to the term definition.'; + +ALTER TABLE taxa_taxon_list_attributes + ADD COLUMN term_name character varying, + ADD COLUMN term_identifier character varying; +COMMENT ON COLUMN taxa_taxon_list_attributes.term_name + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term name. Otherwise ' + 'provide a brief alphanumeric only (with no spaces) version of the attribute name to give it a unique identifier ' + 'within the context of the survey dataset to make it easier to refer to in configuration.'; +COMMENT ON COLUMN taxa_taxon_list_attributes.term_identifier + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term identifier, ' + 'typically the URL to the term definition.'; + +ALTER TABLE termlists_term_attributes + ADD COLUMN term_name character varying, + ADD COLUMN term_identifier character varying; +COMMENT ON COLUMN termlists_term_attributes.term_name + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term name. Otherwise ' + 'provide a brief alphanumeric only (with no spaces) version of the attribute name to give it a unique identifier ' + 'within the context of the survey dataset to make it easier to refer to in configuration.'; +COMMENT ON COLUMN termlists_term_attributes.term_identifier + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term identifier, ' + 'typically the URL to the term definition.'; + +ALTER TABLE person_attributes + ADD COLUMN term_name character varying, + ADD COLUMN term_identifier character varying; +COMMENT ON COLUMN person_attributes.term_name + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term name. Otherwise ' + 'provide a brief alphanumeric only (with no spaces) version of the attribute name to give it a unique identifier ' + 'within the context of the survey dataset to make it easier to refer to in configuration.'; +COMMENT ON COLUMN person_attributes.term_identifier + IS 'If the attribute is linked to a standardised glossary such as Darwin Core then provide the term identifier, ' + 'typically the URL to the term definition.'; \ No newline at end of file diff --git a/modules/indicia_setup/db/version_1_56_0/201802190926_attr_caption_i18n_views.sql b/modules/indicia_setup/db/version_1_58_0/201803262026_attr_dwc_views.sql similarity index 97% rename from modules/indicia_setup/db/version_1_56_0/201802190926_attr_caption_i18n_views.sql rename to modules/indicia_setup/db/version_1_58_0/201803262026_attr_dwc_views.sql index 2275dd4e11..ff7da45884 100644 --- a/modules/indicia_setup/db/version_1_56_0/201802190926_attr_caption_i18n_views.sql +++ b/modules/indicia_setup/db/version_1_58_0/201803262026_attr_dwc_views.sql @@ -5,6 +5,8 @@ CREATE OR REPLACE VIEW list_survey_attributes AS SELECT a.id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, fsb2.name AS outer_structure_block, fsb.name AS inner_structure_block, a.data_type, @@ -41,6 +43,8 @@ CREATE OR REPLACE VIEW list_sample_attributes AS SELECT a.id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, fsb2.name AS outer_structure_block, fsb.name AS inner_structure_block, a.data_type, @@ -80,6 +84,8 @@ CREATE OR REPLACE VIEW list_occurrence_attributes AS a.id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, fsb2.name AS outer_structure_block, fsb.name AS inner_structure_block, a.data_type, ct.control AS control_type, @@ -117,6 +123,8 @@ CREATE OR REPLACE VIEW list_location_attributes AS a.id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, fsb2.name AS outer_structure_block, fsb.name AS inner_structure_block, a.data_type, ct.control AS control_type, @@ -154,6 +162,8 @@ CREATE OR REPLACE VIEW list_taxa_taxon_list_attributes AS SELECT a.id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, fsb2.name AS outer_structure_block, fsb.name AS inner_structure_block, a.data_type, @@ -189,6 +199,8 @@ CREATE OR REPLACE VIEW list_termlists_term_attributes AS SELECT a.id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, fsb2.name AS outer_structure_block, fsb.name AS inner_structure_block, a.data_type, @@ -227,6 +239,8 @@ CREATE OR REPLACE VIEW list_person_attributes AS SELECT a.id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, fsb2.name AS outer_structure_block, fsb.name AS inner_structure_block, a.data_type, @@ -266,6 +280,8 @@ CREATE OR REPLACE VIEW list_survey_attribute_values AS a.id AS survey_attribute_id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, CASE a.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar @@ -319,6 +335,8 @@ CREATE OR REPLACE VIEW list_sample_attribute_values AS a.id AS sample_attribute_id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, CASE a.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar @@ -373,6 +391,8 @@ CREATE OR REPLACE VIEW list_occurrence_attribute_values AS a.id AS occurrence_attribute_id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, CASE a.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar @@ -429,6 +449,8 @@ CREATE OR REPLACE VIEW list_location_attribute_values AS a.id AS location_attribute_id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, CASE a.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar @@ -484,6 +506,8 @@ CREATE OR REPLACE VIEW list_taxa_taxon_list_attribute_values AS a.id AS taxa_taxon_list_attribute_id, a.caption, a.caption_i18n::text, + a.term_name, + a.term_identifier, CASE a.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar @@ -510,6 +534,8 @@ UNION a.id AS taxa_taxon_list_attribute_id, a.caption, a.caption_i18n::text, + a.term_name, + a.term_identifier, CASE a.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar @@ -566,6 +592,8 @@ CREATE OR REPLACE VIEW list_termlists_term_attribute_values AS a.id AS termlists_term_attribute_id, a.caption, a.caption_i18n, + a.term_name, + a.term_identifier, CASE a.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar @@ -620,6 +648,8 @@ CREATE OR REPLACE VIEW list_person_attribute_values AS pa.id AS person_attribute_id, pa.caption, pa.caption_i18n, + pa.term_name, + pa.term_identifier, CASE pa.data_type WHEN 'T'::bpchar THEN 'Text'::bpchar WHEN 'L'::bpchar THEN 'Lookup List'::bpchar diff --git a/modules/indicia_svc_data/controllers/services/data.php b/modules/indicia_svc_data/controllers/services/data.php index c077db0d82..0df1226338 100644 --- a/modules/indicia_svc_data/controllers/services/data.php +++ b/modules/indicia_svc_data/controllers/services/data.php @@ -839,7 +839,7 @@ private function decodeArrayParameter($value) { $decoded = json_decode($value); // Strings which contain commas but not valid JSON are almost certainly mistakes. if ($decoded === null && strpos($value, ',') !== false) { - ValidationError('Validation error', 2003, 'Invalid format for array parameter.'); + throw new ValidationError('Validation error', 2003, 'Invalid format for array parameter.'); } return $decoded === null ? $value : $decoded; } diff --git a/reports/library/occurrences/filterable_dwc_nbn_occurrences.xml b/reports/library/occurrences/filterable_dwc_nbn_occurrences.xml index 5af5b7b4aa..fe4dc055e3 100644 --- a/reports/library/occurrences/filterable_dwc_nbn_occurrences.xml +++ b/reports/library/occurrences/filterable_dwc_nbn_occurrences.xml @@ -9,14 +9,27 @@ FROM cache_occurrences_functional o JOIN cache_occurrences_nonfunctional onf ON onf.id=o.id JOIN cache_taxa_taxon_lists cttl ON cttl.id=o.taxa_taxon_list_id - JOIN cache_taxon_searchterms cts ON cts.taxa_taxon_list_id=o.taxa_taxon_list_id AND cts.name_type='A' + JOIN cache_taxon_searchterms cts ON cts.taxa_taxon_list_id=o.taxa_taxon_list_id AND cts.simplified=false JOIN cache_samples_nonfunctional snf ON snf.id=o.sample_id + LEFT JOIN (sample_attribute_values vdatasetID + JOIN sample_attributes adatasetID ON adatasetID.id=vdatasetID.sample_attribute_id AND adatasetID.term_name='datasetID' + ) ON vdatasetID.sample_id=o.sample_id AND vdatasetID.deleted=false #agreements_join# #joins# WHERE #sharing_filter# #idlist# + + - + +