Commit 29169e13 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use the new format in internal data too.

parent a696a08b
......@@ -102,7 +102,7 @@
$("#dialog-fieldset").children().remove();
var element_id_prefix = element_id.split("_")[0];
var property_list = configuration[element_id_prefix].property_list || [];
var previous_data = that.getData()["element"];
var previous_data = that.getData()["nodes"];
var element_name = previous_data[element_id]['name'] || element_id;
fieldset.append(
......@@ -241,28 +241,25 @@
priv.formatForManpy = function (data) {
var manpy_dict = {}, nodes = {}, edges = {}, edge_id = 0;
$.each(data['element'], function (idx, element) {
var clone_element = {};
/* clone the element and put content of 'data' at the top level. */
$.each(element, function (k, v) {
$.each(data['nodes'], function (idx, node) {
var clone_node = {};
/* clone the node and put content of 'data' at the top level. */
$.each(node, function (k, v) {
if (k == 'data') {
$.each(v, function (kk, vv) {
clone_element[kk] = vv;
});
} else if (k == 'successorList') {
$.each(v, function (i, successor) {
edges[edge_id] = [clone_element['id'], successor, {}];
edge_id += 1;
clone_node[kk] = vv;
});
} else if (k == 'id') {
true; // no need to output
} else {
clone_element[k] = v;
clone_node[k] = v;
}
});
nodes[clone_element['id']] = clone_element;
nodes[node['id']] = clone_node;
});
manpy_dict['nodes'] = nodes;
manpy_dict['edges'] = edges;
manpy_dict['edges'] = data['edges'];
manpy_dict['general'] = data['general'];
return manpy_dict;
};
......
......@@ -239,32 +239,31 @@
}, function (err, response) {
if (response !== undefined && response.data !== undefined) {
// Add all elements
$.each(response.data.element, function (key, value) {
$.each(response.data.nodes, function (key, value) {
var preference_data = response.data.preference !== undefined ?
response.data.preference[value.id] : {};
response.data.preference[key] : {};
$.each(preference_data, function (preference_key,
preference_value) {
value[preference_key] = preference_value;
});
dream_instance.newElement(value);
dream_instance.updateElementData(value.id, {
dream_instance.updateElementData(key, {
data: value.data || {}
});
});
$.each(response.data.edges, function (key, value) {
dream_instance.connect(value[0], value[1]);
});
// Now link elements between them and update id_container
$.each(response.data.element, function (key, value) {
// Now update id_container
$.each(response.data.nodes, function (key, value) {
var element_id = value.id,
prefix, suffix, splitted_element_id,
successor_list = value.successorList || [];
prefix, suffix, splitted_element_id;
splitted_element_id = element_id.split("_");
prefix = splitted_element_id[0];
suffix = splitted_element_id[1];
id_container[prefix] = Math.max((id_container[prefix] || 0),
parseInt(suffix, 10));
$.each(successor_list, function (idx, successor_value) {
dream_instance.connect(value.id, successor_value);
});
});
dream_instance.setGeneralProperties(response.data.general);
dream_instance.initGeneralProperties(); // XXX
......@@ -305,19 +304,27 @@
if (obj.results.working_ratio !== undefined) {
/* when there is only one replication, the ratio is given as a float,
otherwise we have a mapping avg, min max */
blockage_data.push([counter, obj.results.blockage_ratio
.avg || obj.results.blockage_ratio
]);
if (obj.results.blockage_ratio !== undefined) {
blockage_data.push([counter, obj.results.blockage_ratio
.avg || obj.results.blockage_ratio
]);
} else {
blockage_data.push([counter, 0.0]);
}
waiting_data.push([counter, obj.results.waiting_ratio.avg ||
obj.results.waiting_ratio
]);
failure_data.push([counter, obj.results.failure_ratio.avg ||
obj.results.failure_ratio
]);
if (obj.results.failure_ratio !== undefined) {
failure_data.push([counter, obj.results.failure_ratio
.avg || obj.results.failure_ratio
]);
} else {
failure_data.push([counter, 0.0]);
}
working_data.push([counter, obj.results.working_ratio.avg ||
obj.results.working_ratio
]);
ticks.push([counter, dream_instance.getData().element[
ticks.push([counter, dream_instance.getData().nodes[
obj.id].name || obj.id]);
counter++;
}
......
......@@ -91,14 +91,14 @@
});
var updateConnectionData = function (connection, remove) {
var source_element;
source_element = priv.node_container[connection.sourceId];
source_element.successorList = source_element.successorList || [];
if (remove) {
source_element.successorList.splice(source_element.successorList.indexOf(
connection.targetId));
delete(priv.edge_container[connection.id]);
} else {
source_element.successorList.push(connection.targetId);
priv.edge_container[connection.id] = [
connection.sourceId,
connection.targetId,
{}
];
}
priv.onDataChange();
};
......@@ -176,7 +176,8 @@
priv.getData = function () {
return {
"element": priv.node_container,
"nodes": priv.node_container,
"edges": priv.edge_container,
"preference": priv.preference_container,
"general": priv.general_container
};
......@@ -200,6 +201,7 @@
that.start = function () {
priv.node_container = {};
priv.edge_container = {};
priv.preference_container = {};
priv.general_container = {};
priv.initJsPlumb();
......
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