Exemplo n.º 1
0
        public void ImportCorps()
        {
            var families = new CorporateName();
            var response = GetUuids(families.Data.Count);

            for (var i = 0; i < families.Data.Count; i++)
            {
                var request = new RestRequest($"name_authority/{response.uuids[i]}", Method.PUT, DataFormat.Json);
                request.AddJsonBody(new { authoritativeLabel = families.Data[i][0], archivesSpaceUri = families.Data[i][1] });
                var test = _client.Execute(request).Content;
            }
        }
Exemplo n.º 2
0
        public void ImportCorpRelations()
        {
            var corps = new CorporateName();

            for (var i = 0; i < corps.Relations.Count; i++)
            {
                var request = new RestRequest($"name_authority/_find", Method.POST, DataFormat.Json);
                request.AddJsonBody(new { selector = new { archivesSpaceUri = corps.Relations[i][0] } });
                var doc = JsonConvert.DeserializeObject <CouchDocs>(_client.Execute(request).Content);

                request = new RestRequest($"name_authority/{doc.Docs[0]._id}/", Method.PUT, DataFormat.Json);

                if (corps.Relations[i][1] == "personalNameCreator")
                {
                    if (doc.Docs[0].corporateNameCreator == null)
                    {
                        doc.Docs[0].corporateNameCreator = new List <string>();
                    }
                    doc.Docs[0].corporateNameCreator.Add(corps.Relations[i][2]);
                }
                else
                {
                    if (doc.Docs[0].corporateNameSource == null)
                    {
                        doc.Docs[0].corporateNameSource = new List <string>();
                    }
                    doc.Docs[0].corporateNameSource.Add(corps.Relations[i][2]);
                }

                var json = JsonConvert.SerializeObject(doc.Docs[0], new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                });
                request.AddJsonBody(json);
                _client.Execute(request);
            }
        }