Пример #1
0
        public List <MetadataViewModel> Report1()
        {
            List <MetadataViewModel> report = new List <MetadataViewModel>();

            MetadataIndexViewModel model = new MetadataIndexViewModel();
            int offset = 1;
            int limit  = 50;

            model = _metadataService.SearchMetadata("", "", offset, limit);

            foreach (var item in model.MetadataItems)
            {
                try
                {
                    MetadataViewModel md = _metadataService.GetMetadataModel(item.Uuid);
                    if (md.IsDataset())
                    {
                        report.Add(md);
                    }
                }
                catch (Exception ex) { }
            }

            int numberOfRecordsMatched = model.TotalNumberOfRecords;
            int next = model.OffsetNext();


            while (next < numberOfRecordsMatched)
            {
                model = _metadataService.SearchMetadata("", "", next, limit);

                foreach (var item in model.MetadataItems)
                {
                    try
                    {
                        MetadataViewModel md = _metadataService.GetMetadataModel(item.Uuid);
                        if (md.IsDataset())
                        {
                            report.Add(md);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error(e.Message);
                    }
                }

                next = model.OffsetNext();
                if (next == 0)
                {
                    break;
                }
            }

            return(report);
        }
Пример #2
0
        public List<MetadataViewModel> Report1()
        {
            List<MetadataViewModel> report = new List<MetadataViewModel>();

            MetadataIndexViewModel model = new MetadataIndexViewModel();
            int offset = 1;
            int limit = 50;
            model = _metadataService.SearchMetadata("", "", offset, limit);

            foreach (var item in model.MetadataItems)
            {

                try
                {
                    MetadataViewModel md = _metadataService.GetMetadataModel(item.Uuid);
                    if (md.IsDataset())
                        report.Add(md);
                }
                catch (Exception ex) { }
            }

            int numberOfRecordsMatched = model.TotalNumberOfRecords;
            int next = model.OffsetNext();

                while (next < numberOfRecordsMatched)
                {

                    model = _metadataService.SearchMetadata("", "", next, limit);

                    foreach (var item in model.MetadataItems)
                    {
                        try
                        {
                        MetadataViewModel md = _metadataService.GetMetadataModel(item.Uuid);
                        if (md.IsDataset())
                            report.Add(md);
                        }
                        catch (Exception e)
                        {
                            Log.Error(e.Message);
                        }
                    }

                    next = model.OffsetNext();
                    if (next == 0) break;
                }

            return report;
        }
Пример #3
0
        public void GetAllMetadata()
        {
            MetadataIndexViewModel model = new MetadataIndexViewModel();
            int offset = 1;
            int limit  = 50;

            model = _metadataService.SearchMetadata("", "", offset, limit);

            foreach (var item in model.MetadataItems)
            {
                MetaDataEntry md = ValidateMetadata(item.Uuid);
                SaveValidationResult(md);
            }

            int numberOfRecordsMatched = model.TotalNumberOfRecords;
            int next = model.OffsetNext();

            try
            {
                while (next < numberOfRecordsMatched)
                {
                    model = _metadataService.SearchMetadata("", "", next, limit);

                    foreach (var item in model.MetadataItems)
                    {
                        MetaDataEntry md = ValidateMetadata(item.Uuid);
                        SaveValidationResult(md);
                    }

                    next = model.OffsetNext();
                    if (next == 0)
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }
        }
Пример #4
0
        public void GetAllMetadata()
        {
            MetadataIndexViewModel model = new MetadataIndexViewModel();
            int offset = 1;
            int limit = 50;
            model = _metadataService.SearchMetadata("", "", offset, limit);

            foreach(var item in model.MetadataItems)
            {
                MetaDataEntry md = ValidateMetadata(item.Uuid);
                SaveValidationResult(md);
            }

            int numberOfRecordsMatched = model.TotalNumberOfRecords;
            int next = model.OffsetNext();

            try
            {
                while (next < numberOfRecordsMatched)
                {
                    model = _metadataService.SearchMetadata("", "", next, limit);

                    foreach (var item in model.MetadataItems)
                    {
                        MetaDataEntry md = ValidateMetadata(item.Uuid);
                        SaveValidationResult(md);
                    }

                    next = model.OffsetNext();
                    if (next == 0) break;
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }
        }
        public ActionResult Index(MetadataMessages? message, string organization = "", string searchString = "", int offset = 1, int limit = 50)
        {
            ViewBag.StatusMessage =
                message == MetadataMessages.InvalidUuid ? Resources.UI.Error_InvalidUuid
                : "";

            MetadataIndexViewModel model = new MetadataIndexViewModel();

            if (User.Identity.IsAuthenticated)
            {
                string userOrganization = GetSecurityClaim("organization");
                string role = GetSecurityClaim("role");
                if (!string.IsNullOrWhiteSpace(role) && role.Equals("nd.metadata_admin"))
                {
                    model = _metadataService.SearchMetadata(organization, searchString, offset, limit);
                    model.UserIsAdmin = true;
                }
                else
                {
                    model = _metadataService.SearchMetadata(userOrganization, searchString, offset, limit);
                }

                model.UserOrganization = userOrganization;
            }

            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }

            return View(model);
        }
        private static MetadataIndexViewModel ParseSearchResults(int offset, int limit, SearchResultsType results)
        {
            var model    = new MetadataIndexViewModel();
            var metadata = new Dictionary <string, MetadataItemViewModel>();

            if (results.Items != null)
            {
                foreach (var item in results.Items)
                {
                    RecordType record = (RecordType)item;

                    string title        = null;
                    string uuid         = null;
                    string publisher    = null;
                    string creator      = null;
                    string organization = null;
                    string type         = null;
                    string relation     = null;

                    for (int i = 0; i < record.ItemsElementName.Length; i++)
                    {
                        var name  = record.ItemsElementName[i];
                        var value = record.Items[i].Text != null ? record.Items[i].Text[0] : null;

                        if (name == ItemsChoiceType24.title)
                        {
                            title = value;
                        }
                        else if (name == ItemsChoiceType24.identifier)
                        {
                            uuid = value;
                        }
                        else if (name == ItemsChoiceType24.creator)
                        {
                            creator = value;
                        }
                        else if (name == ItemsChoiceType24.publisher)
                        {
                            publisher = value;
                        }
                        else if (name == ItemsChoiceType24.type)
                        {
                            type = value;
                        }
                        else if (name == ItemsChoiceType24.relation)
                        {
                            relation = value;
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(publisher))
                    {
                        organization = publisher;
                    }
                    else
                    {
                        organization = creator;
                    }

                    var metadataItem = new MetadataItemViewModel
                    {
                        Title                    = title,
                        Uuid                     = uuid,
                        Organization             = organization,
                        Type                     = type,
                        Relation                 = relation,
                        GeoNetworkViewUrl        = GeoNetworkUtil.GetViewUrl(uuid),
                        GeoNetworkXmlDownloadUrl = GeoNetworkUtil.GetXmlDownloadUrl(uuid)
                    };

                    if (uuid != null)
                    {
                        metadata.Add(uuid, metadataItem);
                    }
                }

                model.MetadataItems           = metadata.Values.ToList();
                model.Limit                   = limit;
                model.Offset                  = offset;
                model.NumberOfRecordsReturned = int.Parse(results.numberOfRecordsReturned);
                model.TotalNumberOfRecords    = int.Parse(results.numberOfRecordsMatched);
            }
            return(model);
        }
Пример #7
0
        private static MetadataIndexViewModel ParseSearchResults(int offset, int limit, SearchResultsType results)
        {
            var model = new MetadataIndexViewModel();
            var metadata = new Dictionary<string, MetadataItemViewModel>();

            if (results.Items != null)
            {
                foreach (var item in results.Items)
                {
                    RecordType record = (RecordType)item;

                    string title = null;
                    string uuid = null;
                    string publisher = null;
                    string creator = null;
                    string organization = null;
                    string type = null;
                    string relation = null;

                    string uri = null;
                    string uriProtocol = null;
                    string uriName = null;

                    for (int i = 0; i < record.ItemsElementName.Length; i++)
                    {
                        var name = record.ItemsElementName[i];
                        var value = record.Items[i].Text != null ? record.Items[i].Text[0] : null;

                        if (name == ItemsChoiceType24.title)
                            title = value;
                        else if (name == ItemsChoiceType24.identifier)
                            uuid = value;
                        else if (name == ItemsChoiceType24.creator)
                            creator = value;
                        else if (name == ItemsChoiceType24.publisher)
                            publisher = value;
                        else if (name == ItemsChoiceType24.type)
                            type = value;
                        else if (name == ItemsChoiceType24.relation)
                            relation = value;
                        else if (name == ItemsChoiceType24.URI)
                        {
                            uri = value;
                            var uriAttributes = (SimpleUriLiteral)record.Items[i];
                            if (uriAttributes != null)
                            {
                                if (!string.IsNullOrEmpty(uriAttributes.protocol))
                                    uriProtocol = uriAttributes.protocol;
                                if (!string.IsNullOrEmpty(uriAttributes.name))
                                    uriName = uriAttributes.name;
                            }
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(creator))
                    {
                        organization = creator;
                    }
                    else
                    {
                        organization = publisher;
                    }

                    var metadataItem = new MetadataItemViewModel
                    {
                        Title = title,
                        Uuid = uuid,
                        Organization = organization,
                        Type = type,
                        Relation = relation,
                        GeoNetworkViewUrl = GeoNetworkUtil.GetViewUrl(uuid),
                        GeoNetworkXmlDownloadUrl = GeoNetworkUtil.GetXmlDownloadUrl(uuid),
                        Uri = uri,
                        UriProtocol = uriProtocol,
                        UriName = uriName
                    };

                    if (uuid != null)
                        metadata.Add(uuid, metadataItem);

                }

                model.MetadataItems = metadata.Values.ToList();
                model.Limit = limit;
                model.Offset = offset;
                model.NumberOfRecordsReturned = int.Parse(results.numberOfRecordsReturned);
                model.TotalNumberOfRecords = int.Parse(results.numberOfRecordsMatched);
            }
            return model;
        }
Пример #8
0
        public void UpdateAll(BatchData data, string username, string organization)
        {
            try
            {
                MetadataIndexViewModel model = new MetadataIndexViewModel();
                int offset = 1;
                int limit = 50;
                model = _metadataService.SearchMetadata(organization, "", offset, limit);
                model.UserOrganization = organization;

                foreach (var item in model.MetadataItems)
                {
                    data.MetaData.Add(new MetaDataEntry { Uuid = item.Uuid });
                }

                Update(data, username);

                int numberOfRecordsMatched = model.TotalNumberOfRecords;
                int next = model.OffsetNext();

                while (next < numberOfRecordsMatched)
                {
                    data.MetaData = null; data.MetaData = new List<MetaDataEntry>();

                    model = _metadataService.SearchMetadata(organization, "", next, limit);
                    model.UserOrganization = organization;

                    foreach (var item in model.MetadataItems)
                    {
                        data.MetaData.Add(new MetaDataEntry { Uuid = item.Uuid });
                    }

                    Update(data, username);

                    next = model.OffsetNext();
                    if (next == 0) break;
                }

            }

            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }
        }
Пример #9
0
        public ActionResult Index(MetadataMessages? message, string organization = "", string searchString = "", int offset = 1, int limit = 100)
        {
            ViewBag.StatusMessage =
                message == MetadataMessages.InvalidUuid ? Resources.UI.Error_InvalidUuid
                : "";

            MetadataIndexViewModel model = new MetadataIndexViewModel();

            if (User.Identity.IsAuthenticated)
            {
                string userOrganization = GetSecurityClaim("organization");
                string role = GetSecurityClaim("role");
                if (!string.IsNullOrWhiteSpace(role) && role.Equals("nd.metadata_admin"))
                {
                    model = _metadataService.SearchMetadata(organization, searchString, offset, limit);
                    model.UserIsAdmin = true;
                }
                else
                {
                    model = _metadataService.SearchMetadata(userOrganization, searchString, offset, limit);
                }

                model.UserOrganization = userOrganization;
            }

            Dictionary<string, string> OrganizationList = GetListOfOrganizations();
            ViewBag.OrganizationContactMetadata = new SelectList(OrganizationList, "Key", "Value");
            ViewBag.MaintenanceFrequency = new SelectList(GetListOfMaintenanceFrequencyValues(), "Key", "Value");

            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }

            return View(model);
        }
        private static MetadataIndexViewModel ParseSearchResults(int offset, int limit, SearchResultsType results)
        {
            var model = new MetadataIndexViewModel();
            var metadata = new Dictionary<string, MetadataItemViewModel>();

            if (results.Items != null)
            {
                foreach (var item in results.Items)
                {
                    RecordType record = (RecordType)item;

                    string title = null;
                    string uuid = null;
                    string publisher = null;
                    string creator = null;
                    string organization = null;
                    string type = null;
                    string relation = null;

                    for (int i = 0; i < record.ItemsElementName.Length; i++)
                    {
                        var name = record.ItemsElementName[i];
                        var value = record.Items[i].Text != null ? record.Items[i].Text[0] : null;

                        if (name == ItemsChoiceType24.title)
                            title = value;
                        else if (name == ItemsChoiceType24.identifier)
                            uuid = value;
                        else if (name == ItemsChoiceType24.creator)
                            creator = value;
                        else if (name == ItemsChoiceType24.publisher)
                            publisher = value;
                        else if (name == ItemsChoiceType24.type)
                            type = value;
                        else if (name == ItemsChoiceType24.relation)
                            relation = value;
                    }

                    if (!string.IsNullOrWhiteSpace(publisher))
                    {
                        organization = publisher;
                    }
                    else
                    {
                        organization = creator;
                    }

                    var metadataItem = new MetadataItemViewModel { Title = title, Uuid = uuid, Organization = organization, Type = type, Relation = relation };

                    metadata.Add(uuid, metadataItem);

                }

                model.MetadataItems = metadata.Values.ToList();
                model.Limit = limit;
                model.Offset = offset;
                model.NumberOfRecordsReturned = int.Parse(results.numberOfRecordsReturned);
                model.TotalNumberOfRecords = int.Parse(results.numberOfRecordsMatched);
            }
            return model;
        }