RequireVersion parameter cannot be deleted from a saved workflow
In an unsaved workflow (no associated file), RequireVersion can be added and deleted as expected. If I save an entirely empty workflow to a file, I can add RequireVersion but cannot delete it. The URL is an example workflow.
#1 Updated by Christopher Brooks over 13 years ago
This bug is replicatable in a non-Kepler Ptolemy installation.
File -> New -> Graph Editor
Drag in a RequireVersion attribute
Save the model
The RequireVersion attribute cannot be deleted in the model.
BTW - when creating bugs, it is best to not include example models as URLs
because the URLs tend to disappear over time. If the model is added as an
attachment to the bug, then the model will be more closely associated with
#2 Updated by Christopher Brooks over 13 years ago
The problem was that it was not possible to delete a RequireVersion Attribute
from a saved model. One could argue that this is good, since the RequireVersion
attribute is a precondition for the operation of the model. However, software
that tries to be too smart is annoying, and the reason that RequireVersion
could not be deleted is because of a bug, not because of intentional design.
The reason is because VersionAttribute.equals() matches on the version
expression. Thus, if we had a VersionAttribute that had the value 8.0.beta
and a RequireVersion that had the value 8.0.beta, then they were seen as being equal.
What happens is that when we read the model in, we have
VersionAttribute - which is in every model
RequireVersion - which is added by the user
When we delete RequireVersion, the equals() finds first VersionAttribute
at the top and probably deletes it.
The reason this only fails in a saved .xml file is that upon writing the
model is when the VersionAttribute is added.
The fix/workaround is to add equals(Object) and hashCode() to RequireVersion.