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

ENH: Add container-upload post processing

parent 2127218c
No related branches found
No related tags found
1 merge request!1F awi sams
#
# 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
...@@ -37,6 +37,7 @@ from linkahead.cached import cached_query, cached_get_entity_by ...@@ -37,6 +37,7 @@ from linkahead.cached import cached_query, cached_get_entity_by
from bis_utils import (get_do_not_insert_type_names, from bis_utils import (get_do_not_insert_type_names,
replace_entity_urls_by_ids, whitespace_cleanup_in_df) 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_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) from sample_helpers.utils import (CONSTANTS, get_column_header_name, get_entity_name)
# suppress warning of diff function # suppress warning of diff function
...@@ -287,6 +288,8 @@ def main(): ...@@ -287,6 +288,8 @@ def main():
parent_containers.remove(par) parent_containers.remove(par)
# TODO Add notes as CommentAnnotation # TODO Add notes as CommentAnnotation
crawler = Crawler(securityMode=SecurityMode.UPDATE) 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 to_be_synchronized = child_containers + parent_containers
inserts, updates = crawler.synchronize( inserts, updates = crawler.synchronize(
...@@ -296,10 +299,8 @@ def main(): ...@@ -296,10 +299,8 @@ def main():
if "SHARED_DIR" in os.environ: if "SHARED_DIR" in os.environ:
_notify_about_inserts_and_updates(len(inserts), len(updates), htmluserlog_public, _notify_about_inserts_and_updates(len(inserts), len(updates), htmluserlog_public,
crawler.run_id) crawler.run_id)
for ent in inserts + updates: inserts, updates = post_process_inserts_and_updates(isnerts, updates)
ent.retrieve_acl()
ent.grant(role='Stock Manager', priority=False, permission="EDIT:ACL")
ent.update_acl()
logger.info(f"Successfully processed {len(child_containers)} containers and " logger.info(f"Successfully processed {len(child_containers)} containers and "
f"{len(parent_containers)} parent containers.") f"{len(parent_containers)} parent containers.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment