Commit cd193001 authored by Aurel's avatar Aurel

remove synchronization state from workflow

parent 0ac3057e
......@@ -37,6 +37,7 @@ from Products.ERP5Type import PropertySheet
from Products.ERP5SyncML.Utils import PdataHelper
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
_MARKER = []
class SyncMLSignature(XMLObject):
......@@ -65,6 +66,32 @@ class SyncMLSignature(XMLObject):
, PropertySheet.Document
, PropertySheet.SyncMLSignature )
security.declareProtected(Permissions.ModifyPortalContent, 'synchronize')
def synchronize(self):
"""
This is call when subscription get confirmation of the data synchronization
This copy & reset some properties if needed
"""
edit_kw = {}
temporary_data = self.getTemporaryData()
if temporary_data is not None:
# This happens when we have sent the xml
# and we just get the confirmation
self.setData(temporary_data)
edit_kw["temporary_data"] = None
if self.isForce():
edit_kw["force"] = False
if self.hasPartialData():
edit_kw["partial_data"] = None
if self.hasSubscriberXupdate():
edit_kw["subscriber_xupdate"] = None
if self.hasPublisherXupdate():
edit_kw["publisher_xupdate"] = None
if len(edit_kw):
self.edit(**edit_kw)
security.declareProtected(Permissions.ModifyPortalContent, 'setData')
def setData(self, value):
"""
......@@ -248,24 +275,6 @@ class SyncMLSignature(XMLObject):
else:
return self._baseGetPublisherXupdate(default)
security.declareProtected(Permissions.ModifyPortalContent,
'reset')
def reset(self, no_conflict=False):
"""
Clear Signature and change validation_state to not_synchronized
no_conflict : prevent the reset of signature for which conflict
has not been marked resolved, this is usefull when
resetting all signature at the beginning of a sync process
XXX Use a better name and a positive value by default
"""
if no_conflict and self.getValidationState() in (
'conflict',
'conflict_resolved_with_merge',
'conflict_resolved_with_client_command_winning'):
return
if self.getValidationState() != 'not_synchronized':
self.drift()
security.declareProtected(Permissions.ModifyPortalContent,
'getConflictList')
def getConflictList(self):
......@@ -274,22 +283,6 @@ class SyncMLSignature(XMLObject):
"""
return self.contentValues()
security.declareProtected(Permissions.ModifyPortalContent,
'setConflictList')
def setConflictList(self, conflict_list):
"""
XXX is it still usefull ?
"""
return
security.declareProtected(Permissions.ModifyPortalContent,
'resetConflictList')
def resetConflictList(self):
"""
XXX is it still usefull ?
"""
return
security.declareProtected(Permissions.ModifyPortalContent,
'delConflict')
def delConflict(self, conflict):
......
......@@ -115,7 +115,7 @@ class EngineMixin(object):
'conflict_resolved_with_merge'):
# We will have to apply the update, and we should not care
# about conflicts, so we have to force the update
signature.drift()
signature.noConflict()
signature.setForce(True)
syncml_logger.error("\tObject merged %s" %
(status['source'] or status['target']))
......@@ -125,6 +125,8 @@ class EngineMixin(object):
'conflict_resolved_with_client_command_winning')):
syncml_logger.error("\tObject synchronized %s" %
(status['source'] or status['target'],))
if signature.getValidationState() != "no_conflict":
signature.noConflict()
signature.synchronize()
elif status['status_code'] == resolveSyncmlStatusCode('chunk_accepted'):
syncml_logger.info("Chunk was accepted for %s" % (object_gid,))
......
......@@ -318,12 +318,12 @@ class TestERP5DocumentSyncMLMixin(TestERP5SyncMLMixin):
for document in document_server.objectValues():
state_list = self.getSynchronizationState(document)
for state in state_list:
self.assertEqual(state[1], 'synchronized')
self.assertEqual(state[1], 'no_conflict')
document_client1 = self.getDocumentClient1()
for document in document_client1.objectValues():
state_list = self.getSynchronizationState(document)
for state in state_list:
self.assertEqual(state[1], 'synchronized')
self.assertEqual(state[1], 'no_conflict')
# Check for each signature that the tempXML is None
for sub in portal_sync.contentValues(portal_type='SyncML Subscription'):
for m in sub.contentValues():
......@@ -420,13 +420,7 @@ class TestERP5DocumentSyncML(TestERP5DocumentSyncMLMixin):
def getTitle(self):
return "ERP5 Document SyncML"
def setupPublicationAndSubscriptionIdGenerator(self):
portal_sync = self.getSynchronizationTool()
sub1 = portal_sync[self.sub_id1]
pub = portal_sync[self.pub_id]
def checkSynchronizationStateIsConflict(self, portal_type='Text'):
portal_sync = self.getSynchronizationTool()
document_server = self.getDocumentServer()
for document in document_server.objectValues():
if document.getId()==self.id1:
......@@ -643,7 +637,6 @@ class TestERP5DocumentSyncML(TestERP5DocumentSyncMLMixin):
recognize objects (because by default, getGid==getId. Here, we will see
if it also works with a somewhat strange getGid
"""
self.setupPublicationAndSubscriptionIdGenerator()
nb_document = self.createDocumentServerList()
# This will test adding object
self.synchronize(self.sub_id1)
......
......@@ -332,33 +332,33 @@ class TestERP5SyncMLMixin(TestMixin):
for person in person_server.objectValues():
state_list = self.getSynchronizationState(person)
for state in state_list:
self.assertEquals(state[1], 'synchronized')
self.assertEquals(state[1], 'no_conflict')
person_client1 = self.getPersonClient1()
for person in person_client1.objectValues():
state_list = self.getSynchronizationState(person)
for state in state_list:
self.assertEquals(state[1], 'synchronized')
self.assertEquals(state[1], 'no_conflict')
person_client2 = self.getPersonClient2()
for person in person_client2.objectValues():
state_list = self.getSynchronizationState(person)
for state in state_list:
self.assertEquals(state[1], 'synchronized')
self.assertEquals(state[1], 'no_conflict')
# Check for each signature that the tempXML is None
for sub in portal_sync.contentValues(portal_type='SyncML Subscription'):
for m in sub.contentValues():
self.assertEquals(m.getTemporaryData(), None)
self.assertEquals(m.getPartialData(), None)
self.assertEquals(m.getValidationState(), "synchronized")
self.assertEquals(m.getValidationState(), "no_conflict")
for pub in portal_sync.contentValues(portal_type='SyncML Publication'):
for sub in pub.contentValues(portal_type='SyncML Subscription'):
for m in sub.contentValues():
self.assertEquals(m.getPartialData(), None)
self.assertEquals(m.getValidationState(), "synchronized")
self.assertEquals(m.getValidationState(), "no_conflict")
def verifyFirstNameAndLastNameAreNotSynchronized(self, first_name,
last_name, person_server, person_client):
"""
verify that the first and last name are NOT synchronized
verify that the first and last name are NOT no_conflict
"""
self.assertNotEqual(person_server.getFirstName(), first_name)
self.assertNotEqual(person_server.getLastName(), last_name)
......@@ -484,7 +484,6 @@ class TestERP5SyncML(TestERP5SyncMLMixin):
pub.setConduitModuleId('ERP5ConduitTitleGid')
def checkSynchronizationStateIsConflict(self):
portal_sync = self.getSynchronizationTool()
person_server = self.getPersonServer()
for person in person_server.objectValues():
if person.getId()==self.id1:
......@@ -754,7 +753,6 @@ return [context[%r]]
# We will try to get the state of objects
# that are just synchronized
self.test_08_FirstSynchronization()
portal_sync = self.getSynchronizationTool()
person_server = self.getPersonServer()
person1_s = person_server._getOb(self.id1)
state_list_s = self.getSynchronizationState(person1_s)
......@@ -785,6 +783,8 @@ return [context[%r]]
kw = {'first_name':self.first_name1,'last_name':self.last_name1}
person1_c.edit(**kw)
#person1_c.setModificationDate(DateTime()+1)
# import ipdb
# ipdb.set_trace()
self.synchronize(self.sub_id1)
self.checkSynchronizationStateIsSynchronized()
person1_s = person_server._getOb(self.id1)
......@@ -951,8 +951,6 @@ return [context[%r]]
person_server.manage_delObjects(self.id1)
person_client1 = self.getPersonClient1()
person_client1.manage_delObjects(self.id2)
# import ipdb
# ipdb.set_trace()
self.synchronize(self.sub_id1)
self.synchronize(self.sub_id2)
self.checkSynchronizationStateIsSynchronized()
......@@ -1601,7 +1599,7 @@ return [context[%r]]
publication = self.addPublication()
self.addRefreshFormClientOnlySubscription()
nb_person = self.populatePersonClient1()
self.populatePersonClient1()
portal_sync = self.getSynchronizationTool()
subscription1 = portal_sync[self.sub_id1]
self.assertEquals(subscription1.getSyncmlAlertCode(),
......
......@@ -28,9 +28,7 @@
#
##############################################################################
from testERP5SyncML import TestERP5SyncMLMixin
from zLOG import LOG
class TestERP5SyncMLVCard(TestERP5SyncMLMixin):
......
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