__PACKAGE__->register_method(
method => "create_session",
- api_name => "open-ils.url_verify.create_session",
+ api_name => "open-ils.url_verify.session.create",
signature => {
desc => q/Create a URL verify session. Also automatically create and
link a container./,
return $e->data->id;
}
-# _check_for_existing_bucket_items() is used later by session_perform_search()
+# _check_for_existing_bucket_items() is used later by session_search_and_extract()
sub _check_for_existing_bucket_items {
my ($e, $session) = @_;
return;
}
-# _get_all_search_results() is used later by session_perform_search()
+# _get_all_search_results() is used later by session_search_and_extract()
sub _get_all_search_results {
my ($client, $session) = @_;
__PACKAGE__->register_method(
- method => "session_perform_search",
- api_name => "open-ils.url_verify.session_perform_search",
+ method => "session_search_and_extract",
+ api_name => "open-ils.url_verify.session.search_and_extract",
+ stream => 1,
signature => {
desc => q/
Perform the search contained in the session,
- populating the linked bucket /,
+ populating the linked bucket, and extracting URLs /,
params => [
{desc => "Authentication token", type => "string"},
{desc => "url_verify.session id", type => "number"},
],
return => {
- desc => "Number of search results on success, event on failure",
+ desc => q/stream of numbers: first number of search results, then
+ numbers of extracted URLs for each record, grouped into arrays
+ of 10/,
type => "number"
}
}
);
-# XXX TODO send progress updates?
-sub session_perform_search {
+sub session_search_and_extract {
my ($self, $client, $auth, $ses_id) = @_;
my $e = new_editor(authtoken => $auth);
# Make and save a bucket item for each search result.
my $pos = 0;
+ my @item_ids;
+
+ # There's an opportunity below to parallelize the extraction of URLs if
+ # we need to.
+
foreach my $bre_id (@result_ids) {
my $bucket_item =
Fieldmapper::container::biblio_record_entry_bucket_item->new;
$e->create_container_biblio_record_entry_bucket_item($bucket_item) or
return $e->die_event;
+
+ push @item_ids, $e->data->id;
}
+
$e->xact_commit;
- return $pos;
+ $client->respond($pos); # first response: the number of items created
+ # (number of search results)
+
+ $pos = 0;
+ my @url_counts;
+
+ # For each contain item, extract URLs. Report counts of URLs extracted
+ # from each record in batches at every ten records.
+
+ foreach my $item_id (@item_ids) {
+ my $res = $e->json_query({
+ from => ["url_verify.extract_urls", $ses_id, $item_id]
+ }) or return $e->die_event;
+
+ push @url_counts, $res->[0]{extract_urls};
+
+ if (++$pos % 10 == 0) {
+ $client->respond(\@url_counts);
+ @url_counts = ();
+ }
+ }
+
+ $client->respond(\@url_counts) if @url_counts;
+
+ $e->disconnect;
+ return;
}
+
1;
--- /dev/null
+[% WRAPPER base.tt2 %]
+[% ctx.page_title = 'Link Checker - Select URLs' %]
+<script type="text/javascript">
+ dojo.require("dijit.form.Button");
+ dojo.require("openils.widget.FlattenerGrid");
+</script>
+<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ <div dojoType="dijit.layout.ContentPane"
+ layoutAlign="top" class="oils-header-panel">
+ <div>[% ctx.page_title %]</div>
+ <div>
+ <!-- XXX any buttons needed go here -->
+ </div>
+ </div>
+ <!-- <div class="oils-acq-basic-roomy">
+ <label for="org_selector">Show the pull list for:</label>
+ <select
+ id="org_selector" jsId="org_selector"
+ dojoType="openils.widget.OrgUnitFilteringSelect"
+ searchAttr="name" labelAttr="name">
+ </select>
+ </div> -->
+ <table
+ jsid="grid"
+ dojoType="openils.widget.FlattenerGrid"
+ columnPersistKey='"url_verify.select_url"'
+ autoHeight="10"
+ editOnEnter="false"
+ autoCoreFields="true"
+ autoFieldFields="[]"
+ showLoadFilter="true"
+ fmClass="'uvsbrem'" >
+ <thead>
+ <tr>
+ </tr>
+ </thead>
+ </table>
+</div>
+[% END %]
{
"CREATING": "Creating session ...",
"SAVING_TAGS": "Saving tag/subfield selectors ...",
- "PERFORMING_SEARCH": "Performing search ..."
+ "PERFORMING_SEARCH": "Performing search ...",
+ "EXTRACTING_URLS": "Extracting URLs..."
}
progress_dialog.attr("title", localeStrings.CREATING);
progress_dialog.show(true);
fieldmapper.standardRequest(
- ["open-ils.url_verify", "open-ils.url_verify.create_session"], {
+ ["open-ils.url_verify", "open-ils.url_verify.session.create"], {
"params": [openils.User.authtoken, name, search],
"async": true,
"onresponse": function(r) {
if (r = openils.Util.readResponse(r)) {
- create_session.session_id = r; /* we're modal enough to get away with this */
+ /* I think we're modal enough to get away with this. */
+ create_session.session_id = r;
create_session.save_tags();
}
}
};
/* 3) search and populate the container (API call). */
+ var search_result_count = 0;
create_session.perform_search = function() {
progress_dialog.attr("title", localeStrings.PERFORMING_SEARCH);
progress_dialog.show(true);
fieldmapper.standardRequest(
- ["open-ils.url_verify", "open-ils.url_verify.session_perform_search"], {
+ ["open-ils.url_verify",
+ "open-ils.url_verify.session.search_and_extract"], {
"params": [openils.User.authtoken, create_session.session_id],
"async": true,
"onresponse": function(r) {
- /* XXX atm, this responds with the number of created results */
r = openils.Util.readResponse(r);
- progress_dialog.hide();
+ if (!search_result_count) {
+ search_result_count = Number(r);
+ console.log("search_result_count: " + r);
+
+ progress_dialog.show(); /* sic */
+ progress_dialog.attr(
+ "title", localeStrings.EXTRACTING_URLS
+ );
+ progress_dialog.update(
+ {"maximum": search_result_count, "progress": 0}
+ );
+ } else {
+ console.log("r.length: " + r.length);
+ progress_dialog.update({"progress": r.length})
+ }
+ },
+ "oncomplete": function() {
progress_dialog.attr("title", "");
-
+ progress_dialog.hide();
console.warn("XXX TODO redirect to next interface");
}
}