Commit 034bbb7c authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza

added taxonomy constants, fixed auth endpoint name

parent b5734482
...@@ -401,7 +401,7 @@ public class GenesysClient { ...@@ -401,7 +401,7 @@ public class GenesysClient {
public String updateAccession(String instituteCode, String data) throws InterruptedException, GenesysApiException { public String updateAccession(String instituteCode, String data) throws InterruptedException, GenesysApiException {
for (int retry = 0; retry < 5; retry++) { for (int retry = 0; retry < 5; retry++) {
try { try {
return query(Verb.PUT, "/acn/" + instituteCode + "/upsert", null, data); return query(Verb.POST, "/acn/" + instituteCode + "/upsert", null, data);
} catch (final PleaseRetryException e) { } catch (final PleaseRetryException e) {
final long sleepTime = (long) (Math.pow(2, retry) * 100 + Math.pow(2, retry) * 2500 * Math.random()); final long sleepTime = (long) (Math.pow(2, retry) * 100 + Math.pow(2, retry) * 2500 * Math.random());
LOG.warn("Retrying PUT after {} ms.", sleepTime); LOG.warn("Retrying PUT after {} ms.", sleepTime);
...@@ -511,7 +511,7 @@ public class GenesysClient { ...@@ -511,7 +511,7 @@ public class GenesysClient {
* @throws GenesysApiException the Genesys API exception * @throws GenesysApiException the Genesys API exception
*/ */
public String me() throws OAuthAuthenticationException, PleaseRetryException, GenesysApiException { public String me() throws OAuthAuthenticationException, PleaseRetryException, GenesysApiException {
return query("/me"); return query("/me/profile");
} }
/** /**
......
...@@ -51,26 +51,6 @@ public class AccessionJson { ...@@ -51,26 +51,6 @@ public class AccessionJson {
@JsonProperty(value = Accession.GENUS) @JsonProperty(value = Accession.GENUS)
private String genus; private String genus;
/** The new genus. */
@JsonProperty(value = Accession.GENUS_NEW)
private String newGenus;
/** The species. */
@JsonProperty(value = Accession.SPECIES)
private String species;
/** The spauthor. */
@JsonProperty(value = Accession.SPAUTHOR)
private String spauthor;
/** The subtaxa. */
@JsonProperty(value = Accession.SUBTAXA)
private String subtaxa;
/** The subtauthor. */
@JsonProperty(value = Accession.SUBTAUTHOR)
private String subtauthor;
/** The uuid. */ /** The uuid. */
@JsonProperty(value = Accession.UUID) @JsonProperty(value = Accession.UUID)
private String uuid; private String uuid;
...@@ -139,6 +119,10 @@ public class AccessionJson { ...@@ -139,6 +119,10 @@ public class AccessionJson {
@JsonProperty(value = Accession.GEO) @JsonProperty(value = Accession.GEO)
private GeoJson geo; private GeoJson geo;
/** The taxonomy. */
@JsonProperty(value = Accession.TAXONOMY)
private TaxonomyJson taxonomy;
/** The remarks. */ /** The remarks. */
@JsonProperty(value = Accession.REMARKS) @JsonProperty(value = Accession.REMARKS)
private Remark[] remarks; private Remark[] remarks;
...@@ -166,6 +150,7 @@ public class AccessionJson { ...@@ -166,6 +150,7 @@ public class AccessionJson {
public AccessionJson() { public AccessionJson() {
this.geo = new GeoJson(); this.geo = new GeoJson();
this.coll = new CollectingJson(); this.coll = new CollectingJson();
this.taxonomy = new TaxonomyJson();
} }
/** /**
...@@ -284,96 +269,6 @@ public class AccessionJson { ...@@ -284,96 +269,6 @@ public class AccessionJson {
this.genus = genus; this.genus = genus;
} }
/**
* Gets the new genus.
*
* @return the new genus
*/
public String getNewGenus() {
return newGenus;
}
/**
* Sets the new genus.
*
* @param newGenus the new new genus
*/
public void setNewGenus(final String newGenus) {
this.newGenus = newGenus;
}
/**
* Gets the species.
*
* @return the species
*/
public String getSpecies() {
return species;
}
/**
* Sets the species.
*
* @param species the new species
*/
public void setSpecies(final String species) {
this.species = species;
}
/**
* Gets the spauthor.
*
* @return the spauthor
*/
public String getSpauthor() {
return spauthor;
}
/**
* Sets the spauthor.
*
* @param spauthor the new spauthor
*/
public void setSpauthor(final String spauthor) {
this.spauthor = spauthor;
}
/**
* Gets the subtaxa.
*
* @return the subtaxa
*/
public String getSubtaxa() {
return subtaxa;
}
/**
* Sets the subtaxa.
*
* @param subtaxa the new subtaxa
*/
public void setSubtaxa(final String subtaxa) {
this.subtaxa = subtaxa;
}
/**
* Gets the subtauthor.
*
* @return the subtauthor
*/
public String getSubtauthor() {
return subtauthor;
}
/**
* Sets the subtauthor.
*
* @param subtauthor the new subtauthor
*/
public void setSubtauthor(final String subtauthor) {
this.subtauthor = subtauthor;
}
/** /**
* Gets the uuid. * Gets the uuid.
* *
...@@ -662,6 +557,24 @@ public class AccessionJson { ...@@ -662,6 +557,24 @@ public class AccessionJson {
this.geo = geo; this.geo = geo;
} }
/**
* Gets the taxonomy.
*
* @return the taxonomy
*/
public TaxonomyJson getTaxonomy() {
return taxonomy;
}
/**
* Sets the taxonomy.
*
* @param taxonomy the new taxonomy
*/
public void setTaxonomy(final TaxonomyJson taxonomy) {
this.taxonomy = taxonomy;
}
/** /**
* Gets the remarks. * Gets the remarks.
* *
......
...@@ -55,26 +55,6 @@ public interface Api1Constants { ...@@ -55,26 +55,6 @@ public interface Api1Constants {
*/ */
public static final String GENUS = "genus"; public static final String GENUS = "genus";
/**
* May be used to assign a different genus.
*/
public static final String GENUS_NEW = "newGenus";
/**
* Specific epithet portion of the scientific name, in latin, in lowercase letters.
* Following abbreviation is allowed: ‘sp.’
*/
public static final String SPECIES = "species";
/** Corresponds to MCPD SPAUTHOR. */
public static final String SPAUTHOR = "spauthor";
/** Corresponds to MCPD SUBTAXA. */
public static final String SUBTAXA = "subtaxa";
/** Corresponds to MCPD SUBTAUTHOR. */
public static final String SUBTAUTHOR = "subtauthor";
/** /**
* Universally Unique IDentifier for the accession, assigned by the first holding institute * Universally Unique IDentifier for the accession, assigned by the first holding institute
* and immutable when accession is duplicated in another institute. * and immutable when accession is duplicated in another institute.
...@@ -154,6 +134,9 @@ public interface Api1Constants { ...@@ -154,6 +134,9 @@ public interface Api1Constants {
/** Object containing georeference data. */ /** Object containing georeference data. */
public static final String GEO = "geo"; public static final String GEO = "geo";
/** Object containing taxonomy data. */
public static final String TAXONOMY = "taxonomy";
/** MCPD Remarks. */ /** MCPD Remarks. */
public static final String REMARKS = "remarks"; public static final String REMARKS = "remarks";
...@@ -235,4 +218,42 @@ public interface Api1Constants { ...@@ -235,4 +218,42 @@ public interface Api1Constants {
/** Corresponds to GEOREFMETH. */ /** Corresponds to GEOREFMETH. */
public static final String GEOREFMETH = "georefMeth"; public static final String GEOREFMETH = "georefMeth";
} }
/**
* The Interface Taxonomy.
*/
public static interface Taxonomy {
/**
* Reported genus of accession.
*/
public static final String GENUS = "genus";
/**
* May be used to assign a different genus.
*/
public static final String GENUS_NEW = "newGenus";
/**
* Specific epithet portion of the scientific name, in latin, in
* lowercase letters. Following abbreviation is allowed: ‘sp.’
*/
public static final String SPECIES = "species";
/**
* Corresponds to MCPD SPAUTHOR
*/
public static final String SPAUTHOR = "spAuthor";
/**
* Corresponds to MCPD SUBTAXA
*/
public static final String SUBTAXA = "subtaxa";
/**
* Corresponds to MCPD SUBTAUTHOR
*/
public static final String SUBTAUTHOR = "subtAuthor";
}
} }
/*
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.client.oauth.api.accession;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* The Class TaxonomyJson.
*/
public class TaxonomyJson {
/** The genus. */
@JsonProperty(value = Api1Constants.Taxonomy.GENUS)
private String genus;
/** The new genus. */
@JsonProperty(value = Api1Constants.Taxonomy.GENUS_NEW)
private String newGenus;
/** The spAuthor. */
@JsonProperty(value = Api1Constants.Taxonomy.SPAUTHOR)
private String spAuthor;
/** The species. */
@JsonProperty(value = Api1Constants.Taxonomy.SPECIES)
private String species;
/** The subtAuthor. */
@JsonProperty(value = Api1Constants.Taxonomy.SUBTAUTHOR)
private String subtAuthor;
/** The subtaxa. */
@JsonProperty(value = Api1Constants.Taxonomy.SUBTAXA)
private String subtaxa;
/**
* Gets the genus.
*
* @return the genus
*/
public String getGenus() {
return genus;
}
/**
* Sets the genus.
*
* @param genus the new genus
*/
public void setGenus(final String genus) {
this.genus = genus;
}
/**
* Gets the new genus.
*
* @return the new genus
*/
public String getNewGenus() {
return newGenus;
}
/**
* Sets the new genus.
*
* @param newGenus the new new genus
*/
public void setNewGenus(final String newGenus) {
this.newGenus = newGenus;
}
/**
* Gets the spAuthor.
*
* @return the spAuthor
*/
public String getSpAuthor() {
return spAuthor;
}
/**
* Sets the spAuthor.
*
* @param spAuthor the new spAuthor
*/
public void setSpAuthor(final String spAuthor) {
this.spAuthor = spAuthor;
}
/**
* Gets the species.
*
* @return the species
*/
public String getSpecies() {
return species;
}
/**
* Sets the species.
*
* @param species the new species
*/
public void setSpecies(final String species) {
this.species = species;
}
/**
* Gets the subtAuthor.
*
* @return the subtAuthor
*/
public String getSubtAuthor() {
return subtAuthor;
}
/**
* Sets the subtAuthor.
*
* @param subtAuthor the new subtAuthor
*/
public void setSubtAuthor(final String subtAuthor) {
this.subtAuthor = subtAuthor;
}
/**
* Gets the subtaxa.
*
* @return the subtaxa
*/
public String getSubtaxa() {
return subtaxa;
}
/**
* Sets the subtaxa.
*
* @param subtaxa the new subtaxa
*/
public void setSubtaxa(final String subtaxa) {
this.subtaxa = subtaxa;
}
}
...@@ -171,7 +171,7 @@ public class AccessionApiTest { ...@@ -171,7 +171,7 @@ public class AccessionApiTest {
assertThat("Expected matching INSTCODE", aj1.getInstituteCode(), is(instituteCode)); assertThat("Expected matching INSTCODE", aj1.getInstituteCode(), is(instituteCode));
assertThat("Expected ACCENUMB starting with", aj1.getAccessionNumber(), CoreMatchers.startsWith("ACC-")); assertThat("Expected ACCENUMB starting with", aj1.getAccessionNumber(), CoreMatchers.startsWith("ACC-"));
assertThat("Expected GENUS=Genus", aj1.getGenus(), is("Genus")); assertThat("Expected GENUS=Genus", aj1.getGenus(), is("Genus"));
assertThat("Expected SPECIES=null", aj1.getSpecies(), nullValue()); assertThat("Expected SPECIES=null", aj1.getTaxonomy().getSpecies(), nullValue());
} }
} }
......
...@@ -188,17 +188,8 @@ public class MockGenesysServer { ...@@ -188,17 +188,8 @@ public class MockGenesysServer {
if (aj.getSampStat() != null) { if (aj.getSampStat() != null) {
existing.setSampStat(aj.getSampStat()); existing.setSampStat(aj.getSampStat());
} }
if (aj.getSpecies() != null) { if (aj.getTaxonomy() != null) {
existing.setSpecies(aj.getSpecies());
}
if (aj.getSpauthor() != null) {
existing.setSpauthor(aj.getSpauthor());
}
if (aj.getSubtaxa() != null) {
existing.setSubtaxa(aj.getSubtaxa());
}
if (aj.getSubtauthor() != null) {
existing.setSubtauthor(aj.getSubtauthor());
} }
if (aj.getUuid() != null) { if (aj.getUuid() != null) {
if (existing.getUuid() == null) { if (existing.getUuid() == null) {
......
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