Export to MDZIP from a teamwork server project

General discussions about teamwork

Moderator: Moderators

Export to MDZIP from a teamwork server project

Postby grrdoogle77 » Fri May 21, 2010 9:03 am

Good day everyone,


in version 15.5 of the toolset (MagicDraw + TeamWork), it is possible with exportEMF2XMI to export a teamwork project server to an EMF file knowing a project_descriptor.
Is there a similar plugin that would produce a .mdzip file?


My needs are the following: I need to produce artefacts consistent with each other:
  • a report via the report generator
  • a code generation via MIA generation

I could accomplish that with exportEMF2XMI and reportGenerator.
But I can see 2 cons to that. My understanding of the 2 tools is that:
  • the specification of a team server differ from the 2 tools (project_descriptor=teamwork://... for exportEMF2XMI vs. a 3-uple (-server -login -password) for
    reportGenerator
  • in our context, the each operation can be long and there might be a commit between the 2 calls.

That's why I was wondering whether there was a mean to take first a snapshot of the teamwork server.


Thanks in advance
Best regards,

-- R
grrdoogle77
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:0
Joined: Fri May 21, 2010 8:44 am

Re: Export to MDZIP from a teamwork server project

Postby marlel » Tue Jun 01, 2010 5:04 am

Hello,

There are two options.
1) Open teamwork project, generate the report and export to EMF XMI through API.
E.g.
Code: Select all
   public static void main(String[] args)
   {
      Application application = Application.getInstance();
      try
      {
         application.start(false, true, false, new String[0], null);

         try
         {
            // load temwork project
            String remoteName = "teamworkProjectName";
            ProjectDescriptor projectDescriptor = TeamworkUtils
                  .getRemoteProjectDescriptorByQualifiedName(remoteName);
            ProjectsManager projectsManager = application.getProjectsManager();
            projectsManager.loadProject(projectDescriptor, true);

            Project project = application.getProject();
            if (project != null)
            {
               String templateName = "Class Specification Report";
               // get template bean
               TemplateBean templateBean = null;
               List templateList = TemplateHelper.listTemplates();
               for (int i = 0; i < templateList.size(); i++)
               {
                  String name = ((TemplateBean) templateList.get(i)).getName();
                  if (name.equals(templateName))
                  {
                     templateBean = (TemplateBean) templateList.get(i);
                     break;
                  }
               }
               // clone default report bean
               ReportBean reportBean = (ReportBean) templateBean.getDefaultReport().clone();

               // generate task use selected report to generate report
               templateBean.setSelectedReport(reportBean);

               // set selected package id.
               reportBean.getSelectedPackage()
                     .setPackageIds(new String[]{"eee_1045467100313_135436_1"});

               reportBean.getReportProperty().setOutputFile("d:\\_test\\test.rtf");
               // generate report
               try
               {
                  new GenerateTask(templateBean).execute();
               }
               catch (Exception e)
               {
                  throw new TemplateException(e);
               }

               // export to EMF XMI
               EmfUml2XmiPlugin.getInstance().exportXMI(project, "d:\\_test");
            }
         }
         catch (Exception e)
         {
            e.printStackTrace();
         }

         application.shutdown();
      }
      catch (ApplicationExitedException e)
      {
         e.printStackTrace();
      }
   }


2) Open teamwork project save it locally and then work with the saved file.
Code: Select all
try
         {
            Application application = Application.getInstance();
            application.start(false, true, false, new String[0], null);
            
            String remoteName = "teamworkProjectName";
            ProjectDescriptor projectDescriptor = TeamworkUtils
                  .getRemoteProjectDescriptorByQualifiedName(remoteName);
            ProjectsManager projectsManager = application.getProjectsManager();
            projectsManager.loadProject(projectDescriptor, true);

            Project project = application.getProject();
            if (project != null)
            {
               ProjectDescriptor localProjectDescriptor = ProjectDescriptorsFactory
                     .createLocalProjectDescriptor(project, new
                           File("d:\\testTW.mdzip"));
               projectsManager.saveProject(localProjectDescriptor, true);
            }
            
            application.shutdown();
         }
         catch (RemoteException e)
         {
            e.printStackTrace();
         }
         catch (ApplicationExitedException e)
         {
            e.printStackTrace();
         }


Before executing any of these code samples, you should start MagicDraw, login to the required Teamwork Server (in the login dialog select "Auto login to
server") and exit.
When starting these samples specify the java system property install.root=<MagicDraw installation directory>, also change the default the java heap size values (e.g. -Xmx900M -Xss2M -XX:PermSize=40M -XX:MaxPermSize=150M)

Do not forget to add jars in your class path: all jar's (except md_commontw.jar and md_commontw_api.jar) recursively from <MagicDraw installation directory>/lib, and jars from <MagicDraw installation directory>/plugins/com.nomagic.magicdraw.reportwizard, <MagicDraw installation directory>/plugins/com.nomagic.magicdraw.reportwizard/lib, <MagicDraw installation directory>/plugins/com.nomagic.magicdraw.emfuml2xmi_v2, <MagicDraw installation directory>/plugins/com.nomagic.magicdraw.emfuml2xmi_v2/lib.
marlel
 
Posts Rating:


Return to Merging, branching, modules, team collaboration

Who is online

Users browsing this forum: No registered users and 0 guests