From 6a88d199d510a1b29c507b63c7a67012f319ce82 Mon Sep 17 00:00:00 2001 From: HMS17 Date: Wed, 26 Feb 2025 10:45:55 -0500 Subject: [PATCH 1/3] [BI-2397] - Add Methods to BrAPI Java Client --- docs/README.md | 9 +++- src/brapi_methods.js | 1 + src/brapi_methods/batchdeletes.js | 79 +++++++++++++++++++++++++++++++ src/brapi_methods/lists.js | 20 ++++++++ src/brapi_methods/samples.js | 38 +++++++++++++++ src/brapi_methods/trials.js | 26 ++++++++-- 6 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 src/brapi_methods/batchdeletes.js diff --git a/docs/README.md b/docs/README.md index 694bd82..3044385 100644 --- a/docs/README.md +++ b/docs/README.md @@ -44,7 +44,7 @@ const BrAPI = require('./BrAPI.js'); ## How it Works -BrAPI.js has been designed to allow for many simultaneous and interdependent calls to BrAPI to be performed asynchronously. In order to do this, data are managed by a class of objects called **BrAPINodes**. Nodes are organized into a [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph "Directed Acyclic Graph") which represents dependancies. Each node represents a transformation on the data. Basic transformations include [fork](#fork), [join](#join), [map](#map), [reduce](#reduce), and [filter](#filter). BrAPI calls are special transformations. Each BrAPI call can be either a fork (calls returning array data) or a map (calls returning single objects). Data interacts through nodes via tasks. When a task completes, it triggers the creation of new task(s) in all child nodes. With the exception of [reduce](#reduce), the operations can be performed independently on each datum. This means one datum can be transformed across multiple nodes while another moves more slowly. +BrAPI.js has been designed to allow for many simultaneous and interdependent calls to BrAPI to be performed asynchronously. In order to do this, data are managed by a class of objects called **BrAPINodes**. Nodes are organized into a [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph "Directed Acyclic Graph") which represents dependencies. Each node represents a transformation on the data. Basic transformations include [fork](#fork), [join](#join), [map](#map), [reduce](#reduce), and [filter](#filter). BrAPI calls are special transformations. Each BrAPI call can be either a fork (calls returning array data) or a map (calls returning single objects). Data interacts through nodes via tasks. When a task completes, it triggers the creation of new task(s) in all child nodes. With the exception of [reduce](#reduce), the operations can be performed independently on each datum. This means one datum can be transformed across multiple nodes while another moves more slowly. ## Usage Reference @@ -206,6 +206,10 @@ This method registers a callback function which is called once a node has loaded | _node_.attributevalues_modify(_params_,...)||`/attributevalues/{attributeValueDbId}` | `PUT` | | _node_.attributevalues_store(_params_,...)||`/attributevalues` | `POST` | | _node_.attributevalues(_params_,...)||`/attributevalues` | `GET` | +| _node_.batchdeletes_modify(_params_,...)||`/batchDeletes/{batchDeleteDbId}` | `PUT` | +| _node_.batchdeletes_store(_params_,...)||`/batchDeletes` | `POST` | +| _node_.batchdeletes_detail(_params_,...)||`/batchDeletes/{batchDeleteDbId}` | `GET` | +| _node_.batchdeletes_delete(_params_,...)||`/batchDeletes/{batchDeleteDbId}?hardDelete=true` | `DELETE` | | _node_.breedingmethods_detail(_params_,...) | `/breedingmethods/{breedingMethodDbId}` | `/breedingmethods/{breedingMethodDbId}` | `GET` | | _node_.breedingmethods(_params_,...) | `/breedingmethods` | `/breedingmethods` | `GET` | | _node_.calls(_params_,...) | `/calls` (server info) | | `GET` | @@ -241,6 +245,7 @@ This method registers a callback function which is called once a node has loaded | _node_.images(_params_,...) | `/images` | `/images` | `GET` | | _node_.lists_detail(_params_,...) | `/lists/{listDbId}` | `/lists/{listDbId}` | `GET` | | _node_.lists_modify(_params_,...)||`/lists/{listDbId}` | `PUT` | +| _node_.lists_delete(_params_,...)||`/lists/{listDbId}?hardDelete=true` | `DELETE` | | _node_.lists_items_store(_params_,...)||`/lists/{listDbId}/items` | `POST` | | _node_.lists_store(_params_,...)||`/lists` | `POST` | | _node_.lists(_params_,...) | `/lists` | `/lists` | `GET` | @@ -301,6 +306,7 @@ This method registers a callback function which is called once a node has loaded | _node_.referencesets(_params_,...)||`/referencesets` | `GET` | | _node_.samples_detail(_params_,...) | `/samples/{sampleId}` | `/samples/{sampleDbId}` | `GET` | | _node_.samples_modify(_params_,...)||`/samples/{sampleDbId}` | `PUT` | +| _node_.samples_delete(_params_,...)||`/samples/{sampleDbId}?hardDelete=true` | `DELETE` | | _node_.samples_store(_params_,...)||`/samples` | `POST` | | _node_.samples(_params_,...) | `/samples` | `/samples` | `GET` | | _node_.scales_detail(_params_,...) | `/scales/{scaleDbId}` | `/scales/{scaleDbId}` | `GET` | @@ -362,6 +368,7 @@ This method registers a callback function which is called once a node has loaded | _node_.traits(_params_,...) | `/traits` | `/traits` | `GET` | | _node_.trials_detail(_params_,...) | `/trials/{trialDbId}` | `/trials/{trialDbId}` | `GET` | | _node_.trials_modify(_params_,...)||`/trials/{trialDbId}` | `PUT` | +| _node_.trials_delete(_params_,...) | `/trials/{trialDbId}` | `/trials/{trialDbId}?hardDelete=true` | `DELETE` | | _node_.trials_store(_params_,...)||`/trials` | `POST` | | _node_.trials(_params_,...) | `/trials` | `/trials` | `GET` | | _node_.variables_datatypes(_params_,...) | `/variables/datatypes` | | `GET` | diff --git a/src/brapi_methods.js b/src/brapi_methods.js index 2b444c4..7246a15 100644 --- a/src/brapi_methods.js +++ b/src/brapi_methods.js @@ -1,6 +1,7 @@ export * from "./brapi_methods/allelematrices"; export * from "./brapi_methods/attributes"; export * from "./brapi_methods/attributevalues"; +export * from "./brapi_methods/batchdeletes"; export * from "./brapi_methods/breedingmethods"; export * from "./brapi_methods/calls"; export * from "./brapi_methods/callsets"; diff --git a/src/brapi_methods/batchdeletes.js b/src/brapi_methods/batchdeletes.js new file mode 100644 index 0000000..483f306 --- /dev/null +++ b/src/brapi_methods/batchdeletes.js @@ -0,0 +1,79 @@ +/** `GET /batchDeletes/{batchDeleteDbId}` + * @alias BrAPINode.prototype.batchDeletes + * @param {Object} params Parameters to provide to the call + * @param {String} [behavior="fork"] Behavior of the node + * @return {BrAPI_Behavior_Node} + */ +export function batchdeletes_detail (params,behavior){ + var call = { + 'defaultMethod': 'get', + 'urlTemplate': '/batchDeletes/{batchDeleteDbId}', + 'params': params, + 'behaviorOptions': ['fork','map'], + 'behavior': behavior, + } + this.version.check(call.urlTemplate,{ + introduced:"v2.1" + }); + return this.simple_brapi_call(call); +} + +/** `PUT /batchDeletes/{batchDeleteDbId} ` + * @alias BrAPINode.prototype.batchDeletes_modify + * @param {Object} params Parameters to provide to the call + * @param {String} [behavior="fork"] Behavior of the node + * @return {BrAPI_Behavior_Node} + */ +export function batchdeletes_modify (params,behavior){ + var call = { + 'defaultMethod': 'put', + 'urlTemplate': '/batchDeletes/{batchDeleteDbId}', + 'params': params, + 'behaviorOptions': ['fork','map'], + 'behavior': behavior, + } + this.version.check(call.urlTemplate,{ + introduced:"v2.1" + }); + return this.simple_brapi_call(call); +} + +/** `POST /batchDeletes` + * @alias BrAPINode.prototype.batchdeletes_store + * @param {Object} params Parameters to provide to the call + * @param {String} [behavior="fork"] Behavior of the node + * @return {BrAPI_Behavior_Node} + */ +export function batchdeletes_store (params,behavior){ + var call = { + 'defaultMethod': 'post', + 'urlTemplate': '/batchDeletes', + 'params': params, + 'behaviorOptions': ['fork','map'], + 'behavior': behavior, + } + this.version.check(call.urlTemplate,{ + introduced:"v2.1" + }); + return this.simple_brapi_call(call); +} + +/** `DELETE /batchDeletes/{batchDeleteDbId}?hardDelete=true` + * @alias BrAPINode.prototype.batchdeletes_delete + * @param {Object} params Parameters to provide to the call + * @param {String} params.batchDeleteDbId batchDeleteDbId + * @param {hardDelete} params.hardDelete=true whether is a hard or soft delete + * @return {BrAPI_Behavior_Node} + */ +export function batchdeletes_delete(params){ + var call = { + 'defaultMethod': 'delete', + 'urlTemplate': '/batchDeletes/{batchDeleteDbId}?hardDelete=true', + 'params': params, + 'behavior': 'map', + } + this.version.check(call.urlTemplate,{ + introduced:"v2.1" + }); + return this.simple_brapi_call(call); +} \ No newline at end of file diff --git a/src/brapi_methods/lists.js b/src/brapi_methods/lists.js index 6055776..02feef4 100644 --- a/src/brapi_methods/lists.js +++ b/src/brapi_methods/lists.js @@ -120,3 +120,23 @@ export function search_lists(params,behavior){ }); return this.search("lists",params,behavior); }; + +/** `DELETE /lists/{listDbId}?hardDelete=true` + * @alias BrAPINode.prototype.lists_delete + * @param {Object} params Parameters to provide to the call + * @param {String} params.listDbId listDbId + * @param {hardDelete} params.hardDelete=true whether is a hard or soft delete + * @return {BrAPI_Behavior_Node} + */ +export function lists_delete (params){ + var call = { + 'defaultMethod': 'delete', + 'urlTemplate': '/lists/{listDbId}?hardDelete=true', + 'params': params, + 'behavior': 'map', //delete returns empty response, so behavior doesn't matter + } + this.version.check(call.urlTemplate,{ + introduced:"v2.1" //using the highest version number for now + }); + return this.simple_brapi_call(call); +} \ No newline at end of file diff --git a/src/brapi_methods/samples.js b/src/brapi_methods/samples.js index dfbb301..ccdc0f3 100644 --- a/src/brapi_methods/samples.js +++ b/src/brapi_methods/samples.js @@ -112,3 +112,41 @@ export function search_samples(params,behavior,useOld){ return this.search("samples",params,behavior); } }; + +/** `DELETE /samples` + * @alias BrAPINode.prototype.samples todo + * @param {Object} params Parameters to provide to the call + * @return {BrAPI_Behavior_Node} + */ +export function samples (params){ + var call = { + 'defaultMethod': 'delete', + 'urlTemplate': '/samples', + 'params': params, + 'behavior': 'map', + } + this.version.check(call.urlTemplate,{ + introduced:"v1.0" //todo + }); + return this.simple_brapi_call(call); +} + +/** `DELETE /samples/{sampleDbId}?hardDelete=true` + * @alias BrAPINode.prototype.samples_delete + * @param {Object} params Parameters to provide to the call + * @param {String} params.sampleDbId sampleDbId + * @param {hardDelete} params.hardDelete=true whether is a hard or soft delete + * @return {BrAPI_Behavior_Node} + */ +export function samples_delete (params){ + var call = { + 'defaultMethod': 'delete', + 'urlTemplate': '/samples/{sampleDbId}?hardDelete=true', + 'params': params, + 'behavior': 'map', + } + this.version.check(call.urlTemplate,{ + introduced:"v2.1" + }); + return this.simple_brapi_call(call); +} \ No newline at end of file diff --git a/src/brapi_methods/trials.js b/src/brapi_methods/trials.js index 5847719..6da4240 100644 --- a/src/brapi_methods/trials.js +++ b/src/brapi_methods/trials.js @@ -52,7 +52,7 @@ export function trials_detail (params){ 'behavior': 'map', } this.version.check(call.urlTemplate,{ - introduced:"v1.0" + introduced:"v2.1" }); return this.simple_brapi_call(call); } @@ -73,7 +73,7 @@ export function trials_modify (params,behavior){ 'behavior': behavior, } this.version.check(call.urlTemplate,{ - introduced:"v2.0" + introduced:"v2.1" }); return this.simple_brapi_call(call); } @@ -96,7 +96,27 @@ export function trials_search(params,behavior){ */ export function search_trials(params,behavior){ this.version.check("POST /search/trials -> GET /search/trials",{ - introduced:"v2.0" + introduced:"v2.1" }); return this.search("trials",params,behavior); }; + +/** `DELETE /trials/{trialDbId}?hardDelete=true` + * @alias BrAPINode.prototype.trials_delete + * @param {Object} params Parameters to provide to the call + * @param {String} params.trialDbId trialDbId + * @param {hardDelete} params.hardDelete=true whether is a hard or soft delete + * @return {BrAPI_Behavior_Node} + */ +export function trials_delete (params){ + var call = { + 'defaultMethod': 'delete', + 'urlTemplate': '/trials/{trialDbId}?hardDelete=true', + 'params': params, + 'behavior': 'map' + } + this.version.check(call.urlTemplate,{ + introduced:"v2.1" + }); + return this.simple_brapi_call(call); +} From 35a3bb7de507e51889d2338bd48f5368afc71224 Mon Sep 17 00:00:00 2001 From: HMS17 Date: Wed, 26 Feb 2025 10:49:11 -0500 Subject: [PATCH 2/3] [BI-2397] - removing todos --- src/brapi_methods/samples.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/brapi_methods/samples.js b/src/brapi_methods/samples.js index ccdc0f3..ed18f7b 100644 --- a/src/brapi_methods/samples.js +++ b/src/brapi_methods/samples.js @@ -111,24 +111,6 @@ export function search_samples(params,behavior,useOld){ }); return this.search("samples",params,behavior); } -}; - -/** `DELETE /samples` - * @alias BrAPINode.prototype.samples todo - * @param {Object} params Parameters to provide to the call - * @return {BrAPI_Behavior_Node} - */ -export function samples (params){ - var call = { - 'defaultMethod': 'delete', - 'urlTemplate': '/samples', - 'params': params, - 'behavior': 'map', - } - this.version.check(call.urlTemplate,{ - introduced:"v1.0" //todo - }); - return this.simple_brapi_call(call); } /** `DELETE /samples/{sampleDbId}?hardDelete=true` From 6ebdd6594b0ef50d9291f55c54fee3493f9ca9bd Mon Sep 17 00:00:00 2001 From: HMS17 Date: Thu, 27 Feb 2025 10:49:05 -0500 Subject: [PATCH 3/3] [BI-2397] - small fixes --- src/brapi_methods/batchdeletes.js | 2 +- src/brapi_methods/lists.js | 6 +++--- src/brapi_methods/trials.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/brapi_methods/batchdeletes.js b/src/brapi_methods/batchdeletes.js index 483f306..b7a8bf2 100644 --- a/src/brapi_methods/batchdeletes.js +++ b/src/brapi_methods/batchdeletes.js @@ -76,4 +76,4 @@ export function batchdeletes_delete(params){ introduced:"v2.1" }); return this.simple_brapi_call(call); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/brapi_methods/lists.js b/src/brapi_methods/lists.js index 02feef4..2dbff9a 100644 --- a/src/brapi_methods/lists.js +++ b/src/brapi_methods/lists.js @@ -106,7 +106,7 @@ export function lists_items_store (params){ */ export function lists_search(params,behavior){ return this.search_lists(params,behavior,true); -}; +} /** `POST /search/lists -> GET /search/lists` * @alias BrAPINode.prototype.search_lists @@ -119,7 +119,7 @@ export function search_lists(params,behavior){ introduced:"v2.0" }); return this.search("lists",params,behavior); -}; +} /** `DELETE /lists/{listDbId}?hardDelete=true` * @alias BrAPINode.prototype.lists_delete @@ -139,4 +139,4 @@ export function lists_delete (params){ introduced:"v2.1" //using the highest version number for now }); return this.simple_brapi_call(call); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/brapi_methods/trials.js b/src/brapi_methods/trials.js index 6da4240..d5c3507 100644 --- a/src/brapi_methods/trials.js +++ b/src/brapi_methods/trials.js @@ -52,7 +52,7 @@ export function trials_detail (params){ 'behavior': 'map', } this.version.check(call.urlTemplate,{ - introduced:"v2.1" + introduced:"v1.0" }); return this.simple_brapi_call(call); } @@ -73,7 +73,7 @@ export function trials_modify (params,behavior){ 'behavior': behavior, } this.version.check(call.urlTemplate,{ - introduced:"v2.1" + introduced:"v2.0" }); return this.simple_brapi_call(call); } @@ -96,10 +96,10 @@ export function trials_search(params,behavior){ */ export function search_trials(params,behavior){ this.version.check("POST /search/trials -> GET /search/trials",{ - introduced:"v2.1" + introduced:"v2.0" }); return this.search("trials",params,behavior); -}; +} /** `DELETE /trials/{trialDbId}?hardDelete=true` * @alias BrAPINode.prototype.trials_delete @@ -119,4 +119,4 @@ export function trials_delete (params){ introduced:"v2.1" }); return this.simple_brapi_call(call); -} +};