line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2005-2006 IBM Corporation. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# All rights reserved. This program and the accompanying materials |
5
|
|
|
|
|
|
|
# are made available under the terms of the Eclipse Public License v1.0 |
6
|
|
|
|
|
|
|
# which accompanies this distribution, and is available at |
7
|
|
|
|
|
|
|
# http://www.eclipse.org/legal/epl-v10.html |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# File: $Source: /var/lib/cvs/ODO/lib/ODO/Ontology/ObjectWriter.pm,v $ |
10
|
|
|
|
|
|
|
# Created by: Stephen Evanchik( evanchik@us.ibm.com ) |
11
|
|
|
|
|
|
|
# Created on: 03/02/2005 |
12
|
|
|
|
|
|
|
# Revision: $Id: ObjectWriter.pm,v 1.3 2009-11-25 17:58:25 ubuntu Exp $ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Contributors: |
15
|
|
|
|
|
|
|
# IBM Corporation - initial API and implementation |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
package ODO::Ontology::ObjectWriter; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
76
|
|
20
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
93
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
11
|
use ODO::Exception; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
145
|
|
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
104747
|
use Template; |
|
2
|
|
|
|
|
72505
|
|
|
2
|
|
|
|
|
64
|
|
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
2
|
|
23
|
use base qw/ODO/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
195
|
|
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
11
|
use vars qw /$VERSION/; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
781
|
|
29
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/template_filename/); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item serialize( template_data=> \%template_data ) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub serialize { |
50
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
my $parameters = $self->params_to_hash(\@_, 0, undef, {}); |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Parameter::Missing(error=> 'Missing hashref parameter "template_data"') |
54
|
|
|
|
|
|
|
unless(defined($parameters->{'template_data'})); |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Parameter::Invalid(error=> 'Parameter "template_data" must be a hashref') |
57
|
|
|
|
|
|
|
unless(UNIVERSAL::isa($parameters->{'template_data'}, 'HASH')); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $tt = Template->new( |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
INCLUDE_PATH => join(':', @INC), |
62
|
|
|
|
|
|
|
INTERPOLATE => 0, |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Ontology::Template(error=> $Template::ERROR) |
67
|
|
|
|
|
|
|
unless($tt); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $template_results; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $process_results = $tt->process($self->template_filename(), $parameters->{'template_data'}, \$template_results); |
72
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Ontology::TemplateParse(error=> 'Error processing template: ' . $self->template_filename() . ', message: ' . $tt->error()) |
73
|
|
|
|
|
|
|
unless($process_results); |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Ontology::Template(error=> 'Template results are not defined') |
76
|
|
|
|
|
|
|
unless($template_results); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $template_results; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub init { |
84
|
0
|
|
|
0
|
1
|
|
my ($self, $config) = @_; |
85
|
0
|
|
|
|
|
|
$self->params($config, qw/template_filename/); |
86
|
0
|
|
|
|
|
|
return $self |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Copyright (c) 2005-2006 IBM Corporation. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
All rights reserved. This program and the accompanying materials |
97
|
|
|
|
|
|
|
are made available under the terms of the Eclipse Public License v1.0 |
98
|
|
|
|
|
|
|
which accompanies this distribution, and is available at |
99
|
|
|
|
|
|
|
http://www.eclipse.org/legal/epl-v10.html |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |