summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2015-04-21 13:54:52 +0300
committerLV-426 <lv-426@taproot.org.il>2015-04-21 13:54:52 +0300
commit31478c0f18c16e036a9ef8be0a1eb880bc94058e (patch)
tree9c5a2e32e3a9db08f4d6ec503c7fabcc285eb0a5 /src
parent8e14485a55ef0e4075735b7d190b29703f75b58f (diff)
refactoring tools/ contents to more appropriate places
Diffstat (limited to 'src')
-rw-r--r--src/local/domain/cri.rhizi.net/deliverables_generator.js41
-rw-r--r--src/local/utils.sh27
2 files changed, 68 insertions, 0 deletions
diff --git a/src/local/domain/cri.rhizi.net/deliverables_generator.js b/src/local/domain/cri.rhizi.net/deliverables_generator.js
new file mode 100644
index 00000000..c4454609
--- /dev/null
+++ b/src/local/domain/cri.rhizi.net/deliverables_generator.js
@@ -0,0 +1,41 @@
+var fs = require('fs');
+
+function randomDate(start, end) {
+ return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
+}
+
+function deliverableTest() {
+ links=[];
+ nodes=[];
+ var status = "unknown";
+ var nodecounter = 150;
+
+ var addLink = function (source, target, name) {
+ links.push({source:source, target:target, name:name});
+ };
+
+ for (var i = 0; i < nodecounter; i++) {
+ if (Math.random() > 0.7) status = "done";
+ else if (Math.random() > 0.5) status = "current";
+ else status = "waiting";
+ var end = randomDate(new Date(), new Date("01/01/2018"));
+ var start = randomDate(new Date(), end);
+ nodes.push({id:"Task " + i, name: "Task " + i,
+ type:"deliverable", start:start, end:end,
+ status:'status'});
+ }
+
+ for (var i = 0; i < nodecounter; i++) {
+ var endindex = Math.floor(Math.random() * nodecounter);
+ var startindex = Math.floor(Math.random() * nodecounter);
+ if (nodes[endindex].start > nodes[startindex].start && startindex !== endindex) {
+ addLink("Task " + startindex, "Task " + endindex, "depends on", "perm");
+ } else {
+ addLink("Task " + endindex, "Task " + startindex, "depends on", "perm");
+ }
+ }
+
+ return {nodes:nodes, links:links};
+}
+
+fs.writeFileSync('deliverables.json', JSON.stringify(deliverableTest()));
diff --git a/src/local/utils.sh b/src/local/utils.sh
new file mode 100644
index 00000000..df5e2fb6
--- /dev/null
+++ b/src/local/utils.sh
@@ -0,0 +1,27 @@
+# utilities to be sourced for rhizi bash scripts
+
+if [ "x$NEO4J_ROOT" == "x" ]; then
+ NEO4J_SHELL=`which neo4j-shell`
+ if [ "x$NEO4J_SHELL" == "x" ]; then
+ echo missing neo4j-shell, please define NEO4J_ROOT or place neo4j-shell in PATH
+ exit 1
+ fi
+else
+ NEO4J_SHELL="$NEO4J_ROOT/bin/neo4j-shell"
+ if [ ! -e $NEO4J_SHELL ]; then
+ echo "\$NEO4J_ROOT/bin/neo4j-shell does not exist, fix NEO4J_ROOT"
+ exit 1
+ fi
+fi
+
+function quit_if_no_neo4j_running () {
+ if [ `uname` == "Darwin" ]; then
+ neo4j_count=`netstat -na -ptcp 2>/dev/null | grep 7474 | wc -l`
+ else
+ neo4j_count=`netstat -ltnop 2>/dev/null | grep 7474 | wc -l`
+ fi
+ if [ $neo4j_count == "0" ]; then
+ echo run neo4j please
+ exit 0
+ fi
+}