annotate Lib/IMPL/DOM/Schema/Property.pm @ 245:7c517134c42f

Added Unsupported media type Web exception corrected resourceLocation setting in the resource Implemented localizable resources for text messages fixed TT view scopings, INIT block in controls now sets globals correctly.
author sergey
date Mon, 29 Oct 2012 03:15:22 +0400
parents b8c724f6de36
children 0f59b2de72af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
1 package IMPL::DOM::Schema::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
4
165
76515373dac0 Added Class::Template,
wizard
parents: 152
diff changeset
5 use parent qw(IMPL::DOM::Schema::SimpleNode);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
6 require IMPL::DOM::Schema;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
7 require IMPL::DOM::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
8 use IMPL::Class::Property;
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 104
diff changeset
9 use IMPL::DOM::Property qw(_dom);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
11 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
12
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
13 BEGIN {
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 104
diff changeset
14 public _dom property messageRequired => prop_all;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
15 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
16
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
17 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
18 'IMPL::DOM::Schema::SimpleNode' => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
19 my %args = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
21 $args{maxOccur} = 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
22 $args{minOccur} = delete $args{optional} ? 0 : 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
23 $args{nodeName} ||= 'Property';
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
24 $args{messageInflateError} ||= "Failed to inflate a property '%schema.name%' of a node '%node.path%': %error.message%";
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
25
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
26 return %args;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
27 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
28 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
30 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
31 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
32
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
33 $this->messageRequired($args{messageRequired} || 'A property %schema.name% is required in the %node.qname%');
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
34 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
35
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
36 sub Validate {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
37 my ($this,$node,$ctx) = @_;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
38
103
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
39 my $prop = $this->name;
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
40
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
41 # buld a pseudo node for the property value
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
42 my $nodeProp = new IMPL::DOM::Node(nodeName => '::property', nodeValue => eval { $node->$prop() } || $node->nodeProperty($prop));
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
43
103
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
44 if ($nodeProp->nodeValue) {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
45 # we have a value so validate it
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
46 return $this->SUPER::Validate($nodeProp,$ctx);
103
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
47 } elsif($this->minOccur) {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
48 # we don't have a value but it's a mandatory property
103
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
49 return new IMPL::DOM::Schema::ValidationError(
236
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
50 message => $this->messageRequired,
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
51 node => $node,
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
52 schema => $this,
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
53 source => $ctx && $ctx->{Source} || $this
103
c289ed9662ca Schema beta 2
wizard
parents: 101
diff changeset
54 );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
55 }
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
56 return ();
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
57 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
58
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 25
diff changeset
59 1;