“Lessons learned” …creating a complex DNG Extension with Javascript

Currently I’m working on a big DNG Extension that will:

  1. Search Artefacts and their link structure
  2. Create a Workitem “Mirror” at RTC…Workitems with similar names and the same link structure
  3. Link the DNG Artefacts with their RTC Workitems counterparts.

Sounds simple, just create a loop to get the Artefacts and then create the related Workitems. But it isn’t!

Bildschirmfoto 2015-02-02 um 18.01.43

 

And here are the “Lessons learned”.

OSLC isn’t enough

As in my last Blogs mentioned, there exist more then OSLC. RTC and DNG has a rich REST API available like the Reporting API. Believe me you will need the other REST API. BTW, it seems that there are more Web API used by DNG and RTC. You can see them with the Chrome Developer Tools. And some of them look like SOAP Calls.

Use DNG Views 

OSLC Queries are not easy to use (not for me). You can use DNG Views with the DNG Reporting API. DNG Views are a just another name for DNG Queries. Using DNG Views has the advantage that you have a GUI to create a Queries. If someone found a way to get the available DNG Views over REST , let me know. Currently the related Viewname for the Javascript is set from the Gadget Settings.

Use the “Revealing Modul” Pattern

To structure your DNG Extension it make sense to use the “Revealing Modul Pattern” like described here. It helps you to structure your Javascript functions and variables int private or public.

Use Promise/Deferred with AJAX calls

Because JQuery AJAX calls are asynchrone in nature you will run in a “Callback Hell”. I know, I know …you could use AJAX also synchrone but there is a good chance that this will freeze your Web GUI. Javascript and the Web GUI are sharing just one Thread!

Use Logging

Late but not too late I recognise that console.log() isn’t enough. There is log4javascript that also have the possibility to send back the log results to a log server (with AJAX). Don’t forget to enable/disable Logging from the GUI (Gadget Settings).

Use local Variables to cache the results of the AJAX calls

AJAX calls are “expensive” and their results have a lot of informations in the form of RDF/XML. I created a local structure to store the link structure and their properties. Because DNG and RTC using Semantic Web I should use a local RDF store for Javascript like this one. I should…

Open Points

  • Performance? (Creating 4000 to 6000 Workitems)
  • Stability? (Memory consumption of Browser or the JTS Appserver)
  • Interruption of the long running Script because of Laptop Standby or Browser crash?
  • Use a local RDF store?
  • Include “eye candy”

First Results

It works great and it is amazing to see that a complex Workitem structure is created with just one click!

Feel free to comment your experiences with Javascript Extensions.

,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: