EMMAWiki/DeveloperDocumentation/MagemlExporterGenerator: Difference between revisions

From BRF-Software
Jump to navigation Jump to search
imported>KaiRunte
No edit summary
m (6 revisions)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
= Mage-ML Exporter Generator =
= MAGE-ML Exporter Generator =


This page explain how to generate the Mage-ML Exporter and where to find the templates for the generator.
This page explain how to generate the MAGE-ML Exporter and where to find the templates for the generator.
 
== Requirements ==
 
In order to run the MAGE-ML exporter generator you need to have Java (>=1.5) and Apache's Ant (>=1.6) installed.


== Files ==
== Files ==

Latest revision as of 07:17, 26 October 2011

MAGE-ML Exporter Generator

This page explain how to generate the MAGE-ML Exporter and where to find the templates for the generator.

Requirements

In order to run the MAGE-ML exporter generator you need to have Java (>=1.5) and Apache's Ant (>=1.6) installed.

Files

share/perl/EMMA/Exporter/MAGEML.pm -- The generated file.

bin/generate_exporter -- Script for starting the generator.

src/java/mage-ml-generator/templates/ -- The templates used for generating the exporter.

src/java/mage-ml-generator/ -- The project directory of the generator (written in Java). Most likely you will not need to change anything at the Java source-code.

Changing the exporter

Simply change the appropriate template and run the generator by calling bin/generate_exporter. Test the newly generated exporter and commit the MAGEML.pm file and the changed template(s) to the CVS repository with the usual CVS commands.

Finding the appropriate template

Each template creates a comment line in the MAGEML.pm file. If you found the spot you want to change in the MAGEML.pm file, just scroll up to find the closest comment starting with "#Generated by template " to find the template responsible for this section of Perl code.

An Example

Suppose you want to change the configuration of the XML writer in line 45 of MAGEML.pm (at the time point of writing this documentation at least) from: my $writer = new XML::Writer(OUTPUT => *EMMAFH, DATA_INDENT => 2, DATA_MODE => 'true');

to: my $writer = new XML::Writer(OUTPUT => *EMMAFH, DATA_INDENT => 2, DATA_MODE => 'true', UNSAFE => 1);

Looking at the source-code you will the following (or similar):

#Generated by template ExportAllMethod.ftl
sub exportAll {
    my ($self, $output, $referencesHashRef, $logger) = @_;
    if ($output) {
        $logger->info(".zip file: ${output}\n");
        my $tempDirObject = get_tmp_dir_object();
        my $emmaXmlPath = $tempDirObject->dirname();
        my $emmaXmlFile = File::Spec->catdir($emmaXmlPath, "emma_export.xml");
        open (EMMAFH,  ">$emmaXmlFile") or $logger->fatal("Error: opening file $emmaXmlFile\n$!\n");
        $logger->info("Temporary XML file path: ${emmaXmlFile}\n");

        my $writer = new XML::Writer(OUTPUT => *EMMAFH, DATA_INDENT => 2, DATA_MODE => 'true');
...


Apparently the template [[ExportAllMethod]].ftl is responsible for generating this section of code. All you need to do now is loading the template src/java/mage-ml-generator/templates/ExportAllMethod.ftl, change the line, and start the generator by calling bin/generate_exporter. After testing the exporter, do not forget to commit both the MAGEML.pm and the changed template(s) to CVS.