Commit 1c347688 authored by Ivan Tyagov's avatar Ivan Tyagov

Make it possible to define linked Data Streams using successor and predecessor

categories. This is usually needed for Wendelin applications where for some
reasons data is stored in different Data Streams which must form a logical and sorted "link".
Add test.
parent 3ac50a2c
......@@ -67,4 +67,27 @@ class DataStream(BigFile):
for chunk in data.iterate(start_offset, end_offset - start_offset):
chunk_list.append(chunk)
return chunk_list
\ No newline at end of file
return chunk_list
def getRecursiveSuccessorValueList(self):
"""
Return list of all successors (Data Streams) for a Data Stream.
"""
successor_list = []
successor = self.getSuccessorValue()
while successor is not None:
successor_list.append(successor)
successor = successor.getSuccessorValue()
return successor_list
def getRecursivePredecessorValueList(self):
"""
Return list of all predecessor (Data Streams) for a Data Stream.
"""
predecessor_list = []
predecessor = self.getPredecessorValue()
while predecessor is not None:
predecessor_list.append(predecessor)
predecessor = predecessor.getPredecessorValue()
return predecessor_list
\ No newline at end of file
......@@ -45,9 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 71, 2: Arguments number differs from overridden \'appendData\' method (arguments-differ)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
......@@ -50,6 +50,10 @@
<portal_type id="Data Set Module">
<item>business_application</item>
</portal_type>
<portal_type id="Data Stream">
<item>predecessor</item>
<item>successor</item>
</portal_type>
<portal_type id="Data Stream Module">
<item>business_application</item>
</portal_type>
......
......@@ -281,3 +281,43 @@ class Test(ERP5TypeTestCase):
getattr(self.portal.portal_ingestion_policies, "default_http_json", None))
self.assertNotEqual(None,
getattr(self.portal.data_supply_module, "default_http_json", None))
def test_07_LinkedDataStreamList(self):
"""
Test linked Data Streams
"""
data_stream_1 = self.portal.data_stream_module.newContent(title = "Data Stream 1")
data_stream_2 = self.portal.data_stream_module.newContent(title = "Data Stream 2")
data_stream_3 = self.portal.data_stream_module.newContent(title = "Data Stream 3")
data_stream_4 = self.portal.data_stream_module.newContent(title = "Data Stream 4")
data_stream_5 = self.portal.data_stream_module.newContent(title = "Data Stream 5")
# test nothing linked
self.assertSameSet([], data_stream_2.getRecursiveSuccessorValueList())
self.assertSameSet([], data_stream_2.getRecursivePredecessorValueList())
# set linked data streams (1 <--> 2 <--> 3 <--> 4 <--> 5)
data_stream_1.setSuccessorValue(data_stream_2)
data_stream_2.setSuccessorValue(data_stream_3)
data_stream_3.setSuccessorValue(data_stream_4)
data_stream_4.setSuccessorValue(data_stream_5)
# set predecessor
data_stream_2.setPredecessorValue(data_stream_1)
data_stream_3.setPredecessorValue(data_stream_2)
data_stream_4.setPredecessorValue(data_stream_3)
data_stream_5.setPredecessorValue(data_stream_4)
# test successor
self.assertSameSet(data_stream_2.getRecursiveSuccessorValueList(), \
[data_stream_3, data_stream_4, data_stream_5])
self.assertSameSet(data_stream_5.getRecursiveSuccessorValueList(), \
[])
# test predecessor
self.assertSameSet(data_stream_1.getRecursivePredecessorValueList(), \
[])
self.assertSameSet(data_stream_2.getRecursivePredecessorValueList(), \
[data_stream_1])
self.assertSameSet(data_stream_5.getRecursivePredecessorValueList(), \
[data_stream_4, data_stream_3, data_stream_2, data_stream_1])
\ No newline at end of file
......@@ -18,6 +18,8 @@ Data Product Module | business_application
Data Release Module | business_application
Data Set Module | business_application
Data Stream Module | business_application
Data Stream | predecessor
Data Stream | successor
Data Supply Module | business_application
Data Transformation Module | business_application
Device Configuration Module | business_application
......
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