@@ -1402,6 +1402,12 @@ def update_entity(id):
14021402 # Handle linkages update via `after_update_trigger` methods
14031403 if has_dataset_uuids_to_link or has_dataset_uuids_to_unlink :
14041404 after_update (normalized_entity_type , user_token , merged_updated_dict )
1405+ elif normalized_entity_type == 'Collection' :
1406+ # Generate 'before_update_trigger' data and update the entity details in Neo4j
1407+ merged_updated_dict = update_entity_details (request , normalized_entity_type , user_token , json_data_dict , entity_dict )
1408+
1409+ # Handle linkages update via `after_update_trigger` methods
1410+ after_update (normalized_entity_type , user_token , merged_updated_dict )
14051411 else :
14061412 # Generate 'before_update_trigger' data and update the entity details in Neo4j
14071413 merged_updated_dict = update_entity_details (request , normalized_entity_type , user_token , json_data_dict , entity_dict )
@@ -1950,78 +1956,6 @@ def get_next_revisions(id):
19501956
19511957 return jsonify (final_result )
19521958
1953-
1954-
1955- """
1956- Link the given list of datasets to the target collection
1957-
1958- JSON request body example:
1959- {
1960- "dataset_uuids": [
1961- "fb6757b606ac35be7fa85062fde9c2e1",
1962- "81a9fa68b2b4ea3e5f7cb17554149473",
1963- "3ac0768d61c6c84f0ec59d766e123e05",
1964- "0576b972e074074b4c51a61c3d17a6e3"
1965- ]
1966- }
1967-
1968- Parameters
1969- ----------
1970- collection_uuid : str
1971- The UUID of target collection
1972-
1973- Returns
1974- -------
1975- json
1976- JSON string containing a success message with 200 status code
1977- """
1978- @app .route ('/collections/<collection_uuid>/add-datasets' , methods = ['PUT' ])
1979- def add_datasets_to_collection (collection_uuid ):
1980- if READ_ONLY_MODE :
1981- forbidden_error ("Access not granted when entity-api in READ-ONLY mode" )
1982-
1983- # Get user token from Authorization header
1984- user_token = get_user_token (request )
1985-
1986- # Query target entity against uuid-api and neo4j and return as a dict if exists
1987- entity_dict = query_target_entity (collection_uuid , user_token )
1988- if entity_dict ['entity_type' ] != 'Collection' :
1989- bad_request_error (f"The UUID provided in URL is not a Collection: { collection_uuid } " )
1990-
1991- # Always expect a json body
1992- require_json (request )
1993-
1994- # Parse incoming json string into json data(python list object)
1995- json_data_dict = request .get_json ()
1996-
1997- if 'dataset_uuids' not in json_data_dict :
1998- bad_request_error ("Missing 'dataset_uuids' key in the request JSON." )
1999-
2000- if not json_data_dict ['dataset_uuids' ]:
2001- bad_request_error ("JSON field 'dataset_uuids' can not be empty list." )
2002-
2003- # Now we have a list of uuids
2004- dataset_uuids_list = json_data_dict ['dataset_uuids' ]
2005-
2006- # Make sure all the given uuids are datasets (or publications 2/17/23 ~Derek Furst)
2007- for dataset_uuid in dataset_uuids_list :
2008- entity_dict = query_target_entity (dataset_uuid , user_token )
2009- if not schema_manager .entity_type_instanceof (entity_dict ['entity_type' ], 'Dataset' ):
2010- bad_request_error (f"The UUID provided in JSON is not a Dataset or Publication: { dataset_uuid } " )
2011-
2012- try :
2013- app_neo4j_queries .add_datasets_to_collection (neo4j_driver_instance , collection_uuid , dataset_uuids_list )
2014- except TransactionError :
2015- msg = "Failed to create the linkage between the given datasets and the target collection"
2016- # Log the full stack trace, prepend a line with our message
2017- logger .exception (msg )
2018- # Terminate and let the users know
2019- internal_server_error (msg )
2020-
2021- # Send response with success message
2022- return jsonify (message = "Successfully added all the specified datasets to the target collection" )
2023-
2024-
20251959"""
20261960Redirect a request from a doi service for a dataset or collection
20271961
0 commit comments