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
721c8023
Commit
721c8023
authored
Dec 08, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Install Business Commit
parent
3a09348f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
3 deletions
+114
-3
product/ERP5/Document/BusinessCommit.py
product/ERP5/Document/BusinessCommit.py
+24
-0
product/ERP5/Document/BusinessSnapshot.py
product/ERP5/Document/BusinessSnapshot.py
+90
-3
No files found.
product/ERP5/Document/BusinessCommit.py
View file @
721c8023
...
...
@@ -119,3 +119,27 @@ class BusinessCommit(Folder):
id
=
uuid
.
uuid1
()
return
super
(
BusinessCommit
,
self
).
newContent
(
id
,
**
kw
)
def
install
(
self
):
"""
Installation:
- create an empty snapshot that that's similar to a Commit
- fill it with hard links to commits and snapshots
- install it
"""
portal_commit
=
self
.
aq_parent
# Create empty snapshot
snapshot
=
portal_commit
.
newContent
(
portal_type
=
'Business Commit'
)
# 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
)
# Build the snapshot
snapshot
.
buildSnapshot
()
for
item
in
snapshot
.
item_path_list
:
item
.
install
(
self
)
def
getPathList
(
self
):
return
[
l
.
getProperty
(
'item_path'
)
for
l
in
self
.
objectValues
()]
product/ERP5/Document/BusinessSnapshot.py
View file @
721c8023
...
...
@@ -114,9 +114,96 @@ class BusinessSnapshot(Folder):
PropertySheet
.
Version
,
)
def
getEquivalentBusinessCommit
(
self
):
# Attribute to store item list which are basically hardlinks
item_list
=
[]
def
__init__
(
self
,
id
):
"""
While creating a new Business Snapshot, we need to create the hardlinks
and create a snapshot from the commits.
"""
super
(
BusinessSnapshot
,
self
).
__init__
(
id
)
def
install
(
self
):
"""
Returns Business Commit which is the HEAD commit for state of Business
Snapshot.
Installing a snapshot should be similar to installing an installation_state
we used to have for Business Manager(s)
"""
pass
def
getLastSnapshot
(
self
):
portal
=
self
.
getPortalObject
()
commit_tool
=
portal
.
portal_commits
# Get the snapshot list except the current snapshot
snapshot_list
=
[
l
for
l
commit_tool
.
objectValues
(
portal_type
=
'Business Snapshot'
)
if
l
!=
self
]
if
snapshot_list
:
# Get the last created/installed snapshot comparing creation_date
return
max
(
snapshot_list
,
key
=
(
lambda
x
:
x
.
getCreationDate
()))
return
None
def
getItemList
(
self
):
"""
Returns the collection of all Business Item, Business Property Item and
Business Patch item at the given snapshot.
"""
return
self
.
item_list
def
getItemPathList
(
self
):
"""
Returns the path of all Business Item, Business Property Item and
Business Patch item at the given snapshot.
"""
return
[
l
.
getProperty
(
'item_path'
)
for
l
in
self
.
getItemList
()]
def
buildSnapshot
(
self
):
"""
Using equivalent commit, create a snapshot of ZODB state
"""
new_item_list
=
[]
new_item_path_list
=
[]
# Get the equivalent commit for the snapshot
eqv_commit
=
self
.
getPredecessorValue
()
# 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
())
# Get next commit list upto the commit to be installed
portal_commits
=
self
.
aq_parent
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
()
while
(
next_commit
.
getId
()
!=
eqv_commit
.
getId
()):
successor_commit_list
.
append
(
next_commit
)
next_commit
=
next_commit
.
getPredecessorRelatedValue
()
# Append the equivalent commit to successor commits
successor_commit_list
.
append
(
eqv_commit
)
for
commit
in
successor_commit_list
:
for
item
in
commit
.
objectValues
():
item_path
=
item
.
getProperty
(
'item_path'
)
if
item_path
in
new_item_path_list
:
# Replace the old item with same path with new item
new_item_list
=
[
l
if
l
.
getProperty
(
'item_path'
)
!=
item_path
else
item
for
l
in
new_item_list
]
else
:
# Add the item to list if there is no existing item at that path
new_item_list
.
append
(
item
)
new_item_path_list
.
append
(
item_path
)
self
.
item_list
=
new_item_list
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