コード例 #1
0
ファイル: UriHelper.cs プロジェクト: picibird/hbs
        public static Url GetQueryUrl(string sid, SearchRequest searchRequest)
        {
            Url res = new Url(Pazpar2Settings.PAZPAR2_URL)
                      .SetQueryParam("command", "search")
                      .SetQueryParam("session", sid)
                      .SetQueryParam("sort", CreateSortStringFromSearchRequest(searchRequest))
                      .SetQueryParam("query", CreateQueryStringFromSearchRequest(searchRequest));

            if (searchRequest.MaximumRecords.HasValue)
            {
                res.SetQueryParam("maxrecs", searchRequest.MaximumRecords.Value);
            }
            else
            {
                res.SetQueryParam("maxrecs", Pazpar2Settings.MAX_RECORDS);
            }

            string limit = CreateLimitFilterStringFromSearchRequest(searchRequest);

            if (!String.IsNullOrEmpty(limit))
            {
                res.SetQueryParam("limit", limit);
            }

            if (searchRequest.HasSourceFilter())
            {
                string sourceFilterIds = String.Join("|", searchRequest.GetSourceFilterIds());
                res.SetQueryParam("filter", String.Format("pz:id={0}", sourceFilterIds));
            }
            else
            {
                //if has no user source filter applied, check if settings has exclusive filter applied
                if (Pazpar2Settings.LduSourceUsage != LduSourceUsage.ALL)
                {
                    string sourceFilterString = LduSourceUsageHelper.ToFilterString(Pazpar2Settings.LduSourceUsage);
                    res.SetQueryParam("filter", String.Format("pz:id={0}", sourceFilterString));
                    Pici.Log.warn(typeof(UrlHelper), String.Format("SETTING LDU ONLY SOURCE TO", sourceFilterString));
                }
            }
            return(res);
        }