mariarahat / bungeni-editor

Automatically exported from code.google.com/p/bungeni-editor
2 stars 0 forks source link

Add cross-user accept-merge API to bungeniodfdom #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
the default accept / reject change marking functionality doesnt allow
accept-reject changes of other users or merging of one user's changes into
another.

Add an API that merges one users changes into another.

-- auto merge of valid changes
-- flag exceptions
-- flag unresolvable use cases (e.g. clerk typing over a deletion marking
by user)

Original issue reported on code.google.com by ashok.ha...@gmail.com on 1 Mar 2010 at 3:23

GoogleCodeExporter commented 9 years ago
An "update" change - where a user selects text and overwrites with new test is 
depicted in odf as a 
<text:changed-region> with both <text:deletion> and <text:insertion>

Original comment by ashok.ha...@gmail.com on 5 Mar 2010 at 9:00

GoogleCodeExporter commented 9 years ago
doc 1) the MP submits a document with changes
doc 2) the Clerk edits the document and also changes some of the MP's changes
doc 3) the Clerk changes are accepted
doc 4) the Clerk's accepted changes are merged into MP changes.

docs 3) and 4) form the merger process 
doc 3) was done in OpenOffice while doc 4) was created by editing the OOo 
document.

Original comment by ashok.ha...@gmail.com on 5 Mar 2010 at 1:44

Attachments:

GoogleCodeExporter commented 9 years ago
Use Case #1

1) filter the document for all <changed-region> elements submitted by a clerk.
2) for each each changed-region - find the <change-start> element in the 
document
3) check if the first node() preceding-sibling:: axis of the <change-start> 
element
is a <change-end> element (indicating that the change appears in-between another
change). 
(e.g.
//text:change-start[@text:change-id='ct-1409053704']/preceding-sibling::node()[1
][name()='text:change-end']
)
4) check if the found change-end element corresponds to a change submitted by 
the mp.
5) if 4) is true and (4) is a text:insert change -- merge the node content of 
the
clerk's change into the Mps change. if (4) is not true - then substitue the
dc:creator fo the clerk change with the mp's name.

Original comment by ashok.ha...@gmail.com on 8 Mar 2010 at 6:43

GoogleCodeExporter commented 9 years ago

Original comment by ashok.ha...@gmail.com on 8 Mar 2010 at 6:43

GoogleCodeExporter commented 9 years ago
refactoring change nodes (text:insertion) -- clone the nodes from one change. 
delete  
the nodes that were cloned. insert the cloned nodes before the change-end of 
the 
target node. delete the change-start and change-end of the source nodes ... :  

String xPathExpr = "//change-start[@id='2']";
            Node startNode = (Node)  xpath.evaluate(xPathExpr, wdoc, 
XPathConstants.NODE);
            Node endNode = (Node) xpath.evaluate("//change-end[@id='2']", wdoc, 
XPathConstants.NODE);
            Node nextSibling = startNode.getNextSibling();
            ArrayList<Node> clonedNodes = new ArrayList<Node>(0);
            while (!nextSibling.isSameNode(endNode)) {
                Node clonedNode = nextSibling.cloneNode(true);
                clonedNodes.add(clonedNode);
                System.out.println(nextSibling.getNodeName());
                nextSibling = nextSibling.getNextSibling();
            }

            nextSibling = startNode.getNextSibling();
            while(!nextSibling.isSameNode(endNode)) {
                nextSibling.getParentNode().removeChild(nextSibling);
                nextSibling = startNode.getNextSibling();
            }
            startNode.getParentNode().removeChild(startNode);
            endNode.getParentNode().removeChild(endNode);

            /*
            String xPath2 = "//change-end[@id='1']";
            Node endNode = (Node) xpath.evaluate(xPath2, wdoc, XPathConstants.NODE);
          */
            Node endNodeOne = (Node) xpath.evaluate("//change-end[@id='1']", wdoc, 
XPathConstants.NODE);
            for (Node node : clonedNodes) {
                endNodeOne.getParentNode().insertBefore(node, endNodeOne);
            }

Original comment by ashok.ha...@gmail.com on 8 Mar 2010 at 10:17

GoogleCodeExporter commented 9 years ago
overlapped "insertion" pattern completed.

TODO :

"replacement" and overlapped "deletion"

Original comment by ashok.ha...@gmail.com on 9 Mar 2010 at 9:36

GoogleCodeExporter commented 9 years ago
replacement pattern is one where the reviewer deletes some changes submitted by 
a user.
Replacement pattern is one where the reviewer deletes some changes submitted by 
a user.

The replacement change pattern is a composite pattern of text:deletion &
text:insertion ; the <text:deletion> element holds the original change and a
<text:insertion> with a reference to the user information who submitted the 
original
change.
The merge for the replacement pattern will work like this ... :
1) remove the <text:change > for the change id in the document i.e. remove the
reference to the delete
2) remove the changed region from the document
3) merge any post-adjacent i.e. after the delete <text:insert > with any 
pre-adjacent
<text:insert>

Original comment by ashok.ha...@gmail.com on 9 Mar 2010 at 9:50

GoogleCodeExporter commented 9 years ago
"replacement" pattern merge completed.

TODO :

deletion pattern

Original comment by ashok.ha...@gmail.com on 9 Mar 2010 at 10:40

GoogleCodeExporter commented 9 years ago
"replacement" pattern - failure use case ; we use getNextSibling() to get all 
sibling
nodes between <change-start> and <change-end> this fails when thare are "out of
hierarchy" nodes... e.g. the closing </p> between change-start and 
change-end... 

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <change-start id="1" />this is some text<change-end id="1" /><p><change-start
id="2" />ashok</p> new text<change-end id="2" />
</root>

Original comment by ashok.ha...@gmail.com on 9 Mar 2010 at 1:02

GoogleCodeExporter commented 9 years ago

Original comment by ashok.ha...@gmail.com on 14 Apr 2010 at 8:46