Skip to content

Commit

Permalink
Minor fix. Also closes Fix #26
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoEVCosta committed Jul 9, 2019
1 parent dff24c6 commit 2b134d5
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions components/brapi/v1.3/trials_GET.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,47 @@ module.exports = function(options){
var options= options || {body:{},params:{},query:{}};
options.where={}

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call="trials"
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//Where logic
//Do this for each where attribute needed.

//-- active (Optional, ) ... Filter active status true/false.
//sortBy (Optional, ) ... Sort order. Name of the field to sorty by.
//sortOrder (Optional, ) ... Sort order direction: asc/desc
//sortBy (Optional, ) ... Sort order. Name of the field to sorty by.
//sortOrder (Optional, ) ... Sort order direction: asc/desc

//|||||||||||||||TrialId|||||||||||||||||||||||
//|||||||||||||||TrialId|||||||||||||||||||||||
options.params.trialDbId ? metadata={ metadataOnlyRemoveData:true } : metadata={}
attribute=options.params.trialDbId || options.query.trialDbId;
var value=fmtWhereAttr(attribute,"eq")
if ( value != null )
options.where.id=value
delete options.query.id;
//||||||||||||||commonCropName|||||||||||||||||
//||||||||||||||commonCropName|||||||||||||||||
attribute=options.query.commonCropName
var value=fmtWhereAttr(attribute,"eq")
if ( value != null )
options.where["$Study.StudyGermplasm.Germplasm.Species.Crop.commonCropName$"]=value
delete options.query.commonCropName;
//||||||||||||||programDbId|||||||||||||||||||
//||||||||||||||programDbId|||||||||||||||||||
attribute=options.query.programDbId;
var value=fmtWhereAttr(attribute,"eq")
if ( value != null )
options.where.programId=value
delete options.query.programDbId;
//|||||||||||||||||locationDbId||||||||||||||
//|||||||||||||||||locationDbId||||||||||||||
attribute=options.query.locationDbId
var value=fmtWhereAttr(attribute,"eq")
if ( value != null )
options.where["$Study.locationId$"]=value
delete options.query.locationDbId;
//|||||||||||||||||active||||||||||||||
delete options.query.locationDbId;
//|||||||||||||||||active||||||||||||||
attribute=options.query.active
var value=fmtWhereAttr(attribute,"eq")
if ( value != null )
options.where.active=value
delete options.query.active;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return controller(options,call,callback)

}
Expand Down

0 comments on commit 2b134d5

Please sign in to comment.