Commit 3474904a authored by Jérome Perrin's avatar Jérome Perrin

use the same JIO attachement for input & output

parent 92b77d35
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
if (error.status_code === 404) { if (error.status_code === 404) {
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
result_list = [], result_list = [],
document_list = [], document_list = [],
i; i;
if (result) { if (result && result.result_list) {
document_list = result.result_list; document_list = result.result_list;
} }
for (i = 0; i < document_list.length; i += 1) { for (i = 0; i < document_list.length; i += 1) {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
} }
function runSimulation(gadget) { function runSimulation(gadget) {
var result_json;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
...@@ -38,25 +39,42 @@ ...@@ -38,25 +39,42 @@
}); });
}) })
.push(function (body_json) { .push(function (body_json) {
// do not send previous results to simulation engine
var json_without_result = JSON.parse(body_json);
json_without_result.result.result_list = [];
// XXX Hardcoded relative URL // XXX Hardcoded relative URL
return gadget.aq_ajax({ return gadget.aq_ajax({
url: "../../runSimulation", url: "../../runSimulation",
type: "POST", type: "POST",
data: body_json, data: JSON.stringify(json_without_result),
headers: { headers: {
"Content-Type": 'application/json' "Content-Type": 'application/json'
} }
}); });
}) })
.push(function (evt) { .push(function (evt) {
var json_data = JSON.parse(evt.target.responseText); result_json = JSON.parse(evt.target.responseText);
if (json_data.success !== true) { if (result_json.success !== true) {
throw new Error(json_data.error); throw new Error(result_json.error);
} }
// get latest version
return gadget.aq_getAttachment({
"_id": gadget.props.jio_key,
"_attachment": "body.json"
});
}).push(function(data){
data = JSON.parse(data);
// XXX option to always add ?
if (data.general.reset_result_list) {
data.result.result_list = [];
}
data.result.result_list = data.result.result_list.concat(
result_json.data.result.result_list
);
return gadget.aq_putAttachment({ return gadget.aq_putAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json", "_attachment": "body.json",
"_data": JSON.stringify(json_data.data, null, 2), "_data": JSON.stringify(data, null, 2),
"_mimetype": "application/json" "_mimetype": "application/json"
}); });
}) })
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
gadget.props.result_list = capacity_utilisation_graph_widget( gadget.props.result_list = capacity_utilisation_graph_widget(
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
var result = JSON.parse(simulation_json)[0].result, var result = JSON.parse(simulation_json)[0].result,
......
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
var result = calculate_exit_stat( var result = calculate_exit_stat(
......
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
var json_data = JSON.parse(simulation_json); var json_data = JSON.parse(simulation_json);
......
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
console.log("rendering view graph"); console.log("rendering view graph");
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
gadget.props.result = job_gantt_widget( gadget.props.result = job_gantt_widget(
......
...@@ -195,7 +195,7 @@ ...@@ -195,7 +195,7 @@
return RSVP.all([ return RSVP.all([
gadget.aq_getAttachment({ gadget.aq_getAttachment({
"_id": jio_key, "_id": jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}), }),
gadget.getDeclaredGadget("tableeditor") gadget.getDeclaredGadget("tableeditor")
]); ]);
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
gadget.props.series = queue_stat_widget( gadget.props.series = queue_stat_widget(
......
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
"_id": gadget.props.jio_key, "_id": gadget.props.jio_key,
"_attachment": "simulation.json" "_attachment": "body.json"
}) })
.push(function (simulation_json) { .push(function (simulation_json) {
gadget.props.result_list = station_utilisation_graph_widget( gadget.props.result_list = station_utilisation_graph_widget(
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
.push(function (jio_gadget) { .push(function (jio_gadget) {
return jio_gadget.getAttachment({ return jio_gadget.getAttachment({
_id: options.id, _id: options.id,
"_attachment": "simulation.json" "_attachment": "body.json"
}); });
}) })
.push(function (sim_json) { .push(function (sim_json) {
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
.push(function (jio_gadget) { .push(function (jio_gadget) {
return jio_gadget.getAttachment({ return jio_gadget.getAttachment({
_id: options.id, _id: options.id,
"_attachment": "simulation.json" "_attachment": "body.json"
}); });
}) })
.push(function (sim_json) { .push(function (sim_json) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment