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

FEAT: Raise error when identifying event properties are missing

parent 3e341b94
No related branches found
No related tags found
1 merge request!2F sample name
......@@ -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,
})
......
......@@ -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)
......
......@@ -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):
......
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