Пример #1
0
        /// <summary>
        /// Get the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Get(DataPackageSearchDefaultRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            IOpenSearchResultCollection result = null;

            try {
                context.Open();
                context.LogInfo(this, string.Format("/data/package/default/search GET"));
                Terradue.Tep.DataPackage datapackage = DataPackage.GetTemporaryForCurrentUser(context);
                datapackage.SetOpenSearchEngine(MasterCatalogue.OpenSearchEngine);

                OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

                Type responseType = OpenSearchFactory.ResolveTypeFromRequest(HttpContext.Current.Request.QueryString, HttpContext.Current.Request.Headers, ose);

                List <Terradue.OpenSearch.IOpenSearchable> osentities = new List <Terradue.OpenSearch.IOpenSearchable>();
                osentities.AddRange(datapackage.GetOpenSearchableArray());

                var settings = MasterCatalogue.OpenSearchFactorySettings;
                MultiGenericOpenSearchable multiOSE = new MultiGenericOpenSearchable(osentities, settings);
                result = ose.Query(multiOSE, Request.QueryString, responseType);

                MasterCatalogue.ReplaceSelfLinksFormat(result, Request.QueryString);

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
Пример #2
0
        public void SearchDataPackage()
        {
            Terradue.Tep.DataPackage datapackage = DataPackage.GetTemporaryForCurrentUser(context);
            datapackage.LoadItems();
            foreach (RemoteResource res in datapackage.Resources)
            {
                res.Delete();
            }
            datapackage.LoadItems();
            Assert.AreEqual(0, datapackage.Items.Count);

            var ressourceItem = new RemoteResource(context);

            ressourceItem.Location = "https://catalog.terradue.com:443/sentinel1/search?uid=S1A_EW_OCN__2SDH_20200108T051332_20200108T051348_030704_038509_0C1C";
            datapackage.AddResourceItem(ressourceItem);

            ressourceItem          = new RemoteResource(context);
            ressourceItem.Location = "https://catalog.terradue.com:443/sentinel1/search?uid=S1A_IW_RAW__0SSH_20200108T050838_20200108T050910_030704_038508_ED48";
            datapackage.AddResourceItem(ressourceItem);

            ressourceItem          = new RemoteResource(context);
            ressourceItem.Location = "https://catalog.terradue.com:443/sentinel1/search?uid=S1A_IW_OCN__2SDV_20200108T043336_20200108T043412_030704_038504_3458";
            datapackage.AddResourceItem(ressourceItem);

            datapackage.LoadItems();
            Assert.AreEqual(3, datapackage.Items.Count);

            datapackage.SetOpenSearchEngine(MasterCatalogue.OpenSearchEngine);

            List <Terradue.OpenSearch.IOpenSearchable> osentities = new List <Terradue.OpenSearch.IOpenSearchable>();

            osentities.AddRange(datapackage.GetOpenSearchableArray());

            var settings = MasterCatalogue.OpenSearchFactorySettings;
            MultiGenericOpenSearchable multiOSE = new MultiGenericOpenSearchable(osentities, settings, true);

            var parameters = new NameValueCollection();

            IOpenSearchResultCollection osr = ose.Query(multiOSE, parameters);

            Assert.AreEqual(3, osr.TotalResults);
        }