diff --git a/src/schema/provenance_schema.yaml b/src/schema/provenance_schema.yaml index 9733a98e..77fc8eac 100644 --- a/src/schema/provenance_schema.yaml +++ b/src/schema/provenance_schema.yaml @@ -487,6 +487,13 @@ ENTITIES: on_read_trigger: get_collection_associated_publication on_index_trigger: get_collection_associated_publication description: "The publication which uses this collection's data" + status: + type: string + generated: true + transient: true + description: "One of: New|Published" + on_read_trigger: get_collection_status + on_index_trigger: get_collection_status ############################################# Dataset ############################################# Dataset: diff --git a/src/schema/schema_triggers.py b/src/schema/schema_triggers.py index c370428b..513f5c10 100644 --- a/src/schema/schema_triggers.py +++ b/src/schema/schema_triggers.py @@ -921,6 +921,13 @@ def set_dataset_status_new( return property_key, "New" +def set_collection_status_new( + property_key, normalized_type, user_token, existing_data_dict, new_data_dict +): + ## Same as dataset unless otherwise stated + return set_dataset_status_new(property_key, normalized_type, user_token, existing_data_dict, new_data_dict) + + def get_entity_collections( property_key, normalized_type, user_token, existing_data_dict, new_data_dict ): @@ -2870,6 +2877,30 @@ def set_was_derived_from( # No need to log raise +def get_collection_status(property_key, normalized_type, user_token, existing_data_dict, new_data_dict): + """Trigger event method that calls related functions involved with updating the status value. + + Parameters + ---------- + property_key : str + The target property key + normalized_type : str + One of the types defined in the schema yaml: Dataset + user_token: str + The user's globus nexus token + existing_data_dict : dict + A dictionary that contains all existing entity properties + new_data_dict : dict + A merged dictionary that contains all possible input data to be used + """ + doi_url = existing_data_dict.get("doi_url") + + if doi_url is not None: + return property_key, "Published" + else: + return set_collection_status_new(property_key, normalized_type, user_token, existing_data_dict, new_data_dict) + + def update_status(property_key, normalized_type, user_token, existing_data_dict, new_data_dict): """Trigger event method that calls related functions involved with updating the status value.