Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: agdunn on November 01, 2008, 06:01:08 am

Title: Automating the HTML Report (Schedule/On Demand)
Post by: agdunn on November 01, 2008, 06:01:08 am
We are running a decently sized project now (10 contributors, 500+ diagrams) we have a web server which hosts the output of the html report from EA. I have installed EA onto said web server and use vnc to kick of generations when needed.

I would really like to write an app that would enable my team to kick a report generation off without needing access to the server (through a web interface) or likewise set it up to do a generation based on a schedule.

I saw a while back that a gentlemen was working on this in the forums, i dont know if any of you remember. If not then could you point me to the right place to start investigating the EA api's.

Thanks everyone!
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: Oliver F. on November 03, 2008, 11:20:58 pm
Quote
I would really like to write an app that would enable my team to kick a report generation off without needing access to the server (through a web interface) or likewise set it up to do a generation based on a schedule.

I saw a while back that a gentlemen was working on this in the forums, i dont know if any of you remember. If not then could you point me to the right place to start investigating the EA api's.

Not sure whether you are refering to me but I did it.
I wrote a daemon in JAVA which sits in the system tray and waits for a scheduled time, then (besides some other tasks) creates a HTML report. In fact it can even be run as a Windows service.

Basically you will have to connect to the repository, identify the root package as a starting point for the export and then trigger the HTML reporting method.

Connect to the repository:


eaRepository = new org.sparx.Repository();        
        if (eaRepository == null)
            {
                errorMessagePopup("No repository available");
                return false;
            }

        if (!eaRepository.OpenFile(CONNECTION))
        {
            errorMessagePopup("EA repository not accessable");
            return false;
        }

        eaRepository.ChangeLoginUser("admin", "...");


We have to change the current login user to be able to have the appropriate rights.

Get the first root package:

         Collection<Package> c = eaRepository.GetModels();

            for (short i=0;i<cp.GetCount();i++)
            {
                pck = cp.GetAt(i);
                pck.ApplyUserLock();
                                        eaProjectInterface.RunHTMLReport(pck.GetPackageGUID(), EXPORTPATH, "png", "<default>", ".html");
               }


This is basically it. I omitted try/catch blocks here for readibility but make sure you catch possible exceptions as often as possible.

I hope this  helps.

Oliver
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: agdunn on November 07, 2008, 06:46:36 am
Thanks so much oliver, Would you mind briefly explaining how you set this up to run as a system tray app or a service?
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: Oliver F. on November 07, 2008, 07:09:52 pm
Quote
Thanks so much oliver, Would you mind briefly explaining how you set this up to run as a system tray app or a service?
This goes beyond EA so it is going to be offtopic.

I can only speak for JAVA apps at the moment, as I did not do it for other languages.

Basically you can search sourceforge.net for a software which encapsulates the windows service API and lets it run as a Windows service.
Search for the terms "JAVA" and "Windows service".

To run it in the system tray SUN has introduced the abstract System.SystemTray class to get access to the instance and the java.awt.TrayIcon API.
If you look in a recent JAVA API documentation you can easily find how to accomplish this. I believe some GUI tutorials from SUN also cover this issue.

Hope this helps.

Oliver
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: Anne on November 25, 2008, 10:02:26 am
This looks promisinga nd I'm going to try to implement it this weekend.  But where do I find the java packages to use on this (i.e. org.sparx.Repository)?
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: Oliver F. on November 25, 2008, 09:05:21 pm
Quote
This looks promisinga nd I'm going to try to implement it this weekend.  But where do I find the java packages to use on this (i.e. org.sparx.Repository)?

From the SparxSystems directory go to EA/Java API
There is a ReadMe which will help you further.

Oliver
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: agdunn on November 26, 2008, 01:12:58 am
Anne let me know if you get anything working, I had started writing this project but had to sideline it  :(

I am hoping to get back to it soon, but dont know when.
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: Anne on November 27, 2008, 03:25:20 am
Quote

From the SparxSystems directory go to EA/Java API
There is a ReadMe which will help you further.

Oliver

Can you give me an exact URL - I'm not having any luck finding the API.
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: Alain Bo on November 27, 2008, 04:14:17 am
C:\Program Files\Sparx Systems\EA\Java API\readme.txt
Title: Re: Automating the HTML Report (Schedule/On Demand
Post by: Anne on November 27, 2008, 04:20:41 am
 ;) thanks.  I was thinking it was a download.