3 package OpenILS::Application::Fielder;
4 use OpenILS::Application;
5 use base qw/OpenILS::Application/;
7 use Unicode::Normalize;
8 use OpenSRF::EX qw/:try/;
10 use OpenSRF::AppSession;
11 use OpenSRF::Utils::SettingsClient;
12 use OpenSRF::Utils::Logger qw/:level/;
14 use OpenILS::Utils::Fieldmapper;
15 use OpenSRF::Utils::JSON;
17 use OpenILS::Utils::CStoreEditor qw/:funcs/;
20 use XML::LibXML::XPathContext;
23 our %namespace_map = (
24 oils_persist=> {ns => 'http://open-ils.org/spec/opensrf/IDL/persistence/v1'},
25 oils_obj => {ns => 'http://open-ils.org/spec/opensrf/IDL/objects/v1'},
26 idl => {ns => 'http://opensrf.org/spec/IDL/base/v1'},
27 reporter => {ns => 'http://open-ils.org/spec/opensrf/IDL/reporter/v1'},
28 perm => {ns => 'http://open-ils.org/spec/opensrf/IDL/permacrud/v1'},
32 my $log = 'OpenSRF::Utils::Logger';
34 my $parser = XML::LibXML->new();
35 my $xslt = XML::LibXSLT->new();
37 my $xpc = XML::LibXML::XPathContext->new();
38 $xpc->registerNs($_, $namespace_map{$_}{ns}) for ( keys %namespace_map );
44 my $conf = OpenSRF::Utils::SettingsClient->new;
45 my $idl_file = $conf->config_value( 'IDL' );
47 $idl = $parser->parse_file( $idl_file );
49 $log->debug( 'IDL XML file loaded' );
56 sub CRUD_action_object_permcheck {
61 my $query = $obj->{query};
62 my $fields = $obj->{fields};
64 return undef unless $fields;
65 return undef unless $query;
67 $fields = [$fields] if (!ref($fields));
71 my $obj_class = $self->{class_hint};
73 my $req = $e-json_query({
74 select => { $obj_class => $fields },
79 while (my $res = $req->recv) {
80 $client->respond($res->content);
87 sub generate_methods {
89 for my $class_node ( $xpc->findnodes( '//idl:class[@oils_persist:field_safe="true"]', $idl->documentElement ) ) {
90 my $hint = $class_node->getAttribute('id');
91 $log->debug("Fielder class_node $hint");
93 __PACKAGE__->register_method(
94 method => 'CRUD_action_object_permcheck',
95 api_name => 'open-ils.fielder.' . $hint,
103 $log->error("error generating Fielder methods: $e");