return query;
}
+ /**
+ *
+ * @param tnrMsg
+ * @param mode
+ * @throws DRFChecklistException
+ *
+ * TODO remove parameter SearchMode, since it in now included in the TnrMsg.query.request
+ */
public void resolveNames(TnrMsg tnrMsg, SearchMode mode) throws DRFChecklistException {
TnrMsgUtils.updateWithSearchMode(tnrMsg, mode);
List<Query> queryList = tnrMsg.getQuery();
+ // selecting one request as representative, only
+ // the search mode and addSynonmy flag are important
+ // for the further usage of the request object
+ Query.Request request = queryList.get(0).getRequest();
+
for (ServiceProviderInfo checklistInfo : getServiceProviderInfo().getSubChecklists()) {
URI namesUri = buildUriFromQueryList(queryList,
"/cdmserver/" + checklistInfo.getId() + "/name_catalogue.json",
"taxonUuid",
null);
String taxonResponseBody = processRESTService(taxonUri);
- updateQueriesWithResponse(taxonResponseBody, checklistInfo);
+ updateQueriesWithResponse(taxonResponseBody, checklistInfo, request);
}
}
}
}
- private void updateQueriesWithResponse(String responseBody, ServiceProviderInfo ci) throws DRFChecklistException {
+ private void updateQueriesWithResponse(String responseBody, ServiceProviderInfo ci, Query.Request request) throws DRFChecklistException {
JSONArray responseBodyJson = parseResponseBody(responseBody);
Taxon accName = generateAccName(taxon);
tnrResponse.setTaxon(accName);
- generateSynonyms(relatedTaxa, tnrResponse);
+
+ if(request.isAddSynonymy()){
+ generateSynonyms(relatedTaxa, tnrResponse);
+ }
+
Query query = taxonIdQueryMap.get(taxonUuid);
if(query != null) {
query.getResponse().add(tnrResponse);
if(nameGUID != null){
logger.debug("nameGUID : " + nameGUID);
PESIRecord record = pesinspt.getPESIRecordByGUID(nameGUID);
- Response tnrResponse = tnrResponseFromRecord(pesinspt, record, SearchMode.valueOf(query.getRequest().getSearchMode()));
+ Response tnrResponse = tnrResponseFromRecord(pesinspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
} else {
logger.debug("no match for " + name);
PESIRecord[] records = pesinspt.getPESIRecords(name, true);
if(records != null){
for (PESIRecord record : records) {
- Response tnrResponse = tnrResponseFromRecord(pesinspt, record, SearchMode.valueOf(query.getRequest().getSearchMode()));
+ Response tnrResponse = tnrResponseFromRecord(pesinspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
}
}
PESIRecord[] records = pesinspt.getPESIRecordsByVernacular(name);
if(records != null){
for (PESIRecord record : records) {
- Response tnrResponse = tnrResponseFromRecord(pesinspt, record, SearchMode.valueOf(query.getRequest().getSearchMode()));
+ Response tnrResponse = tnrResponseFromRecord(pesinspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
}
}
PESIRecord[] records = pesinspt.getPESIRecordsByVernacular("%" + name + "%");
if(records != null){
for (PESIRecord record : records) {
- Response tnrResponse = tnrResponseFromRecord(pesinspt, record, SearchMode.valueOf(query.getRequest().getSearchMode()));
+ Response tnrResponse = tnrResponseFromRecord(pesinspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
}
}
* @param searchMode TODO
* @throws RemoteException
*/
- private Response tnrResponseFromRecord(PESINameServicePortType pesinspt, PESIRecord record, SearchMode searchMode) throws RemoteException {
+ private Response tnrResponseFromRecord(PESINameServicePortType pesinspt, PESIRecord record, Query.Request request) throws RemoteException {
Response tnrResponse = TnrMsgUtils.tnrResponseFor(getServiceProviderInfo());
+ SearchMode searchMode = SearchMode.valueOf(request.getSearchMode());
+
String accNameGUID = record.getValid_guid();
if(SCIENTIFICNAME_SEARCH_MODES.contains(searchMode)){
tnrResponse.setMatchingNameString(record.getScientificname());
}
PESIRecord[] records = pesinspt.getPESISynonymsByGUID(accNameGUID);
- if(records != null && records.length > 0) {
+ if(request.isAddSynonymy() && records != null && records.length > 0) {
generateSynonyms(records,tnrResponse);
}
}
* @return
* @throws RemoteException
*/
- private Response tnrResponseFromRecord(AphiaNameServicePortType aphianspt, AphiaRecord record, SearchMode searchMode)
+ private Response tnrResponseFromRecord(AphiaNameServicePortType aphianspt, AphiaRecord record, Query.Request request)
throws RemoteException {
+
Response tnrResponse = TnrMsgUtils.tnrResponseFor(getServiceProviderInfo());
+ SearchMode searchMode = SearchMode.valueOf(request.getSearchMode());
+
int accNameGUID = record.getValid_AphiaID();
String matchingName = record.getScientificname();
if(SCIENTIFICNAME_SEARCH_MODES.contains(searchMode)){
AphiaRecord[] synonyms = aphianspt.getAphiaSynonymsByID(accNameGUID);
- if(synonyms != null && synonyms.length > 0) {
+ if(request.isAddSynonymy() && synonyms != null && synonyms.length > 0) {
generateSynonyms(synonyms, tnrResponse);
}
return tnrResponse;
Integer nameAphiaID = aphianspt.getAphiaID(name, false);
logger.debug("nameAphiaID : " + nameAphiaID);
record = aphianspt.getAphiaRecordByID(nameAphiaID);
- Response tnrResponse = tnrResponseFromRecord(aphianspt, record, SearchMode.scientificNameExact);
+ Response tnrResponse = tnrResponseFromRecord(aphianspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
} catch(NullPointerException npe) {
//FIXME : Workaround for NPE thrown by the aphia stub due to a,
AphiaRecord[] records = aphianspt.getAphiaRecords(name + "%", true, fuzzy, false, 1);
if(records != null){
for (AphiaRecord record : records) {
- Response tnrResponse = tnrResponseFromRecord(aphianspt, record, SearchMode.scientificNameLike);
+ Response tnrResponse = tnrResponseFromRecord(aphianspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
}
}
AphiaRecord[] records = aphianspt.getAphiaRecordsByVernacular(name, false, 1);
if(records != null){
for (AphiaRecord record : records) {
- Response tnrResponse = tnrResponseFromRecord(aphianspt, record, SearchMode.vernacularNameExact);
+ Response tnrResponse = tnrResponseFromRecord(aphianspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
}
}
AphiaRecord[] records = aphianspt.getAphiaRecordsByVernacular(name, true, 1);
if(records != null){
for (AphiaRecord record : records) {
- Response tnrResponse = tnrResponseFromRecord(aphianspt, record, SearchMode.vernacularNameLike);
+ Response tnrResponse = tnrResponseFromRecord(aphianspt, record, query.getRequest());
query.getResponse().add(tnrResponse);
}
}
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
* <sequence>
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="searchMode" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="addSynonymy" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* </sequence>
* </restriction>
* </complexContent>
* {@link BigDecimal }
*
*/
- @ApiModelProperty("Duration of the request in milliseconds")
+ @ApiModelProperty("Duration of the request processing in the specific checklist client in milliseconds.")
public BigDecimal getDuration() {
return duration;
}
* <sequence>
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="searchMode" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="addSynonymy" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* </sequence>
* </restriction>
* </complexContent>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"name",
- "searchMode"
+ "searchMode",
+ "addSynonymy"
})
public static class Request {
protected String name;
@XmlElement(required = true)
protected String searchMode;
+ protected boolean addSynonymy;
/**
* Gets the value of the name property.
this.searchMode = value;
}
+ /**
+ * Gets the value of the addSynonymy property.
+ *
+ */
+ @ApiModelProperty("Indicates whether the synonymy of the accepted taxon should be included into the response. Turning this option on may lead to an increased response time.")
+ public boolean isAddSynonymy() {
+ return addSynonymy;
+ }
+
+ /**
+ * Sets the value of the addSynonymy property.
+ *
+ */
+ public void setAddSynonymy(boolean value) {
+ this.addSynonymy = value;
+ }
+
}
}
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.02.02 at 03:37:10 PM CET
+// Generated on: 2015.02.03 at 02:45:08 PM CET
//
@javax.xml.bind.annotation.XmlSchema(namespace = "http://bgbm.org/biovel/drf/tnr/msg", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
return finalTnrMsgList;
}
- public static TnrMsg convertStringToTnrMsg(String name, SearchMode searchMode) {
+ public static TnrMsg convertStringToTnrMsg(String name, SearchMode searchMode, boolean addSynonymy) {
TnrMsg tnrMsg = new TnrMsg();
Query query = new Query();
Request request = new Request();
request.setName(name);
request.setSearchMode(searchMode.toString());
+ request.setAddSynonymy(addSynonymy);
query.setRequest(request);
tnrMsg.getQuery().add(query);
return tnrMsg;
}
- public static List<TnrMsg> convertStringListToTnrMsgList(List<String> names, SearchMode searchMode) {
+ public static List<TnrMsg> convertStringListToTnrMsgList(List<String> names, SearchMode searchMode, boolean addSynonymy) {
List<TnrMsg> tnrMsgList = new ArrayList<TnrMsg>();
Iterator<String> itrStringMsg = names.iterator();
while(itrStringMsg.hasNext()) {
- TnrMsg tnrMsg = convertStringToTnrMsg(itrStringMsg.next(), searchMode);
+ TnrMsg tnrMsg = convertStringToTnrMsg(itrStringMsg.next(), searchMode, addSynonymy);
tnrMsgList.add(tnrMsg);
}
return tnrMsgList;
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
+ <xsd:element name="addSynonymy" type="xsd:boolean">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <annox:annotate target="getter">
+ @com.wordnik.swagger.annotations.ApiModelProperty("Indicates whether the synonymy of the accepted taxon should be included into the response. Turning this option on may lead to an increased response time.")
+ </annox:annotate>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
@Test
public void nameCompleteStringListTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException {
parser = new DRFCSVInputParser();
- List<TnrMsg> tnrMsgs = TnrMsgUtils.convertStringListToTnrMsgList(nameCompleteList, SearchMode.scientificNameExact);
+ List<TnrMsg> tnrMsgs = TnrMsgUtils.convertStringListToTnrMsgList(nameCompleteList, SearchMode.scientificNameExact, false);
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/singleNameCompleteOnly.csv","UTF-8"));
List<String> chosenKeyList = new ArrayList<String>();
chosenKeyList.add("7ddf754f-d193-4cc9-b351-99906754a03b");