1 package OpenILS::Application::Cat::Utils;
2 use strict; use warnings;
3 use OpenILS::Application::AppUtils;
4 use OpenILS::Utils::Fieldmapper;
7 use OpenSRF::Utils::SettingsParser;
8 use OpenILS::Utils::FlatXML;
9 use OpenILS::Utils::ModsParser;
11 my $mods_utils = OpenILS::Utils::ModsParser->new();
14 #my $parser = XML::LibXML->new();
15 #my $xslt = XML::LibXSLT->new();
16 #my $xslt_doc = $parser->parse_file( "/pines/cvs/ILS/Open-ILS/xsl/MARC21slim2MODS.xsl" );
17 #my $mods_sheet = $xslt->parse_stylesheet( $xslt_doc );
21 $class = ref($class) || $class;
22 return bless( {}, $class );
26 # ---------------------------------------------------------------------------
27 # Converts an XML nodeset into a tree
28 # This method expects a blessed Fieldmapper::biblio::record_node object
30 my($class, $nodeset) = @_;
32 for my $child (@$nodeset) {
33 next unless ($child and defined($child->parent_node));
34 my $parent = $nodeset->[$child->parent_node];
36 warn "No Parent For " . $child->intra_doc_id() . "\n";
38 $parent->children([]) unless defined($parent->children);
41 push( @{$parent->children}, $child );
48 # ---------------------------------------------------------------------------
49 # Converts a tree into an xml nodeset
50 # This method expects a blessed Fieldmapper::biblio::record_node object
54 my($self, $node, $newnodes) = @_;
55 return $newnodes unless $node;
57 if(!$newnodes) { $newnodes = []; }
58 push( @$newnodes, $node );
60 if( $node->children() ) {
62 for my $child (@{ $node->children() }) {
64 new Fieldmapper::biblio::record_node ($child);
65 if(!defined($child->parent_node)) {
66 $child->parent_node($node->intra_doc_id);
67 $child->ischanged(1); #just to be sure
69 $self->tree2nodeset( $child, $newnodes );
73 $node->children([]); #we don't need them hanging around
78 # Removes any deleted nodes from the tree
81 my($self, $nodeset) = @_;
83 for my $node (@$nodeset) {
84 if(!$node->isdeleted() ) {
85 push @newnodes, $node;