Skip to content
Snippets Groups Projects
Commit 3e341b94 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-sample-name' of...

Merge branch 'f-sample-name' of gitlab.indiscale.com:caosdb/src/linkahead-sample-management into f-sample-name
parents 29b2b317 aaf057af
No related branches found
No related tags found
1 merge request!2F sample name
......@@ -13,6 +13,7 @@ from bis_utils import (create_email_with_link_text,
get_options_row, send_mail_with_defaults)
from sample_helpers.sample_registration_get_person_identifier import get_person_identifier
from sample_helpers.sample_registration_post_processing import post_process_samples
from sample_helpers.sample_registration_check_column_names import check_column_names
from sample_helpers.utils import CONSTANTS, get_column_header_name, get_entity_name
ERROR_PREFIX = CONSTANTS["error_prefix"]
......@@ -34,8 +35,9 @@ def get_column_names(data):
other_names = data["required_column_names"].split(',') + data["column_names"]
starting_names.extend([name.strip()
for name in other_names if name.strip() not in starting_names])
return [get_column_header_name(name) for name in starting_names]
cnames = [get_column_header_name(name) for name in starting_names]
check_column_names(cnames)
return cnames
def create_sample_entities(data):
responsible_person_id = int(data["responsible_person"])
......
#
# Copyright (C) 2025 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2025 Henrik tom Wörden <h.tomwoerden@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
import linkahead as db
import logging
from caosadvancedtools.datainconsistency import DataInconsistencyError
from .utils import CONSTANTS, get_column_header_name, get_entity_name
from .sample_upload_column_definitions import use_custom_names
logger = logging.getLogger("caosadvancedtools")
def check_column_names(names: list[str]) -> None:
event_and_position_properties = use_custom_names([
"Campaign",
"Biome",
"Device",
"Elevation start",
"Elevation stop",
"End date",
"responsible_person_event",
"igsn_doi_prop",
"Latitude start",
"Latitude stop",
"Level",
"locality_description_prop",
"locality_name_prop",
"Longitude start",
"Longitude stop",
"Sphere",
"Start date",
])
needs_events = False
for name in names:
if name in event_and_position_properties:
needs_events = True
appended = []
if needs_events:
for name in use_custom_names([
"Longitude start",
"Latitude start",
"Elevation start",
"Start date",
]):
if name not in names:
names.append(name)
appended.append(name)
if appended:
logger.warning(
"The following columns were added in order to allow consitent data insertion:\n"
f"{', '.join(appended)}"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment