Commit dce6323f authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Upon migration, Workflow History of ZODB Components must be kept.

Also, upon installation of bt5s, install WorkflowItem before Components as it
is needed to restore history.

Another solution would have been to validate() ZODB Components automatically
upon bt5 installation but it would mean losing 'modified' state information
and also imply that *all of them* will be validated even if a developer wants
to publish non-validated ZODB Components.
parent 34ff8432
......@@ -4808,6 +4808,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
# ( and more )
_item_name_list = [
'_registered_version_priority_selection_item',
'_workflow_item',
'_product_item',
'_document_item',
'_property_sheet_item',
......@@ -4817,7 +4818,6 @@ Business Template is a set of definitions, such as skins, portal types and categ
'_role_item',
'_tool_item',
'_message_translation_item',
'_workflow_item',
'_site_property_item',
'_portal_type_item',
#'_portal_type_workflow_chain_item',
......@@ -6084,6 +6084,11 @@ Business Template is a set of definitions, such as skins, portal types and categ
if migrated_id_list:
template_id_list_method(migrated_id_list)
path_list = self.getTemplateKeepWorkflowPathList()
path_list.extend([ ('portal_components/' + id_)
for id_ in migrated_id_list ])
self.setTemplateKeepWorkflowPathList(path_list)
component_dict = component_portal_type_dict.get('Document Component')
if component_dict:
......
......@@ -7215,29 +7215,37 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
def stepCreateZodbDocument(self, sequence=None, **kw):
document_id = self.component_module + '.erp5.' + self.document_title
self.getPortalObject().portal_components.newContent(
component = self.portal.portal_components.newContent(
id=document_id,
version='erp5',
reference=self.document_title,
text_content=self.document_data,
portal_type=self.component_portal_type)
component.validate()
sequence.edit(document_title=self.document_title,
document_id=document_id,
document_data=self.document_data)
def stepAddZodbDocumentToBusinessTemplate(self, sequence=None, **kw):
getattr(sequence['current_bt'], self.set_template_id_method_name)(
sequence['document_id'])
sequence['current_bt'].setProperty(self.template_property,
sequence['document_id'])
sequence['current_bt'].setTemplateKeepWorkflowPathList(
'portal_components/' + sequence['document_id'])
def stepRemoveZodbDocument(self, sequence=None, **kw):
self.getPortalObject().portal_components.deleteContent(
sequence['document_id'])
def stepCheckZodbDocumentExists(self, sequence=None, **kw):
def stepCheckZodbDocumentExistsAndValidated(self, sequence=None, **kw):
self.assertHasAttribute(self.getPortalObject().portal_components,
sequence['document_id'])
self.assertEquals(getattr(self.getPortalObject().portal_components,
sequence['document_id']).getValidationState(),
'validated')
def stepCheckZodbDocumentRemoved(self, sequence=None, **kw):
component_tool = self.getPortalObject().portal_components
self.failIf(sequence['document_id'] in component_tool.objectIds())
......@@ -7305,7 +7313,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
CheckBuiltBuildingState \
CheckNoTrashBin \
CheckSkinsLayers \
CheckZodbDocumentExists \
CheckZodbDocumentExistsAndValidated \
UninstallBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
......@@ -7370,7 +7378,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
CheckBuiltBuildingState \
CheckNoTrashBin \
CheckSkinsLayers \
CheckZodbDocumentExists \
CheckZodbDocumentExistsAndValidated \
UninstallBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
......@@ -7379,8 +7387,6 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
set_template_id_method_name = 'setTemplateDocumentId'
def stepCopyAndMigrateDocumentBusinessTemplate(self, sequence=None, **kw):
"""
Simulate migration from filesystem to ZODB
......@@ -7393,30 +7399,26 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
cb_data = template_tool.manage_copyObjects([current_bt.getId()])
copied, = template_tool.manage_pasteObjects(cb_data)
copied_bt = template_tool._getOb(copied['new_id'])
getattr(copied_bt, self.set_template_id_method_name)(sequence['document_id'])
self.commit()
sequence.edit(current_bt=copied_bt)
importFromFilesystem = DocumentComponent.importFromFilesystem
copied_bt.migrateSourceCodeFromFilesystem(
{self.component_portal_type: {sequence['document_title']: 'erp5'}})
def stepImportDocumentFromFilesystem(self, sequence=None, **kw):
sequence.edit(current_bt=copied_bt)
def stepCheckDocumentMigration(self, sequence=None, **kw):
"""
Import a Component from Filesystem to ZODB
Check bt5 migration of Document from the Filesystem to ZODB
"""
component_tool = self.getPortalObject().portal_components
bt = sequence.get('current_bt')
component_id = '%s.erp5.%s' % (self.component_module,
sequence.get('document_title'))
document_object = self.importFromFilesystem(
component_tool,
sequence['document_title'],
'erp5')
self.assertEquals(bt.getTemplateKeepWorkflowPathList(),
['portal_components/' + component_id])
sequence.edit(document_id=document_object.getId())
self.assertEquals(bt.getProperty(self.template_property),
[component_id])
def stepCheckDocumentMigration(self, sequence=None, **kw):
"""
Check migration of Document from the Filesystem to ZODB
"""
component_id = sequence['document_id']
component_tool = self.getPortalObject().portal_components
self.failUnless(component_id in component_tool.objectIds())
......@@ -7424,11 +7426,14 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
self.assertEquals(component.getReference(), sequence['document_title'])
self.assertEquals(component.getTextContent(), sequence['document_data'])
self.assertEquals(component.getPortalType(), self.component_portal_type)
sequence.edit(document_id=component_id)
def test_BusinessTemplateWithZodbDocumentMigrated(self):
"""Checks that if Business Template defines Document and PropertySheet
Document is not removed after Property Sheet was migrated and Business Template
was updated"""
"""
Checks that if Business Template defines filesystem Document, they are
properly migrated to ZODB, can be imported again and the ZODB Document is
properly removed upon uninstall
"""
sequence_list = SequenceList()
sequence_string = '\
CreateDocument \
......@@ -7458,11 +7463,8 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
CheckNoTrashBin \
CheckDocumentExists \
\
ImportDocumentFromFilesystem \
Tic \
CheckDocumentRemoved \
CheckDocumentMigration \
CopyAndMigrateDocumentBusinessTemplate \
CheckDocumentMigration \
Tic \
\
CheckDraftBuildingState \
......@@ -7485,7 +7487,7 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
InstallWithoutForceBusinessTemplate \
Tic \
\
CheckZodbDocumentExists \
CheckZodbDocumentExistsAndValidated \
CheckInstalledInstallationState \
CheckBuiltBuildingState \
\
......@@ -7524,8 +7526,6 @@ class TestExtensionTemplateItem(TestDocumentTemplateItem):
# Specific to ZODB Extension Component
component_module = ExtensionComponent._getDynamicModuleNamespace()
component_portal_type = ExtensionComponent.portal_type
importFromFilesystem = ExtensionComponent.importFromFilesystem
set_template_id_method_name = 'setTemplateExtensionId'
from Products.ERP5Type.Core.TestComponent import TestComponent
......@@ -7545,8 +7545,6 @@ class TestTestTemplateItem(TestDocumentTemplateItem):
# Specific to ZODB Extension Component
component_module = TestComponent._getDynamicModuleNamespace()
component_portal_type = TestComponent.portal_type
importFromFilesystem = TestComponent.importFromFilesystem
set_template_id_method_name = 'setTemplateTestId'
def stepAddTestToBusinessTemplate(self, sequence=None, **kw):
bt = sequence['current_bt']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment