File Coverage

blib/lib/WebService/Cmis/PropertyDefinition.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package WebService::Cmis::PropertyDefinition;
2              
3             =head1 NAME
4              
5             WebService::Cmis::PropertyDefinition
6              
7             =head1 SYNOPSIS
8              
9             =head1 DESCRIPTION
10              
11             This class represents a property definition of an object type
12             type.
13              
14             =cut
15              
16 1     1   21432 use strict;
  1         59  
  1         64  
17 1     1   93 use warnings;
  1         2  
  1         48  
18 1     1   835 use XML::LibXML qw(:libxml);
  0            
  0            
19             use Error qw(:try);
20              
21             =head1 METHODS
22              
23             =over 4
24              
25             =item new(%params)
26              
27             constructur. %params must provide an xmlDoc property.
28              
29             =cut
30              
31             sub new {
32             my $class = shift;
33              
34             my $this= bless({@_}, $class);
35              
36             }
37              
38             =item getAttributes -> %attrs
39              
40             returns a hash of attributes of this property definition
41              
42             =cut
43              
44             sub getAttributes {
45             my $this = shift;
46              
47             unless (defined $this->{attributes}) {
48             throw Error::Simple("no xmlDoc while reading attributes") unless defined $this->{xmlDoc};
49              
50             $this->{attributes} = ();
51             foreach my $node ($this->{xmlDoc}->childNodes) {
52             next unless $node->nodeType eq XML_ELEMENT_NODE;
53             my $key = $node->nodeName;
54             $key =~ s/^cmis://g;
55             $this->{attributes}{$key} = $node->string_value;
56             }
57             }
58              
59             return $this->{attributes};
60             }
61              
62             =item getAttribute($name) -> $value
63              
64             getter to retrieve the attribute values
65              
66             =cut
67              
68             sub getAttribute {
69             return $_[0]->getAttributes->{$_[1]};
70             }
71              
72             =item toString
73              
74             returns a string representation of this cmis property
75              
76             =cut
77              
78             sub toString {
79             return $_[0]->getId;
80             }
81              
82             =item getId
83              
84             getter for cmis:id
85              
86             =cut
87              
88             sub getId {
89             return $_[0]->getAttribute("id");
90             }
91              
92              
93             =item getCardinality
94              
95             getter for cmis:cardinality
96              
97             =cut
98              
99             sub getCardinality {
100             return $_[0]->getAttribute("cardinality");
101             }
102              
103             =item getDescription
104              
105             getter for cmis:description
106              
107             =cut
108              
109             sub getDescription {
110             return $_[0]->getAttribute("description");
111             }
112              
113             =item getDisplayName
114              
115             getter for cmis:displayName
116              
117             =cut
118              
119             sub getDisplayName {
120             return $_[0]->getAttribute("displayName");
121             }
122              
123             =item getLocalName
124              
125             getter for cmis:localName
126              
127             =cut
128              
129             sub getLocalName {
130             return $_[0]->getAttribute("localName");
131             }
132              
133             =item getLocalNamespace
134              
135             getter for cmis:localNamespace
136              
137             =cut
138              
139             sub getLocalNamespace {
140             return $_[0]->getAttribute("localNamespace");
141             }
142              
143             =item getPropertyType
144              
145             getter for cmis:propertyType
146              
147             =cut
148              
149             sub getPropertyType {
150             return $_[0]->getAttribute("propertyType");
151             }
152              
153             =item getQueryName
154              
155             getter for cmis:queryName
156              
157             =cut
158              
159             sub getQueryName {
160             return $_[0]->getAttribute("queryName");
161             }
162              
163             =item getUpdatability
164              
165             getter for cmis:updatability
166              
167             =cut
168              
169             sub getUpdatability {
170             return $_[0]->getAttribute("updatability");
171             }
172              
173             =item isInherited
174              
175             getter for cmis:inherited
176              
177             =cut
178              
179             sub isInherited {
180             require WebService::Cmis::Property;
181             return WebService::Cmis::Property::parseBoolean($_[0]->getAttribute("inherited"));
182             }
183              
184             =item isOpenChoice
185              
186             getter for cmis:openchoice
187              
188             =cut
189              
190             sub isOpenChoice {
191             require WebService::Cmis::Property;
192             return WebService::Cmis::Property::parseBoolean($_[0]->getAttribute("openChoice"));
193             }
194              
195             =item isOrderable
196              
197             getter for cmis:orderable
198              
199             =cut
200              
201             sub isOrderable {
202             require WebService::Cmis::Property;
203             return WebService::Cmis::Property::parseBoolean($_[0]->getAttribute("orderable"));
204             }
205              
206             =item isQueryable
207              
208             getter for cmis:queryable
209              
210             =cut
211              
212             sub isQueryable {
213             require WebService::Cmis::Property;
214             return WebService::Cmis::Property::parseBoolean($_[0]->getAttribute("queryable"));
215             }
216              
217             =item isRequired
218              
219             getter for cmis:required
220              
221             =cut
222              
223             sub isRequired {
224             require WebService::Cmis::Property;
225             return WebService::Cmis::Property::parseBoolean($_[0]->getAttribute("required"));
226             }
227              
228             =back
229              
230             =head1 AUTHOR
231              
232             Michael Daum C<< >>
233              
234             =head1 COPYRIGHT AND LICENSE
235              
236             Copyright 2012-2013 Michael Daum
237              
238             This module is free software; you can redistribute it and/or modify it under
239             the same terms as Perl itself. See F.
240              
241             =cut
242              
243             1;