Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed May 4, 2023
2 parents 3c4dcc2 + fbc4d0e commit 034ebf1
Show file tree
Hide file tree
Showing 8 changed files with 746 additions and 17 deletions.
4 changes: 2 additions & 2 deletions application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
*
* @var string
*/
$config['version'] = '8.18.1';
$config['version'] = '8.19.0';

/**
* Version release date.
*
* @var string
*/
$config['release_date'] = '2023-04-27';
$config['release_date'] = '2023-05-04';

/**
* Link to the code repository downloads page.
Expand Down
43 changes: 32 additions & 11 deletions application/libraries/Attribute_Value_ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ protected function attribute_validation(Validation $array, $type) {
}

public function save() {
if ($this->delete_if_empty())
if ($this->delete_if_empty()) {
return $this;
else
}
else {
return parent::save();
}
}

/**
Expand Down Expand Up @@ -193,10 +195,8 @@ protected function delete_if_empty() {
/**
* Override set handler to translate WKT to PostGIS internal spatial data.
*/
public function __set($key, $value)
{
if ($key === 'geom_value')
{
public function __set($key, $value) {
if ($key === 'geom_value') {
if ($value) {
$row = $this->db->query("SELECT ST_GeomFromText('$value', ".kohana::config('sref_notations.internal_srid').") AS geom")->current();
$value = $row->geom;
Expand All @@ -208,16 +208,37 @@ public function __set($key, $value)
/**
* Override get handler to translate PostGIS internal spatial data to WKT.
*/
public function __get($column)
{
public function __get($column) {
$value = parent::__get($column);

if ($column === 'geom_value' && !empty($value))
{
if ($column === 'geom_value' && !empty($value)) {
$row = $this->db->query("SELECT ST_asText('$value') AS wkt")->current();
$value = $row->wkt;
}
return $value;
}

}
/**
* Post submit of a single attribute value.
*
* Occurs only when an attribute value submitted in isolation. Updates the
* parent record updated metadata to reflect the change in the attribute
* value, making it easier to detect when anything about a record has been
* changed.
*
* @param bool $isInsert
* True if the operation is an insert, false for an update.
*/
protected function postSubmit($isInsert) {
if ($this->wantToUpdateMetadata) {
// Value has changed, so trigger metadata update on parent.
$parentEntity = substr($this->object_name, 0, strpos($this->object_name, '_'));
$parentTable = inflector::plural($parentEntity);
$parentTableFk = $parentEntity . '_id';
$parentTableId = $this->$parentTableFk;
$this->db->query("UPDATE $parentTable SET updated_on='now()', updated_by_id=$this->updated_by_id WHERE id=$parentTableId");
}
return parent::postSubmit($isInsert);
}

}
10 changes: 6 additions & 4 deletions application/libraries/MY_ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ private function createChildRecords() {
if (array_key_exists('subModels', $this->submission)) {
// Iterate through the subModel array, linking them to this model.
foreach ($this->submission['subModels'] as $key => $a) {
Kohana::log("debug", "Submitting submodel ".$a['model']['id'].".");
Kohana::log("debug", "Submitting submodel " . $a['model']['id'] . ".");
// Establish the right model.
$modelName = $a['model']['id'];
// Alias old images tables to new media tables.
Expand Down Expand Up @@ -1521,9 +1521,11 @@ private function createChildRecords() {
$m->identifiers = array_merge($this->identifiers);
$result = $m->inner_submit();
$this->nestedChildModelIds[] = $m->getSubmissionResponseMetadata();
if ($m->wantToUpdateMetadata && !$this->wantToUpdateMetadata && preg_match('/_(image|medium)$/', $m->object_name)) {
// we didn't update the parent's metadata. But a child image has been changed, so we want to update the parent record metadata.
// i.e. adding an image to a record causes the record to be edited and therefore to get its status reset.
if ($m->wantToUpdateMetadata && !$this->wantToUpdateMetadata && preg_match('/_(image|medium|value)$/', $m->object_name)) {
// We didn't update the parent's metadata. But a child image or
// attribute value has been changed, so we want to update the parent
// record metadata. I.e. adding an image to a record causes the
// record to be edited and therefore to get its status reset.
$this->wantToUpdateMetadata = TRUE;
$this->set_metadata();
$this->validate(new Validation($this->as_array()), TRUE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Following indexes are duplicates.
DROP INDEX IF EXISTS ix_occurrence_attribute_values_created_by_id;
DROP INDEX IF EXISTS ix_occurrence_attribute_values_updated_by_id;
DROP INDEX IF EXISTS ix_sample_attribute_values_created_by_id;
DROP INDEX IF EXISTS ix_sample_attribute_values_updated_by_id;
DROP INDEX IF EXISTS ix_location_attribute_values_created_by_id;
DROP INDEX IF EXISTS ix_location_attribute_values_updated_by_id;
1 change: 1 addition & 0 deletions modules/process_checker/config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
process_checker.php
56 changes: 56 additions & 0 deletions modules/process_checker/config/process_checker.php.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* @file
* Example config file for the Process Checker module.
*
* Indicia, the OPAL Online Recording Toolkit.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* 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.
*
* @author Indicia Team
* @license http://www.gnu.org/licenses/gpl.html GPL
* @link https://github.com/indicia-team/warehouse/
*/

$config['checks'] = [
'survey2checkOccs' => [
'website_id' => 1,
'survey_id' => 2,
'start_record_id' => 1000000,
'start_date' => '2023-01-01',
// Ignore records added recently as they may still be being processed.
// Format must be one that is accepted when casting to interval in plpgsql,
// e.g. '2 days'::interval.
'ignore_recent' => '2 days',
'checks' => ['cache_presence', 'cache_absence', 'cache_spatial_index', 'cache_attributes', 'es_presence', 'es_absence'],
// Check entity occurrence or sample.
'entity' => 'occurrence',
'esEndpoint' => 'es',
'esIdPrefix' => 'dev|',
],
'survey2checkSamples' => [
'website_id' => 1,
'survey_id' => 2,
'start_record_id' => 1000000,
'start_date' => '2023-01-01',
// Ignore records added recently as they may still be being processed.
// Format must be one that is accepted when casting to interval in plpgsql,
// e.g. '2 days'::interval.
'ignore_recent' => '2 days',
'checks' => ['cache_presence', 'cache_absence', 'cache_spatial_index', 'cache_attributes', 'es_presence', 'es_absence'],
// Check entity occurrence or sample.
'entity' => 'sample',
'esEndpoint' => 'es-samples',
'esIdPrefix' => 'dev|',
],
];
Loading

0 comments on commit 034ebf1

Please sign in to comment.