Beispiel #1
0
        public InspireDataService UpdateInspireDataService(InspireDataService originalDataService, InspireDataService inspireDataServiceFromKartkatalogen)
        {
            originalDataService.Name        = inspireDataServiceFromKartkatalogen.Name;
            originalDataService.Seoname     = RegisterUrls.MakeSeoFriendlyString(originalDataService.Name);
            originalDataService.Description = inspireDataServiceFromKartkatalogen.Description;
            originalDataService.OwnerId     = inspireDataServiceFromKartkatalogen.OwnerId;
            originalDataService.Modified    = DateTime.Now;

            originalDataService.Uuid            = inspireDataServiceFromKartkatalogen.Uuid;
            originalDataService.InspireDataType = inspireDataServiceFromKartkatalogen.InspireDataType;
            originalDataService.UpdateInspireTheme(inspireDataServiceFromKartkatalogen.InspireThemes);

            if (originalDataService.InspireDeliveryMetadata != null)
            {
                originalDataService.InspireDeliveryMetadata.StatusId =
                    _datasetDeliveryService.GetMetadataStatus(inspireDataServiceFromKartkatalogen.Uuid, originalDataService.InspireDeliveryMetadata.AutoUpdate,
                                                              originalDataService.InspireDeliveryMetadata.StatusId);
            }

            originalDataService.InspireDeliveryMetadataInSearchService.StatusId = "good";

            if (originalDataService.InspireDeliveryServiceStatus != null)
            {
                originalDataService.InspireDeliveryServiceStatus.StatusId = _datasetDeliveryService.GetInspireServiceStatus(originalDataService.InspireDataType, inspireDataServiceFromKartkatalogen.Uuid, originalDataService.InspireDeliveryServiceStatus.StatusId);
            }

            originalDataService.Url         = inspireDataServiceFromKartkatalogen.Url;
            originalDataService.ServiceType = inspireDataServiceFromKartkatalogen.ServiceType;

            _dbContext.Entry(originalDataService).State = EntityState.Modified;
            _dbContext.SaveChanges();

            return(originalDataService);
        }
Beispiel #2
0
        private void NewInspireDataServiceFromKartkatalogen(InspireDataService inspireDataService, Synchronize synchronizationJob)
        {
            if (!_registerItemService.ItemNameIsValid(inspireDataService))
            {
                return;
            }
            inspireDataService.SystemId      = Guid.NewGuid();
            inspireDataService.Seoname       = RegisterUrls.MakeSeoFriendlyString(inspireDataService.Name);
            inspireDataService.SubmitterId   = _registerService.GetOrganizationIdByUserName();
            inspireDataService.DateSubmitted = DateTime.Now;
            inspireDataService.Modified      = DateTime.Now;
            inspireDataService.RegisterId    = _registerService.GetInspireStatusRegisterId();
            inspireDataService.VersioningId  = _registerItemService.NewVersioningGroup(inspireDataService);
            inspireDataService.VersionNumber = 1;
            inspireDataService.StatusId      = "Submitted";

            var metadataStatus = _datasetDeliveryService.GetMetadataStatus(inspireDataService.Uuid);
            var inspireDeliveryMetadataInSearchService = "good";
            var inspireDeliveryServiceStatus           = _datasetDeliveryService.GetInspireServiceStatus(inspireDataService.InspireDataType, inspireDataService.Uuid, "deficient");

            inspireDataService.InspireDeliveryMetadataId = _datasetDeliveryService.CreateDatasetDelivery(metadataStatus);
            inspireDataService.InspireDeliveryMetadataInSearchServiceId = _datasetDeliveryService.CreateDatasetDelivery(inspireDeliveryMetadataInSearchService);
            inspireDataService.InspireDeliveryServiceStatusId           = _datasetDeliveryService.CreateDatasetDelivery(inspireDeliveryServiceStatus);

            _dbContext.InspireDataServices.Add(inspireDataService);
            _dbContext.SaveChanges();
            synchronizationJob.AddedLog.Add(new SyncLogEntry(inspireDataService, "Lagt til"));
        }
        private MdServiceExistence MappingServiceExistence(InspireDataService InspireDataService)
        {
            MdServiceExistence mdServiceExistence = new MdServiceExistence();

            mdServiceExistence.mdConformity               = InspireDataService.MetadataIsGood(); // Metadatakrav oppfylt -  Skal settes til "true"
            mdServiceExistence.discoveryAccessibility     = true;                                // Metadata for tjeneste tilgjengelig gjennom søketjeneste Skal settes til "true"
            mdServiceExistence.discoveryAccessibilityUuid = InspireDataService.Uuid;             // UUID til metadata for tjenesten

            return(mdServiceExistence);
        }
        private SpatialDataService MappingSpatialDataService(InspireDataService inspireDataService)
        {
            var spatialDataService = new SpatialDataService();

            spatialDataService.name               = inspireDataService.Name;
            spatialDataService.respAuthority      = inspireDataService.Owner?.name;
            spatialDataService.uuid               = inspireDataService.Uuid;
            spatialDataService.Themes             = GetThemes(inspireDataService.InspireThemes);
            spatialDataService.MdServiceExistence = MappingServiceExistence(inspireDataService);
            spatialDataService.NetworkService     = MappingNetworkService(inspireDataService);
            return(spatialDataService);
        }
        public void Update(InspireDataService inspireDataService)
        {
            if (inspireDataService != null)
            {
                if (inspireDataService.InspireDeliveryMetadata != null)
                {
                    MetadataAutoUpdate        = inspireDataService.InspireDeliveryMetadata.AutoUpdate;
                    MetadataNote              = inspireDataService.InspireDeliveryMetadata.Note;
                    MetadataStatusId          = inspireDataService.InspireDeliveryMetadata.Status.value;
                    MetadataStatus            = inspireDataService.InspireDeliveryMetadata.Status.DescriptionTranslated();
                    InspireDeliveryMetadataId = inspireDataService.InspireDeliveryMetadataId;
                }
                if (inspireDataService.InspireDeliveryMetadataInSearchService != null)
                {
                    //InspireDeliveryMetadataInSearchService = inspireDataService.InspireDeliveryMetadataInSearchService;
                    InspireDeliveryMetadataInSearchServiceId = inspireDataService.InspireDeliveryMetadataInSearchServiceId;
                    MetadataInSearchAutoUpdate      = inspireDataService.InspireDeliveryMetadataInSearchService.AutoUpdate;
                    MetadataInSearchServiceNote     = inspireDataService.InspireDeliveryMetadataInSearchService.Note;
                    MetadataInSearchServiceStatusId = inspireDataService.InspireDeliveryMetadataInSearchService.Status.value;
                    MetadataInSearchServiceStatus   = inspireDataService.InspireDeliveryMetadataInSearchService.Status.DescriptionTranslated();
                }
                if (inspireDataService.InspireDeliveryServiceStatus != null)
                {
                    //InspireDeliveryServiceStatus = inspireDataService.InspireDeliveryServiceStatus;
                    InspireDeliveryServiceStatusId = inspireDataService.InspireDeliveryServiceStatusId;
                    ServiceStatusAutoUpdate        = inspireDataService.InspireDeliveryServiceStatus.AutoUpdate;
                    ServiceStatusNote = inspireDataService.InspireDeliveryServiceStatus.Note;
                    ServiceStatusId   = inspireDataService.InspireDeliveryServiceStatus.Status.value;
                    ServiceStatus     = inspireDataService.InspireDeliveryServiceStatus.Status.DescriptionTranslated();
                }

                InspireDataType = inspireDataService.InspireDataType;
                Requests        = inspireDataService.Requests;
                NetworkService  = inspireDataService.IsNetworkService();
                Sds             = inspireDataService.IsSds();
                Url             = inspireDataService.Url;
                InspireThemes   = inspireDataService.InspireThemes;
                Uuid            = inspireDataService.Uuid;
                MetadataUrl     = WebConfigurationManager.AppSettings["KartkatalogenUrl"] + "metadata/uuid/" + Uuid;
                ServiceType     = inspireDataService.ServiceType;

                UpdateRegisterItem(inspireDataService);
            }
        }
        private NetworkService MappingNetworkService(InspireDataService inspireDataService)
        {
            NetworkService networkService = new NetworkService();

            networkService.directlyAccessible = inspireDataService.IsNetworkService(); //Er dette en Network Service" Skal settes til "true" for <NnServiceType> in (discovery, view, download, transformation, invoke)

            networkService.URL         = inspireDataService.Url ?? string.Empty;
            networkService.userRequest = inspireDataService.Requests;
            try
            {
                networkService.NnServiceType = (NnServiceType)Enum.Parse(typeof(NnServiceType), inspireDataService.ServiceType);
            }
            catch (Exception)
            {
                return(networkService);
            }

            return(networkService);
        }
Beispiel #7
0
        public InspireDataService FetchInspireDataServiceFromKartkatalogen(string uuid)
        {
            var inspireDataService = new InspireDataService();
            var url = WebConfigurationManager.AppSettings["KartkatalogenUrl"] + "api/getdata/" + uuid;
            var c   = new System.Net.WebClient {
                Encoding = System.Text.Encoding.UTF8
            };

            try
            {
                var json = c.DownloadString(url);

                dynamic data = Newtonsoft.Json.Linq.JObject.Parse(json);
                if (data != null)
                {
                    inspireDataService.Name        = data.Title;
                    inspireDataService.Description = data.Abstract;
                    inspireDataService.Uuid        = data.Uuid;

                    inspireDataService.OwnerId = mapOrganizationNameToId(
                        data.ContactOwner != null && data.ContactOwner.Organization != null
                            ? data.ContactOwner.Organization.Value
                            : "Kartverket");

                    inspireDataService.InspireThemes = GetInspireThemes(data.KeywordsInspire);

                    inspireDataService.Url = data.DistributionUrl;
                    inspireDataService.GetServiceType(data.ServiceType.ToString());

                    inspireDataService.InspireDataType = data.DistributionDetails.ProtocolName;
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                System.Diagnostics.Debug.WriteLine(url);
                return(null);
            }

            return(inspireDataService);
        }
 public InspireDataServiceViewModel(InspireDataService item)
 {
     Update(item);
 }
Beispiel #9
0
 public void DeleteInspireDataService(InspireDataService inspireDataService)
 {
     inspireDataService.InspireThemes.Clear();
     _dbContext.InspireDataServices.Remove(inspireDataService);
     _dbContext.SaveChanges();
 }
Beispiel #10
0
        public InspireDataService UpdateInspireDataServiceFromKartkatalogen(InspireDataService originalInspireDataService)
        {
            var inspireDatasetFromKartkatalogen = _metadataService.FetchInspireDataServiceFromKartkatalogen(originalInspireDataService.Uuid);

            return(inspireDatasetFromKartkatalogen == null ? originalInspireDataService : UpdateInspireDataService(originalInspireDataService, inspireDatasetFromKartkatalogen));
        }