Commit 4fda6835 authored by Matija Obreza's avatar Matija Obreza

Testing JSON Ignore nulls

parent 66f7600c
Pipeline #13937 passed with stage
in 42 seconds
......@@ -64,7 +64,7 @@ namespace GenesysPGR.Client.Api
/// in Genesys.</returns>
public string[] Exists(string instCode, string[] accns)
{
string result = Query(HttpVerb.Put, string.Format("/acn/{0}/check", instCode), null, JsonConvert.SerializeObject(accns));
string result = Query(HttpVerb.Put, string.Format("/acn/{0}/check", instCode), null, JsonConvert.SerializeObject(accns, jsonSettings));
return JsonConvert.DeserializeObject<string[]>(result);
}
......@@ -80,7 +80,7 @@ namespace GenesysPGR.Client.Api
/// <returns>JSON response string</returns>
public string UpdateJson(string instCode, GenericObject[] accnsArray)
{
return Query(HttpVerb.Post, string.Format("/acn/{0}/upsert", instCode), null, JsonConvert.SerializeObject(accnsArray));
return Query(HttpVerb.Post, string.Format("/acn/{0}/upsert", instCode), null, JsonConvert.SerializeObject(accnsArray, jsonSettings));
}
/// <summary>
......@@ -95,7 +95,7 @@ namespace GenesysPGR.Client.Api
/// <returns>List of AccessionOpResponse objects indicating success or failure for each record</returns>
public AccessionOpResponse[] Update(string instCode, Accession[] accnsArray)
{
string result = QueryWithRetry(HttpVerb.Post, string.Format("/acn/{0}/upsert", instCode), null, JsonConvert.SerializeObject(accnsArray));
string result = QueryWithRetry(HttpVerb.Post, string.Format("/acn/{0}/upsert", instCode), null, JsonConvert.SerializeObject(accnsArray, jsonSettings));
return JsonConvert.DeserializeObject<AccessionOpResponse[]>(result);
}
......@@ -110,7 +110,7 @@ namespace GenesysPGR.Client.Api
/// <returns>List of AccessionOpResponse objects indicating success or failure for each record</returns>
public AccessionOpResponse[] Delete(string instituteCode, Accession[] accessions)
{
string result = Query(HttpVerb.Post, string.Format("/acn/{0}/delete", instituteCode), null, JsonConvert.SerializeObject(accessions));
string result = Query(HttpVerb.Post, string.Format("/acn/{0}/delete", instituteCode), null, JsonConvert.SerializeObject(accessions, jsonSettings));
return JsonConvert.DeserializeObject<AccessionOpResponse[]>(result);
}
......
......@@ -35,6 +35,11 @@ namespace GenesysPGR.Client.Api
/// </summary>
public abstract class BaseApi
{
protected JsonSerializerSettings jsonSettings = new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
};
/// <summary>
/// Maximum number of milliseconds to wait before retrying
/// </summary>
......
......@@ -50,11 +50,28 @@ namespace GenesysPGR.Client.Model
[JsonProperty(PropertyName = "doi")]
public string DOI { get; set; }
private object uuid;
/// <summary>
/// Universally Unique IDentifier for the accession, assigned by the first holding institute and immutable when accession is duplicated in another institute.
/// </summary>
[JsonProperty(PropertyName = "uuid")]
public Guid? Uuid { get; private set; }
[JsonProperty(PropertyName = "uuid", NullValueHandling = NullValueHandling.Ignore)]
public Guid? Uuid
{
get
{
if (this.uuid == null || this.uuid == DBNull.Value)
{
return null;
}
return (Guid) this.uuid;
}
set
{
this.uuid = value == null ? DBNull.Value : (object) value;
}
}
/// <summary>
/// WIEWS code of accession holding institute.
......
......@@ -28,9 +28,6 @@ namespace GenesysPGR.Client.Model
/// </summary>
public class Taxonomy
{
[JsonProperty(PropertyName = "spAuthor")]
private object spAuthor;
/// <summary>
/// May be used to assign a different "genus"
/// </summary>
......@@ -43,9 +40,12 @@ namespace GenesysPGR.Client.Model
[JsonProperty(PropertyName = "species")]
public string Species { get; set; }
private object spAuthor;
/// <summary>
/// Corresponds to MCPD SPAUTHOR
/// </summary>
[JsonProperty(PropertyName = "spAuthor")]
public string SpAuthor
{
get
......
......@@ -220,7 +220,7 @@ namespace GenesysPGR.Client.Console
new Accession() { InstituteCode = InstituteCode, AccessionNumber = testAcceNumb, Taxonomy = new Taxonomy() { Genus = testGenus } }
});
System.Console.WriteLine(JsonConvert.SerializeObject(deleteResponse));
if (!deleteResponse[0].HasError)
if (deleteResponse[0].HasError)
LogFailure("Delete Accession", "Accession delete responded with failure or did not delete the expected count");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment