diff --git a/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/container_update_post_processing.py b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/container_update_post_processing.py new file mode 100644 index 0000000000000000000000000000000000000000..e8f696b7c6fbe6352fe618d37a138ac796614cd3 --- /dev/null +++ b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/container_update_post_processing.py @@ -0,0 +1,33 @@ +# +# Copyright (C) 2025 Indiscale GmbH <info@indiscale.com> +# Copyright (C) 2025 Florian Spreckelsen <f.spreckelsen@indiscale.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# 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 + + +def post_process_containers_before_sync(child_containers): + + return child_containers + + +def post_process_parent_containers_before_sync(parent_containers): + + return parent_containers + + +def post_process_inserts_and_updates(inserts, updates): + + return inserts, updates diff --git a/sample-management-custom/caosdb-server/scripting/bin/update_containers.py b/sample-management-custom/caosdb-server/scripting/bin/update_containers.py index 4739d5c4ea22ac6a613afbf468285d21e80d1fc8..44c6c73021a0b9ad400f703ac8fa95c0d087dea3 100755 --- a/sample-management-custom/caosdb-server/scripting/bin/update_containers.py +++ b/sample-management-custom/caosdb-server/scripting/bin/update_containers.py @@ -37,6 +37,7 @@ from linkahead.cached import cached_query, cached_get_entity_by from bis_utils import (get_do_not_insert_type_names, replace_entity_urls_by_ids, whitespace_cleanup_in_df) from sample_helpers.container_update_get_parent import get_container_by_identifier +from sample_helpers.container_update_post_processing import (post_process_containers_before_sync, post_process_parent_containers_before_sync, post_process_inserts_and_updates) from sample_helpers.utils import (CONSTANTS, get_column_header_name, get_entity_name) # suppress warning of diff function @@ -287,6 +288,8 @@ def main(): parent_containers.remove(par) # TODO Add notes as CommentAnnotation crawler = Crawler(securityMode=SecurityMode.UPDATE) + child_containers = post_process_containers_before_sync(child_containers) + parent_containers = post_process_parent_containers_before_sync(parent_containers) to_be_synchronized = child_containers + parent_containers inserts, updates = crawler.synchronize( @@ -296,10 +299,8 @@ def main(): if "SHARED_DIR" in os.environ: _notify_about_inserts_and_updates(len(inserts), len(updates), htmluserlog_public, crawler.run_id) - for ent in inserts + updates: - ent.retrieve_acl() - ent.grant(role='Stock Manager', priority=False, permission="EDIT:ACL") - ent.update_acl() + inserts, updates = post_process_inserts_and_updates(isnerts, updates) + logger.info(f"Successfully processed {len(child_containers)} containers and " f"{len(parent_containers)} parent containers.")