]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Cat/Utils.pm
early catalogue code. currently just turns a nodeset into tree and
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Cat / Utils.pm
1 package OpenILS::Application::Cat::Utils;
2 use strict; use warnings;
3
4 use constant INTRA_DOC  => 2;
5 use constant PARENT             => 3;
6 use constant TYPE                       => 4;
7 use constant NAME                       => 5;
8 use constant VALUE              => 6;
9 use constant CHILDREN   => 7;
10
11
12 # Converts an XML nodeset into a tree
13 sub nodeset2tree {
14         my($class, $nodeset) = @_;
15
16         my $size = @$nodeset;
17         for my $index (0..$size) {
18
19                 my $child = $nodeset->[$index];
20
21                 if( $child and defined($child->[PARENT]) ) {
22                         my $parent = $nodeset->[$child->[PARENT]];
23                         push( @{$parent->[CHILDREN]}, $child );
24                 }
25         }
26         return $nodeset->[0];
27 }
28
29
30 sub tree2nodeset {
31
32 }
33  
34
35 1;