Skip to content

Commit 33a4ace

Browse files
author
Niklaus Johner
committed
Patch Task syncing to avoid predecessor resolution issue.
We skip syncing the predecessor as this uses IntIds to resolve it, which fails in the HBA migration as IntIds rely on path and also get updated in an event handler. It is fine to not update the predecessor as it anyway does not change during a move operation.
1 parent cbd3aa7 commit 33a4ace

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

opengever/maintenance/scripts/repository_migration.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,66 @@ def __iter__(self):
121121
self.patch_refs(ReportSection, '__iter__', __iter__)
122122

123123

124+
class PatchTaskSyncWith(MonkeyPatch):
125+
""" We skip syncing the predecessor as this uses IntIds to resolve it,
126+
which fails in the HBA migration as IntIds rely on path and also get
127+
updated in an event handler. It is fine to not update the predecessor
128+
as it anyway does not change during a move operation.
129+
"""
130+
131+
def __call__(self):
132+
from opengever.globalindex.model.task import Task
133+
134+
def sync_with(self, plone_task):
135+
"""Sync this task instace with its corresponding plone taks."""
136+
self.title = plone_task.safe_title
137+
self.text = plone_task.text
138+
139+
self.breadcrumb_title = plone_task.get_breadcrumb_title(
140+
self.MAX_BREADCRUMB_LENGTH,
141+
)
142+
143+
self.physical_path = plone_task.get_physical_path()
144+
self.review_state = plone_task.get_review_state()
145+
self.icon = plone_task.getIcon()
146+
self.responsible = plone_task.responsible
147+
self.is_private = plone_task.is_private
148+
self.issuer = plone_task.issuer
149+
self.deadline = plone_task.deadline
150+
self.completed = plone_task.date_of_completion
151+
152+
# we need to have python datetime objects for make it work with sqlite
153+
self.modified = plone_task.modified().asdatetime().replace(tzinfo=None)
154+
self.task_type = plone_task.task_type
155+
self.is_subtask = plone_task.get_is_subtask()
156+
self.sequence_number = plone_task.get_sequence_number()
157+
self.reference_number = plone_task.get_reference_number()
158+
159+
self.containing_dossier = safe_unicode(
160+
plone_task.get_containing_dossier_title(),
161+
)
162+
163+
self.dossier_sequence_number = plone_task.get_dossier_sequence_number()
164+
self.assigned_org_unit = plone_task.responsible_client
165+
self.principals = plone_task.get_principals()
166+
167+
self.predecessor = self.query_predecessor(
168+
*plone_task.get_predecessor_ids()
169+
)
170+
171+
self.containing_subdossier = safe_unicode(
172+
plone_task.get_containing_subdossier(),
173+
)
174+
175+
# predecessor = plone_task.get_tasktemplate_predecessor()
176+
# if predecessor:
177+
# self.tasktemplate_predecessor = predecessor.get_sql_object()
178+
179+
self.sync_reminders(plone_task)
180+
181+
self.patch_refs(Task, 'sync_with', sync_with)
182+
183+
124184
class RepositoryPosition(object):
125185

126186
def __init__(self, position=None, title=None, description=None):
@@ -1018,6 +1078,7 @@ def main():
10181078
PatchCommitSection()()
10191079
PatchReindexContainersSection()()
10201080
PatchReportSection()()
1081+
PatchTaskSyncWith()()
10211082

10221083
logger.info('starting analysis')
10231084
analyser = RepositoryExcelAnalyser(mapping_path, options.output)

0 commit comments

Comments
 (0)