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

ENH: Move adding of special sample properties to separate module

parent 16ab9c3d
No related branches found
No related tags found
1 merge request!1F awi sams
......@@ -47,6 +47,7 @@ from bis_utils import (get_do_not_insert_type_names,
return_value_if_not_none,
send_mail_with_defaults,
SPECIAL_TREATMENT_SAMPLE)
from sample_helpers.sample_upload_add_special_properties import add_special_properties
from sample_helpers.sample_upload_get_event import add_event_to_sample
from sample_helpers.sample_upload_get_person import get_person
from sample_helpers.sample_upload_post_processing import post_process_samples
......@@ -369,29 +370,8 @@ def update_sample_records(data, htmluserlog_public):
msg = "There is no Sample with ID = {} in the system.".format(row["BIS ID"])
raise DataInconsistencyError(msg)
sample = _update_property(entity=sample, property_id=person_property_id,
property_name="Main User",
value=get_person(row["Main User"]))
if "Parent BIS ID" in row and return_value_if_not_none(row["Parent BIS ID"]) is not None:
sample = _update_property(entity=sample, property_id=parent_sample_property_id,
value=row["Parent BIS ID"])
if ("Sampling Person" in row
and return_value_if_not_none(row["Sampling Person"]) is not None):
sample = _update_property(entity=sample, property_id=sampling_person_property_id,
property_name="Sampling Person",
value=get_person(row["Sampling Person"]))
if "PI" in row and return_value_if_not_none(row["PI"]) is not None:
sample = _update_property(entity=sample, property_id=db.get_entity_by_name("PI").id,
property_name="PI",
value=get_person(row["PI"]))
if "Storage ID" in row and return_value_if_not_none(row["Storage ID"]) is not None:
sample = _update_property(entity=sample, property_id=container_property_id,
property_name="Container",
value=get_container(row))
if "PDFReport" in data.columns:
sample = _update_property(
entity=sample, property_id=pdfreport_property_id, property_name="PDFReport", value=row["PDFReport"])
# All special properties are added here
sample = add_special_properties(sample, row)
# Add additional properties
for property_name in additional_property_ids.keys():
......
#
# Copyright (C) 2025 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2025 Florian Spreckelsen <f.spreckelsen@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 pandas as pd
from caosadvancedtools.datainconsistency import DataInconsistencyError
from .utils import get_column_header_name, get_entity_name
from ..bis_utils import return_value_if_not_none
def add_special_properties(sample: db.Record, data: pd.Series) -> db.Record:
"""This function adds all the properties that can not be added
trivially from the given data row to the sample.
"""
# TODO Add special treatment properties to sample
return sample
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