-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwizardpages.py
More file actions
616 lines (508 loc) · 28.2 KB
/
Copy pathwizardpages.py
File metadata and controls
616 lines (508 loc) · 28.2 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
# classes for the pages in the wizard
import math
import sys, traceback
from gettext import GNUTranslations
from PySide6.QtWidgets import QWizard, QWizardPage, QLabel, QLineEdit, QGridLayout, QMessageBox, QComboBox, QPlainTextEdit, QWidget, QScrollArea
from PySide6.QtGui import QRegularExpressionValidator
from PySide6.QtCore import QRegularExpression, Qt, QThread
from config import ImporterConfig
from dataobjects import ImporterData, AuthData, YesNo, FileBrowseType, ItemFileMatchType
from dspaceauthservice import AuthException, DspaceAuthService
from communityservice import CommunityException, CommunityService
from widgets import FileBrowser, SchemaFieldSelect, RadioButton
from excelfileservice import ExcelFileService, ExcelFileException
from fileservice import ItemFileService
from utils import Utils
from itemservice import ItemService, ItemException
from worker import ImportWorker
class DSpaceWizardPages(QWizardPage):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations) -> None:
super().__init__()
self._config = config
self._lang_i18n = lang_i18n
lang_i18n.install()
def translation_value(self, translation_key: str) -> str:
return self._lang_i18n.gettext(translation_key)
def _show_critical_message_box(self, message: str):
msgBox = QMessageBox()
msgBox.setText(message)
msgBox.setIcon(QMessageBox.Critical)
msgBox.exec()
def _no_yes_options(self) -> dict:
return {YesNo.NO: _("No"), YesNo.YES: _("Yes")}
def _file_match_options(self) -> dict:
return {ItemFileMatchType.EXACT: _("file_name_match_exact"), ItemFileMatchType.BEGINS: _("file_name_match_begins_with")}
def _scroll_area_width(self) -> int:
#self._config.window_width() - (0.05 * self._config.window_width())
return self._config.window_width() - 25
def _scroll_area_height(self) -> int:
#self._config.window_height() - (0.25 * self._config.window_height())
return self._config.window_height() - 125
class LoginPage(DSpaceWizardPages):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations, auth_data: AuthData) -> None:
super().__init__(config=config, lang_i18n=lang_i18n)
self._auth_data = auth_data
self.setTitle(_("login_page_title"))
self.setSubTitle(_("login_page_subtitle"))
service_label = QLabel(text=" ".join([_("login_page_service_url"), config.dspace_rest_url()]))
username_label = QLabel(text=_("login_page_username_label"))
self.username_edit = QLineEdit()
# validator for username - email address
re = QRegularExpression("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b", QRegularExpression.CaseInsensitiveOption)
validator = QRegularExpressionValidator(re)
self.username_edit.setValidator(validator)
#username_edit.textChanged.connect(self.__adjust_text_color(username_edit))
password_label = QLabel(text=_("login_page_password_label"))
self.password_edit = QLineEdit()
self.password_edit.setEchoMode(QLineEdit.Password)
layout = QGridLayout()
layout.addWidget(service_label, 0, 0, 1, 2)
layout.addWidget(username_label, 1, 0)
layout.addWidget(self.username_edit, 1, 1)
layout.addWidget(password_label, 2, 0)
layout.addWidget(self.password_edit, 2, 1)
self.setLayout(layout)
# register the fields and make them required
self.registerField("username*", self.username_edit)
self.registerField("password*", self.password_edit)
def validatePage(self) -> bool:
# this is called when next or finished is clicked
# since registerField is used and the fields are required can only check that they are valid to login to dspace
# validator on username does not validate string if field not in registerField?
# return the tokens
# setup a data structure where the tokens from the login are saved and can be refreshed
is_valid = False
if len(self.username_edit.text()) > 0 and len(self.password_edit.text()) > 0:
try:
auth_service = DspaceAuthService(self._config, self._auth_data)
auth_service.logon(self.username_edit.text(), self.password_edit.text())
is_valid = True
except AuthException:
self._show_critical_message_box("Invalid username and password")
else:
self._show_critical_message_box("The username and password are required")
return is_valid
#######################################################################################################################
class CollectionPage(DSpaceWizardPages):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations, auth_data: AuthData, shared_data: ImporterData) -> None:
super().__init__(config=config, lang_i18n=lang_i18n)
self.shared_data = shared_data
# to get the communities and collections
self.community_service = CommunityService(self._config, auth_data)
self.setTitle(_("collection_page_title"))
self.setSubTitle(_("collection_page_subtitle"))
# instructions
instruction_label = QLabel()
instruction_label.setText(_("collection_page_instructions"))
#combo boxes for communities and collections
community_label = QLabel(text=_("collection_page_community_label"))
self.community_select = QComboBox()
self.community_select.currentIndexChanged.connect(self.change_community)
collection_label = QLabel(text=_("collection_page_collection_label"))
self.collection_select = QComboBox()
# community_select.clear will clear all items from select
layout = QGridLayout()
layout.addWidget(instruction_label, 0, 0, 1, 2)
layout.addWidget(community_label, 1, 0)
layout.addWidget(self.community_select, 1, 1)
layout.addWidget(collection_label, 2, 0)
layout.addWidget(self.collection_select, 2, 1)
layout.setRowStretch(3, 1)
# widget to hold the controls
container = QWidget()
container.setLayout(layout)
container.resize(self._config.window_width(), self._config.window_height())
# scroll area and add container widget
scroll = QScrollArea(self)
scroll.setWidget(container)
scroll.setWidgetResizable(True)
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.resize(self._scroll_area_width(), self._scroll_area_height())
scroll.update()
#self.setLayout(layout)
# register fields to make them required
self.registerField("collection*", self.collection_select)
def change_community(self, index):
try:
if index > 0: # 0 index is blank
curr_dso = self.community_select.itemData(index)
# get the sub communities
sub_comm_list = self.community_service.get_subcommunities(curr_dso) # list of DSO
self.community_select.clear()
if curr_dso is None:
self.community_select.insertItem(0, "")
index = 1
else:
self.community_select.insertItem(0, curr_dso.name)
if curr_dso.parent is None:
self.community_select.insertItem(1, "Back", userData=None)
else:
self.community_select.insertItem(1, "Back", userData=self.community_service.get_community_dso(curr_dso.parent))
index = 2
for sub_comm in sub_comm_list:
self.community_select.insertItem(index, sub_comm.name, userData=sub_comm)
index = index + 1
# populate the collections
coll_list = self.community_service.get_collections(curr_dso) # list of DSO
self.collection_select.clear()
index = 0
for coll in coll_list:
self.collection_select.insertItem(index, coll.name, userData=coll)
index = index + 1
except CommunityException as err:
self._show_critical_message_box(str(err))
def initializePage(self) -> None:
try:
if len(self.community_service.communities_and_collections) == 0:
# request to query communities
self.community_service.get_top_communities()
# populate the community drop down
self.community_select.insertItem(0, "")
index = 1
for _, dso in self.community_service.communities_and_collections.items():
self.community_select.insertItem(index, dso.name, userData=dso)
index = index + 1
except CommunityException as err:
self._show_critical_message_box(str(err))
def validatePage(self) -> bool:
if self.collection_select.currentIndex == -1:
self._show_critical_message_box("The collection to import the data to is required.")
return False
self.shared_data.selected_collection = self.collection_select.currentData()
return True
#######################################################################################################################
class ExcelFileSelectPage(DSpaceWizardPages):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations, shared_data: ImporterData) -> None:
super().__init__(config, lang_i18n)
self.shared_data = shared_data
self.setTitle(_("excel_page_title"))
self.setSubTitle(_("excel_page_subtitle"))
# instructions
instruction_label = QLabel()
instruction_label.setText(_("excel_page_instructions"))
# file select for excel file
self.excel_file = FileBrowser(FileBrowseType.FILE, _("excel_page_import_file_label"), "Excel files (*.xlsx)", _("excel_page_file_select_button"))
self.excel_file.fileSelected.connect(self.excel_file_selected)
# sheet in excel file
excel_sheet_label = QLabel()
excel_sheet_label.setText(_("excel_page_sheet_label"))
self.excel_sheet_select = QComboBox()
layout = QGridLayout()
layout.addWidget(instruction_label, 0, 0, 1, 2)
layout.addWidget(self.excel_file, 1, 0, 1, 2)
layout.addWidget(excel_sheet_label, 2, 0)
layout.addWidget(self.excel_sheet_select, 2, 1)
layout.setRowStretch(3, 1)
# widget to hold the controls
container = QWidget()
container.setLayout(layout)
container.resize(self._config.window_width(), self._config.window_height())
# scroll area and add container widget
scroll = QScrollArea(self)
scroll.setWidget(container)
scroll.setWidgetResizable(True)
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.resize(self._scroll_area_width(), self._scroll_area_height())
scroll.update()
#self.setLayout(layout)
# register the excel sheet select to make it required
self.registerField("excelSheet*", self.excel_sheet_select)
def excel_file_selected(self, file_name):
#print("in excel file selected handler")
print(f"importing data from {file_name}")
# instantiate excel file service
try:
self.excelService = ExcelFileService()
self.excelService.set_file(file_name)
self.shared_data.item_file = file_name
# extract sheets and populate the excel_sheet_select widget
self.excel_sheet_select.clear()
self.excel_sheet_select.insertItems(0, self.excelService.get_sheet_names())
except ExcelFileException as err:
self.excel_sheet_select.clear()
self._show_critical_message_box(str(err))
def validatePage(self) -> bool:
# selected sheet - get the columns headings of the selected sheet
try:
self.excelService.set_column_headings(self.excel_sheet_select.currentText())
self.shared_data.item_file_sheet = self.excel_sheet_select.currentText()
except ExcelFileException as err:
self._show_critical_message_box(str(err))
return False
return super().validatePage()
#######################################################################################################################
class MappingPage(DSpaceWizardPages):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations, shared_data: ImporterData) -> None:
super().__init__(config, lang_i18n)
self.shared_data = shared_data
self.setTitle(_("mapping_page_title"))
self.setSubTitle(_("mapping_page_subtitle"))
def initializePage(self) -> None:
excelFileService = ExcelFileService()
# table layout for the mapping
layout = QGridLayout()
instruction_label = QLabel()
instruction_label.setText(_("mapping_page_instructions"))
layout.addWidget(instruction_label, 0, 0, 1, 2)
column_label = QLabel()
column_label.setText(_("mapping_page_column_heading"))
metadata_label = QLabel()
metadata_label.setText(_("mapping_page_metadata_heading"))
layout.addWidget(column_label, 1, 0)
layout.addWidget(metadata_label, 1, 1)
# display the columns
self.col_list = {}
index = 2
column_headings = excelFileService.get_column_headings()
for col in column_headings:
self.col_list[col] = {}
self.col_list[col]["col_label"] = QLabel()
self.col_list[col]["col_label"].setText(col)
self.col_list[col]["schema"] = SchemaFieldSelect(self.shared_data)
layout.addWidget(self.col_list[col]["col_label"], index, 0)
layout.addWidget(self.col_list[col]["schema"], index, 1)
index = index + 1
# specify title column,
title_label = QLabel()
title_label.setText(_("mapping_page_title_column_label"))
self.title_select = QComboBox()
self.title_select.insertItem(0, "")
self.title_select.insertItems(1, column_headings)
layout.addWidget(title_label, index, 0)
layout.addWidget(self.title_select, index, 1)
index = index + 1
# column with the item uuid (optional)
item_uuid_label = QLabel()
item_uuid_label.setText(_("mapping_page_item_uuid_column_label"))
self.item_uuid_select = QComboBox()
self.item_uuid_select.insertItem(0, "")
self.item_uuid_select.insertItems(1, column_headings)
layout.addWidget(item_uuid_label, index, 0)
layout.addWidget(self.item_uuid_select, index, 1)
index = index + 1
# column with primary bitstream file name (optional)
primary_bitstream_label = QLabel()
primary_bitstream_label.setText(_("mapping_page_primary_bitstream_label"))
self.primary_bitstream_select = QComboBox()
self.primary_bitstream_select.insertItem(0, "")
self.primary_bitstream_select.insertItems(1, column_headings)
layout.addWidget(primary_bitstream_label, index, 0)
layout.addWidget(self.primary_bitstream_select, index, 1)
index = index + 1
# if to update existing
update_existing_label = QLabel()
update_existing_label.setText(_("mapping_page_update_existing_label"))
self.update_existing = RadioButton(self._no_yes_options())
layout.addWidget(update_existing_label, index, 0)
layout.addWidget(self.update_existing, index, 1)
index = index + 1
# if to update the item's metadata to match the metadata in the excel file
metadata_to_match_label = QLabel()
metadata_to_match_label.setText(_("mapping_page_existing_metadata_to_match_label"))
self.metadata_to_match = RadioButton(self._no_yes_options())
layout.addWidget(metadata_to_match_label, index, 0)
layout.addWidget(self.metadata_to_match, index, 1)
index = index + 1
# if to remove metadata in dspace not in excel file
remove_extra_existing_label = QLabel()
remove_extra_existing_label.setText(_("mapping_page_remove_extra_existing_metadata_label"))
self.remove_extra_metadata = RadioButton(self._no_yes_options())
layout.addWidget(remove_extra_existing_label, index, 0)
layout.addWidget(self.remove_extra_metadata, index, 1)
# widget to hold the controls
container = QWidget()
container.setLayout(layout)
container.resize(self._config.window_width(), self._config.window_height())
# scroll area and add container widget
scroll = QScrollArea(self)
scroll.setWidget(container)
scroll.setWidgetResizable(True)
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.resize(self._scroll_area_width(), self._scroll_area_height())
scroll.update()
# register title_label to make it required
self.registerField("titleField*", self.title_select)
def validatePage(self) -> bool:
# validate page, at least one column is mapped to a metadata field
self.mapping = {}
for row in self.col_list:
#print(self.col_list[row]["schema"].selected_schema_field())
if len(self.col_list[row]["schema"].selected_schema_field()) > 0:
if not self.col_list[row]["schema"].selected_schema_field() in self.mapping:
self.mapping[self.col_list[row]["schema"].selected_schema_field()] = []
self.mapping[self.col_list[row]["schema"].selected_schema_field()].append(row) # mapping[metadata_field] = list of columns
if len(self.mapping) == 0:
self._show_critical_message_box(_("mapping_page_column_schema_mapping_required"))
return False
# title is required
if self.title_select.currentIndex() == 0:
self._show_critical_message_box(_("mapping_page_title_column_required"))
return False
# if update existing is YES, item uuid column has to be chosen
if self.update_existing.selected_option()[0] == YesNo.YES:
if self.item_uuid_select.currentIndex() == 0:
self._show_critical_message_box(_("mapping_page_item_uuid_column_required"))
return False
# save selections
print(f"selected collection = {self.shared_data.selected_collection.name}")
self.shared_data.column_mapping = self.mapping
self.shared_data.title_column = self.title_select.currentText()
self.shared_data.item_uuid_column = self.item_uuid_select.currentText()
self.shared_data.update_existing = self.update_existing.selected_option()[0]
self.shared_data.primary_bitstream_column = self.primary_bitstream_select.currentText()
self.shared_data.remove_extra_metadata = self.remove_extra_metadata.selected_option()[0]
self.shared_data.metadata_to_match = self.metadata_to_match.selected_option()[0]
return super().validatePage()
#######################################################################################################################
class FilePage(DSpaceWizardPages):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations, shared_data: ImporterData) -> None:
super().__init__(config, lang_i18n)
self.shared_data = shared_data
self.setTitle(_("file_page_title"))
self.setSubTitle(_("file_page_subtitle"))
def initializePage(self) -> None:
excelFileService = ExcelFileService()
# instruction label
instruction_label = QLabel()
instruction_label.setText(_("file_page_instructions"))
instruction_label.setWordWrap(True)
# directory
self.file_dir = FileBrowser(FileBrowseType.DIR, _("file_page_item_dir_label"), "", _("file_page_item_dir_select_button"))
self.file_dir.fileSelected.connect(self.dir_selected)
# file name columns
file_name_column_label = QLabel()
file_name_column_label.setText(_("file_page_file_name_column_label"))
self.file_name_column = QComboBox()
self.file_name_column.insertItems(0, excelFileService.get_column_headings())
# match file name
match_file_name_label = QLabel()
match_file_name_label.setText(_("file_page_match_file_name_label"))
self.match_file_name = RadioButton(self._file_match_options())
# extension for files
file_name_extension_label = QLabel()
file_name_extension_label.setText(_("file_page_file_name_extension_label"))
self.file_name_extension = QLineEdit()
# remove existing files for duplicate
remove_existing_files_label = QLabel()
remove_existing_files_label.setText(_("file_page_remove_existing_for_duplicate"))
self.remove_existing_files = RadioButton(self._no_yes_options())
layout = QGridLayout()
layout.addWidget(instruction_label, 0, 0, 1, 2)
layout.addWidget(self.file_dir, 1, 0, 1, 2)
layout.addWidget(file_name_column_label, 2, 0)
layout.addWidget(self.file_name_column, 2, 1)
layout.addWidget(match_file_name_label, 3, 0)
layout.addWidget(self.match_file_name, 3, 1)
layout.addWidget(file_name_extension_label, 4, 0)
layout.addWidget(self.file_name_extension, 4, 1)
layout.addWidget(remove_existing_files_label, 5, 0)
layout.addWidget(self.remove_existing_files, 5, 1)
layout.setRowStretch(6, 1)
# container for the controls
container = QWidget()
container.setLayout(layout)
container.resize(self._config.window_width(), self._config.window_height())
# scroll area and add container widget
scroll = QScrollArea(self)
scroll.setWidget(container)
scroll.setWidgetResizable(True)
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
scroll.resize(self._scroll_area_width(), self._scroll_area_height())
scroll.update()
#self.setLayout(layout)
# any required fields to register?
def dir_selected(self, path):
self.shared_data.item_directory = path
def validatePage(self) -> bool:
# if match_file_name is begins with, file name extension is required
if self.match_file_name.selected_option()[0] == ItemFileMatchType.BEGINS and len(self.file_name_extension.text().strip()) == 0:
self._show_critical_message_box(f"The field {_('file_page_file_name_extension_label')} is required")
return False
# save values
self.shared_data.file_name_column = self.file_name_column.currentText()
self.shared_data.file_name_matching = self.match_file_name.selected_option()[0]
self.shared_data.file_extension = self.file_name_extension.text().strip()
self.shared_data.remove_existing_files = self.remove_existing_files.selected_option()[0]
return True
#######################################################################################################################
class SummaryPage(DSpaceWizardPages):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations, auth_data: AuthData, shared_data: ImporterData) -> None:
super().__init__(config, lang_i18n)
self.shared_data = shared_data
self.excel_service = ExcelFileService()
self.item_file_service = ItemFileService()
self.item_service = ItemService(config, auth_data)
self.show_summary = False
self.setTitle(_("summary_page_title"))
# change name of next button to import
self.setButtonText(QWizard.NextButton, "Import")
self.summary = QPlainTextEdit()
self.summary.setReadOnly(True)
layout = QGridLayout()
layout.addWidget(self.summary)
self.setLayout(layout)
self.setCommitPage(True)
def initializePage(self) -> None:
# check the item files to ensure all exists
summary_data = []
for row_index, file_name, item_uuid, item_title in self.excel_service.file_itemuuiud_title(self.shared_data.file_name_column, self.shared_data.item_uuid_column, self.shared_data.title_column):
#print(f"checking file {file_name} for title {item_title}")
if file_name is not None and len(self.shared_data.item_directory) > 0 and not self.item_file_service.item_file_exists(file_name, self.shared_data.file_name_matching, self.shared_data.file_extension, self.shared_data.item_directory):
summary_data.append(f"File not found for row {row_index}, (title {item_title})")
try:
if item_uuid is not None and not Utils.valid_uuid(item_uuid):
summary_data.append(f"Item UUID for row {row_index} (title {item_title}) is not a valid format")
elif item_uuid is not None and self.item_service.owning_collection(item_uuid) != self.shared_data.selected_collection.uuid:
summary_data.append(f"Item UUID for row {row_index} (title {item_title}) is not in collection {self.shared_data.selected_collection.name}")
except ItemException as err:
summary_data.append(f"Item UUID for row {row_index} (title {item_title}) error getting owning collection {err}")
if len(summary_data) == 0:
# can import, show summary values
self.show_summary = True
summary_data.append(_("summary_page_import_into_collection")+" "+self.shared_data.selected_collection.name)
summary_data.append(_("summary_page_using_file")+" "+self.shared_data.item_file+", "+_("summary_page_file_sheet")+" "+self.shared_data.item_file_sheet)
summary_data.append(_("summary_page_title_column")+" "+self.shared_data.title_column)
summary_data.append(_("summary_page_item_uuid_column")+" "+self.shared_data.item_uuid_column)
summary_data.append(_("summary_page_update_existing")+" "+(_("Yes") if self.shared_data.update_existing else _("No")))
summary_data.append(_("summary_page_metadata_to_match")+" "+(_("Yes") if self.shared_data.metadata_to_match else _("No")))
summary_data.append(_("summary_page_remove_extra_metadata")+" "+(_("Yes") if self.shared_data.remove_extra_metadata else _("No")))
summary_data.append(_("summary_page_item_directory")+" "+self.shared_data.item_directory)
self.summary.setPlainText("\n".join(summary_data))
def isComplete(self) -> bool:
return self.show_summary
#######################################################################################################################
class ImportResultsPage(DSpaceWizardPages):
def __init__(self, config: ImporterConfig, lang_i18n: GNUTranslations, auth_data: AuthData, shared_data: ImporterData) -> None:
super().__init__(config, lang_i18n)
self.shared_data = shared_data
self.auth_data = auth_data
self.processing_completed = False
self.setTitle(_("import_results_page_title"))
self.results = QPlainTextEdit()
layout = QGridLayout()
layout.addWidget(self.results)
self.setLayout(layout)
def initializePage(self) -> None:
self.worker_thread = QThread()
self.worker = ImportWorker(self.shared_data, self._config, self.auth_data)
self.worker.moveToThread(self.worker_thread)
# connect signals and slots
self.worker_thread.started.connect(self.worker.run)
self.worker.finished.connect(self.worker_thread.quit)
self.worker.finished.connect(self.worker.deleteLater)
self.worker_thread.finished.connect(self.worker_thread.deleteLater)
self.worker.progress.connect(self.report_progress)
self.worker_thread.finished.connect(self.set_completed)
self.worker.finished.connect(self.set_completed)
self.worker_thread.start()
def report_progress(self, str):
self.results.appendPlainText(str + "\n")
def set_completed(self):
self.processing_completed = True
self.completeChanged.emit()
def isComplete(self) -> bool:
return self.processing_completed