adding open-ils.fielder app
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Apr 2008 13:16:42 +0000 (13:16 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 14 Apr 2008 13:16:42 +0000 (13:16 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9335 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/examples/opensrf.xml.example
Open-ILS/src/perlmods/OpenILS/Application/Fielder.pm [new file with mode: 0644]

index 5a4ca53..dba433b 100644 (file)
@@ -1778,7 +1778,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="bib_rec" reltype="might_have" key="id" map="" class="rhrr"/>
                </links>
        </class>
-       <class id="aou" controller="open-ils.cstore" oils_obj:fieldmapper="actor::org_unit" oils_persist:tablename="actor.org_unit" reporter:label="Organizational Unit">
+       <class id="aou" controller="open-ils.cstore" oils_obj:fieldmapper="actor::org_unit" oils_persist:tablename="actor.org_unit" reporter:label="Organizational Unit" oils_persist:field_safe="true">
                <fields oils_persist:primary="id" oils_persist:sequence="actor.org_unit_id_seq">
                        <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
                        <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
index d75bcba..f3d8d30 100644 (file)
@@ -695,6 +695,24 @@ vim:et:ts=4:sw=4:
                </unix_config>
             </open-ils.permacrud>
 
+            <open-ils.fielder>
+               <keepalive>3</keepalive>
+               <stateless>1</stateless>
+               <language>perl</language>
+               <implementation>OpenILS::Application::Fielder</implementation>
+               <max_requests>17</max_requests>
+               <unix_config>
+                  <unix_sock>open-ils.fielder_unix.sock</unix_sock>
+                  <unix_pid>open-ils.fielder_unix.pid</unix_pid>
+                  <max_requests>1000</max_requests>
+                  <unix_log>open-ils.fielder_unix.log</unix_log>
+                  <min_children>5</min_children>
+                  <max_children>15</max_children>
+                  <min_spare_children>3</min_spare_children>
+                  <max_spare_children>5</max_spare_children>
+               </unix_config>
+            </open-ils.fielder>
+
         </apps>
     </default>
 
@@ -729,6 +747,7 @@ vim:et:ts=4:sw=4:
                 <appname>open-ils.reporter</appname>  
                 <appname>open-ils.reporter-store</appname>  
                 <appname>open-ils.permacrud</appname>  
+                <appname>open-ils.fielder</appname>  
             </activeapps>
         </localhost>
     </hosts>
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Fielder.pm b/Open-ILS/src/perlmods/OpenILS/Application/Fielder.pm
new file mode 100644 (file)
index 0000000..c555d70
--- /dev/null
@@ -0,0 +1,109 @@
+# vim:et:ts=4:sw=4:
+
+package OpenILS::Application::Fielder;
+use OpenILS::Application;
+use base qw/OpenILS::Application/;
+
+use Unicode::Normalize;
+use OpenSRF::EX qw/:try/;
+
+use OpenSRF::AppSession;
+use OpenSRF::Utils::SettingsClient;
+use OpenSRF::Utils::Logger qw/:level/;
+
+use OpenILS::Utils::Fieldmapper;
+use OpenSRF::Utils::JSON;
+
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+
+use XML::LibXML;
+use XML::LibXML::XPathContext;
+use XML::LibXSLT;
+
+our %namespace_map = (
+    oils_persist=> {ns => 'http://open-ils.org/spec/opensrf/IDL/persistence/v1'},
+    oils_obj    => {ns => 'http://open-ils.org/spec/opensrf/IDL/objects/v1'},
+    idl         => {ns => 'http://opensrf.org/spec/IDL/base/v1'},
+    reporter    => {ns => 'http://open-ils.org/spec/opensrf/IDL/reporter/v1'},
+    perm        => {ns => 'http://open-ils.org/spec/opensrf/IDL/permacrud/v1'},
+);
+
+
+my $log = 'OpenSRF::Utils::Logger';
+
+my $parser = XML::LibXML->new();
+my $xslt = XML::LibXSLT->new();
+
+my $xpc = XML::LibXML::XPathContext->new();
+$xpc->registerNs($_, $namespace_map{$_}{ns}) for ( keys %namespace_map );
+
+my $idl;
+
+sub initialize {
+
+    my $conf = OpenSRF::Utils::SettingsClient->new;
+    my $idl_file = $conf->config_value( 'IDL' );
+
+    $idl = $parser->parse_file( $idl_file );
+
+    $log->debug( 'IDL XML file loaded' );
+
+    generate_methods();
+
+}
+sub child_init {}
+
+sub CRUD_action_object_permcheck {
+    my $self = shift;
+    my $client = shift;
+    my $obj = shift;
+
+    my $query = $obj->{query};
+    my $fields = $obj->{fields};
+
+    return undef unless $fields;
+    return undef unless $query;
+
+    $fields = [$fields] if (!ref($fields));
+
+    my $e = new_editor();
+
+    my $obj_class = $self->{class_hint};
+
+    my $req = $e-json_query({
+        select  => { $obj_class => $fields },
+        from    => $obj_class,
+        where   => $query
+    });
+
+    while (my $res = $req->recv) {
+        $client->respond($res->content);
+    }
+
+    return undef;
+
+}
+
+sub generate_methods {
+    try {
+        for my $class_node ( $xpc->findnodes( '//idl:class[@oils_persist:field_safe="true"]', $idl->documentElement ) ) {
+            my $hint = $class_node->getAttribute('id');
+            $log->debug("Fielder class_node $hint");
+        
+            __PACKAGE__->register_method(
+                method          => 'CRUD_action_object_permcheck',
+                api_name        => 'open-ils.fielder.' . $hint,
+                class_hint      => $hint,
+                stream          => 1,
+                argc            => 1
+            );
+        }
+    } catch Error with {
+        my $e = shift;
+        $log->error("error generating Fielder methods: $e");
+    };
+}
+
+
+1;
+