Types returned by : fromHTMLBodyString() and replaceLink()

The .class file is only produced by the JDT if there is no error in the Java source file. Then this .class is loaded by M2Doc.

It’s possible that both instances of JDT try to compile the class if it’s present in two running workspace.

I was describing:

  • one Capella Studio for instance with your plugins (services, templates, addon, …)
  • You create an Eclipse launch configuration
    • in this workspace you have your .genconf file and your model

But to work with M2Doc you really only need one workspace since M2Doc will be able to load service class in the current workspace.

It was exactly the opposite (in some sort) haha:

  • Open Capella with my projects
  • Bring my services, by just opening the plugins located in my CS.

Very possible!
Indeed the changes I made were in CS, at the same time I had opened it in Capella and both were running.
Capella is such a machine, let’s agree.
__

I will try to copy paste my plugins inside the Capella workspace and see how it goes,
I could also compile those (with the Template) into an update site like you described, will keep you updated.

Copy pasting the Plugins of CS into Capella Workspace does not seem to get me that far:

You are using the Capella Studio ? because in Capella PDE tools are not installed by default I think (or might need the developer capability to be selected).

I tried inside another Capella Installation, I don’t why it did not work with the first one I will try to figure out the difference later. However as for now, well:
image
The second capella config seemed to let met open the java extension easily:

Then I made sure i had ONLY the plugins containing my JS in the workspace + the capella project itself (all inside Capella, not CS)
So I was able to add the service into the template
However when generating the doc, only the function with EObject was recognized yet again, the Capablity or CapellaObject not so much!
Validation doc:


Generated doc:

__
What other problem could it be? I really had my plugin INSIDE the capella workspace this time.
You claim I could transform my plugins from CS into an update site and add to them a template that could this time work?
What if I wanted to create a new template in addition to the one put inside the update site?

I never noticed when adding an update site into Capella whether the java extension from odesign could be added through the template wizard? It appears strange to me, this means that ALL Capella Extensions could have their java extensions/classes/JS added into M2DOC Templates? I must try this anyway but if you any any other input please tell, thanks.

(Note: unrelated, I played with the word “static” to see, but that has no correlation whatoever)

A second note:

  • Inside Capella, I don’t find the “build path” option to be able to add my external Jar’s (if needed), so I commented out the functions who needed the Jars, i just want to make the test1 and test2 functions work

Maybe you can check the .class file date see when it has been compiled also check is the methods are present. If you are using separate plugins for your template and your service make sure you have a dependency from the template plugin to the service plugin and that the package containing the service class is exported in the MANIFEST.MF.

Yes the update site should deploy everything in a Capella but it’s not really practical at development time.

Also try to add an other service taking an EObject as parameter see if it’s a compilation issue or a typing issue.

Did you add dependencies to Capella plugins using the MANIFEST.MF ?

Also try to check the error log view and see if anything useful pops up.

I checked inside Capella installation, the copy pasted plugins, the .class had not been updated true, I tried to add a new function (inside Capella), without regenerating (I would not know how to that outisde CS eventhough I had plug-in view activated) and he did not recognize the new function (EObject param), So I went to copy paste a new version of the plugins that were regenerated just now. Opened the Temp Wizard, deleted previous services (I have 2 btw: the editor version and normal version), saved, then added the updated version of both services. Strangely enough I found a new kind of error, this is page one of the validation document:


**Invalid block: can't load service class: org.polarsys.capella.vp.j_services.design.service.J_ServicesOpenJavaServiceInvalid block: can't load service class: org.polarsys.capella.vp.j_services.design.service.J_ServicesOpenJavaService**
(this was inside the generated non validation doc)

Deleted the services, and this time the generation has normal behaviour:


(none were recognized because I deleted the services)
Installing the services again, produce the first error, strange, it just thinks I am adding the older version of the plugins (the one who were not generated updated, that I had to delete and replace with new plugins ther were more recently generated), so when it does not find the older version of my plugins it does that?
Restarting Capella would not solve this, I will just make a new template at this point:

Same problem, it seems that deleting the older version of the plugins and replacing them with the same (same name) ones through new plugins '(that were regenerated prior) is just a bad idea.
I need know to use a new Capella installation who had no plugin inside its workspace in the beginning or make a new class/JS.
__

Not Not really, I will check that out.

I will experiment with this and tell you.

Interesting, will chek that out!

__
Before doing any of that, I will try to do your first suggestion → Use plugins that were recently regenerated and see how it goes.
Your suggestion assumes that eventhough my functions had their return value changed ( and taken into account WITHOUT REGENERATING the plugins), that does not mean creating new functions (the ones with capability and CapellaElement as param) should be incoropated, this your sugegstion checking the .class last modification date. In Any case i will try this and tell you.

Are you calling your services from a template construct ? because there is this bug that could produce this behavior. A nightly build is available with a fix:

https://s3-eu-west-1.amazonaws.com/obeo-m2doc-releases/master/nightly/repository

I use the following:

  • Capella Studio → a java extension inside design that contians my classes/functions.
  • Capella → one project with M2DOC
    → I copy paste the plugins from CS into capella workspace
    → The service appers in the template wizard, I add it and save
    → I regenerate the M2DOC doc.

So… i am not sure what is Template construct here?
__

I got an error, when I deleted the plugins copied from CS and replace them with a new one, the template will say it needs the service…

Its as if Capella only saved the very first version of the JS from the first JS, and deleting them (even though i replaced them with updated version) makes it as if there is no more service … I cant call them anymore (even the function EObject does nto work, the word doc is not generated at all , it has an error asking for the missing services)

I will have to use a new capella, new template OR a new CS JS/new plugins.
I will try to do it.

It was not able to open due to these errors:

Errors

I think it was related to the fact I may had not “deleted” the CS project (the open opened from another workspace not the one copied), while at the same time opening THE SAME project copy pasted into Capella workspace.

Anyway,
I tried to create a new EObject function as you have recommanded, it works:
image
Template:
image
Result returned:

Reminder: the 2 functions that are not working are the one who get Capability and and CapellaElement as params respectively.
Reminder2: the UCD element is actually a capability, proof:
image
(Unless I am missing something)?
(The M2DOC template makes use of the variable “UCD” in other places with no problem)


To summerize the experiment:

  • Copy pasting the plugins into Capella (From CS with No errors)

  • JS appears, and is added into the T Wizard.
    image

  • There are no nsURI to add except those that ALREADY exist in my templates:

→ Result:
Only EObject function work
Capablility Does not
CapellaElement Dosn’t either.


Next steps:

  1. Try to check your other suggestions (dependencies, Manifest etc…)
  2. Try another non Eobject function but with another element of Capella, maybe a Logical Component instead of a Capability to observe how that goes.

Edit1: Tried it with Logical Component, same problem:


Here are the error LOGS:

→ The missing library is NOT used, I commented all lines of code using it, I don’t think that’s the problem? If it was, then the EObject functions should not be working I believe. (I did not know how to add it in Capella anyway, I did not find the Build path option anyway)

Edit 2: Deleting current plugins from Capella needs to be within Capella (and selecting the option deleting nesting…), This allows for reinjection of new updated plugins into the model without problems.
I will check the manifest and dependcies stuff now and try to follow your other suggestion.

Not sure what is happening here but this service class declares many services with EClasses from the Capella metamodel as parameters. And is used in the sample templates. Maybe you can have a look at the plugin and check if something is different from your plugin.

You need to open the error log view not the problems view to see if something wrong is happening when you start your generation.

  1. Ok Added that function into my class:
    image
    No error, everything has been imported.

  2. I had the choice between 2 or three objects/classes → I have always chosen the Object data.something:
    image

  3. No apparent error during plugins generations (CS), except an unrelated error I Believe?

  4. Copy pasted the plugins into Capella and opened them, problems → (The same screen shot as before (explorer contextual core. cannot be resolved…)

  5. Errors however:
    image


Generation of M2DOC provide the following feedback:
Validation:


(Capability not recognized as usual, but YOUR function seems to not producing any error)

However the GENERATED DOCUMENT is as follows:

→ I AM SO CONFUSED.
(never had this before)

__
By the way, I am not trying to make a function that contains 2 parameters, to makes things clear, here are my testing functions:
image

Is the problem more related to EMF Eclipse java methods and elements needing things like “factory” ?
Simply having “Capability” as a parameter would not work, wherevas EObject does work well? (Replacing Capability with EObject will literally print “aaa3” = function works)
Are there some (casting) considerations to take in account or something?

Did you set the self variable value in your .genconf file ?

I think it’s an issue with the configuration of your plugin preventing the class loading… but I can’t think of something else that could trigger this behavior. Maybe the JDT error is what is preventing M2Doc from loading the class because we use the classpath computed by the JDT to load the class…

If you can provide a simplified project witht this issue I can have a look.

1 Like

Maybe.
I will restart everything, Capella, Capella Studio, and the JS’s.
Ok I am sending you the simplified project here:
template.docx (19.8 KB)

TestCapellaProject.afm (347 Bytes)
TestCapellaProject.aird (12.5 KB)
TestCapellaProject.capella (22.8 KB)

Problem: I can’t send you the Capella Studio Plugins but here are the functions I am declaring in the design file (the JS):

public String test0(EObject B) {
        return "Test0Result_EOB";
	}

public String test1(Capability B) {
        return "Test1Result_CAPA";
    }
public static String test2(CapellaElement B) {
        return "Test2Result_CElm";
    }

One problem, The template I gave you contain all usRUI but also the Services missing (you dont have them because you dont have the plugins) I will make for you a new fresh template.

To simulate the same behaviour, you will have to:

  • Add the plugins of CS (copy paste) inside the Capella workspace
  • RE open projects (Menu > Open project from file system) and choose the Capella workspace → select the new folder containing your imported plugins → press ok (the plugins will appear)
  • Add the JS into the template with the wizard.
  • Create a genconf that uses it
    You can now genarate a document, let me give you a fresh template right quick.

Edit: Fresh Template added
templateYvan.docx (17.7 KB)

Capella 5.1
M2DOC 3.1.0

You will see that Eobject functions work but Capability would not! Nor Capella Element functions.

__
One last observation:
All extensions I made through update site (or the old drag and drop method), well none of their JS would appear in the template wizard. I just tried it to confirm. ONLY the plugins I “open” in my project explorer, can appear inside the wizard. Am I missing something here? (Unless you were talking about template that are incorporated inside an extension and they everything is packed together inside update site)

I will have a look. If possible you should update M2Doc to version 3.2.1. Also the Sirius integration of M2Doc 3.1.0 is not compatible with Capella 5.1.0 (M2Doc 3.2.0 is the minimal supported version). I guess this should not be the root cause of your issue but it will prevent you from exporting diagrams.

For more details on provided version of M2Doc for each version of Capella you can check this page.

I will continue my tests with M2Doc 3.2.0.

1 Like

Thank you!

I am not the only one using the template, I don’t know if updating can be done easilly without breaking things, but I will give it a try certainly.
(If you have any question about my environement, please tell me, I hope it was clear enough, I know you don’t use Capella Studio much from my understanding, compared to classical eclipse dev methods)

I reproduce the problem. I opened a bug:

As a workaround, you can use the following project in you workspace:

test.zip (15.8 KB)

Then start a runtime

Finally import the following project in the runtime project:

TestCapellaProject.zip (8.1 KB)

1 Like

Thank you very much, that’s interesting so there is indeed a bug, everyone wins this could help future users I suppose, and attract more users theoretically.
Ok let’s try it.
Since you mentioned activating the developer capabilities, it means you are talking about Capella. (it also have the same exec jre version). OK. Here is what I see:
image

Question:

    • Inside the runtime made through Capella, do you make sure the “capella ‘test’ project” is also opened? (indeed we need its template when configuring the genconf)
      → This means that Importing the other capella project (TestCapellaProject), which contains our genconf, is necessarily paralleled with opening the “test” project which contains the class and the template.
      So this is what we should be seeing at this point:
      image

→ It does not seem to be working?


What Am I missing?

  1. How did you make the “test” project? Which option did you choose:
    image
    ?
    I usually just make kitalpha DSL projects, don’t use anything else in Capella Studio. (I am asking to be able to recreate it afterwards)

Thanks!

The test project is in your first workspace, it will be loaded as par of the target platform when you launch the runtime. In the runtime you only need the TestCapellaProject with the model. Then configure the .genconf using the template registry. It will load the template in your first workspace. And when you produce an update site and install, it will load the template form the deployed plugin.

This way you can edit your services and template in the first workspace. But you need to start a runtime for testing. If you start your runtime in debug mode it’s possible to debug your services and it might reload the .class after change in the source code.

1 Like