Mercurial > pumpbridge
annotate src/edgecontrol.coffee @ 32:ca0b44c1a870 tip
Readme: twitter in the summary, it is best working currently.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Mon, 13 Oct 2014 13:22:17 +0200 |
parents | a52b5b244e51 |
children |
rev | line source |
---|---|
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
1 # Copyright (C) 2014 by Intevation GmbH |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
2 # Author: Mathias Gebbe <mgebbe@intevation.de> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
3 # |
3 | 4 # This file is Free Software under the Apache License, Version 2.0; |
5 # and comes with NO WARRANTY! | |
6 # See the documentation coming with pumpbridge for details. | |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
7 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
8 async = require("async") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
9 _ = require("underscore") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
10 Edge = require("./edge") |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
11 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
12 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
13 removeEdges = (userid, network, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
14 delEdge = (edge, callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
15 unless edge.to.indexOf(network) is -1 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
16 edge.del callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
17 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
18 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
19 async.parallel [ |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
20 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
21 return Edge.search( |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
22 from: userid |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
23 , (err, edges) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
24 if err |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
25 callback err |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
26 else |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
27 async.each edges, delEdge, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
28 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
29 ) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
30 (callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
31 return Edge.search( |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
32 to: userid |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
33 , (err, edges) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
34 if err |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
35 callback err |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
36 else |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
37 async.each edges, delEdge, callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
38 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
39 ) |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
40 ], callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
41 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
42 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
43 addEdge = (from, to) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
44 async.waterfall [(callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
45 Edge.create |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
46 from: from |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
47 to: to |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
48 , callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
49 return |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
50 |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
51 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
52 return |
17
a52b5b244e51
removed unnecessary underscore and replaced it with async
Mathias Gebbe <mgebbe@intevation.de>
parents:
3
diff
changeset
|
53 |
0
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
54 deleteEdge = (from, to) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
55 async.waterfall [(callback) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
56 bank = Edge.bank() |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
57 bank.del Edge.type, Edge.key(from, to), callback |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
58 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
59 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
60 ], (err, result) -> |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
61 return |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
62 |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
63 exports.removeEdges = removeEdges |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
64 exports.deleteEdge = deleteEdge |
b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
Mathias Gebbe <mgebbe@intevation.de>
parents:
diff
changeset
|
65 exports.addEdge = addEdge |