Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
4600dd9f
Commit
4600dd9f
authored
Dec 11, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add function for creating snapshot
parent
71da67c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
17 deletions
+55
-17
product/ERP5/Document/BusinessCommit.py
product/ERP5/Document/BusinessCommit.py
+24
-8
product/ERP5/Document/BusinessSnapshot.py
product/ERP5/Document/BusinessSnapshot.py
+31
-9
No files found.
product/ERP5/Document/BusinessCommit.py
View file @
4600dd9f
...
...
@@ -120,17 +120,14 @@ class BusinessCommit(Folder):
return
super
(
BusinessCommit
,
self
).
newContent
(
id
,
**
kw
)
def
install
(
self
):
def
createEquivalentSnapshot
(
self
):
"""
Installation:
- create an empty snapshot that that's similar to a Commit
- fill it with hard links to commits and snapshots
- install it
This function uses the current commit to create a new snapshot
"""
portal_commit
=
self
.
aq_parent
# Create empty snapshot
snapshot
=
portal_commit
.
newContent
(
portal_type
=
'Business
Commi
t'
)
snapshot
=
portal_commit
.
newContent
(
portal_type
=
'Business
Snapsho
t'
)
# Add the current commit as predecessor. This way we can have the BI
# BPI in that commit to the Business Snapshot also.
snapshot
.
setPredecessorValue
(
self
)
...
...
@@ -138,8 +135,27 @@ class BusinessCommit(Folder):
# Build the snapshot
snapshot
.
buildSnapshot
()
for
item
in
snapshot
.
item_list
:
return
snapshot
def
install
(
self
):
"""
Installation:
- check if there is already an equivalent snapshot
- if not, create one and install it
"""
successor_list
=
self
.
getPredecessorRelatedValueList
()
# Check if the successor list has a snapshot in it
try
:
eqv_snapshot
=
[
l
for
l
in
successor_list
if
l
.
getPortalType
()
==
'Business Snapshot'
][
0
]
except
IndexError
:
# Create a new equivalent snapshot
eqv_snapshot
=
self
.
createEquivalentSnapshot
()
for
item
in
eqv_snapshot
.
item_list
:
item
.
install
(
self
)
def
getPathList
(
self
):
def
get
Item
PathList
(
self
):
return
[
l
.
getProperty
(
'item_path'
)
for
l
in
self
.
objectValues
()]
product/ERP5/Document/BusinessSnapshot.py
View file @
4600dd9f
...
...
@@ -174,18 +174,40 @@ class BusinessSnapshot(Folder):
# Get last created snapshot
last_snapshot
=
self
.
getLastSnapshot
()
# [1]: Extend the item_list with list of items from last snapshot
new_item_list
.
extend
(
last_snapshot
.
getItemList
())
new_item_path_list
.
extend
(
last_snapshot
.
getItemPathList
())
# Commit list of all commits between the last snapshot/first commit and the
# current snapshot
successor_commit_list
=
[]
# Get next predecessor commit for this snapshot using the equivalent commit
# Notice that we don't use the snapshot to get the next commit as the
# snapshot is mere a state which uses `predecessor` just for mentioning the
# equivalent commit.
next_commit
=
eqv_commit
.
getPredecessorRelatedValue
()
# If there is last snapshot, then combine all the commit afterwards to create
# new snapshot
if
last_snapshot
:
# [1]: Extend the item_list with list of items from last snapshot
new_item_list
.
extend
(
last_snapshot
.
getItemList
())
new_item_path_list
.
extend
(
last_snapshot
.
getItemPathList
())
# Get next predecessor commit for this snapshot using the equivalent commit
# Notice that we don't use the snapshot to get the next commit as the
# snapshot is mere a state which uses `predecessor` just for mentioning the
# equivalent commit.
# Here the first next commit should be the commit created after last snapshot
# which we can get using the equivalent commit of last snapshot and then
# finding the next commit for it
next_commit
=
last_snapshot
.
getPredecessorValue
().
getPredecessorRelatedValue
()
# If there is no last snapshot, create a new one by combining all the commits
else
:
# Get the oldest commit and start from there to find the next commit
oldest_commit
=
min
(
self
.
aq_parent
.
objectValues
(
portal_type
=
'Business Commit'
),
key
=
(
lambda
x
:
x
.
getCreationDate
()))
new_item_list
.
extend
(
oldest_commit
.
objectValues
())
new_item_path_list
.
extend
(
oldest_commit
.
getItemPathList
())
next_commit
=
oldest_commit
.
getPredecessorRelatedValue
()
# Fill sucessor commit list
while
(
next_commit
.
getId
()
!=
eqv_commit
.
getId
()):
successor_commit_list
.
append
(
next_commit
)
next_commit
=
next_commit
.
getPredecessorRelatedValue
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment