Check for and show invalid references before saving
Currently, if a model contains references to objects that are not contained in a resource, an exception (DanglingHREFException
inside a WrappedIOException
), which only says which object is referenced and not contained in a resource.
For example:
The object 'ca.mcgill.sel.ram.impl.ClassImpl@795374b8 (name: E) (partiality: none, visibility: concern) (abstract: false)' is not contained in a resource.
However, the user might have no idea where it is referenced from.
In general, the best solution would be that the validator checks for this using an OCL rule, if possible. At least, it would be great to be able to show to the user all the locations that reference objects that are not contained in a resource before allowing to save.
Comments (4)
-
reporter -
reporter References
#463: Adds a check to find uncontained references before saving.In case of existing uncontained references, they are shown to the user instead of saving. The list contains a guidance to the user on where the reference is located, i.e., the object containing the reference and a (in)direct container is presented.
→ <<cset ac24d0af3904>>
-
reporter - changed status to resolved
-
reporter OCL rules in #456 references branch contain a
getRootContainer()
method that uses closure to find the top-most root container. - Log in to comment
I was able to use the following constraint, however, I am unable to provide it in a general way for a super-class like
COREModelElement
:For example, I could add it to
context Parameter
and then inside this context write a constraint which checks whethergetRootContainer(type).oclIsUndefined()
. As soon as I movegetRootContainer
out I am unable to call it from there.