Bug 569035 - Add examples of how to save a model+stereotypes
Summary: Add examples of how to save a model+stereotypes
Status: UNCONFIRMED
Alias: None
Product: MDT.UML2
Classification: Modeling
Component: Core (show other bugs)
Version: 5.5.0   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: UML2 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-22 10:35 EST by gary s thompson CLA
Modified: 2022-04-08 08:48 EDT (History)
1 user (show)

See Also:


Attachments
Better documentation and save (23.34 KB, application/octet-stream)
2022-04-08 08:16 EDT, Ed Willink CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description gary s thompson CLA 2020-11-22 10:35:13 EST
as discussed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=543231 and https://www.eclipse.org/forums/index.php/m/1834967/#msg_1834967 it is not obvious how to save a url model to a file  with stereotypes applied. There are several gotchas as discussed in the forum thread thread above. I have modified  IntroductionToUMLProfiles.java to include examples of hoot save a model with stereotypes applied in Java, the code is at https://www.eclipse.org/forums/index.php?t=getfile&id=39380&. To be complete and reasonable this most probably ought to have some updated url to show hoot do it in the ui (though I am not sure how that works...)
Comment 1 gary s thompson CLA 2020-11-22 12:36:51 EST
fumble fingers, here is a correct version:

As discussed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=543231 and https://www.eclipse.org/forums/index.php/m/1834967/#msg_1834967 it is not obvious how to save a uml model to a file  with stereotypes applied. There are several gotchas as discussed in the forum thread thread above. I have modified  IntroductionToUMLProfiles.java to include examples of how to save a model with stereotypes applied in Java, the code is at https://www.eclipse.org/forums/index.php?t=getfile&id=39380&. To be complete and reasonable this most probably ought to have some updated html to show how to carry out the same operation in the uml2 ui (though I am not sure how that would work as its not clear how to create a resource before the file is saved or how to add the applied stereotypes when editing is complete... however, maybe this is something that is solved in the ui code already)
Comment 2 Ed Willink CLA 2020-11-23 07:52:15 EST
Your mail group message seems to suggest that the contribution is incomplete;

a missing ecore namespace declaration and a missing schemaDeclaration.

The schemaDeclaration is probably a trivial Resource saveOptions bug.

The missing ecore namespace may be a similar problem to https://bugs.eclipse.org/bugs/show_bug.cgi?id=568819 where a types declaration is missing.

Perhaps some loop over transitive dependencies is missing that locates the required declarations.
Comment 3 gary s thompson CLA 2020-11-30 17:14:50 EST
Hi Ed

the example is not incomplete it all works fine, the problem is that when I try and setup a parallel version of the code in my program I don't get the same results....

regards
Gary
Comment 4 gary s thompson CLA 2020-12-05 07:00:30 EST
so in my own code when saving I needed to add 

xmiResource.defaultSaveOptions.put(XMIResource.OPTION_SCHEMA_LOCATION, true)

but this isn't in the example code, not quite sure whey the two need different treatment
Comment 5 Ed Willink CLA 2020-12-05 13:31:17 EST
Probably because you are actually using the result whereas the example was developed as a demonstration that was 'tested' by eye.
Comment 6 gary s thompson CLA 2020-12-15 08:15:42 EST
(In reply to Ed Willink from comment #5)
> Probably because you are actually using the result whereas the example was
> developed as a demonstration that was 'tested' by eye.

Unfortunately that's not the reason as its a runnable example and all works when run...
Comment 7 Ed Willink CLA 2022-04-08 08:16:35 EDT
Created attachment 288418 [details]
Better documentation and save

Attached is rescued from my workspace. It seems that I was motivated to do better and so the attached was created on 21 November 2020, 18:38:02

It seems that it never got contributed.

It solves the problems in https://www.eclipse.org/forums/index.php/mv/msg/1110528/1851540/#msg_1851540
Comment 8 Ed Willink CLA 2022-04-08 08:48:44 EDT
(In reply to Ed Willink from comment #7)
> It seems that it never got contributed.

The code seems ok, but there is clearly at least one new half-written comment.

Inspecting my email at the time, it appears that all the builds started failing the following day as Java 11 started to impose itself via Tycho / Maven currency.

I suspect that I got interrupted while tweaking the comments and then got well distracted by fixing OCL, QVT, ... and forgot to come back to it.