Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Add implementation for standalone converter, CLI and abstract converter interfaces#32

Merged
01Parzival10 merged 22 commits intomainfrom
refactor-standalone
May 13, 2025
Merged

Add implementation for standalone converter, CLI and abstract converter interfaces#32
01Parzival10 merged 22 commits intomainfrom
refactor-standalone

Conversation

@Entenwilli
Copy link
Member

@Entenwilli Entenwilli commented Mar 18, 2025

This PR adds standalone functionality for the converter, a CLI and abstract converter interfaces:

  • The Converters can now be executed standalone without Eclipse and with any paths desired
  • A Interactive CLI exists that can do all Conversion (even ones with steps, like PCM→DFD→Web)
  • The Converters now have abstract interfaces, allowing them to be chained easily
  • The Converters will only take a model as input, the other possible parameters (like annotations for DFD2Web) are set before conversion

This PR closes DataFlowAnalysis/DataFlowAnalysis#222

@Entenwilli Entenwilli added the enhancement New feature or request label Mar 18, 2025
@Entenwilli Entenwilli added this to the 4.1.0 milestone Mar 18, 2025
@Entenwilli Entenwilli self-assigned this Mar 18, 2025
@Entenwilli Entenwilli force-pushed the refactor-standalone branch 3 times, most recently from 1afc853 to 8eb45d8 Compare March 18, 2025 19:01
@Entenwilli Entenwilli requested a review from uuqjz March 18, 2025 19:41
@Entenwilli
Copy link
Member Author

@uuqjz Please review, I would like to have some feedback from you. Documentation is also starting to get added. See the readme.md on the branch. I would delegate the technical details (e.g. the Conversion Details section) to you, as I have only been active with the PCM Converter (which I will describe in the documentation myself)

@Entenwilli Entenwilli force-pushed the refactor-standalone branch 3 times, most recently from 239d16a to 54f88a3 Compare March 21, 2025 18:29
@Entenwilli Entenwilli marked this pull request as ready for review March 21, 2025 18:30
Copy link
Collaborator

@uuqjz uuqjz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good but slighlty overengineered.
I am wondering why we add an extra layer to each model to store the saving and read logic instead of putting it directly into the model. Maybe you can explain the benefits.

Further i suggest that someone else (Nicolas and or Tom) should review to.

@Entenwilli
Copy link
Member Author

The idea behind the abstraction of the input and output models for the converts is threefold:

1. Single Responsibility (Principle)

The converter should only be responsible for converting a loaded model to another loaded model.
It should not be the responsibility of the converter to load the model.
Additionally and aside from the principle, this also causes the converters to only have one method that is exposed to the outside.
This reduces the amount of required constructors of the converters

2. Better Maintainability

The older methods for handling different methods for loading the same model had lots of duplicate code. (e.g. the actual conversion). Some parts (like the high level calls to do the conversion) were not always extracted into a single method, instead spreading the code to all constructors

3. Enabling a common CLI interface

As the CLI works best when the converters have a common interface for the conversion, a common constructor would have been needed either way. Therefore, an interface like this would have been needed anyway, as the models require different elements, like Strings containing paths or the models themselves. Additionally, some converters need only one file, while some others require multiple.

@uuqjz uuqjz requested a review from Nicolas-Boltz March 31, 2025 10:47
@sebinside sebinside self-requested a review April 22, 2025 11:10
@Entenwilli Entenwilli force-pushed the refactor-standalone branch from 65b68d2 to 70e493b Compare April 25, 2025 12:26
@Entenwilli
Copy link
Member Author

@uuqjz @sebinside @Nicolas-Boltz Ready for review. Conflicts resolved/rebased

Copy link
Member

@sebinside sebinside left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are couple of quick comments, besides the required rebase.

Additionally, I ran the standalone converter in interactive mode to convert JSON to DFD (which worked perfectly) and DFD to JSON which produced the following exception. Maybe I misused it, in that case, more hints / enhanced exception handling would be welcome ;)

Exception in thread "main" java.lang.RuntimeException: Cannot create a resource for 'file:/C:/[...]/OnlineShopDFDsimple/onlineshop.dataflowdiagram'; a registered resource factory is needed
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:403)
	at org.dataflowanalysis.analysis.resource.ResourceProvider.loadModelContent(ResourceProvider.java:122)
	at org.dataflowanalysis.analysis.dfd.resource.DFDURIResourceProvider.loadRequiredResources(DFDURIResourceProvider.java:36)
	at org.dataflowanalysis.converter.dfd2web.DataFlowDiagramAndDictionary.<init>(DataFlowDiagramAndDictionary.java:112)
	at org.dataflowanalysis.converter.interactive.ConvertTask.getConverterModelInteractive(ConvertTask.java:144)
	at org.dataflowanalysis.converter.interactive.ConvertTask.runConversion(ConvertTask.java:122)
	at org.dataflowanalysis.converter.interactive.ConvertTask.handleInteractive(ConvertTask.java:84)
	at org.dataflowanalysis.converter.interactive.ConvertTask.main(ConvertTask.java:42)

@Entenwilli
Copy link
Member Author

Here are couple of quick comments, besides the required rebase.

Additionally, I ran the standalone converter in interactive mode to convert JSON to DFD (which worked perfectly) and DFD to JSON which produced the following exception. Maybe I misused it, in that case, more hints / enhanced exception handling would be welcome ;)

Exception in thread "main" java.lang.RuntimeException: Cannot create a resource for 'file:/C:/[...]/OnlineShopDFDsimple/onlineshop.dataflowdiagram'; a registered resource factory is needed
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:403)
	at org.dataflowanalysis.analysis.resource.ResourceProvider.loadModelContent(ResourceProvider.java:122)
	at org.dataflowanalysis.analysis.dfd.resource.DFDURIResourceProvider.loadRequiredResources(DFDURIResourceProvider.java:36)
	at org.dataflowanalysis.converter.dfd2web.DataFlowDiagramAndDictionary.<init>(DataFlowDiagramAndDictionary.java:112)
	at org.dataflowanalysis.converter.interactive.ConvertTask.getConverterModelInteractive(ConvertTask.java:144)
	at org.dataflowanalysis.converter.interactive.ConvertTask.runConversion(ConvertTask.java:122)
	at org.dataflowanalysis.converter.interactive.ConvertTask.handleInteractive(ConvertTask.java:84)
	at org.dataflowanalysis.converter.interactive.ConvertTask.main(ConvertTask.java:42)

This issue should be fixed by 0a69912

@Entenwilli Entenwilli requested review from sebinside and uuqjz April 25, 2025 13:29
@Entenwilli
Copy link
Member Author

@sebinside Issues should be resolved now

@Entenwilli Entenwilli force-pushed the refactor-standalone branch from 5b8f95f to 4474df8 Compare April 25, 2025 13:39
@01Parzival10
Copy link
Contributor

When I run it in normal mode and select PCM the options for output model are:
Please enter the desired destination model:
[1] WebEditor Diagram
[2] Data Flow Diagram Model

When I run it in debug mode the options are
Please enter the desired destination model:
[1] Data Flow Diagram Model
[2] WebEditor Diagram

While not too big of an issue this could cause a lot of confusion when you try to debug and quickly enter the numbers.

@01Parzival10
Copy link
Contributor

01Parzival10 commented Apr 28, 2025

image

When converting PCM to DFD, assignments without input or output pin are created. They can cause issues with the analysis. As far as I can tell this did not happen before.

Edit: This is the Audi Model

@Entenwilli Entenwilli force-pushed the refactor-standalone branch 2 times, most recently from 4a0f7af to 6abaad0 Compare May 3, 2025 10:00
@Entenwilli
Copy link
Member Author

image

When converting PCM to DFD, assignments without input or output pin are created. They can cause issues with the analysis. As far as I can tell this did not happen before.

Edit: This is the Audi Model

Test implemented in 6abaad0. It does not seem to be an issue anymore

@Entenwilli Entenwilli force-pushed the refactor-standalone branch from 6abaad0 to 7242708 Compare May 3, 2025 10:03
@Entenwilli
Copy link
Member Author

@sebinside @01Parzival10 This PR is ready for a re-review and can be merged

Copy link
Contributor

@01Parzival10 01Parzival10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@01Parzival10 01Parzival10 merged commit a3070e0 into main May 13, 2025
1 check passed
@01Parzival10 01Parzival10 deleted the refactor-standalone branch May 13, 2025 11:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Standalone Converter and Analysis Functionality from Binary

5 participants