Changeset 22828


Ignore:
Timestamp:
09/09/10 10:43:33 (17 months ago)
Author:
alex
Message:

Made node handling cleaner with attribute methods, and added check for confused xml formats (new constraint style under old-style nodes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/mnw21/pathquery_refactor/intermine/perl/lib/InterMine/Query/Handler.pm

    r22613 r22828  
    3434    is => 'rw', 
    3535    isa => HashRef, 
     36); 
     37 
     38has current_node => ( 
     39    is      => 'ro', 
     40    writer  => 'set_current_node', 
     41    clearer => 'clear_current_node', 
     42    isa     => Str, 
    3643); 
    3744 
     
    101108    elsif ($args->{Name} eq 'node') { 
    102109    my $path = $args->{Attributes}{path}; 
    103     $self->{current_node} = $path; 
     110    $self->set_current_node($path); 
    104111    $query->add_constraint( 
    105112                   path => $path, 
     
    146153    $self->query->add_constraint(%args); 
    147154    } 
     155    elsif ($name eq 'node') { 
     156    $self->clear_current_node; 
     157    } 
    148158    $self->pop_element; 
    149159} 
     
    152162    my $self = shift; 
    153163    my $attr = $self->current_constraint_attr; 
    154     my %args = (path => ($attr->{path} || $self->{current_node}) ); 
     164    confess "Constraint element cannot have a path attribute inside a node" 
     165    if ($attr->{path} and $self->current_node); 
     166    my %args = (path => ($attr->{path} || $self->current_node) ); 
    155167    $args{code}        = $attr->{code} if $attr->{code}; 
    156168    $args{op}          = $attr->{op}   if $attr->{op}; 
Note: See TracChangeset for help on using the changeset viewer.