| 600 | } |
| 601 | |
| 602 | bool RemoteBCL::startComponentLibraryMetaSearch(const std::string& searchTerm, const std::string& componentType, const std::string& filterType) { |
| 603 | // can't start another request until last one is done |
| 604 | if (m_httpResponse && !m_httpResponse->is_done()) { |
| 605 | return false; |
| 606 | } |
| 607 | |
| 608 | m_lastMetaSearch.reset(); |
| 609 | |
| 610 | auto client = getClient(remoteUrl(), m_timeOutSeconds); |
| 611 | web::uri_builder builder(to_string_t("/api/metasearch/")); |
| 612 | |
| 613 | // web::uri::encode_data_string will Encodes a string by converting all characters |
| 614 | // except for RFC 3986 unreserved characters to their hexadecimal representation. (eg: '+' => %2B, ' ' => %20) |
| 615 | std::string query = searchTerm.empty() ? "*" : searchTerm; |
| 616 | builder.append_path(web::uri::encode_data_string(utility::conversions::to_string_t(query + ".xml"))); |
| 617 | |
| 618 | builder.append_query(to_string_t("fq[]"), to_string_t("bundle:" + filterType)); |
| 619 | |
| 620 | if (!componentType.empty() && componentType != "*") { |
| 621 | std::string filter = (filterType == "nrel_component") ? "sm_vid_Component_Tags" : "sm_vid_Measure_Tags"; |
| 622 | filter += ":\"" + componentType + "\""; |
| 623 | builder.append_query(to_string_t("fq[]"), to_string_t(filter)); |
| 624 | } |
| 625 | |
| 626 | builder.append_query(to_string_t("api_version"), to_string_t(m_apiVersion)); |
| 627 | |
| 628 | m_httpResponse = client.request(web::http::methods::GET, builder.to_string()) |
| 629 | .then([](web::http::http_response resp) { return resp.extract_utf8string(); }) |
| 630 | .then([this](const std::string& xml) { |
| 631 | auto remoteQueryResponse = processReply(xml); |
| 632 | |
| 633 | if (remoteQueryResponse) { |
| 634 | m_lastMetaSearch = processMetaSearchResponse(*remoteQueryResponse); |
| 635 | } |
| 636 | |
| 637 | if (m_lastMetaSearch) { |
| 638 | setLastTotalResults(m_lastMetaSearch->numResults()); |
| 639 | } else { |
| 640 | setLastTotalResults(0); |
| 641 | } |
| 642 | }); |
| 643 | |
| 644 | // LOG(Debug, m_remoteUrl << builder.to_string()); |
| 645 | |
| 646 | return true; |
| 647 | } |
| 648 | |
| 649 | bool RemoteBCL::startComponentLibraryMetaSearch(const std::string& searchTerm, const unsigned componentTypeTID, const std::string& filterType) { |
| 650 | // can't start another request until last one is done |
no test coverage detected