You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched and found no existing similar issues
How are you using Studio?
Legend Studio
Current and expected behavior
Problem with the Removing elements from the EXPLORER tree's context menus.
When experimenting with Legend Studio, latest version from docker and also master branch from github, I discovered that when using the context menu in the Explorer tree to remove some elements, Legend Studio would end up in the text mode reporting the following error:
I believe that message goes on to say "Redirected to text mode..." or something along those lines, as I end up in the text editor with one or more errors depending on element I removed and elements referring to it.
I will list the types of elements (packageableElements) and conditions in the "steps to reproduce" section.
Problem with renaming some elements from the EXPLORER tree's context menus.
However, as I was exploring this further, I discovered similar problems with some elements when simply renaming them. While in many cases any reference to them by other elements were automatically updated, in some cases I received the following message:
And just as with the first problem when removing some elements, I was redirected to text mode with many errors in the text.
As a programmer, I was able to figure out what to do to resolve the errors, but since the Graphics interface is intended to allow non-programmers to edit the elements and relationships without needing to understand Legend Pure in depth, my understanding is that for the feature allowing the removal of an element, Legend Studio should either automatically clean up references to removed elements, or it should warn the user that there are dependent elements and possibly not allow the element to be removed until all references to it are removed. For renaming, Studio should ensure all references are properly renamed.
Unique circumstances for the problems to occur
So far, it seems like these problems with renaming and removing occur with elements that are referenced by Mappings, by Associations, or by FileGenerations that are included in a Generation Specification.
Steps to reproduce
####Test Pure code
I provided the Legend Pure script I have used to demonstrate the problem in the "Model data" section below. It is based on "Legend Showcase - Installer Demo" but without the Postscript db and with a FileGenerator and GenerationSpecification added in the "generator" package.
Unique circumstances for the problems to occur
So far, it seems like these problems with renaming and removing occur with elements that are referenced by Mappings, by Associations, or by FileGenerations that are included in a Generation Specification.
Reproducing the Remove problem when removing a File Generation element.
Use the script provided in the "Model data" section and exit text mode.
Expand the "generate" package. You'll see two elements, "genjson" and "MyGenerationSpecification".
Click on "MyGenerationSpecification" and in the graphical view, in the lower section "File Generations" you'll find that "genjson" is listed.
Back on the EXPLORER tree, right click on "genjson" to get its context menu and click on "Remove".
You'll see the error message I wrote about, and you'll be in text mode.
The problem, you'll see, is that generate::genjson is still in the file generation list, even though that element no longer exists in the script.
In order to go back to the graphical mode and properly recompile the script, remove "generate::genjson" from between the brackets (leaving that list empty). It's easy enough to fix, but non-programmers shouldn't need to worry about this.
Renaming of a File Generation element, on the other hand, works just fine.
Reproducing the Remove problem when removing a Database element
Use the script provided in the "Model data" section and exit text mode.
Expand the "database" package. You'll see the single database element: db1
Right click on db1 to get its context menu and click on "Remove"
You'll see the error message I wrote about, and you'll be in text mode.
Here, the problem is that there is a Relational Mapping using tables and fields from that database. But the "Remove" did not clean up this dependency, nor did it warn the users of the dependency and prevent the database element from being removable. There error looks like:
For a regular user to fix this problem, it's much more difficult than the File Generation problem. They would have to know how to edit out the mapping or know how to type a new database definition, etc. Legend Studio doesn't provide a means to undo the action (to my knowledge) when the problem was generated this way.
Reproduction the Rename problem when renaming a Database element
Unlike the Generation Specification rename working even though its remove has problems (first case above), with Mappings, even renaming the database element has problems.
Use the script provided in the "Model data" section and exit text mode.
Expand the "database" package. You'll see the single database element: db1
Right click on db1 to get its context menu and click on "Rename"
When the Rename Element dialog appears, change "database::db1" to "database::db2" and press "Rename".
You'll get the rename error message and you'll be in text mode.
The problem here is again with the Relational Mapping. The table mapping automatically now references "database::db2" but the element mappings are incorrectly still referencing "database::db1", which no longer exists.
In this case, though not desirable, the user can fix the problem by using the text editing's Find/Replace feature, either renaming "database::db2" back to "database::db1" or the other way around.
Rather than have the complete steps for other cases, I'll just name them:
Rename domain::Firm to domain::Company. You'll see parts of MappingTests that did not change from Firm. (Of course, Firm_Person will not change either, but this isn't the problem.)
Rename domain::Person to domain::Employee. You'll find that the Index for the employees array in the Mappings is not changed. Here is one of them:
There may be additional cases, but the one's above are those I have discovered so far.
Legend:
Using the Docker-Compose Installer with all the Legend components with snapshot releases.
Also when stopping the Studio in Docker and running the latest master branch from my
local Visual Code.
System:
OS: macOS 12.7.6
Binaries:
Node: 22.3.0 - /private/var/folders/68/6jc0j8dd08bc5q544_rs_tjh0000gn/T/xfs-854339c9/node
Yarn: 4.2.1 - /private/var/folders/68/6jc0j8dd08bc5q544_rs_tjh0000gn/T/xfs-854339c9/yarn
npm: 10.8.1 - /usr/local/bin/npm
Browser: Tested with Brave
Possible solution and workaround
Original Attempted Solution
When I first discovered the problems above, I was testing File Generation elements. I made an initial attempt to add a fix for this, by modifying the deleteElement method in GraphEditFormModeState.ts to have a handlePostDeleteAction, where I checked if the element was of instance FileGenerationSpecification and if so, I called a new method generationSpecification_deleteGenerationElementFromAll which I added to DSL_Generation_GraphModifierHelper.ts. While this worked for that case (I still have it), I realized it was not a general solution.
Looking for a more general solution
I have not used Mobx observers, with action, flowResult, etc, before, so I am not able to determine if the problems are due to missing observer relationships. Also, I could not find methods in the Store classes to allow me to navigate through the element tree (though I have not looked at its use of the visitor pattern yet).
Today, I noticed that in PureModel.ts, the deleteElement method looks for DeadReferenceCleaner plugins. But as far as I can tell from debugging in the browser, there are no current DeadReferenceCleaner plugins.
Happy to help, if somone can point me in the right direction.
I mentioned above that I have a specific solution the the File Generation removal. I can create a Pull Request just for that, if requested. However, I would rather have a solution were the Graph tree is properly iterated to properly update the dependencies for renamed and removed elements. Or, alternatively for the case of removal, if there is a method to search for element dependencies, the Remove option can be disabled in the context menu.
I am primarily a Java developer, though I am familiar enough with React and Typescript to make the changes above (not submitted) and to debug the code. However, as I mentioned, I have not used Mobx before, so I was not able to determine all the parts of the code that observe the rename and delete operations on these elements.
In any case, I hope the information I've provided here is helpful.
Regards,
Jim Nelson
jimnelson372
Contribution
I would like to work on the fix for this issue
The text was updated successfully, but these errors were encountered:
jimnelson372
changed the title
Bug: Explorer Tree's Rename and Remove operations on PackageableElements not cleaning up references
Bug: Explorer Tree's Rename and Remove operations on PackageableElements causing recompile failure, not cleaning up references
Aug 16, 2024
jimnelson372
changed the title
Bug: Explorer Tree's Rename and Remove operations on PackageableElements causing recompile failure, not cleaning up references
Bug: Explorer Tree's Rename and Remove operations on PackageableElements causing Pure recompile failure, not cleaning up references
Aug 16, 2024
jimnelson372
changed the title
Bug: Explorer Tree's Rename and Remove operations on PackageableElements causing Pure recompile failure, not cleaning up references
Bug: Explorer Tree's Rename and Remove operations on PackageableElements causing text recompile failure, not cleaning up references
Aug 16, 2024
Similar issues
How are you using Studio?
Legend Studio
Current and expected behavior
Problem with the Removing elements from the EXPLORER tree's context menus.
When experimenting with Legend Studio, latest version from docker and also master branch from github, I discovered that when using the context menu in the Explorer tree to remove some elements, Legend Studio would end up in the text mode reporting the following error:
I believe that message goes on to say "Redirected to text mode..." or something along those lines, as I end up in the text editor with one or more errors depending on element I removed and elements referring to it.
I will list the types of elements (packageableElements) and conditions in the "steps to reproduce" section.
Problem with renaming some elements from the EXPLORER tree's context menus.
However, as I was exploring this further, I discovered similar problems with some elements when simply renaming them. While in many cases any reference to them by other elements were automatically updated, in some cases I received the following message:
And just as with the first problem when removing some elements, I was redirected to text mode with many errors in the text.
As a programmer, I was able to figure out what to do to resolve the errors, but since the Graphics interface is intended to allow non-programmers to edit the elements and relationships without needing to understand Legend Pure in depth, my understanding is that for the feature allowing the removal of an element, Legend Studio should either automatically clean up references to removed elements, or it should warn the user that there are dependent elements and possibly not allow the element to be removed until all references to it are removed. For renaming, Studio should ensure all references are properly renamed.
Unique circumstances for the problems to occur
So far, it seems like these problems with renaming and removing occur with elements that are referenced by Mappings, by Associations, or by FileGenerations that are included in a Generation Specification.
Steps to reproduce
####Test Pure code
I provided the Legend Pure script I have used to demonstrate the problem in the "Model data" section below. It is based on "Legend Showcase - Installer Demo" but without the Postscript db and with a FileGenerator and GenerationSpecification added in the "generator" package.
Unique circumstances for the problems to occur
So far, it seems like these problems with renaming and removing occur with elements that are referenced by Mappings, by Associations, or by FileGenerations that are included in a Generation Specification.
Reproducing the Remove problem when removing a File Generation element.
Reproducing the Remove problem when removing a Database element
Reproduction the Rename problem when renaming a Database element
Unlike the Generation Specification rename working even though its remove has problems (first case above), with Mappings, even renaming the database element has problems.
Rather than have the complete steps for other cases, I'll just name them:
There may be additional cases, but the one's above are those I have discovered so far.
Model data
Environment
Possible solution and workaround
Original Attempted Solution
When I first discovered the problems above, I was testing File Generation elements. I made an initial attempt to add a fix for this, by modifying the
deleteElement
method inGraphEditFormModeState.ts
to have ahandlePostDeleteAction
, where I checked if the element was of instanceFileGenerationSpecification
and if so, I called a new methodgenerationSpecification_deleteGenerationElementFromAll
which I added toDSL_Generation_GraphModifierHelper.ts
. While this worked for that case (I still have it), I realized it was not a general solution.Looking for a more general solution
I have not used Mobx observers, with action, flowResult, etc, before, so I am not able to determine if the problems are due to missing observer relationships. Also, I could not find methods in the Store classes to allow me to navigate through the element tree (though I have not looked at its use of the visitor pattern yet).
Today, I noticed that in
PureModel.ts
, thedeleteElement
method looks for DeadReferenceCleaner plugins. But as far as I can tell from debugging in the browser, there are no current DeadReferenceCleaner plugins.Happy to help, if somone can point me in the right direction.
I mentioned above that I have a specific solution the the File Generation removal. I can create a Pull Request just for that, if requested. However, I would rather have a solution were the Graph tree is properly iterated to properly update the dependencies for renamed and removed elements. Or, alternatively for the case of removal, if there is a method to search for element dependencies, the Remove option can be disabled in the context menu.
I am primarily a Java developer, though I am familiar enough with React and Typescript to make the changes above (not submitted) and to debug the code. However, as I mentioned, I have not used Mobx before, so I was not able to determine all the parts of the code that observe the rename and delete operations on these elements.
In any case, I hope the information I've provided here is helpful.
Regards,
Jim Nelson
jimnelson372
Contribution
The text was updated successfully, but these errors were encountered: