Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed Mar 27, 2018
2 parents 0d78369 + 529bc93 commit 420e45e
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 16 deletions.
2 changes: 1 addition & 1 deletion application/config/config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @var string
*/
$config['version'] = '1.57.0';
$config['version'] = '1.58.0';
/**
* Version release date.
*
Expand Down
16 changes: 7 additions & 9 deletions application/controllers/licence.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@
* 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
*/

/**
* Controller providing CRUD access to the licences list.
*
* @package Core
* @subpackage Controllers
*/
class Licence_Controller extends Gridview_Base_Controller {

Expand All @@ -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');
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions application/libraries/ATTR_ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
28 changes: 28 additions & 0 deletions application/views/custom_attribute/custom_attribute_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@
'helpText' => $helpText,
]);
}
if (array_key_exists('term_name', $this->model->as_array())) {
$helpText = <<<TXT
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.
TXT;
echo data_entry_helper::text_input([
'fieldname' => "$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 = <<<TXT
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.
TXT;
echo data_entry_helper::text_input([
'fieldname' => "$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",
Expand Down
76 changes: 76 additions & 0 deletions modules/indicia_setup/db/version_1_58_0/201803261544_attr_dwc.sql
Original file line number Diff line number Diff line change
@@ -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.';
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/indicia_svc_data/controllers/services/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
28 changes: 24 additions & 4 deletions reports/library/occurrences/filterable_dwc_nbn_occurrences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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#
</query>
<params>
<param name="dataset_name"
display="Dataset name"
datatype="string"
default="Indicia"
description="Name of the dataset to populate into Dwc datasetName." />
<param name="rights_holder"
display="Rights holder"
datatype="string"
default="Not set"
description="A person or organisation owning or managing rights over the resource." />
<param name="smpattrs"
display="Sample attribute list"
datatype="smpattrs"
Expand Down Expand Up @@ -112,10 +125,9 @@ END"
datatype="text"
term="http://purl.org/dc/terms/license" />
<column name="rightsHolder"
sql="null::text"
sql="'#rights_holder#'"
datatype="text"
term="http://purl.org/dc/terms/rightsHolder" />
<!-- check since using output_sref, this is not relevant? -->
<column name="coordinateUncertaintyInMeters"
sql="CASE
WHEN o.sensitive=true OR snf.privacy_precision IS NOT NULL OR snf.entered_sref_system NOT SIMILAR TO '[0-9]+' THEN
Expand Down Expand Up @@ -146,9 +158,17 @@ END"
datatype="integer"
term="http://rs.tdwg.org/dwc/terms/decimaLongitude" />
<column name="datasetName"
sql="snf.website_title || ' | ' || CASE WHEN SUBSTRING(snf.survey_title FROM 1 FOR LENGTH(snf.website_title)) = snf.website_title THEN trim(substring(snf.survey_title FROM LENGTH(snf.website_title)+1)) ELSE snf.survey_title END"
sql="'#dataset_name#'"
datatype="text"
term="http://rs.tdwg.org/dwc/terms/datasetName" />
<column name="datasetID"
sql="vdatasetID.text_value"
datatype="text"
term="http://rs.tdwg.org/dwc/terms/datasetID" />
<column name="collectionCode"
sql="snf.website_title || ' | ' || CASE WHEN SUBSTRING(snf.survey_title FROM 1 FOR LENGTH(snf.website_title)) = snf.website_title THEN trim(substring(snf.survey_title FROM LENGTH(snf.website_title)+1)) ELSE snf.survey_title END"
datatype="text"
term="http://rs.tdwg.org/dwc/terms/collectionCode" />
<column name="locality"
sql="o.location_name"
datatype="text"
Expand Down

0 comments on commit 420e45e

Please sign in to comment.