EMMAWiki/DeveloperDocumentation/MagemlExporterGenerator: Difference between revisions
imported>KaiRunte No edit summary |
imported>KaiRunte No edit summary |
||
Line 16: | Line 16: | ||
== Changing the exporter == | == Changing the exporter == | ||
Simply change the appropriate template and run the generator by calling <code><nowiki>bin/generate_exporter</nowiki></code>. Test the newly generated exporter and | Simply change the appropriate template and run the generator by calling <code><nowiki>bin/generate_exporter</nowiki></code>. 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 == | == 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. | 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: | |||
<code><nowiki>my $writer = new XML::Writer(OUTPUT => *EMMAFH, DATA_INDENT => 2, DATA_MODE => 'true');</nowiki></code> | |||
to: | |||
<code><nowiki>my $writer = new XML::Writer(OUTPUT => *EMMAFH, DATA_INDENT => 2, DATA_MODE => 'true', UNSAFE => 1);</nowiki></code> | |||
Looking at the source-code you will the following (or similar): | |||
<pre><nowiki> | |||
#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'); | |||
... | |||
</nowiki></pre> | |||
Apparently the template [[ExportAllMethod]].ftl is responsible for generating this section of code. All you need to do now is loading the template <code><nowiki>src/java/mage-ml-generator/templates/ExportAllMethod.ftl</nowiki></code>, change the line, and start the generator by calling <code><nowiki>bin/generate_exporter</nowiki></code>. After testing the exporter, do not forget to commit both the MAGEML.pm and the changed template(s) to CVS. |
Revision as of 11:54, 13 September 2007
Mage-ML Exporter Generator
This page explain how to generate the Mage-ML Exporter and where to find the templates for the generator.
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.