-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubertool.js
124 lines (119 loc) · 2.84 KB
/
ubertool.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
var aqua = null
var eco = null;
var expo = null;
var pest = null;
var terre = null;
var use = null;
var ubertool = null;
exports.setDB = function(db)
{
aqua = db.collection('AquaticToxicity');
eco = db.collection('EcosystemInputs');
expo = db.collection('ExposureConcentrations');
pest = db.collection('PesticideProperties');
terre = db.collection('TerrestrialToxicity');
use = db.collection('Use');
ubertool = db.collection('Ubertool');
console.log("added ubertool-related collections");
}
exports.getAllConfigNames = function(config_type,callback)
{
var config_collection = null;
if(config_type == 'aqua')
{
config_collection = aqua;
} else if(config_type == 'eco')
{
config_collection = eco;
} else if(config_type == 'expo')
{
config_collection = expo;
} else if(config_type == 'pest')
{
config_collection = pest;
} else if(config_type == 'terre')
{
config_collection = terre;
} else if(config_type == 'use')
{
config_collection = use;
} else if(config_type == 'ubertool')
{
config_collection = ubertool;
}
if(config_collection != null)
{
config_collection.find().toArray(function(err,all_data) {
var config_names = [];
for(i = 0; i < all_data.length; i++)
{
config_names.push(all_data[i].config_name);
}
callback(null,config_names);
});
}
}
exports.getConfigData = function(config_type,config,callback)
{
var config_collection = null;
if(config_type == 'aqua')
{
config_collection = aqua;
} else if(config_type == 'eco')
{
config_collection = eco;
} else if(config_type == 'expo')
{
config_collection = expo;
} else if(config_type == 'pest')
{
config_collection = pest;
} else if(config_type == 'terre')
{
config_collection = terre;
} else if(config_type == 'use')
{
config_collection = use;
} else if(config_type == 'ubertool')
{
config_collection = ubertool;
}
if(config_collection != null)
{
config_collection.findOne({'config_name':config},function(err,config_data) {
callback(null,config_data);
});
}
}
exports.addUpdateConfig = function(config_type,config,json_data,callback)
{
var config_collection = null;
if(config_type == 'aqua')
{
config_collection = aqua;
} else if(config_type == 'eco')
{
config_collection = eco;
} else if(config_type == 'expo')
{
config_collection = expo;
} else if(config_type == 'pest')
{
config_collection = pest;
} else if(config_type == 'terre')
{
config_collection = terre;
} else if(config_type == 'use')
{
config_collection = use;
} else if(config_type == 'ubertool')
{
config_collection = ubertool;
}
if(config_collection != null)
{
config_collection.update({'config_name':config}, json_data, {upsert:true, w:1},function(err,doc){
callback(null,doc);
});
}
}