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 c15df79805965ec982012775a113704979ecdf1b..19495418e9918265307de0e59789ae1e962ffd4e 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 @@ -85,6 +85,7 @@ 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: + sample = update_property(sample, event_rt.id, event, property_name=event_rt.name) return sample @@ -108,39 +109,39 @@ def _create_position(mode: str, lat: float, lng: float, ele: float): def _perform_sanity_checks(sample, data): - if (get_column_header_name("end_date") in data and - return_value_if_not_none(data[get_column_header_name("end_date")]) is not None): - if (get_column_header_name("start_date") not in data or - return_value_if_not_none(data[get_column_header_name("start_date")]) is None): + if (get_column_header_name("end_date_prop") in data and + return_value_if_not_none(data[get_column_header_name("end_date_prop")]) is not None): + if (get_column_header_name("start_date_prop") not in data or + return_value_if_not_none(data[get_column_header_name("start_date_prop")]) is None): raise DataInconsistencyError( f"Sample with {get_entity_name('entity_id')} {sample.id} has a " - f"{get_column_header_name('end_date')} but no valid " - f"{get_column_header_name('start_date')}." + f"{get_column_header_name('end_date_prop')} but no valid " + f"{get_column_header_name('start_date_prop')}." ) for name in ["start", "stop"]: - bool_list = [get_column_header_name(f"{val}_{name}") in data for val in [ - "latitude", "longitude", "elevation"]] + bool_list = [get_column_header_name(f"{val} {name}") in data for val in [ + "Latitude", "Longitude", "Elevation"]] raise_error = False if any(bool_list): if not all(bool_list): raise_error = True - elif any([return_value_if_not_none(data[get_column_header_name(f"{val}_{name}")]) is None for val in ["latitude", "longitude", "elevation"]]): + elif any([return_value_if_not_none(data[get_column_header_name(f"{val} {name}")]) is None for val in ["Latitude", "Longitude", "Elevation"]]): raise_error = True if raise_error: raise DataInconsistencyError( - f"Sample with {get_entity_name('entity_id')} {sample.id} has an " + f"Sample with {get_column_header_name('entity_id')} {sample.id} has an " f"invalid {name} position. Please make sure that latitude, longitude, " "and elevation are provided." ) # only need to check lat since we already checked that if lat is # present, lng and ele are present, too - if (get_column_header_name("latitude_stop") in data and - return_value_if_not_none(data[get_column_header_name("latitude_stop")]) is not None): - if (get_column_header_name("latitude_start") not in data or - return_value_if_not_none(data[get_column_header_name("latitude_start")]) is not None): + if (get_column_header_name("Latitude stop") in data and + return_value_if_not_none(data[get_column_header_name("Latitude stop")]) is not None): + if (get_column_header_name("Latitude start") not in data or + return_value_if_not_none(data[get_column_header_name("Latitude start")]) is not None): raise DataInconsistencyError( f"Sample with {get_entity_name('entity_id')} {sample.id} has a " f"{get_entity_name('StopPosition')} but no valid "