Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Hawk » Tracking deleted model elements(How to track deleted model elements)
Tracking deleted model elements [message #1830455] Mon, 27 July 2020 04:16 Go to next message
Saheed Popoola is currently offline Saheed PopoolaFriend
Messages: 21
Registered: June 2019
Junior Member
Hello
I noticed the remove method is called in two places within the transactionalupdate. The first for all retyped nodes (which means they are eventually deleted), the second was when managing obsolete nodes. I'm not sure if all these nodes to be deleted actually contain ONLY the deleted model elements.
Secondly, is it safe to assume that the nodes in variable "private Map<String, IGraphNode> nodes" with the exception of the nodes of (added,updated, unchanged, and retyped) are actually the nodes of deleted elements.
Thirdly, how do I extract the IHawkObject from IGraphNode.
Re: Tracking deleted model elements [message #1830465 is a reply to message #1830455] Mon, 27 July 2020 09:34 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 597
Registered: January 2010
Location: Birmingham, UK
Senior Member

Retyped nodes are those where the object with a certain identifier (for EMF, this is usually the URI fragment, as in "uriFragment" inside "file:///path/to/resource#uriFragment") has been replaced with another with a different type. This can happen often if your EMF resource is not using UUIDs/IDs to locate objects, but is rather using paths in the containment tree. Hawk will remove the old model element node and add a new model element node. The second time is when managing nodes that have been simply deleted rather than replaced, indeed. All the elements of "nodes" refer to model elements, because the only place where we add them is here:

			// Get existing nodes from the store (and their signatures)
			for (IGraphEdge e : fileNode.getIncomingWithType(ModelElementNode.EDGE_LABEL_FILE)) {
				IGraphNode n = e.getStartNode();
				nodes.put(n.getProperty(IModelIndexer.IDENTIFIER_PROPERTY).toString(), n);

				signatures.put((String) n.getProperty(IModelIndexer.IDENTIFIER_PROPERTY),
						(byte[]) n.getProperty(IModelIndexer.SIGNATURE_PROPERTY));
			}


Only model elements are related to file nodes via the "file" edge.

By the way, for your purposes, you should consider "retyped" as removed as well. If myResource#/0/0/1 had a Widget and I replaced it with a Midget, it still counts as me having deleted the old Widget.

Third, you cannot extract a IHawkObject from an IGraphNode, they are fundamentally different things. An IHawkObject is the in-memory representation of a model element loaded from a model fragment file (in the case of EMF, an EMFObject is a thin wrapper over the EObject). An IGraphNode is an interface over a graph node in the database backend.

If you need to extract information from an IGraphNode, I would suggest using the org.eclipse.hawk.graph.ModelElementNode wrapper over it. It is a read-only wrapper that understands the "effective schema" of the graphs built by Hawk, so you can just do things like this:

IGraphNode gn = /* ... */;
ModelElementNode men = new ModelElementNode(gn);

Map<String, Slot> slots = men.getTypeNode().getSlots();
for (Slot s : slots.values()) {
  System.out.println(men.getSlotValue(s));
}
Previous Topic:Indexing model changes
Next Topic:Linking model elements
Goto Forum:
  


Current Time: Fri May 24 19:52:38 GMT 2024

Powered by FUDForum. Page generated in 0.03692 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top