File tree 2 files changed +44
-2
lines changed
2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+
4
+ speciesFolder=" JSON-Lit"
5
+ host=" localhost:9001"
6
+ route=" community/create"
7
+ header=" Content-Type:application/json"
8
+ method=" POST"
9
+
10
+ curl $host /$route -X $method --data ' {"species": ["iJO1366","Mb_iUPDATE","iRsp1095"], "master": "iJO1366"}' -H $header
11
+
Original file line number Diff line number Diff line change @@ -2,10 +2,41 @@ var router = require('express').Router();
2
2
3
3
var MetabolicModel = App . Model ( 'metabolicmodel' ) ;
4
4
5
+ function compareMetabolites ( specieId , masterMetabolites ) {
6
+ MetabolicModel . findOne ( { id : specieId } , function ( err , model ) {
7
+ model . metabolites . forEach ( function ( metabolite ) {
8
+
9
+ if ( metabolite . id in masterMetabolites ) {
10
+ console . log ( specieId , metabolite . id ) ;
11
+ }
12
+ } )
13
+ } ) ;
14
+ }
15
+
5
16
function createCommunity ( req , res , next ) {
6
- res . send ( 'Creating a community\n' ) ;
17
+ MetabolicModel . findOne ( { id : req . body . master } , function ( err , model ) {
18
+ if ( err ) {
19
+ res . status ( 500 ) . send ( '500 Internal Server Error' ) ;
20
+ return ;
21
+ }
22
+
23
+ var masterMetabolites = new Object ( ) ;
24
+
25
+ model . metabolites . forEach ( function ( metabolite ) {
26
+ masterMetabolites [ metabolite . id ] = metabolite ;
27
+ } ) ;
28
+
29
+ req . body . species . forEach ( function ( specie ) {
30
+ if ( specie !== req . body . master ) {
31
+ console . log ( specie ) ;
32
+ compareMetabolites ( specie , masterMetabolites ) ;
33
+ }
34
+ } )
35
+
36
+ res . send ( masterMetabolites ) ;
37
+ } ) ;
7
38
}
8
39
9
- router . post ( '/' , createCommunity )
40
+ router . post ( '/' , createCommunity ) ;
10
41
11
42
module . exports = router ;
You can’t perform that action at this time.
0 commit comments