diff --git a/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_column_definitions.py b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_column_definitions.py index 3bd2b859c7f59d9143372314ff880dd49cadff50..251f5f1dc1fb43e9d8f7d162a94cc02bf3ddfc7a 100644 --- a/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_column_definitions.py +++ b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_column_definitions.py @@ -91,7 +91,7 @@ COLUMN_CONVERTER = use_custom_names({ "Collector": semicolon_separated_list, "Curator": semicolon_separated_list, "Embargo": _embargo_converter, - "Event responsible": semicolon_separated_list, + "responsible_person_event": semicolon_separated_list, "Sphere": semicolon_separated_list, }) diff --git a/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py index 19495418e9918265307de0e59789ae1e962ffd4e..3bc494783c97242c432f5abbd93145499cba26f0 100644 --- a/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py +++ b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py @@ -15,6 +15,7 @@ # 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 @@ -85,6 +86,20 @@ def add_event_to_sample(sample: db.Record, data: pd.Series) -> db.Record: # only add if there was any event data at all: if len(event.properties) > 0: + # Start date and position are identifying event properties + if event.get_property(get_entity_name("start_date_prop")) is None: + raise DataInconsistencyError( + f"Sample with {get_column_header_name('entity_id')} {sample.id} has an " + f"{get_entity_name('event_rt')} but is missing a { + get_column_header_name('start_date_prop')} " + "which is required." + ) + if event.get_property(get_entity_name(position_prop.name)) is None: + raise DataInconsistencyError( + f"Sample with {get_column_header_name('entity_id')} {sample.id} has an " + f"{get_entity_name('event_rt')} but is missing start position information " + "which is required." + ) sample = update_property(sample, event_rt.id, event, property_name=event_rt.name) diff --git a/sample-management-custom/caosdb-server/scripting/bin/upload_sample_template.py b/sample-management-custom/caosdb-server/scripting/bin/upload_sample_template.py index db9aa64f6d6e4383f14247dd23bc2bac7ff3bf85..1e25408f5da7d3d073cef81f31364e468f930bf5 100755 --- a/sample-management-custom/caosdb-server/scripting/bin/upload_sample_template.py +++ b/sample-management-custom/caosdb-server/scripting/bin/upload_sample_template.py @@ -40,8 +40,7 @@ from caosadvancedtools.serverside import helper from caosadvancedtools.table_importer import CSVImporter from caoscrawler.logging import configure_server_side_logging -from bis_utils import (replace_entity_urls_by_ids, - whitespace_cleanup_in_df) +from bis_utils import (replace_entity_urls_by_ids) from sample_helpers.sample_upload_column_definitions import ( COLUMN_CONVERTER, DATATYPE_DEFINITIONS, OBLIGATORY_COLUMNS, OBLIGATORY_COLUMNS_CHILD, SPECIAL_TREATMENT_SAMPLE) @@ -96,8 +95,8 @@ def read_data_from_file(filename): ) raise DataInconsistencyError("There was a problem with the CSV upload.") - # strip leading and trailing whitespaces - return whitespace_cleanup_in_df(df) + # TODO: strip leading and trailing whitespaces + return df def _get_converter_from_property_datatype(dt):