Is there a way to see what property is a NewObject change referring to in Javers? - javers

When handling onNewObject(NewObject change) of the ChangeProcessor interface, is there a way to figure out where in the object graph (relative to the top objects compared) that new object is? The full path, not just relative to the immediate parent?
I have two properties of type Address somewhere lower in the graph, and if I print the change global ID, I get something like ...Address/22984 and ...Address/22985, which doesn't tell me what each of those Address objects represent. I'd need to get the full path back up to the root object that shows in javers.initial(rootObject).

JaVers dosn't record paths from the first object but for Value Objects, you can read the path recorded in ValueObjectId. It's the path from an owning Entity to a Value Object. For example:
Employee/1#primaryAddress

Related

How to get the coordinate of a THREE.JS object on the map

After loaded an object to a map using this example (https://docs.mapbox.com/mapbox-gl-js/example/add-3d-model/), how can you retrieve the object's coordinate back? I want to set the centre when the object moves.
Basically you cannot do it, unless you assign modelAsMercatorCoordinate as a variable in the new object userData when it’s instantiated and before it’s added into the scene.
To find it in any other part of the code, you’ll need to loop over this.scene.children and find the object in that collection, considering there are also 2 lights added, it will be this.scene.children[2] but it’s much better to assign to it a name and then look for it through that with this.scene.getObjectByName

Appending type data inline

In my use case I have a RAML 1.0 library created by our R&D department that contains definition of multiple data types. Those data types are defined in a generic, parametrized manner so when I reference them in my RAML I do so using following syntax:
type: { resourceTypes.collectionWithCriteria: {itemName: reward, itemCriteria: types.RewardCriteria, itemType : types.RewardList} }
This generates proper GET request with query string defined by types.RewardCriteria and response defined by types.RewardList. It also generates the description for the GET resource defined as: Retrieves the list of <<itemName | !pluralize>>, which ends up being Retrieves the list of rewards.
In my RAML I would like to append additional description to my GET resource, however I 'd rather avoid overwriting library-generated one. Is that possible? I've already tried inline description and using overlay file, both of which simply replace description from the library.
You cannot append for a single value simple property.
The merging rules for traits / resource types state that the description will be replaced:
Every explicit node wins over the ones that are declared in a resource
type or trait. The rest are simply merged.
Also, the merging rules of overlays and extensions states that:.
If the property is a Simple Property
If the property is a Single-value Simple Property,
The property value in the identically named Current Target Tree Object property is replaced with its value from Current Extension Tree Object property.

Implementing cached qualified names in ECore

I have to classes, Container and Containable, and I'd like to implement qualified names ( root/containerA/containerB/containableXYZ )
So, Container derives from Containable and Containable has a fullName Property which I set as derived, transient & volatile which works
return (parent != null) ? parent.getName() + SEPARATOR + getName() : getName();
But now I'm worried that in big models at each level of the hierarchy the same path is computed unnecessarily - Each container could cache it's path
But if the parent of the container changes - how do i automatically recompute it's path?
In EMF objects are contained in a Resource which has a tree hierarchy. What you can do is to extend the Resource to intercept when an object is being attached or detached from the tree.
See: ResourceImpl.attached()
Other thing you can do is to override the method eBasicSetContainer() in your class. The best is to have an abstract common root class for your all model classes. Then what you can do is to intercept this method and update the path when the new container objects is not null.
In both cases (intercepting Resource or EObject), make sure that you also re-compute the path of any contained element in the subtree of the element being changed. This can be easily done by re-computing the path recursively iterating over the subtree using: EcoreUtil.getAllProperContents(EObject)
BTW, you can also use the EcoreUtil.getIdentification() which returns the qualified name of the element using its URI.

In Xcode, is there a way to list only relevant methods for an object?

Is there some way in Xcode to enter an object's name, and then get a list of the methods that can be used with that object, sorted either hierarchically by inheritance or by return value type?
I know you can get a list of methods by pressing Control-Space after entering the object's name in standard bracket messaging syntax; however, this list often contains numerous methods that are not applicable to the given object. As a result, you still have to scroll through a bunch of garbage, and then look up the class definitions for the object, or reference custom object implementations you have created in order to see which methods will work.

What Query/Path-Language is used for References in Ecore-derived XMI-Instances?

Assume that I have an Ecore-model containing a package and some classes that make reference to each other. If i create a "Dynamic Instance", Eclipse produces an XMI-file and I can instantiate some classes. Containment-relations are directly serialized to an XML-tree in the XMI (the children elements in the example). But if I instantiate references to elements that are already contained somewhere in the tree, the Editor writes Path-Expressions like in the following, for the currentChild attribute:
<parent currentChild="//#parent/#children.1">
<children/>
<children/>
</parent>
As far as I know this is not XPath, because:
The "childrens" are elements not attributes and have not to be referenced via "#"
XPath uses the e.g., elem[1] and not elem.1 to get e.g., the second elem of a list
What is it and where can I find a information on it? I already tried to browse the EMF pages/specs but could not find it.
It's an EMF Fragment Path. The Javadoc describes it like this:
String org.eclipse.emf.ecore.InternalEObject.eURIFragmentSegment(EStructuralFeature eFeature, EObject eObject)
Returns the fragment segment that, when passed to eObjectForURIFragmentSegment, will resolve to the given object in this object's given feature.
The feature argument may be null in which case it will be deduced, if possible. The default result will be of the form:
"#feature-name[.index]"
The index is used only for many-valued features; it represents the position within the list.
Parameters:
eFeature the feature relating the given object to this object, or null.
eObject the object to be identified.
Returns:
the fragment segment that resolves to the given object in this object's given feature.

Resources