Пример #1
0
        public PageUrlResult UpdateCustomUrl(SeoUrl dto)
        {
            var portalSettings = PortalController.Instance.GetCurrentPortalSettings();

            return(_pageUrlsController.UpdateCustomUrl(dto.SaveUrl, _tabController.GetTab(dto.TabId, portalSettings.PortalId, false)));
        }
Пример #2
0
        public PageUrlResult UpdateCustomUrl(SeoUrl dto)
        {
            PortalSettings portalSettings = PortalController.Instance.GetCurrentSettings() as PortalSettings;

            return(UpdateCustomUrl(dto.SaveUrl, TabController.Instance.GetTab(dto.TabId, portalSettings.PortalId, false)));
        }
Пример #3
0
        public void ShouldReturnFalseWhenTitleDoesNotMatch()
        {
            var seoUrl = new SeoUrl("Skog og landskap", "AR-5");

            seoUrl.Matches("skog-og-landskap", "ar5sadfsdf").Should().BeFalse();
        }
Пример #4
0
        public Metadata(SearchResultItem item, UrlHelper urlHelper)
        {
            Uuid                 = item.Uuid;
            Title                = item.Title;
            Abstract             = item.Abstract;
            Type                 = item.Type;
            TypeName             = item.TypeName;
            TypeTranslated       = TranslateType();
            Theme                = item.Theme;
            Organization         = item.Organization;
            OrganizationLogo     = item.OrganizationLogoUrl;
            ThumbnailUrl         = item.ThumbnailUrl;
            DistributionUrl      = item.DistributionUrl;
            DistributionProtocol = item.DistributionProtocol;
            DistributionName     = item.DistributionName;
            DistributionType     = item.DistributionType;
            GetCapabilitiesUrl   = GetGetCapabilitiesUrl(item);
            if (urlHelper != null)
            {
                ShowDetailsUrl = WebConfigurationManager.AppSettings["KartkatalogenUrl"] + "metadata/uuid/" + item.Uuid;
                string s = new SeoUrl(item.Organization, "").Organization;
                OrganizationUrl = WebConfigurationManager.AppSettings["KartkatalogenUrl"] + "metadata/" + s;
            }

            if (item.NationalInitiative != null && item.NationalInitiative.Contains(UI.OpenData) ||
                (!string.IsNullOrEmpty(item.DataAccess) && (item.DataAccess == UI.OpenData ||
                                                            item.DataAccess.Contains("ingen begrensninger") || item.DataAccess.Contains("no limitations"))))
            {
                IsOpenData = true;
            }
            else
            {
                IsOpenData = false;
            }

            AccessIsOpendata   = IsOpenData;
            AccessIsRestricted = SimpleMetadataUtil.IsRestricted(item.OtherConstraintsAccess);
            AccessIsProtected  = SimpleMetadataUtil.IsProtected(item.AccessConstraint);

            if (item.NationalInitiative != null && item.NationalInitiative.Contains("Det offentlige kartgrunnlaget"))
            {
                IsDokData = true;
            }
            else
            {
                IsDokData = false;
            }


            LegendDescriptionUrl           = item.LegendDescriptionUrl;
            ProductSheetUrl                = item.ProductSheetUrl;
            ProductSpecificationUrl        = item.ProductSpecificationUrl;
            DatasetServices                = item.DatasetServices;
            DatasetServicesWithShowMapLink = AddDatasetServicesWithShowMapLink(DatasetServices);
            ServiceDatasets                = item.ServiceDatasets;
            Distributions                       = item.Distributions;
            Bundles                             = item.Bundles;
            ServiceLayers                       = item.ServiceLayers;
            AccessConstraint                    = item.AccessConstraint;
            OtherConstraintsAccess              = item.OtherConstraintsAccess;
            DataAccess                          = item.DataAccess;
            ServiceDistributionUrlForDataset    = item.ServiceDistributionUrlForDataset;
            ServiceUuid                         = item.ServiceDistributionUuidForDataset;
            ServiceWfsDistributionUrlForDataset = item.ServiceWfsDistributionUrlForDataset != null ? item.ServiceWfsDistributionUrlForDataset : WfsServiceUrl();
            Date        = item.Date;
            DatasetName = item.DatasetName;

            if (Type == "dataset" || Type == "series")
            {
                if (!string.IsNullOrWhiteSpace(item.ServiceDistributionProtocolForDataset))
                {
                    string commonPart = SimpleMetadataUtil.GetCommonPartOfNorgeskartUrl(item.ServiceDistributionProtocolForDataset, true);

                    if (item.ServiceDistributionProtocolForDataset.Contains(SimpleMetadataUtil.OgcWms))
                    {
                        if (!string.IsNullOrWhiteSpace(item.ServiceDistributionUrlForDataset))
                        {
                            ServiceUrl = $"{commonPart}{RemoveQueryString(item.ServiceDistributionUrlForDataset)}";

                            if (!string.IsNullOrWhiteSpace(item.ServiceDistributionNameForDataset))
                            {
                                ServiceUrl += $"&addLayers={item.ServiceDistributionNameForDataset}";
                            }
                        }
                    }
                    else if (item.ServiceDistributionProtocolForDataset.Contains(SimpleMetadataUtil.OgcWfs))
                    {
                        if (!string.IsNullOrWhiteSpace(item.ServiceDistributionNameForDataset) && !string.IsNullOrWhiteSpace(item.ServiceDistributionUrlForDataset))
                        {
                            ServiceUrl = $"{commonPart}{RemoveQueryString(item.ServiceDistributionUrlForDataset)}&addLayers={item.ServiceDistributionNameForDataset}";
                        }
                        else if (!string.IsNullOrWhiteSpace(item.DistributionUrl))
                        {
                            ServiceUrl = $"{commonPart}{RemoveQueryString(item.DistributionUrl)}";
                        }
                    }
                }

                if (item.Serie != null)
                {
                    Serie = AddSerie(item.Serie);
                }
            }

            if (Type == "service" || Type == "servicelayer")
            {
                if (!string.IsNullOrWhiteSpace(item.DistributionProtocol) && !string.IsNullOrWhiteSpace(item.DistributionUrl))
                {
                    string commonPart = $"{SimpleMetadataUtil.GetCommonPartOfNorgeskartUrl(item.DistributionProtocol, true)}{RemoveQueryString(item.DistributionUrl)}";

                    if (item.DistributionProtocol.Contains(SimpleMetadataUtil.OgcWms) || item.DistributionProtocol.Contains(SimpleMetadataUtil.OgcWfs))
                    {
                        DownloadUrl = commonPart;

                        if (!string.IsNullOrWhiteSpace(item.DistributionName))
                        {
                            DownloadUrl += $"&addLayers={item.DistributionName}";
                        }
                    }
                }

                if (string.IsNullOrEmpty(ServiceUuid) && string.IsNullOrWhiteSpace(item.DistributionName))
                {
                    ServiceUuid = Uuid;
                }
            }

            if (Type == "series" && item.SerieDatasets != null && item.SerieDatasets.Count > 0)
            {
                SerieDatasets = AddSerieDatasets(item.SerieDatasets);
            }

            else
            {
                DownloadUrl = item.DistributionUrl;
                if (!DownloadLink())
                {
                    DownloadUrl = MakeDownloadUrlRelative();
                }
            }

            MapUrl = GetMapUrl();

            SpatialScope = item.SpatialScope;
        }
Пример #5
0
        public void ShouldReturnFalseWhenOrganizationDoesNotMatch()
        {
            var seoUrl = new SeoUrl("Skog og landskap", "AR-5");

            seoUrl.Matches("skogoglandskap", "ar-5").Should().BeFalse();
        }
Пример #6
0
        public void ShouldReturnTrueWhenBothOrganizationAndTitleMatches()
        {
            var seoUrl = new SeoUrl("Skog og landskap", "WMS AR-5");

            seoUrl.Matches("skog-og-landskap", "wms-ar-5").Should().BeTrue();
        }
        public string GetOrganizationSeoName()
        {
            var seoUrl = new SeoUrl(Organization, Title);

            return(seoUrl.Organization);
        }
        public SearchResultItemViewModel(SearchResultItem item)
        {
            Uuid                  = item.Uuid;
            Title                 = item.Title;
            Abstract              = item.Abstract;
            Type                  = item.Type;
            Theme                 = item.Theme;
            Organization          = item.Organization;
            OrganizationShortName = !string.IsNullOrEmpty(item.OrganizationShortName) ? item.OrganizationShortName : item.Organization;
            OrganizationLogoUrl   = GetOrganizationLogoUrl(item.OrganizationLogoUrl);
            ThumbnailUrl          = item.ThumbnailUrl;
            MaintenanceFrequency  = item.MaintenanceFrequency;
            DistributionType      = item.DistributionType;
            DistributionUrl       = item.DistributionUrl;
            GetCapabilitiesUrl    = item.DistributionDetails.DistributionDetailsGetCapabilitiesUrl();
            TypeCssClass          = GetInnholdstypeCSS();
            TypeTranslated        = GetInnholdstype();
            DistributionProtocol  = item.DistributionProtocol;
            var seoUrl = new SeoUrl(Organization, Title);

            OrganizationSeoName = seoUrl.Organization;
            TitleSeo            = seoUrl.Title;

            if (!string.IsNullOrEmpty(item.OtherConstraintsAccess) && item.OtherConstraintsAccess.ToLower() == "no restrictions")
            {
                IsOpendata = true;
            }
            if (!string.IsNullOrEmpty(item.OtherConstraintsAccess) && item.OtherConstraintsAccess.ToLower() == "norway digital restricted")
            {
                IsRestricted = true;
            }
            if (item.AccessConstraint == "restricted")
            {
                IsOffline = true;
            }

            if (Type == "dataset")
            {
                if (!string.IsNullOrWhiteSpace(item.ServiceDistributionProtocolForDataset))
                {
                    string commonPart = SimpleMetadataUtil.GetCommonPartOfNorgeskartUrl(item.ServiceDistributionProtocolForDataset, true);

                    if (item.ServiceDistributionProtocolForDataset.Contains(SimpleMetadataUtil.OgcWms))
                    {
                        if (!string.IsNullOrWhiteSpace(item.ServiceDistributionUrlForDataset))
                        {
                            ServiceUrl = $"{commonPart}{RemoveQueryString(item.ServiceDistributionUrlForDataset)}";

                            if (!string.IsNullOrWhiteSpace(item.ServiceDistributionNameForDataset))
                            {
                                ServiceUrl += $"&addLayers={item.ServiceDistributionNameForDataset}";
                            }
                        }
                    }
                    else if (item.ServiceDistributionProtocolForDataset.Contains(SimpleMetadataUtil.OgcWfs))
                    {
                        if (!string.IsNullOrWhiteSpace(item.ServiceDistributionNameForDataset) && !string.IsNullOrWhiteSpace(item.ServiceDistributionUrlForDataset))
                        {
                            ServiceUrl = $"{commonPart}{RemoveQueryString(item.ServiceDistributionUrlForDataset)}&addLayers={item.ServiceDistributionNameForDataset}";
                        }
                        else if (!string.IsNullOrWhiteSpace(item.DistributionUrl))
                        {
                            ServiceUrl = $"{commonPart}{RemoveQueryString(item.DistributionUrl)}";
                        }
                    }
                }
            }

            if (Type == "service" || Type == "servicelayer")
            {
                if (!string.IsNullOrWhiteSpace(item.DistributionProtocol) && !string.IsNullOrWhiteSpace(item.DistributionUrl))
                {
                    string commonPart = $"{SimpleMetadataUtil.GetCommonPartOfNorgeskartUrl(item.DistributionProtocol, true)}{RemoveQueryString(item.DistributionUrl)}";

                    if (item.DistributionProtocol.Contains(SimpleMetadataUtil.OgcWms) || item.DistributionProtocol.Contains(SimpleMetadataUtil.OgcWfs))
                    {
                        DownloadUrl = commonPart;

                        if (!string.IsNullOrWhiteSpace(item.DistributionName))
                        {
                            DownloadUrl += $"&addLayers={item.DistributionName}";
                        }
                    }
                }
            }
            else
            {
                DownloadUrl = item.DistributionUrl;
                if (!DownloadLink())
                {
                    DownloadUrl = MakeDownloadUrlRelative();
                }
            }

            LegendDescriptionUrl    = item.LegendDescriptionUrl;
            ProductSheetUrl         = item.ProductSheetUrl;
            ProductSpecificationUrl = item.ProductSpecificationUrl;
            ServiceUuid             = item.Uuid;
            if (item.Type == "dataset")
            {
                ServiceUuid = item.ServiceDistributionUuidForDataset;
            }

            if (!string.IsNullOrEmpty(item.ParentIdentifier) && Type == "servicelayer")
            {
                ServiceUuid = item.ParentIdentifier;
            }

            ServiceDistributionAccessConstraint = item.ServiceDistributionAccessConstraint;
            MetadataLinkRouteValueDictionary    = ShowMetadataLinkRouteValueDictionary();
            MapTitleTag         = GetMapTitleTag();
            ShowDownloadService = DownloadService();
            ShowDownloadLink    = DownloadLink();
            AddToCartUrl        = GetAddToCartUrl();
            MapUrl = GetMapUrl();
        }
Пример #9
0
        private void PrepareViewBagForEditing(MetadataViewModel model)
        {
            ViewBag.TopicCategoryValues         = new SelectList(GetListOfTopicCategories(CultureHelper.GetCurrentCulture()), "Key", "Value", model.TopicCategory);
            ViewBag.SpatialRepresentationValues = new SelectList(GetListOfSpatialRepresentations(CultureHelper.GetCurrentCulture()), "Key", "Value", model.SpatialRepresentation);

            ViewBag.VectorFormats = new SelectList(GetListOfVectorFormats(), "Key", "Value");
            ViewBag.RasterFormats = new SelectList(GetListOfRasterFormats(), "Key", "Value");

            ViewBag.predefinedDistributionProtocols = new SelectList(GetListOfpredefinedDistributionProtocols(CultureHelper.GetCurrentCulture()), "Key", "Value");
            ViewBag.UnitsOfDistributionValues       = new SelectList(GetListOfUnitsOfDistribution(CultureHelper.GetCurrentCulture()), "Key", "Value", model.UnitsOfDistribution);
            ViewBag.MaintenanceFrequencyValues      = new SelectList(GetListOfMaintenanceFrequencyValues(CultureHelper.GetCurrentCulture()), "Key", "Value", model.MaintenanceFrequency);
            ViewBag.StatusValues             = new SelectList(GetListOfStatusValues(CultureHelper.GetCurrentCulture()), "Key", "Value", model.Status);
            ViewBag.SecurityConstraintValues = new SelectList(GetListOfClassificationValues(CultureHelper.GetCurrentCulture()), "Key", "Value", model.SecurityConstraints);
            ViewBag.UseConstraintValues      = new SelectList(GetListOfRestrictionValues(CultureHelper.GetCurrentCulture()), "Key", "Value", model.UseConstraints);
            ViewBag.LicenseTypesValues       = new SelectList(GetListOfLicenseTypes(), "Key", "Value", model.OtherConstraintsLink);
            if (!string.IsNullOrEmpty(model.OtherConstraintsAccess) && (model.OtherConstraintsAccess.ToLower() == "no restrictions" || model.OtherConstraintsAccess.ToLower() == "norway digital restricted"))
            {
                model.AccessConstraints = model.OtherConstraintsAccess;
            }
            ViewBag.AccessConstraintValues = new SelectList(GetListOfRestrictionValuesAdjusted(CultureHelper.GetCurrentCulture()), "Key", "Value", model.AccessConstraints);
            ViewBag.CreateProductSheetUrl  =
                System.Web.Configuration.WebConfigurationManager.AppSettings["ProductSheetGeneratorUrl"] + model.Uuid;
            ViewBag.ThumbnailUrl =
                System.Web.Configuration.WebConfigurationManager.AppSettings["EditorUrl"] + "thumbnails/";
            ViewBag.GeoNetworkViewUrl        = GeoNetworkUtil.GetViewUrl(model.Uuid);
            ViewBag.GeoNetworkXmlDownloadUrl = GeoNetworkUtil.GetXmlDownloadUrl(model.Uuid);
            var seoUrl = new SeoUrl("", model.Title);

            ViewBag.KartkatalogViewUrl = System.Web.Configuration.WebConfigurationManager.AppSettings["KartkatalogUrl"] + "Metadata/" + seoUrl.Title + "/" + model.Uuid;

            Dictionary <string, string> OrganizationList = GetListOfOrganizations(CultureHelper.GetCurrentCulture());


            if (model.ContactMetadata != null && string.IsNullOrEmpty(model.ContactMetadata.Organization))
            {
                if (Request.Form["ContactMetadata.Organization.Old"] != null || !string.IsNullOrWhiteSpace(Request.Form["ContactMetadata.Organization.Old"]))
                {
                    model.ContactMetadata.Organization = Request.Form["ContactMetadata.Organization.Old"].ToString();
                }
            }

            if (model.ContactPublisher != null && string.IsNullOrEmpty(model.ContactPublisher.Organization))
            {
                if (Request.Form["ContactPublisher.Organization.Old"] != null || !string.IsNullOrWhiteSpace(Request.Form["ContactPublisher.Organization.Old"]))
                {
                    model.ContactPublisher.Organization = Request["ContactPublisher.Organization.Old"].ToString();
                }
            }


            if (model.ContactOwner != null && string.IsNullOrEmpty(model.ContactOwner.Organization))
            {
                if (Request.Form["ContactOwner.Organization.Old"] != null || !string.IsNullOrWhiteSpace(Request.Form["ContactOwner.Organization.Old"]))
                {
                    model.ContactOwner.Organization = Request["ContactOwner.Organization.Old"].ToString();
                }
            }

            var contactMetadataOrganization  = (model.ContactMetadata != null && model.ContactMetadata.Organization != null) ? model.ContactMetadata.Organization : "";
            var contactPublisherOrganization = (model.ContactPublisher != null && model.ContactPublisher.Organization != null) ? model.ContactPublisher.Organization : "";
            var contactOwnerOrganization     = (model.ContactOwner != null && model.ContactOwner.Organization != null) ? model.ContactOwner.Organization : "";

            ViewBag.OrganizationContactMetadataValues  = new SelectList(OrganizationList, "Key", "Value", contactMetadataOrganization);
            ViewBag.OrganizationContactPublisherValues = new SelectList(OrganizationList, "Key", "Value", contactPublisherOrganization);
            ViewBag.OrganizationContactOwnerValues     = new SelectList(OrganizationList, "Key", "Value", contactOwnerOrganization);
            ViewBag.OrganizationDistributorValues      = new SelectList(OrganizationList, "Key", "Value");

            Dictionary <string, string> ReferenceSystemsList = GetListOfReferenceSystems();

            ViewBag.ReferenceSystemsValues = new SelectList(ReferenceSystemsList, "Key", "Value");

            ViewBag.NationalThemeValues      = new SelectList(GetListOfNationalTheme(CultureHelper.GetCurrentCulture()), "Key", "Value");
            ViewBag.NationalInitiativeValues = new SelectList(GetListOfNationalInitiative(), "Key", "Value");
            ViewBag.CatalogValues            = new SelectList(GetListOfCatalogs(), "Key", "Value");
            ViewBag.InspireValues            = new SelectList(GetListOfInspire(CultureHelper.GetCurrentCulture()), "Key", "Value");
            ViewBag.InspirePriorityDatasets  = new SelectList(_metadataService.GetPriorityDatasets(), "Key", "Value");

            IEnumerable <SelectListItem> conceptItems = from concept in model.KeywordsConcept
                                                        select new SelectListItem
            {
                Text     = concept.Split('|')[0].ToString(),
                Value    = concept.ToString(),
                Selected = true,
            };

            ViewBag.Concepts = new MultiSelectList(conceptItems, "Value", "Text", conceptItems.Select(c => c.Value).ToArray());

            var productspesifications = GetRegister("produktspesifikasjoner", model);

            if (!string.IsNullOrEmpty(model.ProductSpecificationUrl))
            {
                KeyValuePair <string, string> prodspecSelected = new KeyValuePair <string, string>(model.ProductSpecificationUrl, model.ProductSpecificationUrl);
                if (!productspesifications.ContainsKey(prodspecSelected.Key))
                {
                    productspesifications.Add(prodspecSelected.Key, prodspecSelected.Value);
                }
            }
            ViewBag.ProductspesificationValues = new SelectList(productspesifications, "Key", "Value", model.ProductSpecificationUrl);

            var orderingInstructions = GetSubRegister("metadata-kodelister/kartverket/norge-digitalt-tjenesteerklaering", model);

            if (!string.IsNullOrEmpty(model.OrderingInstructions))
            {
                KeyValuePair <string, string> orderingInstructionsSelected = new KeyValuePair <string, string>(model.OrderingInstructions, model.OrderingInstructions);
                if (!orderingInstructions.ContainsKey(orderingInstructionsSelected.Key))
                {
                    orderingInstructions.Add(orderingInstructionsSelected.Key, orderingInstructionsSelected.Value);
                }
            }
            ViewBag.OrderingInstructionsValues = new SelectList(orderingInstructions, "Key", "Value", model.OrderingInstructions);

            ViewBag.ProductsheetValues      = new SelectList(GetRegister("produktark", model), "Key", "Value", model.ProductSheetUrl);
            ViewBag.LegendDescriptionValues = new SelectList(GetRegister("tegneregler", model), "Key", "Value", model.LegendDescriptionUrl);

            ViewBag.ValideringUrl = System.Web.Configuration.WebConfigurationManager.AppSettings["ValideringUrl"] + "api/metadata/" + model.Uuid;

            ViewBag.Municipalities = new KomDataService().GetListOfMunicipalityOrganizations();

            ViewBag.NewDistribution = false;

            ViewBag.IsAdmin = "0";
            string role = GetSecurityClaim("role");

            if (!string.IsNullOrWhiteSpace(role) && role.Equals("nd.metadata_admin"))
            {
                ViewBag.IsAdmin = "1";
            }
        }