Last active
August 29, 2015 14:00
-
-
Save kenwebb/11358183 to your computer and use it in GitHub Desktop.
Neo4j Movie-Actor example - with Roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Sun May 11 2014 11:26:48 GMT-0400 (EDT)--> | |
<XholonWorkbook> | |
<Notes><![CDATA[ | |
Xholon | |
------ | |
Title: Neo4j Movie-Actor example - with Roles | |
Description: | |
Url: http://www.primordion.com/Xholon/gwt/ | |
InternalName: 11358183 | |
Keywords: | |
My Notes | |
-------- | |
This workbook is a variation of "Neo4j Movie-Actor example", available as: | |
https://gist.github.com/kenwebb/11286090 | |
Updated May 11, 2014 | |
-------------------- | |
I've added a Scalable Vector Graphics (SVG) image to the app, | |
which I generated while the app was loaded. Here's what I did: | |
- Right-click the Application node in the runtime GUI (either the clsc or d3cp GUI) | |
- Select `Attributes` | |
- Select the `AllowConfigSrv` attribute, and change it's value from `false` to `true` | |
- Click outside the `Attributes` overlay | |
- You'll now be able to configure parameters in some of the exporters | |
- Right-click the MovieActorSystem node in the runtime GUI | |
- Select `Export > Graphviz` from the menu | |
- Customize the parameters in the dat.GUI[5] form. I set the following: | |
gvCluster cluster | |
defaultColor #90b0cc | |
shouldSpecifyRankdir checked | |
rankdir TB | |
- Click `doExport` | |
- Xholon will create a graphviz tab, with the code to generate a Graphviz[6] image | |
- Visit http://www.webgraphviz.com/ | |
- Copy the Graphviz code from the Xholon tab, and paste it into the webgraphviz text area | |
- Click `Generate Graph!` | |
- I used Firebug to copy the generated SVG, and paste it into this workbook | |
- I changed the SVG scale from `scale(1 1)` to `scale(0.8 0.8)`, to make it smaller | |
- Various other online tools can generate an image from the Graphviz content, | |
or you can use the Graphviz program on your desktop computer | |
References | |
---------- | |
(1) http://www.neo4j.org/console?id=cineasts | |
(2) http://www.neo4j.org/ | |
(3) http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html | |
(4) http://www.webgraphviz.com/ | |
(5) http://workshop.chromeexperiments.com/examples/gui/ | |
"dat.GUI creates an interface that you can use to modify variables" | |
(6) http://www.graphviz.org/ | |
]]></Notes> | |
<_-.XholonClass> | |
<!-- domain objects --> | |
<MovieActorSystem/> | |
<Movie/> | |
<Actor/> | |
<MovieRole/> | |
</_-.XholonClass> | |
<xholonClassDetails> | |
<Actor xhType="XhtypePureActiveObject"> | |
<port name="port" index="0" connector=".[@roleName='Keanu Reeves']/../Movie[@roleName='The Matrix']/MovieRole[@roleName='Neo']"/> | |
<port name="port" index="1" connector=".[@roleName='Keanu Reeves']/../Movie[@roleName='The Matrix Reloaded']/MovieRole[@roleName='Neo']"/> | |
<port name="port" index="2" connector=".[@roleName='Keanu Reeves']/../Movie[@roleName='The Matrix Revolutions']/MovieRole[@roleName='Neo']"/> | |
<port name="port" index="0" connector=".[@roleName='Laurence Fishburne']/../Movie[@roleName='The Matrix']/MovieRole[@roleName='Morpheus']"/> | |
<port name="port" index="1" connector=".[@roleName='Laurence Fishburne']/../Movie[@roleName='The Matrix Reloaded']/MovieRole[@roleName='Morpheus']"/> | |
<port name="port" index="2" connector=".[@roleName='Laurence Fishburne']/../Movie[@roleName='The Matrix Revolutions']/MovieRole[@roleName='Morpheus']"/> | |
<port name="port" index="0" connector=".[@roleName='Carrie-Anne Moss']/../Movie[@roleName='The Matrix']/MovieRole[@roleName='Trinity']"/> | |
<port name="port" index="1" connector=".[@roleName='Carrie-Anne Moss']/../Movie[@roleName='The Matrix Reloaded']/MovieRole[@roleName='Trinity']"/> | |
<port name="port" index="2" connector=".[@roleName='Carrie-Anne Moss']/../Movie[@roleName='The Matrix Revolutions']/MovieRole[@roleName='Trinity']"/> | |
</Actor> | |
</xholonClassDetails> | |
<MovieActorSystem> | |
<Movie roleName="The Matrix" year="1999-03-31"> | |
<MovieRole roleName="Neo"/> | |
<MovieRole roleName="Morpheus"/> | |
<MovieRole roleName="Trinity"/> | |
</Movie> | |
<Movie roleName="The Matrix Reloaded" year="2003-05-07"> | |
<MovieRole roleName="Neo"/> | |
<MovieRole roleName="Morpheus"/> | |
<MovieRole roleName="Trinity"/> | |
</Movie> | |
<Movie roleName="The Matrix Revolutions" year="2003-10-27"> | |
<MovieRole roleName="Neo"/> | |
<MovieRole roleName="Morpheus"/> | |
<MovieRole roleName="Trinity"/> | |
</Movie> | |
<Actor roleName="Keanu Reeves"/> | |
<Actor roleName="Laurence Fishburne"/> | |
<Actor roleName="Carrie-Anne Moss"/> | |
</MovieActorSystem> | |
<MovieActorSystembehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[ | |
var beh = { | |
postConfigure: function() { | |
this.writeCypher(); | |
this.cnode.remove(); | |
}, | |
// write out the Xholon app in a Neo4j Cypher format, similar to the original | |
writeCypher: function() { | |
var node = this.cnode.parent().first(); | |
var relationships = ""; | |
while (node) { | |
if (node.xhc().name() == "Movie") { | |
// (matrix1:Movie { id : '603', title : 'The Matrix', year : '1999-03-31' }), | |
node.println("(node" + node.id() + ":Movie { title : '" + node.role() | |
+ "', year : '" + node.year + "' }),"); | |
} | |
else if (node.xhc().name() == "Actor") { | |
// (neo:Actor { name:'Keanu Reeves' }), | |
node.println("(node" + node.id() + ":Actor { name : '" + node.role() + "' }),"); | |
// (matrix1)<-[:ACTS_IN { role : 'Neo' }]-(neo), | |
var i = 0; | |
var role = node.port(i++); | |
while (role) { | |
var movie = role.parent(); | |
relationships = relationships + "(node" + movie.id() + ")<-[:ACTS_IN { role : '" | |
+ role.role() + "' }]-(node" + node.id() + "),\n"; | |
role = node.port(i++); | |
} | |
} | |
node = node.next(); | |
} | |
this.cnode.parent().println(relationships); | |
} | |
} | |
]]></MovieActorSystembehavior> | |
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml, | |
<svg width="886pt" height="161pt" viewBox="0.00 0.00 886.00 160.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | |
<g id="graph1" class="graph" transform="scale(0.8 0.8) rotate(0) translate(4 156.8)"> | |
<title>35</title> | |
<polygon fill="white" stroke="white" points="-4,5 -4,-156.8 883,-156.8 883,5 -4,5"></polygon> | |
<text text-anchor="middle" x="439" y="-8.2" font-family="Times,serif" font-size="14.00">MovieActorSystem</text> | |
<g id="graph2" class="cluster"><title>cluster36</title> | |
<polygon fill="none" stroke="black" points="8,-32.8 8,-108.8 290,-108.8 290,-32.8 8,-32.8"></polygon> | |
<text text-anchor="middle" x="149" y="-92.2" font-family="Times,serif" font-size="14.00">The Matrix</text> | |
</g> | |
<g id="graph3" class="cluster"><title>cluster40</title> | |
<polygon fill="none" stroke="black" points="298,-32.8 298,-108.8 580,-108.8 580,-32.8 298,-32.8"></polygon> | |
<text text-anchor="middle" x="439" y="-92.2" font-family="Times,serif" font-size="14.00">The Matrix Reloaded</text> | |
</g> | |
<g id="graph4" class="cluster"><title>cluster44</title> | |
<polygon fill="none" stroke="black" points="588,-32.8 588,-108.8 870,-108.8 870,-32.8 588,-32.8"></polygon> | |
<text text-anchor="middle" x="729" y="-92.2" font-family="Times,serif" font-size="14.00">The Matrix Revolutions</text> | |
</g> | |
<!-- 37 --> | |
<g id="node2" class="node"><title>37</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="43" cy="-58.8" rx="27.1849" ry="18"></ellipse> | |
<text text-anchor="middle" x="43" y="-54.6" font-family="Times,serif" font-size="14.00">Neo</text> | |
</g> | |
<!-- 38 --> | |
<g id="node3" class="node"><title>38</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="138" cy="-58.8" rx="50.2877" ry="18"></ellipse> | |
<text text-anchor="middle" x="138" y="-54.6" font-family="Times,serif" font-size="14.00">Morpheus</text> | |
</g> | |
<!-- 39 --> | |
<g id="node4" class="node"><title>39</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="244" cy="-58.8" rx="37.2901" ry="18"></ellipse> | |
<text text-anchor="middle" x="244" y="-54.6" font-family="Times,serif" font-size="14.00">Trinity</text> | |
</g> | |
<!-- 41 --> | |
<g id="node6" class="node"><title>41</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="333" cy="-58.8" rx="27.1849" ry="18"></ellipse> | |
<text text-anchor="middle" x="333" y="-54.6" font-family="Times,serif" font-size="14.00">Neo</text> | |
</g> | |
<!-- 42 --> | |
<g id="node7" class="node"><title>42</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="428" cy="-58.8" rx="50.2877" ry="18"></ellipse> | |
<text text-anchor="middle" x="428" y="-54.6" font-family="Times,serif" font-size="14.00">Morpheus</text> | |
</g> | |
<!-- 43 --> | |
<g id="node8" class="node"><title>43</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="534" cy="-58.8" rx="37.2901" ry="18"></ellipse> | |
<text text-anchor="middle" x="534" y="-54.6" font-family="Times,serif" font-size="14.00">Trinity</text> | |
</g> | |
<!-- 45 --> | |
<g id="node10" class="node"><title>45</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="623" cy="-58.8" rx="27.1849" ry="18"></ellipse> | |
<text text-anchor="middle" x="623" y="-54.6" font-family="Times,serif" font-size="14.00">Neo</text> | |
</g> | |
<!-- 46 --> | |
<g id="node11" class="node"><title>46</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="718" cy="-58.8" rx="50.2877" ry="18"></ellipse> | |
<text text-anchor="middle" x="718" y="-54.6" font-family="Times,serif" font-size="14.00">Morpheus</text> | |
</g> | |
<!-- 47 --> | |
<g id="node12" class="node"><title>47</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="824" cy="-58.8" rx="37.2901" ry="18"></ellipse> | |
<text text-anchor="middle" x="824" y="-54.6" font-family="Times,serif" font-size="14.00">Trinity</text> | |
</g> | |
<!-- 48 --> | |
<g id="node13" class="node"><title>48</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="255" cy="-134.8" rx="66.3052" ry="18"></ellipse> | |
<text text-anchor="middle" x="255" y="-130.6" font-family="Times,serif" font-size="14.00">Keanu Reeves</text> | |
</g> | |
<!-- 48->37 --> | |
<g id="edge5" class="edge"><title>48->37</title> | |
<path fill="none" stroke="black" d="M190.758,-129.884C148.438,-126.328 97.5392,-119.891 79,-108.8 69.4883,-103.11 61.723,-93.844 55.8716,-84.8931"></path> | |
<polygon fill="black" stroke="black" points="58.8026,-82.9751 50.6643,-76.1913 52.796,-86.5695 58.8026,-82.9751"></polygon> | |
</g> | |
<!-- 48->41 --> | |
<g id="edge7" class="edge"><title>48->41</title> | |
<path fill="none" stroke="black" d="M281.869,-118.245C286.103,-115.33 290.299,-112.141 294,-108.8 302.232,-101.369 310.096,-92.0807 316.577,-83.5948"></path> | |
<polygon fill="black" stroke="black" points="319.446,-85.6016 322.561,-75.475 313.811,-81.4489 319.446,-85.6016"></polygon> | |
</g> | |
<!-- 48->45 --> | |
<g id="edge9" class="edge"><title>48->45</title> | |
<path fill="none" stroke="black" d="M301.784,-121.885C311.389,-119.849 321.476,-118.005 331,-116.8 358.903,-113.27 558.862,-121.414 584,-108.8 594.457,-103.553 603.014,-94.0588 609.421,-84.8156"></path> | |
<polygon fill="black" stroke="black" points="612.498,-86.4972 614.896,-76.1772 606.586,-82.7498 612.498,-86.4972"></polygon> | |
</g> | |
<!-- 49 --> | |
<g id="node14" class="node"><title>49</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="428" cy="-134.8" rx="87.4876" ry="18"></ellipse> | |
<text text-anchor="middle" x="428" y="-130.6" font-family="Times,serif" font-size="14.00">Laurence Fishburne</text> | |
</g> | |
<!-- 49->38 --> | |
<g id="edge11" class="edge"><title>49->38</title> | |
<path fill="none" stroke="black" d="M366.203,-122.002C354.227,-120.021 341.749,-118.168 330,-116.8 300.59,-113.375 224.534,-119.688 197,-108.8 182.989,-103.259 169.837,-93.0433 159.522,-83.3676"></path> | |
<polygon fill="black" stroke="black" points="161.795,-80.6939 152.22,-76.1602 156.878,-85.6759 161.795,-80.6939"></polygon> | |
</g> | |
<!-- 49->42 --> | |
<g id="edge13" class="edge"><title>49->42</title> | |
<path fill="none" stroke="black" d="M428,-116.637C428,-107.858 428,-96.9626 428,-87.0675"></path> | |
<polygon fill="black" stroke="black" points="431.5,-86.87 428,-76.87 424.5,-86.87 431.5,-86.87"></polygon> | |
</g> | |
<!-- 49->46 --> | |
<g id="edge15" class="edge"><title>49->46</title> | |
<path fill="none" stroke="black" d="M489.422,-121.949C501.196,-119.985 513.453,-118.152 525,-116.8 554.628,-113.331 631.257,-119.764 659,-108.8 673.012,-103.263 686.165,-93.0468 696.479,-83.3705"></path> | |
<polygon fill="black" stroke="black" points="699.123,-85.6785 703.781,-76.1625 694.206,-80.6968 699.123,-85.6785"></polygon> | |
</g> | |
<!-- 50 --> | |
<g id="node15" class="node"><title>50</title> | |
<ellipse fill="#90b0cc" stroke="black" cx="617" cy="-134.8" rx="82.4465" ry="18"></ellipse> | |
<text text-anchor="middle" x="617" y="-130.6" font-family="Times,serif" font-size="14.00">Carrie-Anne Moss</text> | |
</g> | |
<!-- 50->39 --> | |
<g id="edge17" class="edge"><title>50->39</title> | |
<path fill="none" stroke="black" d="M559.147,-121.875C547.552,-119.867 535.423,-118.036 524,-116.8 498.577,-114.049 317.502,-118.876 294,-108.8 281.608,-103.487 270.566,-93.5768 262.032,-84.0518"></path> | |
<polygon fill="black" stroke="black" points="264.59,-81.656 255.478,-76.2506 259.231,-86.1587 264.59,-81.656"></polygon> | |
</g> | |
<!-- 50->43 --> | |
<g id="edge19" class="edge"><title>50->43</title> | |
<path fill="none" stroke="black" d="M594.331,-117.23C590.813,-114.487 587.265,-111.617 584,-108.8 574.462,-100.572 564.452,-90.9749 555.915,-82.4659"></path> | |
<polygon fill="black" stroke="black" points="558.367,-79.968 548.841,-75.3303 553.396,-84.8962 558.367,-79.968"></polygon> | |
</g> | |
<!-- 50->47 --> | |
<g id="edge21" class="edge"><title>50->47</title> | |
<path fill="none" stroke="black" d="M697.919,-131.386C724.287,-127.982 752.943,-121.343 777,-108.8 788.318,-102.899 798.47,-93.2235 806.418,-84.0223"></path> | |
<polygon fill="black" stroke="black" points="809.214,-86.1315 812.809,-76.1652 803.783,-81.7145 809.214,-86.1315"></polygon> | |
</g> | |
</g> | |
</svg> | |
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient> | |
</XholonWorkbook> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment