-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #41 generates a searchID for /search/observationtables POST
- Loading branch information
1 parent
fa8f9a2
commit 288fa47
Showing
5 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Created by Bruno Costa 24-05-2019 | ||
* Generated by Utilities/createTable.py | ||
*/ | ||
'use strict'; | ||
|
||
module.exports = function(sequelize, DataTypes) { | ||
const Search = sequelize.define('Search', { | ||
id: { | ||
type: DataTypes.INTEGER(11), | ||
autoIncrement: true, | ||
primaryKey: true, | ||
allowNull: false, | ||
unique: true, | ||
}, | ||
germplasmDbIds:{ | ||
type: DataTypes.JSON, | ||
allowNull: true | ||
}, | ||
locationDbIds:{ | ||
type: DataTypes.JSON, | ||
allowNull: true | ||
}, | ||
observationLevel: DataTypes.STRING(254), | ||
observationTimeStampRangeStart: DataTypes.DATE, | ||
observationTimeStampRangeEnd: DataTypes.DATE, | ||
observationVariableDbIds:{ | ||
type: DataTypes.JSON, | ||
allowNull: true | ||
}, | ||
programDbIDs:{ | ||
type: DataTypes.JSON, | ||
allowNull: true | ||
}, | ||
seasonDbIds:{ | ||
type: DataTypes.JSON, | ||
allowNull: true | ||
}, | ||
studyDbIds:{ | ||
type: DataTypes.JSON, | ||
allowNull: true | ||
}, | ||
trialDbIds:{ | ||
type: DataTypes.JSON, | ||
allowNull: true | ||
}, | ||
}, { | ||
tableName: 'Search', | ||
timestamps: false, | ||
underscored: false, | ||
|
||
classMethods: { | ||
associate: function associate(models) { | ||
} | ||
}, | ||
}); | ||
return Search; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var fmtWhereAttr = require('./../helpers/formatWhereAttribute'); | ||
var controller = require('./../controllers/callController_v1.3'); | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
var callStructure = require('./../structures/v1.3/observationtables'); | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
module.exports = function(options){ | ||
var options= options || {body:{},params:{},query:{}}; | ||
options.where={} | ||
|
||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
call="observationunits" | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
//Where logic | ||
//Do this for each where attribute needed. | ||
|
||
//missing sort and sortBy | ||
|
||
|
||
//|||||||||||||||||search|||||||||||||| | ||
// attribute=options.params.searchResultsDbId | ||
// var value=fmtWhereAttr(attribute,"in") | ||
// if ( value != null ) | ||
// options.where.searchId=value | ||
// delete options.params.searchResultsDbId; | ||
///||||||||||||||||||||||||||||||||||||||||| | ||
attribute="2"; | ||
var value=fmtWhereAttr(attribute,"in") | ||
if ( value != null ) | ||
options.where.studyId=value | ||
|
||
|
||
|
||
|
||
return controller(options,call,callback) | ||
|
||
} | ||
|
||
function callback(res){ | ||
//[The attribute in main table used as uniqueId] | ||
var attribute="id" | ||
//Metadata | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
var metadata={} | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
return {metadata:metadata,attribute:attribute,callStructure:callStructure}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
var controller = require('./../controllers/callControllerCreate_v1.3'); | ||
var callStructure = require('./../structures/v1.3/observationtables_POST'); | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
module.exports = function(options){ | ||
var options= options || {body:{},params:{},query:{}}; | ||
options.where={} | ||
options.inserts={} | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
call="observationtables_post" | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
//Where logic | ||
//Do this for each where attribute needed. | ||
|
||
//missing sort and sortBy | ||
|
||
function sanitizeArray(inString){ //Sanitize the array that is being inserted into table | ||
let array=JSON.parse(inString) | ||
if (array instanceof Array){ | ||
function isInt(item){ | ||
return typeof item == 'number' | ||
} | ||
if(array.every(isInt)){ | ||
return array | ||
}else{ | ||
return [] | ||
} | ||
}else{ | ||
return [] | ||
} | ||
} | ||
|
||
options.inserts.studyDbIds=sanitizeArray(options.body.studyDbId) | ||
|
||
|
||
return controller(options,call,callback); | ||
|
||
} | ||
|
||
function callback(res){ | ||
//[The attribute in main table used as uniqueId] | ||
var attribute="id" | ||
//Metadata | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
var metadata={} | ||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
return {metadata:metadata,attribute:attribute,callStructure:callStructure}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters