.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "UR::Context::ObjectFabricator 3pm" .TH UR::Context::ObjectFabricator 3pm "2019-01-02" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" UR::Context::ObjectFabricator \- Track closures used to fabricate objects from data sources .SH "DESCRIPTION" .IX Header "DESCRIPTION" Object Fabricators are closures that accept listrefs of data returned by data source iterators, take slices out of them, and construct \s-1UR\s0 objects out of the results. They also handle updating the query cache and merging changed \s-1DB\s0 data with previously cached objects. .PP UR::Context::ObjectFabricator objects are used internally by UR::Context, and not intended to be used directly. .SH "METHODS" .IX Header "METHODS" .IP "create_for_loading_template" 4 .IX Item "create_for_loading_template" .Vb 3 \& my $fab = UR::Context::ObjectFabricator\->create_for_loading_template( \& $context, $loading_tmpl_hashref, $template_data, \& $rule, $rule_template, $values, $dsx); .Ve .Sp Returns an object fabricator instance that is able to construct objects of the rule's target class from rows of data returned by data source iterators. Object fabricators are used a part of the object loading process, and are called by \fBUR::Context::get_objects_for_class_and_rule()\fR to transform a row of data returned by a data source iterator into a \s-1UR\s0 object. .Sp For each class involved in a get request, the system prepares a loading template that describes which columns of the data source data are to be used to construct an instance of that class. For example, in the case where a \fBget()\fR is done on a child class, and the parent and child classes store data in separate tables linked by a relation\-property/foreign\-key, then the query against the data source will involve and \s-1SQL\s0 join (for \s-1RDBMS\s0 data sources). That join will produce a result set that includes data from both tables. .Sp The \f(CW$loading_tmpl_hashref\fR will have information about which columns of that result set map to which properties of each involved class. The heart of the fabricator closure is a list slice extracting the data for that class and assigning it to a hash slice of properties to fill in the initial object data for its class. The remainder of the closure is bookkeeping to keep the object cache ($UR::Context::all_objects_loaded) and query cache ($UR::Context::all_params_loaded) consistent. .Sp The interaction of the object fabricator, the query cache, object cache pruner and object loading iterators that may or may not have loaded all their data requires that the object fabricators keep a list of changes they plan to make to the query cache instead of applying them directly. When the Underlying Context Loading iterator has loaded the last row from the Data Source Iterator, it calls \f(CW\*(C`finalize()\*(C'\fR on the object fabricator to tell it to go ahead and apply its changes; essentially treating that data as a transaction. .IP "all_object_fabricators" 4 .IX Item "all_object_fabricators" .Vb 1 \& my @fabs = UR::Context::ObjectFabricator\->all_object_fabricators(); .Ve .Sp Returns a list of all object fabricators that have not yet been finalized .IP "fabricate" 4 .IX Item "fabricate" .Vb 1 \& my $ur_object = $fab\->fabricate([columns,from,data,source]); .Ve .Sp Given a listref of data pulled from a data source iterator, it slices out the appropriate columns from the list and constructs a single object to return. .IP "is_loading_in_progress_for_boolexpr" 4 .IX Item "is_loading_in_progress_for_boolexpr" .Vb 1 \& my $bool = $fab\->is_loading_in_progress_for_boolexpr($boolexpr); .Ve .Sp Given a UR::BoolExpr instance, it returns true if the given fabricator is prepared to construct objects matching this boolexpr. This is used by UR::Context to know if other iterators are still pulling in objects that could match another iterator's boolexpr, and it should therefore not trust that the object cache is conplete. .IP "finalize" 4 .IX Item "finalize" .Vb 1 \& $fab\->finalize(); .Ve .Sp Indicates to the iterator that the caller is done using it for constructing objects, probably because the data source has no more data or the iterator that was using this fabricator has gone out of scope. .IP "apply_all_params_loaded" 4 .IX Item "apply_all_params_loaded" .Vb 1 \& $fab\->apply_all_params_loaded(); .Ve .Sp As the fabricator constructs objects, it buffers changes to all_params_loaded (the Context's query cache) to maintain consistency if multiple iterators are working concurrently. At the appripriate time, call \fBapply_all_params_loaded()\fR to take those changes and apply them to the current Context's all_params_loaded.