summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2006-10-14 01:32:18 +0000
committerfukachan <fukachan>2006-10-14 01:32:18 +0000
commit4fc8c2a7fd0b4e5fd05b4b4278aee08ab3d509d5 (patch)
tree1807b051ec35634b1abe3d2133a0fe6f25e39c6f /fml
parentfde106d53c639085758133b4b30c6311b0c987bf (diff)
downloadfml8-4fc8c2a7fd0b4e5fd05b4b4278aee08ab3d509d5.tar.gz
fml8-4fc8c2a7fd0b4e5fd05b4b4278aee08ab3d509d5.tar.bz2
fml8-4fc8c2a7fd0b4e5fd05b4b4278aee08ab3d509d5.zip
fmlproj: GanttProject XML format extension.
--xml options dump GanttProject XML format by default.
Diffstat (limited to 'fml')
-rw-r--r--fml/etc/command_line_options4
-rw-r--r--fml/lib/FML/Demo/Chart.pm118
-rw-r--r--fml/lib/FML/Demo/Project.pm28
-rw-r--r--fml/lib/FML/Process/Project.pm13
4 files changed, 155 insertions, 8 deletions
diff --git a/fml/etc/command_line_options b/fml/etc/command_line_options
index 713b9975..4b15cbf2 100644
--- a/fml/etc/command_line_options
+++ b/fml/etc/command_line_options
@@ -1,5 +1,5 @@
#
-# $FML: command_line_options,v 1.19 2006/02/01 12:35:45 fukachan Exp $
+# $FML: command_line_options,v 1.20 2006/02/04 06:48:58 fukachan Exp $
#
# map between programs and options
#
@@ -49,7 +49,7 @@ menu.cgi
# demo
fmlsch debug! help! -D=s -F=s -m=s a! h! -o=s%
fmlsch.cgi
-fmlproj debug! html! csv!
+fmlproj debug! html! csv! xml!
# compatibility
fml.pl ctladdr! debug! help! -c=s -o=s%
diff --git a/fml/lib/FML/Demo/Chart.pm b/fml/lib/FML/Demo/Chart.pm
index 3191c928..5583a1f4 100644
--- a/fml/lib/FML/Demo/Chart.pm
+++ b/fml/lib/FML/Demo/Chart.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Chart.pm,v 1.3 2006/09/24 06:18:38 fukachan Exp $
+# $FML: Chart.pm,v 1.4 2006/10/08 09:11:13 fukachan Exp $
#
package FML::Demo::Chart;
@@ -354,6 +354,122 @@ sub print_as_csv
}
+# Descriptions: print as GanttProject XML format.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: none
+sub print_as_xml
+{
+ my ($self) = @_;
+ my $data = $self->{ _data };
+ my $alias = $self->get_alias();
+ my ($column_list) = $self->_generate_column_list();
+ my ($k, $v, $prev_level, $cut_counter);
+
+ # task template
+ my $task_template = q{<task id="__id__" name="__name__" color="#8cb6ce" meeting="false" start="__start__" duration="__duration__" complete="__complete__" priority="__priority__" expand="true"/>};
+
+
+ # main data.
+ $self->_print_xml_preamble();
+ DATA:
+ for my $id (sort {$a <=> $b} keys %$data) {
+ my $template = $task_template;
+ my $is_top = $data->{ $id }->{ item1 } ? 1 : 0;
+ my $is_top_n = $data->{ $id + 1 }->{ item1 } ? 1 : 0;
+ my $name = $data->{ $id }->{ item1 } || $data->{ $id }->{ item2 };
+ my $start = $data->{ $id }->{ start_time } || ''; $start =~ s@/@-@g;
+ my $duration = $data->{ $id }->{ duration } || '0';
+
+ unless ($name) {
+ $name ||= '';
+ print "<!--ignore id=\"$id\" name=\"$name\" -->\n";
+ next DATA;
+ }
+
+ unless ($is_top) {
+ $name =~ s/^/ /;
+ }
+
+ $template =~ s/__id__/$id/g;
+ $template =~ s/__name__/$name/g;
+ $template =~ s/__start__/$start/g;
+ $template =~ s/__duration__/$duration/g;
+ $template =~ s/__complete__/0/g;
+ $template =~ s/__priority__/1/g;
+
+ print $template;
+ print "\n";
+ }
+
+ $self->_print_xml_trailor();
+}
+
+
+# Descriptions: print GanttProject xml format preamble.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: none
+sub _print_xml_preamble
+{
+ print <<_EOF_;
+<?xml version="1.0" encoding="EUC-JP"?>
+<project name="Untitled Gantt Project" company="" webLink="http://" view-date="2006-10-12" view-index="0" gantt-divider-location="316" resource-divider-location="301" version="2.0">
+<description></description>
+<view zooming-state="default:2"/>
+<!-- -->
+<calendars>
+<day-types>
+<day-type id="0"/>
+<day-type id="1"/>
+<calendar id="1" name="default">
+<default-week sun="1" mon="0" tue="0" wed="0" thu="0" fri="0" sat="1"/>
+<overriden-day-types/>
+<days/>
+</calendar>
+</day-types>
+</calendars>
+<tasks color="#8cb6ce">
+<taskproperties>
+<taskproperty id="tpd0" name="type" type="default" valuetype="icon"/>
+<taskproperty id="tpd1" name="priority" type="default" valuetype="icon"/>
+<taskproperty id="tpd2" name="info" type="default" valuetype="icon"/>
+<taskproperty id="tpd3" name="name" type="default" valuetype="text"/>
+<taskproperty id="tpd4" name="begindate" type="default" valuetype="date"/>
+<taskproperty id="tpd5" name="enddate" type="default" valuetype="date"/>
+<taskproperty id="tpd6" name="duration" type="default" valuetype="int"/>
+<taskproperty id="tpd7" name="completion" type="default" valuetype="int"/>
+<taskproperty id="tpd8" name="coordinator" type="default" valuetype="text"/>
+<taskproperty id="tpd9" name="predecessorsr" type="default" valuetype="text"/>
+</taskproperties>
+_EOF_
+}
+
+
+# Descriptions: print GanttProject xml format trailor.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: none
+sub _print_xml_trailor
+{
+ print <<_EOF_;
+</tasks>
+<resources/>
+<allocations/>
+<vacations/>
+<taskdisplaycolumns>
+<displaycolumn property-id="tpd3" order="0" width="75"/>
+<displaycolumn property-id="tpd4" order="1" width="75"/>
+<displaycolumn property-id="tpd5" order="2" width="75"/>
+</taskdisplaycolumns>
+<previous/>
+<roles roleset-name="Default"/>
+</project>
+_EOF_
+
+}
+
+
=head1 UTILITY
=head2 set_format($format)
diff --git a/fml/lib/FML/Demo/Project.pm b/fml/lib/FML/Demo/Project.pm
index b8b5ea75..ea236aaa 100644
--- a/fml/lib/FML/Demo/Project.pm
+++ b/fml/lib/FML/Demo/Project.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Project.pm,v 1.4 2006/10/08 06:33:31 fukachan Exp $
+# $FML: Project.pm,v 1.5 2006/10/08 09:10:27 fukachan Exp $
#
package FML::Demo::Project;
@@ -272,6 +272,18 @@ sub build
for my $day (@$date_list) {
$chart->add($line, $day, $mark);
}
+
+ # save information for GanttProject XML format.
+ my $duration = $#$date_list + 1;
+ $chart->add($line, "duration", $duration);
+ my $range_start = $self->{ _date_range }->[0];
+ $range_start = $self->_canonical_date($range_start);
+ $chart->add($line, "start_time", $date_list->[0] || $range_start);
+ }
+ else {
+ my $range_start = $self->{ _date_range }->[0];
+ $range_start = $self->_canonical_date($range_start);
+ $chart->add($line, "start_time", $date_list->[0] || $range_start);
}
if ($status) {
@@ -315,6 +327,18 @@ sub print_as_csv
}
+# Descriptions: print as GanntProject XML format.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: none
+sub print_as_xml
+{
+ my ($self) = @_;
+ my $chart = $self->{ _chart };
+ $chart->print_as_xml();
+}
+
+
=head1 Japanese Specific Methods
=head2 get_mark_nl()
@@ -348,7 +372,7 @@ if ($0 eq __FILE__) {
my $proj = new FML::Demo::Project;
$proj->parse($file);
$proj->build();
- $proj->print_as_csv();
+ $proj->print_as_xml();
}
diff --git a/fml/lib/FML/Process/Project.pm b/fml/lib/FML/Process/Project.pm
index dae9247e..94f62a33 100644
--- a/fml/lib/FML/Process/Project.pm
+++ b/fml/lib/FML/Process/Project.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2006 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Project.pm,v 1.2 2006/07/09 12:11:13 fukachan Exp $
+# $FML: Project.pm,v 1.3 2006/10/10 09:53:22 fukachan Exp $
#
package FML::Process::Project;
@@ -137,8 +137,11 @@ sub run
elsif (defined $option->{ csv }) {
$proj->print_as_csv();
}
+ elsif (defined $option->{ xml }) {
+ $proj->print_as_xml();
+ }
else {
- $proj->print_as_csv();
+ $proj->print_as_xml();
}
}
@@ -159,10 +162,14 @@ sub help
print <<"_EOF_";
-Usage: $name [--debug] [--html] [--csv]
+Usage: $name [--debug] [--html] [--csv] [--xml]
--debug debug mode on
+--html dump data as html table format
+--csv dump data as CSV
+--xml dump data as GanttProject xml format
+
_EOF_
}