Skip to content

Commit 9a820a4

Browse files
committed
dev(WoRMS): adjust some endpoints interface due to split "WoRMS or not"
1 parent b2e7692 commit 9a820a4

File tree

3 files changed

+87
-125
lines changed

3 files changed

+87
-125
lines changed

openapi.json

Lines changed: 81 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi":"3.0.2",
33
"info":{
44
"title":"EcoTaxa",
5-
"version":"0.0.41"
5+
"version":"0.0.42"
66
},
77
"servers":[
88
{
@@ -5729,30 +5729,6 @@
57295729
"name":"name",
57305730
"in":"query"
57315731
},
5732-
{
5733-
"description":"Worms Aphia Id",
5734-
"required":true,
5735-
"schema":{
5736-
"title":"Aphia Id",
5737-
"type":"integer",
5738-
"description":"Worms Aphia Id"
5739-
},
5740-
"example":2367,
5741-
"name":"aphia_id",
5742-
"in":"query"
5743-
},
5744-
{
5745-
"description":"The Worms rank",
5746-
"required":true,
5747-
"schema":{
5748-
"title":"rank",
5749-
"type":"string",
5750-
"description":"The Worms rank"
5751-
},
5752-
"example":"Class",
5753-
"name":"rank",
5754-
"in":"query"
5755-
},
57565732
{
57575733
"description":"It's not possible to create a root taxon.",
57585734
"required":true,
@@ -5949,13 +5925,13 @@
59495925
"Taxonomy Tree"
59505926
],
59515927
"summary":"Add Worms Taxon",
5952-
"description":"add worms taxon with or without lineage information",
5928+
"description":"Add worms taxon with or without lineage information",
59535929
"operationId":"add_worms_taxon",
59545930
"requestBody":{
59555931
"content":{
59565932
"application/json":{
59575933
"schema":{
5958-
"$ref":"#/components/schemas/TaxoWormsModel"
5934+
"$ref":"#/components/schemas/AddWormsTaxonModel"
59595935
}
59605936
}
59615937
},
@@ -6890,6 +6866,18 @@
68906866
}
68916867
}
68926868
},
6869+
"AddWormsTaxonModel":{
6870+
"title":"AddWormsTaxonModel",
6871+
"type":"object",
6872+
"properties":{
6873+
"aphia_id":{
6874+
"title":"AphiaId",
6875+
"type":"integer",
6876+
"description":"The unique numeric aphia_id of the taxon in WoRMS.",
6877+
"example":12876
6878+
}
6879+
}
6880+
},
68936881
"BackupExportReq":{
68946882
"title":"Backup Export request Model",
68956883
"required":[
@@ -7885,7 +7873,8 @@
78857873
"taxoserver_url":{
78867874
"title":"EcoTaxoServer URL",
78877875
"type":"string",
7888-
"description":"url of taxonomy server ecotaxoserver"
7876+
"description":"url of taxonomy server ecotaxoserver",
7877+
"default":"https://ecotaxoserver.obs-vlfr.fr/"
78897878
}
78907879
},
78917880
"description":"Values which can be considered identical over the lifetime of the back-end."
@@ -10910,6 +10899,7 @@
1091010899
"title":"TaxaSearchRsp",
1091110900
"required":[
1091210901
"id",
10902+
"status",
1091310903
"text",
1091410904
"pr"
1091510905
],
@@ -10921,6 +10911,12 @@
1092110911
"description":"The taxon/category IDs.",
1092210912
"example":14334
1092310913
},
10914+
"status":{
10915+
"title":"Status",
10916+
"type":"string",
10917+
"description":"The taxon/category status, 'D' for Deprecated, 'A' for Approved or 'N' for Not approved.",
10918+
"example":"P"
10919+
},
1092410920
"aphia_id":{
1092510921
"title":"Aphia Id",
1092610922
"type":"integer",
@@ -10947,58 +10943,6 @@
1094710943
}
1094810944
}
1094910945
},
10950-
"TaxoWormsModel":{
10951-
"title":"TaxoWormsModel",
10952-
"required":[
10953-
"name",
10954-
"lineage",
10955-
"status"
10956-
],
10957-
"type":"object",
10958-
"properties":{
10959-
"aphia_id":{
10960-
"title":"AphiaId",
10961-
"type":"integer",
10962-
"description":"The unique numeric aphia_id of the taxon if in Worms.",
10963-
"example":12876
10964-
},
10965-
"rank":{
10966-
"title":"Rank",
10967-
"type":"string",
10968-
"description":"The rank in Worms of the taxon.",
10969-
"example":"Echinodermata X"
10970-
},
10971-
"name":{
10972-
"title":"Name",
10973-
"type":"string",
10974-
"description":"The name of the taxon.",
10975-
"example":"Echinodermata X"
10976-
},
10977-
"lineage":{
10978-
"title":"Taxon Worms lineage",
10979-
"type":"object",
10980-
"description":"The lineage of the taxon in Worms.",
10981-
"example":{
10982-
"2":{
10983-
"AphiaID":1,
10984-
"rank":"Superdomain",
10985-
"scientificname":"Biota"
10986-
}
10987-
}
10988-
},
10989-
"status":{
10990-
"title":"Worms taxon status",
10991-
"type":"string",
10992-
"description":"The taxon status in worms 'accepted' .",
10993-
"example":"accepted"
10994-
},
10995-
"creator_email":{
10996-
"title":"Creator email",
10997-
"description":"Email of the creator of the taxon.",
10998-
"example":"creator.user@emaim.com"
10999-
}
11000-
}
11001-
},
1100210946
"TaxonCentral":{
1100310947
"title":"TaxonCentral",
1100410948
"required":[
@@ -11121,11 +11065,13 @@
1112111065
"id",
1112211066
"name",
1112311067
"type",
11124-
"nb_objects",
11125-
"nb_children_objects",
11068+
"status",
1112611069
"display_name",
1112711070
"lineage",
1112811071
"id_lineage",
11072+
"lineage_status",
11073+
"nb_objects",
11074+
"nb_children_objects",
1112911075
"children"
1113011076
],
1113111077
"type":"object",
@@ -11136,18 +11082,6 @@
1113611082
"description":"The taxon/category IDs.",
1113711083
"example":1
1113811084
},
11139-
"aphia_id":{
11140-
"title":"Aphia Id",
11141-
"type":"integer",
11142-
"description":"The Worms aphia_id of the taxon.",
11143-
"example":"null"
11144-
},
11145-
"renm_id":{
11146-
"title":"Renm id",
11147-
"type":"integer",
11148-
"description":"The advised replacement ID if the taxon/category is deprecated.",
11149-
"example":"null"
11150-
},
1115111085
"name":{
1115211086
"title":"Name",
1115311087
"type":"string",
@@ -11160,17 +11094,11 @@
1116011094
"description":"The taxon/category type, 'M' for Morpho or 'P' for Phylo.",
1116111095
"example":"P"
1116211096
},
11163-
"nb_objects":{
11164-
"title":"Nb objects",
11165-
"type":"integer",
11166-
"description":"How many objects are classified in this category.",
11167-
"example":34118
11168-
},
11169-
"nb_children_objects":{
11170-
"title":"Nb children objects",
11171-
"type":"integer",
11172-
"description":"How many objects are classified in this category children (not itself).",
11173-
"example":30091727
11097+
"status":{
11098+
"title":"Status",
11099+
"type":"string",
11100+
"description":"The taxon/category status, 'D' for Deprecated, 'A' for Approved or 'N' for Notapproved.",
11101+
"example":"P"
1117411102
},
1117511103
"display_name":{
1117611104
"title":"Display name",
@@ -11200,6 +11128,54 @@
1120011128
1
1120111129
]
1120211130
},
11131+
"lineage_status":{
11132+
"title":"Id lineage",
11133+
"type":"string",
11134+
"description":"The taxon ancestors' status, including self, in first.",
11135+
"example":"DDAAA"
11136+
},
11137+
"renm_id":{
11138+
"title":"Renm id",
11139+
"type":"integer",
11140+
"description":"The advised replacement ID if the taxon/category is deprecated.",
11141+
"example":"null"
11142+
},
11143+
"nb_objects":{
11144+
"title":"Nb objects",
11145+
"type":"integer",
11146+
"description":"How many objects are classified in this category.",
11147+
"example":34118
11148+
},
11149+
"nb_children_objects":{
11150+
"title":"Nb children objects",
11151+
"type":"integer",
11152+
"description":"How many objects are classified in this category children (not itself).",
11153+
"example":30091727
11154+
},
11155+
"aphia_id":{
11156+
"title":"Aphia ID",
11157+
"type":"integer",
11158+
"description":"The WoRMS aphia_id of the taxon.",
11159+
"example":"null"
11160+
},
11161+
"rank":{
11162+
"title":"Rank",
11163+
"type":"string",
11164+
"description":"The WoRMS rank of the taxon.",
11165+
"example":"null"
11166+
},
11167+
"closest_worms":{
11168+
"title":"Closest WoRMS parent",
11169+
"type":"integer",
11170+
"description":"The id of the next WoRMS taxon.",
11171+
"example":"null"
11172+
},
11173+
"closest_phylo":{
11174+
"title":"Closest Phylo parent",
11175+
"type":"integer",
11176+
"description":"The id of the closest parent Phylo taxon.",
11177+
"example":"null"
11178+
},
1120311179
"children":{
1120411180
"title":"Children",
1120511181
"type":"array",

py/API_operations/TaxoManager.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,18 @@ def add_taxon(self, current_user_id: UserIDT, taxon_params: Dict) -> str:
9292

9393
def search_worms_name(self, name: str) -> List[Dict]:
9494
ret = self.client.call("/wormstaxon/%s" % name, {})
95-
print('ret----',ret)
9695
ret = ret.json()
9796
return ret
9897

9998
def add_worms_taxon(
10099
self,
101-
taxon: TaxoWormsModel,
100+
aphia_id: int,
102101
current_user_id: UserIDT,
103102
) -> Dict:
104103
_user = RightsBO.user_can_add_taxonomy(self.ro_session, current_user_id)
105104
current_user: User = self.session.query(User).get(current_user_id)
106-
taxon.creator_email = current_user.email
107-
endpointparam: Dict[str, str] = {"taxon": json.dumps(taxon.dict())}
108-
ret = self.client.call("/addwormstaxon/", endpointparam)
105+
taxon = {"aphia_id": aphia_id, "creator_email": current_user.email}
106+
ret = self.client.call("/addwormstaxon/", taxon)
109107
return ret
110108

111109
def push_stats(self) -> Any:

py/main.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,18 +3331,6 @@ def add_taxon_in_central(
33313331
description="The taxon/category verbatim name.",
33323332
example="Echinodermata",
33333333
),
3334-
aphia_id: int = Query(
3335-
...,
3336-
title="Aphia Id",
3337-
description="Worms Aphia Id",
3338-
example=2367,
3339-
),
3340-
rank: str = Query(
3341-
...,
3342-
title="rank",
3343-
description="The Worms rank",
3344-
example="Class",
3345-
),
33463334
parent_id: int = Query(
33473335
...,
33483336
title="Parent Id",
@@ -3533,14 +3521,14 @@ def search_worms_name(
35333521
response_class=Response,
35343522
)
35353523
def add_worms_taxon(
3536-
taxon: TaxoWormsModel = Body(...),
3524+
taxon: AddWormsTaxonModel = Body(...),
35373525
_current_user: Optional[int] = Depends(get_optional_current_user),
35383526
) -> Response:
35393527
"""
3540-
add worms taxon with or without lineage information
3528+
Add worms taxon with or without lineage information
35413529
"""
35423530
with CentralTaxonomyService() as sce:
3543-
ret = sce.add_worms_taxon(taxon, _current_user)
3531+
ret = sce.add_worms_taxon(taxon.aphia_id, _current_user)
35443532
response = Response(json.dumps(ret.json()), media_type="application/json")
35453533
response.status_code = ret.status_code
35463534
return response

0 commit comments

Comments
 (0)