Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Aspect Model change/refactoring operations #643

Merged
merged 33 commits into from
Aug 14, 2024

Conversation

atextor
Copy link
Contributor

@atextor atextor commented Aug 13, 2024

Description

This PR adds the Java API (the AspectChangeManager and the Change interface)
for editing/refactoring AspectModels. Changes are done in-memory and a report
can be generated for performed changes; writing changes back to the file system
is a separate step. The AspectChangeManager allows to undo/redo changes. Several
basic refactoring operations are implemented, such as renaming files, renaming
model elements and moving model elements to other or new files in the same or
another namespace.

A samm aspect edit move command is added to samm-cli that allows using the
move element functionality.

In order to allow refactoring changes to be written back, the PR also fixes
functionality of the model pretty printer:

  • Unused RDF prefixes are removed
  • The original order of declared model elements is retained (so written files
    are not randomly reordered any more)
  • The aspect prettyprint command now also works for Aspect Model files that do
    not contain a samm:Aspect declaration.

This PR incidentally also fixes displaying samm-cli help for subcommands of subcommands, which was broken; now e.g. samm help aspect to openapi will correctly display the help for the openapi subcommand

Fixes #625. Fixes #450.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

atextor added 28 commits August 13, 2024 08:44
Fixes eclipse-esmf#450. Properly supporting samm:Namespace in the element instantiation and
the DefaultNamespace implementation is a prerequisite for enabling the
PrettyPrinter to write Aspect Model files that don't contain an Aspect model
element definition.
Creating an AspectModel from a list of AspectModelFiles should be located next
to the other methods that create an AspectModel from various input sources
@atextor atextor marked this pull request as draft August 13, 2024 07:23
@@ -44,10 +44,10 @@ public void accept( final AspectModel aspectModel, final OutputStream outputStre

private static void addFileToArchive( final AspectModelFile file, final ZipOutputStream zos, final String rootPath )
throws IOException {
final String aspectString = AspectSerializer.INSTANCE.apply( file.aspect() );
final String aspectString = AspectSerializer.INSTANCE.aspectToString( file.aspect() );
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, so good!

Copy link
Contributor

@Yauhenikapl Yauhenikapl left a comment

Choose a reason for hiding this comment

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

LGTM!

@atextor atextor marked this pull request as ready for review August 13, 2024 13:03
@atextor atextor merged commit 71587cd into eclipse-esmf:main Aug 14, 2024
4 checks passed
@atextor atextor deleted the 625-move-element branch August 14, 2024 06:33
@atextor atextor mentioned this pull request Aug 14, 2024
7 tasks
Copy link

Release v2.9.5 addresses this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Rectoring: API for moving elements [Task] Implement support for samm:Namespace
2 participants