1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <chapter xml:id="data_models_and_access" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="EN"
\r
3 xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink">
\r
5 <title>Evergreen Data Models and Access</title>
\r
7 <abstract id="DM_abstract">
\r
8 <simpara>This chapter was taken from Dan Scott's <emphasis>Developer Workshop</emphasis>, February 2010.</simpara>
\r
10 <section id="exploring_database_schema">
\r
11 <title>Exploring the Database Schema</title>
\r
12 <simpara>The database schema is tied pretty tightly to PostgreSQL. Although PostgreSQL
\r
13 adheres closely to ANSI SQL standards, the use of schemas, SQL functions
\r
14 implemented in both plpgsql and plperl, and PostgreSQL’s native full-text
\r
15 search would make it… challenging… to port to other database platforms.</simpara>
\r
16 <simpara>A few common PostgreSQL interfaces for poking around the schema and
\r
17 manipulating data are:</simpara>
\r
21 psql (the command line client)
\r
26 pgadminIII (a GUI client).
\r
30 <simpara>Or you can read through the source files in Open-ILS/src/sql/Pg.</simpara>
\r
31 <simpara>Let’s take a quick tour through the schemas, pointing out some highlights
\r
32 and some key interdependencies:</simpara>
\r
36 actor.org_unit → asset.copy_location
\r
41 actor.usr → actor.card
\r
46 biblio.record_entry → asset.call_number → asset.copy
\r
51 config.metabib_field → metabib.*_field_entry
\r
55 This documentation also contains an Appendix for the Evergreen <xref linkend="databaseschema"/>.
\r
57 <section id="_database_access_methods">
\r
58 <title>Database access methods</title>
\r
59 <simpara>You could use direct access to the database via Perl DBI, JDBC, etc,
\r
60 but Evergreen offers several database CRUD services for
\r
61 creating / retrieving / updating / deleting data. These avoid tying
\r
62 you too tightly to the current database schema and they funnel database
\r
63 access through the same mechanism, rather than tying up connections
\r
64 with other interfaces.</simpara>
\r
66 <section id="_evergreen_interface_definition_language_idl">
\r
67 <title>Evergreen Interface Definition Language (IDL)</title>
\r
68 <simpara>Defines properties and required permissions for Evergreen classes.
\r
69 To reduce network overhead, a given object is identified via a
\r
70 class-hint and serialized as a JSON array of properties (no named properties).</simpara>
\r
71 <simpara>As of 1.6, fields will be serialized in the order in which they appear
\r
72 in the IDL definition file, and the is_new / is_changed / is_deleted
\r
73 properties are automatically added. This has greatly reduced the size of
\r
74 the <literal>fm_IDL.xml</literal> file and makes DRY people happier :)</simpara>
\r
78 … oils_persist:readonly tells us, if true, that the data lives in the database, but is pulled from the SELECT statement defined in the <oils_persist:source_definition> child element
\r
82 <simplesect id="_idl_basic_example_config_language_map">
\r
83 <title>IDL basic example (config.language_map)</title>
\r
84 <programlisting language="xml" linenumbering="unnumbered"><class id="clm" controller="open-ils.cstore open-ils.pcrud"
\r
85 oils_obj:fieldmapper="config::language_map"
\r
86 oils_persist:tablename="config.language_map"
\r
87 reporter:label="Language Map" oils_persist:field_safe="true"> <co id="dmCO5-1"/> <co id="dmCO5-2"/> <co id="dmCO5-3"/> <co id="dmCO5-4"/>
\r
88 <fields oils_persist:primary="code" oils_persist:sequence=""> <co id="dmCO5-5"/>
\r
89 <field reporter:label="Language Code" name="code"
\r
90 reporter:selector="value" reporter:datatype="text"/> <co id="dmCO5-6"/>
\r
91 <field reporter:label="Language" name="value"
\r
92 reporter:datatype="text" oils_persist:i18n="true"/> <co id="dmCO5-7"/>
\r
95 <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1"> <co id="dmCO5-8"/>
\r
97 <create global_required="true" permission="CREATE_MARC_CODE"> <co id="dmCO5-9"/>
\r
98 <retrieve global_required="true"
\r
99 permission="CREATE_MARC_CODE UPDATE_MARC_CODE DELETE_MARC_CODE">
\r
100 <update global_required="true" permission="UPDATE_MARC_CODE">
\r
101 <delete global_required="true" permission="DELETE_MARC_CODE">
\r
104 </class></programlisting>
\r
106 <callout arearefs="dmCO5-1">
\r
108 The <literal>class</literal> element defines the attributes and permissions for classes,
\r
109 and relationships between classes.
\r
114 The <literal>id</literal> attribute on the <literal>class</literal> element defines the class hint that is
\r
115 used everywhere in Evergreen.
\r
120 The <literal>controller</literal> attribute defines the OpenSRF
\r
121 services that provide access to the data for the class objects.
\r
126 <callout arearefs="dmCO5-2">
\r
128 The <literal>oils_obj::fieldmapper</literal> attribute defines the name of the class that
\r
129 is generated by <literal>OpenILS::Utils::Fieldmapper</literal>.
\r
132 <callout arearefs="dmCO5-3">
\r
134 The <literal>oils_persist:tablename</literal> attribute defines the name of the table
\r
135 that contains the data for the class objects.
\r
138 <callout arearefs="dmCO5-4">
\r
140 The reporter interface uses <literal>reporter:label</literal> attribute values in
\r
141 the source list to provide meaningful class and attribute names. The
\r
142 <literal>open-ils.fielder</literal> service generates a set of methods that provide direct
\r
143 access to the classes for which <literal>oils_persist:field_safe</literal> is <literal>true</literal>. For
\r
146 <screen>srfsh# request open-ils.fielder open-ils.fielder.clm.atomic \
\r
147 {"query":{"code":{"=":"eng"}}}
\r
156 <callout arearefs="dmCO5-5">
\r
158 The <literal>fields</literal> element defines the list of fields for the class.
\r
163 The <literal>oils_persist:primary</literal> attribute defines the column that acts as
\r
164 the primary key for the table.
\r
169 The <literal>oils_persist:sequence</literal> attribute holds the name of the database
\r
175 <callout arearefs="dmCO5-6">
\r
177 Each <literal>field</literal> element defines one property of the class.
\r
182 The <literal>name</literal> attribute defines the getter/setter method name for the field.
\r
187 The <literal>reporter:label</literal> attribute defines the attribute name as used in
\r
188 the reporter interface.
\r
193 The <literal>reporter:selector</literal> attribute defines the field used in the reporter
\r
194 filter interface to provide a selectable list. This gives the user a more
\r
195 meaningful access point than the raw numeric ID or abstract code.
\r
200 The <literal>reporter:datatype</literal> attribute defines the type of data held by
\r
201 this property for the purposes of the reporter.
\r
206 <callout arearefs="dmCO5-7">
\r
208 The <literal>oils_persist:i18n</literal> attribute, when <literal>true</literal>, means that
\r
209 translated values for the field’s contents may be accessible in
\r
213 <callout arearefs="dmCO5-8">
\r
215 The <literal>permacrud</literal> element defines the permissions (if any) required
\r
216 to <emphasis role="strong">c</emphasis>reate, <emphasis role="strong">r</emphasis>etrieve, <emphasis role="strong">u</emphasis>pdate, and <emphasis role="strong">d</emphasis>elete data for this
\r
217 class. <literal>open-ils.permacrud</literal> must be defined as a controller for the class
\r
218 for the permissions to be applied.
\r
221 <callout arearefs="dmCO5-9">
\r
223 Each action requires one or more <literal>permission</literal> values that the
\r
224 user must possess to perform the action.
\r
229 If the <literal>global_required</literal> attribute is <literal>true</literal>, then the user must
\r
230 have been granted that permission globally (depth = 0) to perform
\r
236 The <literal>context_field</literal> attribute denotes the <literal><field></literal> that identifies
\r
237 the org_unit at which the user must have the pertinent permission.
\r
242 An action element may contain a <literal><context_field></literal> element that
\r
243 defines the linked class (identified by the <literal>link</literal> attribute) and
\r
244 the field in the linked class that identifies the org_unit where
\r
245 the permission must be held.
\r
250 If the <literal><context_field></literal> element contains a <literal>jump</literal> attribute,
\r
251 then it defines a link to a link to a class with a field identifying
\r
252 the org_unit where the permission must be held.
\r
261 <simplesect id="_reporter_data_types_and_their_possible_values">
\r
262 <title>Reporter data types and their possible values</title>
\r
266 <literal>bool</literal>: Boolean <literal>true</literal> or <literal>false</literal>
\r
271 <literal>id</literal>: ID of the row in the database
\r
276 <literal>int</literal>: integer value
\r
281 <literal>interval</literal>: PostgreSQL time interval
\r
286 <literal>link</literal>: link to another class, as defined in the <literal><links></literal>
\r
287 element of the class definition
\r
292 <literal>money</literal>: currency amount
\r
297 <literal>org_unit</literal>: list of org_units
\r
302 <literal>text</literal>: text value
\r
307 <literal>timestamp</literal>: PostgreSQL timestamp
\r
312 <simplesect id="_idl_example_with_linked_fields_actor_workstation">
\r
313 <title>IDL example with linked fields (actor.workstation)</title>
\r
314 <simpara>Just as tables often include columns with foreign keys that point
\r
315 to values stored in the column of a different table, IDL classes
\r
316 can contain fields that link to fields in other classes. The <literal><links></literal>
\r
317 element defines which fields link to fields in other classes, and
\r
318 the nature of the relationship:</simpara>
\r
319 <programlisting language="xml" linenumbering="unnumbered"><class id="aws" controller="open-ils.cstore"
\r
320 oils_obj:fieldmapper="actor::workstation"
\r
321 oils_persist:tablename="actor.workstation"
\r
322 reporter:label="Workstation">
\r
323 <fields oils_persist:primary="id"
\r
324 oils_persist:sequence="actor.workstation_id_seq">
\r
325 <field reporter:label="Workstation ID" name="id"
\r
326 reporter:datatype="id"/>
\r
327 <field reporter:label="Workstation Name" name="name"
\r
328 reporter:datatype="text"/>
\r
329 <field reporter:label="Owning Library" name="owning_lib"
\r
330 reporter:datatype="org_unit"/>
\r
331 <field reporter:label="Circulations" name="circulations"
\r
332 oils_persist:virtual="true" reporter:datatype="link"/> <co id="dmCO6-1"/>
\r
334 <links> <co id="dmCO6-2"/>
\r
335 <link field="owning_lib" reltype="has_a" key="id"
\r
336 map="" class="aou"/> <co id="dmCO6-3"/>
\r
337 <link field="circulations" reltype="has_many" key="workstation"
\r
338 map="" class="circ"/>
\r
339 <link field="circulation_checkins" reltype="has_many"
\r
340 key="checkin_workstation" map="" class="circ"/>
\r
342 </class></programlisting>
\r
344 <callout arearefs="dmCO6-1">
\r
346 This field includes an <literal>oils_persist:virtual</literal> attribute with the value of
\r
347 <literal>true</literal>, meaning that the linked class <literal>circ</literal> is a virtual class.
\r
350 <callout arearefs="dmCO6-2">
\r
352 The <literal><links></literal> element contains 0 or more <literal><link></literal> elements.
\r
355 <callout arearefs="dmCO6-3">
\r
357 Each <literal><link></literal> element defines the field (<literal>field</literal>) that links to a different
\r
358 class (<literal>class</literal>), the relationship (<literal>rel_type</literal>) between this field and the target
\r
359 field (<literal>key</literal>). If the field in this class links to a virtual class, the (<literal>map</literal>)
\r
360 attribute defines the field in the target class that returns a list of matching
\r
361 objects for each object in this class.
\r
367 <section id="open_ils_cstore_literal_data_access_interfaces">
\r
368 <title><literal>open-ils.cstore</literal> data access interfaces</title>
\r
369 <simpara>For each class documented in the IDL, the <literal>open-ils.cstore</literal> service
\r
370 automatically generates a set of data access methods, based on the
\r
371 <literal>oils_persist:tablename</literal> class attribute.</simpara>
\r
372 <simpara>For example, for the class hint <literal>clm</literal>, cstore generates the following
\r
373 methods with the <literal>config.language_map</literal> qualifer:</simpara>
\r
377 <literal>open-ils.cstore.direct.config.language_map.id_list {"code" { "like": "e%" } }</literal>
\r
379 <simpara>Retrieves a list composed only of the IDs that match the query.</simpara>
\r
383 <literal>open-ils.cstore.direct.config.language_map.retrieve "eng"</literal>
\r
385 <simpara>Retrieves the object that matches a specific ID.</simpara>
\r
389 <literal>open-ils.cstore.direct.config.language_map.search {"code" : "eng"}</literal>
\r
391 <simpara>Retrieves a list of objects that match the query.</simpara>
\r
395 <literal>open-ils.cstore.direct.config.language_map.create <_object_></literal>
\r
397 <simpara>Creates a new object from the passed in object.</simpara>
\r
401 <literal>open-ils.cstore.direct.config.language_map.update <_object_></literal>
\r
403 <simpara>Updates the object that has been passed in.</simpara>
\r
407 <literal>open-ils.cstore.direct.config.language_map.delete "eng"</literal>
\r
409 <simpara>Deletes the object that matches the query.</simpara>
\r
413 <section id="_open_ils_pcrud_data_access_interfaces">
\r
414 <title>open-ils.pcrud data access interfaces</title>
\r
415 <simpara>For each class documented in the IDL, the <literal>open-ils.pcrud</literal> service
\r
416 automatically generates a set of data access methods, based on the
\r
417 <literal>oils_persist:tablename</literal> class attribute.</simpara>
\r
418 <simpara>For example, for the class hint <literal>clm</literal>, <literal>open-ils.pcrud</literal> generates the following
\r
419 methods that parallel the <literal>open-ils.cstore</literal> interface:</simpara>
\r
423 <literal>open-ils.pcrud.id_list.clm <_authtoken_>, { "code": { "like": "e%" } }</literal>
\r
428 <literal>open-ils.pcrud.retrieve.clm <_authtoken_>, "eng"</literal>
\r
433 <literal>open-ils.pcrud.search.clm <_authtoken_>, { "code": "eng" }</literal>
\r
438 <literal>open-ils.pcrud.create.clm <_authtoken_>, <_object_></literal>
\r
443 <literal>open-ils.pcrud.update.clm <_authtoken_>, <_object_></literal>
\r
448 <literal>open-ils.pcrud.delete.clm <_authtoken_>, "eng"</literal>
\r
453 <section id="_transaction_and_savepoint_control">
\r
454 <title>Transaction and savepoint control</title>
\r
455 <simpara>Both <literal>open-ils.cstore</literal> and <literal>open-ils.pcrud</literal> enable you to control database transactions
\r
456 to ensure that a set of operations either all succeed, or all fail,
\r
457 atomically:</simpara>
\r
461 <literal>open-ils.cstore.transaction.begin</literal>
\r
466 <literal>open-ils.cstore.transaction.commit</literal>
\r
471 <literal>open-ils.cstore.transaction.rollback</literal>
\r
476 <literal>open-ils.pcrud.transaction.begin</literal>
\r
481 <literal>open-ils.pcrud.transaction.commit</literal>
\r
486 <literal>open-ils.pcrud.transaction.rollback</literal>
\r
490 <simpara>At a more granular level, <literal>open-ils.cstore</literal> and <literal>open-ils.pcrud</literal> enable you to set database
\r
491 savepoints to ensure that a set of operations either all succeed, or all
\r
492 fail, atomically, within a given transaction:</simpara>
\r
496 <literal>open-ils.cstore.savepoint.begin</literal>
\r
501 <literal>open-ils.cstore.savepoint.commit</literal>
\r
506 <literal>open-ils.cstore.savepoint.rollback</literal>
\r
511 <literal>open-ils.pcrud.savepoint.begin</literal>
\r
516 <literal>open-ils.pcrud.savepoint.commit</literal>
\r
521 <literal>open-ils.pcrud.savepoint.rollback</literal>
\r
525 <simpara>Transactions and savepoints must be performed within a stateful
\r
526 connection to the <literal>open-ils.cstore</literal> and <literal>open-ils.pcrud</literal> services.
\r
527 In <literal>srfsh</literal>, you can open a stateful connection using the <literal>open</literal>
\r
528 command, and then close the stateful connection using the <literal>close</literal>
\r
529 command - for example:</simpara>
\r
530 <screen>srfsh# open open-ils.cstore
\r
531 ... perform various transaction-related work
\r
532 srfsh# close open-ils.cstore</screen>
\r
533 <simplesect id="_json_queries">
\r
534 <title>JSON Queries</title>
\r
535 <simpara>Beyond simply retrieving objects by their ID using the <literal>\*.retrieve</literal>
\r
536 methods, you can issue queries against the <literal>\*.delete</literal> and <literal>\*.search</literal>
\r
537 methods using JSON to filter results with simple or complex search
\r
538 conditions.</simpara>
\r
539 <simpara>For example, to generate a list of barcodes that are held in a
\r
540 copy location that allows holds and is visible in the OPAC:</simpara>
\r
541 <programlisting language="sh" linenumbering="unnumbered">srfsh# request open-ils.cstore open-ils.cstore.json_query <co id="dmCO7-1"/>
\r
542 {"select": {"acp":["barcode"], "acpl":["name"]}, <co id="dmCO7-2"/>
\r
543 "from": {"acp":"acpl"}, <co id="dmCO7-3"/>
\r
544 "where": [ <co id="dmCO7-4"/>
\r
545 {"+acpl": "holdable"}, <co id="dmCO7-5"/>
\r
546 {"+acpl": "opac_visible"} <co id="dmCO7-6"/>
\r
550 "barcode":"BARCODE1",
\r
555 "barcode":"BARCODE2",
\r
559 <callout arearefs="dmCO7-1">
\r
561 Invoke the <literal>json_query</literal> service.
\r
564 <callout arearefs="dmCO7-2">
\r
566 Select the <literal>barcode</literal> field from the <literal>acp</literal> class and the <literal>name</literal>
\r
567 field from the <literal>acpl</literal> class.
\r
570 <callout arearefs="dmCO7-3">
\r
572 Join the <literal>acp</literal> class to the <literal>acpl</literal> class based on the linked field
\r
573 defined in the IDL.
\r
576 <callout arearefs="dmCO7-4">
\r
578 Add a <literal>where</literal> clause to filter the results. We have more than one
\r
579 condition beginning with the same key, so we wrap the conditions inside
\r
583 <callout arearefs="dmCO7-5">
\r
585 The first condition tests whether the boolean value of the <literal>holdable</literal>
\r
586 field on the <literal>acpl</literal> class is true.
\r
589 <callout arearefs="dmCO7-6">
\r
591 The second condition tests whether the boolean value of the
\r
592 <literal>opac_visible</literal> field on the <literal>acpl</literal> class is true.
\r
596 <simpara>For thorough coverage of the breadth of support offered by JSON
\r
597 query syntax, see <ulink url="http://open-ils.org/dokuwiki/doku.php?id=documentation:technical:jsontutorial">JSON Queries: A Tutorial</ulink>.</simpara>
\r
599 <simplesect id="_fleshing_linked_objects">
\r
600 <title>Fleshing linked objects</title>
\r
601 <simpara>A simplistic approach to retrieving a set of objects that are linked to
\r
602 an object that you are retrieving - for example, a set of call numbers
\r
603 linked to the barcodes that a given user has borrowed - would be to:
\r
604 1. Retrieve the list of circulation objects (<literal>circ</literal> class)
\r
605 for a given user (<literal>usr</literal> class).
\r
606 2. For each circulation object, look up the target copy (<literal>target_copy</literal>
\r
607 field, linked to the <literal>acp</literal> class).
\r
608 3. For each copy, look up the call number for that copy (<literal>call_number</literal>
\r
609 field, linked to the <literal>acn</literal> class).</simpara>
\r
610 <simpara>However, this would result in potentially hundreds of round-trip
\r
611 queries from the client to the server. Even with low-latency connections,
\r
612 the network overhead would be considerable. So, built into the <literal>open-ils.cstore</literal> and
\r
613 <literal>open-ils.pcrud</literal> access methods is the ability to <emphasis>flesh</emphasis> linked fields -
\r
614 that is, rather than return an identifier to a given linked field,
\r
615 the method can return the entire object as part of the initial response.</simpara>
\r
616 <simpara>Most of the interfaces that return class instances from the IDL offer the
\r
617 ability to flesh returned fields. For example, the
\r
618 <literal>open-ils.cstore.direct.\*.retrieve</literal> methods allow you to specify a
\r
619 JSON structure defining the fields you wish to flesh in the returned object.</simpara>
\r
620 <formalpara><title>Fleshing fields in objects returned by <literal>open-ils.cstore</literal></title><para>
\r
621 <programlisting language="sh" linenumbering="unnumbered">srfsh# request open-ils.cstore open-ils.cstore.direct.asset.copy.retrieve 1, \
\r
623 "flesh": 1, <co id="dmCO8-1"/>
\r
624 "flesh_fields": { <co id="dmCO8-2"/>
\r
625 "acp": ["location"]
\r
628 </para></formalpara>
\r
630 <callout arearefs="dmCO8-1">
\r
632 The <literal>flesh</literal> argument is the depth at which objects should be fleshed.
\r
633 For example, to flesh out a field that links to another object that includes
\r
634 a field that links to another object, you would specify a depth of 2.
\r
637 <callout arearefs="dmCO8-2">
\r
639 The <literal>flesh_fields</literal> argument contains a list of objects with the fields
\r
640 to flesh for each object.
\r
644 <simpara>Let’s flesh things a little deeper. In addition to the copy location,
\r
645 let’s also flesh the call number attached to the copy, and then flesh
\r
646 the bibliographic record attached to the call number.</simpara>
\r
647 <formalpara><title>Fleshing fields in fields of objects returned by <literal>open-ils.cstore</literal></title><para>
\r
648 <programlisting language="java" linenumbering="unnumbered">request open-ils.cstore open-ils.cstore.direct.asset.copy.retrieve 1, \
\r
652 "acp": ["location", "call_number"],
\r
656 </para></formalpara>
\r
659 <section id="_adding_an_idl_entry_for_resolverresolver">
\r
660 <title>Adding an IDL entry for ResolverResolver</title>
\r
661 <simpara>Most OpenSRF methods in Evergreen define their object interface in the
\r
662 IDL. Without an entry in the IDL, the prospective caller of a given
\r
663 method is forced to either call the method and inspect the returned
\r
664 contents, or read the source to work out the structure of the JSON
\r
665 payload. At this stage of the tutorial, we have not defined an entry
\r
666 in the IDL to represent the object returned by the
\r
667 <literal>open-ils.resolver.resolve_holdings</literal> method. It is time to complete
\r
668 that task.</simpara>
\r
669 <simpara>The <literal>open-ils.resolver</literal> service is unlike many of the other classes
\r
670 defined in the IDL because its data is not stored in the Evergreen
\r
671 database. Instead, the data is requested from an external Web service
\r
672 and only temporarily cached in <literal>memcached</literal>. Fortunately, the IDL
\r
673 enables us to represent this kind of class by setting the
\r
674 <literal>oils_persist:virtual</literal> class attribute to <literal>true</literal>.</simpara>
\r
675 <simpara>So, let’s add an entry to the IDL for the <literal>open-ils.resolver.resolve_holdings</literal>
\r
677 <programlisting language="xml" linenumbering="unnumbered"></programlisting>
\r
678 <simpara>And let’s make <literal>ResolverResolver.pm</literal> return an array composed of our new
\r
679 <literal>rhr</literal> classes rather than raw JSON objects:</simpara>
\r
680 <programlisting language="perl" linenumbering="unnumbered"></programlisting>
\r
681 <simpara>Once we add the new entry to the IDL and copy the revised <literal>ResolverResolver.pm</literal>
\r
682 Perl module to <literal>/openils/lib/perl5/OpenILS/Application/</literal>, we need to:</simpara>
\r
683 <orderedlist numeration="arabic">
\r
686 Copy the updated IDL to both the <literal>/openils/conf/</literal> and
\r
687 <literal>/openils/var/web/reports/</literal> directories. The Dojo approach to
\r
688 parsing the IDL uses the IDL stored in the reports directory.
\r
693 Restart the Perl services to make the new IDL visible to the services
\r
694 and refresh the <literal>open-ils.resolver</literal> implementation
\r
699 Rerun <literal>/openils/bin/autogen.sh</literal> to regenerate the JavaScript versions
\r
700 of the IDL required by the HTTP translator and gateway.
\r
704 <simpara>We also need to adjust our JavaScript client to use the nifty new
\r
705 objects that <literal>open-ils.resolver.resolve_holdings</literal> now returns.
\r
706 The best approach is to use the support in Evergreen’s Dojo extensions
\r
707 to generate the JavaScript classes directly from the IDL XML file.</simpara>
\r
708 <formalpara><title>Accessing classes defined in the IDL via Fieldmapper</title><para>
\r
709 <programlisting language="html" linenumbering="unnumbered"></programlisting>
\r
710 </para></formalpara>
\r
712 <callout arearefs="">
\r
714 Load the Dojo core.
\r
717 <callout arearefs="">
\r
719 <literal>fieldmapper.AutoIDL</literal> reads <literal>/openils/var/reports/fm_IDL.xml</literal> to
\r
720 generate a list of class properties.
\r
723 <callout arearefs="">
\r
725 <literal>fieldmapper.dojoData</literal> seems to provide a store for Evergreen data
\r
729 <callout arearefs="">
\r
731 <literal>fieldmapper.Fieldmapper</literal> converts the list of class properties into
\r
735 <callout arearefs="">
\r
737 <literal>fieldmapper.standardRequest</literal> invokes an OpenSRF method and returns
\r
738 an array of objects.
\r
741 <callout arearefs="">
\r
743 The first argument to <literal>fieldmapper.standardRequest</literal> is an array
\r
744 containing the OpenSRF service name and method name.
\r
747 <callout arearefs="">
\r
749 The second argument to <literal>fieldmapper.standardRequest</literal> is an array
\r
750 containing the arguments to pass to the OpenSRF method.
\r
753 <callout arearefs="">
\r
755 As Fieldmapper has instantiated the returned objects based on their
\r
756 class hints, we can invoke getter/setter methods on the objects.
\r