VOL-1387 : Fixed issue introduced with watch mechanism submission

- Added flag to determine when a revision is watched
- Added flag to determine when a revision is stored
- Refactored confusing method names for Set/GetChildren
- Fixed issue with deletion of devices due to previous submission

Change-Id: I68c46951f9d40d47e4e74854bba449c9fec4a427
diff --git a/db/model/node.go b/db/model/node.go
index b8daadd..55b0eb7 100644
--- a/db/model/node.go
+++ b/db/model/node.go
@@ -302,8 +302,8 @@
 	field := names[name]
 
 	if field != nil && field.IsContainer {
-		children := make([]Revision, len(rev.GetChildren()[name]))
-		copy(children, rev.GetChildren()[name])
+		children := make([]Revision, len(rev.GetChildren(name)))
+		copy(children, rev.GetChildren(name))
 
 		if field.Key != "" {
 			if path != "" {
@@ -341,7 +341,7 @@
 		}
 	}
 
-	childRev := rev.GetChildren()[name][0]
+	childRev := rev.GetChildren(name)[0]
 	childNode := childRev.GetNode()
 	return childNode.getPath(childRev, path, depth)
 }
@@ -409,8 +409,8 @@
 			}
 			keyValue := field.KeyFromStr(key)
 
-			children = make([]Revision, len(rev.GetChildren()[name]))
-			copy(children, rev.GetChildren()[name])
+			children = make([]Revision, len(rev.GetChildren(name)))
+			copy(children, rev.GetChildren(name))
 
 			idx, childRev := n.findRevByKey(children, field.Key, keyValue)
 			childNode := childRev.GetNode()
@@ -448,7 +448,7 @@
 			log.Errorf("cannot index into container with no keys")
 		}
 	} else {
-		childRev := rev.GetChildren()[name][0]
+		childRev := rev.GetChildren(name)[0]
 		childNode := childRev.GetNode()
 		newChildRev := childNode.Update(path, data, strict, txid, makeBranch)
 		updatedRev := rev.UpdateChildren(name, []Revision{newChildRev}, branch)
@@ -543,8 +543,8 @@
 					n.GetProxy().InvokeCallbacks(PRE_ADD, false, data)
 				}
 
-				children = make([]Revision, len(rev.GetChildren()[name]))
-				copy(children, rev.GetChildren()[name])
+				children = make([]Revision, len(rev.GetChildren(name)))
+				copy(children, rev.GetChildren(name))
 
 				_, key := GetAttributeValue(data, field.Key, 0)
 
@@ -582,8 +582,8 @@
 			}
 			keyValue := field.KeyFromStr(key)
 
-			children = make([]Revision, len(rev.GetChildren()[name]))
-			copy(children, rev.GetChildren()[name])
+			children = make([]Revision, len(rev.GetChildren(name)))
+			copy(children, rev.GetChildren(name))
 
 			idx, childRev := n.findRevByKey(children, field.Key, keyValue)
 
@@ -592,7 +592,7 @@
 
 			children[idx] = newChildRev
 
-			rev = rev.UpdateChildren(name, branch.GetLatest().GetChildren()[name], branch)
+			rev = rev.UpdateChildren(name, branch.GetLatest().GetChildren(name), branch)
 			rev.Drop(txid, false)
 			n.makeLatest(branch, rev.GetBranch().GetLatest(), nil)
 
@@ -649,14 +649,14 @@
 				path = partition[1]
 			}
 			keyValue := field.KeyFromStr(key)
-			children = make([]Revision, len(rev.GetChildren()[name]))
-			copy(children, rev.GetChildren()[name])
+			children = make([]Revision, len(rev.GetChildren(name)))
+			copy(children, rev.GetChildren(name))
 			if path != "" {
 				idx, childRev := n.findRevByKey(children, field.Key, keyValue)
 				childNode := childRev.GetNode()
 				newChildRev := childNode.Remove(path, txid, makeBranch)
 				children[idx] = newChildRev
-				rev := rev.UpdateChildren(name, children, branch)
+				rev.SetChildren(name, children)
 				branch.GetLatest().Drop(txid, false)
 				n.makeLatest(branch, rev, nil)
 				return rev
@@ -671,7 +671,7 @@
 			}
 			childRev.Drop(txid, true)
 			children = append(children[:idx], children[idx+1:]...)
-			rev := rev.UpdateChildren(name, children, branch)
+			rev.SetChildren(name, children)
 			branch.GetLatest().Drop(txid, false)
 			n.makeLatest(branch, rev, postAnnouncement)
 			return rev
@@ -812,8 +812,8 @@
 			}
 			keyValue := field.KeyFromStr(key)
 			var children []Revision
-			children = make([]Revision, len(rev.GetChildren()[name]))
-			copy(children, rev.GetChildren()[name])
+			children = make([]Revision, len(rev.GetChildren(name)))
+			copy(children, rev.GetChildren(name))
 			if _, childRev := n.findRevByKey(children, field.Key, keyValue); childRev != nil {
 				childNode := childRev.GetNode()
 				return childNode.createProxy(path, fullPath, n, exclusive)
@@ -822,7 +822,7 @@
 			log.Error("cannot index into container with no keys")
 		}
 	} else {
-		childRev := rev.GetChildren()[name][0]
+		childRev := rev.GetChildren(name)[0]
 		childNode := childRev.GetNode()
 		return childNode.createProxy(path, fullPath, n, exclusive)
 	}