[open-ils-commits] r9335 - in trunk/Open-ILS: examples src/perlmods/OpenILS/Application

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 14 09:54:42 EDT 2008


Author: miker
Date: 2008-04-14 09:16:42 -0400 (Mon, 14 Apr 2008)
New Revision: 9335

Added:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Fielder.pm
Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
   trunk/Open-ILS/examples/opensrf.xml.example
Log:
adding open-ils.fielder app

Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2008-04-14 12:29:49 UTC (rev 9334)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2008-04-14 13:16:42 UTC (rev 9335)
@@ -1778,7 +1778,7 @@
 			<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" />

Modified: trunk/Open-ILS/examples/opensrf.xml.example
===================================================================
--- trunk/Open-ILS/examples/opensrf.xml.example	2008-04-14 12:29:49 UTC (rev 9334)
+++ trunk/Open-ILS/examples/opensrf.xml.example	2008-04-14 13:16:42 UTC (rev 9335)
@@ -695,6 +695,24 @@
                </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 @@
                 <appname>open-ils.reporter</appname>  
                 <appname>open-ils.reporter-store</appname>  
                 <appname>open-ils.permacrud</appname>  
+                <appname>open-ils.fielder</appname>  
             </activeapps>
         </localhost>
     </hosts>

Added: trunk/Open-ILS/src/perlmods/OpenILS/Application/Fielder.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Fielder.pm	                        (rev 0)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Fielder.pm	2008-04-14 13:16:42 UTC (rev 9335)
@@ -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;
+



More information about the open-ils-commits mailing list