-
Notifications
You must be signed in to change notification settings - Fork 11
/
load_referential_splitter.py
executable file
·66 lines (57 loc) · 2.85 KB
/
load_referential_splitter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# This file is part of Open-Capture.
# Open-Capture is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Open-Capture 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 General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Open-Capture. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
# @dev : Oussama BRICH <oussama.brich@edissyum.com>
import json
import argparse
from src.backend.main import create_classes_from_custom_id
from bin.scripts.splitter_metadata.load_referential import load_referential
from bin.scripts.splitter_metadata.load_referential_standard import load_referential as load_referential_standard
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Reload metadata for Splitter.')
parser.add_argument("-m", '--methods', help='Config JSON for matadata methods')
parser.add_argument("-c", '--custom-id', help='Custom id')
args = parser.parse_args()
database, config, _, _, _, log, _, _, _, docservers, _, _, _ = create_classes_from_custom_id(args.custom_id)
with open(args.methods) as split_methods:
split_methods = split_methods.read()
split_methods = json.loads(split_methods)
cursor = database.conn.cursor()
cursor.execute("TRUNCATE TABLE metadata", {})
for method in split_methods['methods']:
method['referentialMode'] = 0
if method['id'] in ["alfresco_referential_standard"]:
log.info(f"Reload metadata for {method['id']}....")
_args = {
'log': log,
'config': config,
'database': database,
'method_data': method,
'docservers': docservers,
'form_id': method['form_id']
}
load_referential_standard(_args)
log.info(f"{method['id']} metadata reload with success.")
elif method['id'] in ["alfresco_referential"]:
log.info(f"Reload metadata for {method['id']}....")
_args = {
'log': log,
'config': config,
'database': database,
'method_data': method,
'docservers': docservers,
'form_id': method['form_id']
}
load_referential(_args)
log.info(f"{method['id']} metadata reload with success.")
# Commit and close database connection
database.conn.commit()
database.conn.close()