From: <mwl...@us...> - 2010-01-26 16:34:33
|
Revision: 1024 http://cishell.svn.sourceforge.net/cishell/?rev=1024&view=rev Author: mwlinnem Date: 2010-01-26 16:34:27 +0000 (Tue, 26 Jan 2010) Log Message: ----------- An example jython CIShell algorithm (not tested to see if it still works). Added Paths: ----------- trunk/examples/test_jython_algorithm/.project trunk/examples/test_jython_algorithm/.pydevproject trunk/examples/test_jython_algorithm/META-INF/ trunk/examples/test_jython_algorithm/META-INF/MANIFEST.MF trunk/examples/test_jython_algorithm/OSGI-INF/ trunk/examples/test_jython_algorithm/OSGI-INF/algorithm.properties trunk/examples/test_jython_algorithm/OSGI-INF/component.xml trunk/examples/test_jython_algorithm/OSGI-INF/l10n/ trunk/examples/test_jython_algorithm/OSGI-INF/l10n/bundle_en.properties trunk/examples/test_jython_algorithm/OSGI-INF/metatype/ trunk/examples/test_jython_algorithm/OSGI-INF/metatype/METADATA.XML trunk/examples/test_jython_algorithm/README.txt trunk/examples/test_jython_algorithm/build.properties trunk/examples/test_jython_algorithm/donkey.py Added: trunk/examples/test_jython_algorithm/.project =================================================================== --- trunk/examples/test_jython_algorithm/.project (rev 0) +++ trunk/examples/test_jython_algorithm/.project 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>jbdd</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.python.pydev.PyDevBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.python.pydev.pythonNature</nature> + </natures> +</projectDescription> Added: trunk/examples/test_jython_algorithm/.pydevproject =================================================================== --- trunk/examples/test_jython_algorithm/.pydevproject (rev 0) +++ trunk/examples/test_jython_algorithm/.pydevproject 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?eclipse-pydev version="1.0"?> + +<pydev_project> +<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property> +<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> +</pydev_project> Added: trunk/examples/test_jython_algorithm/META-INF/MANIFEST.MF =================================================================== --- trunk/examples/test_jython_algorithm/META-INF/MANIFEST.MF (rev 0) +++ trunk/examples/test_jython_algorithm/META-INF/MANIFEST.MF 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Sample Jython Algorithm +Bundle-SymbolicName: org.cishell.templates.wizards.samplejythonalgorithm +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Bundle-Localization: plugin +Import-Package: org.cishell.templates.jythonrunner, + org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.osgi.framework;version="1.3.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml Added: trunk/examples/test_jython_algorithm/OSGI-INF/algorithm.properties =================================================================== --- trunk/examples/test_jython_algorithm/OSGI-INF/algorithm.properties (rev 0) +++ trunk/examples/test_jython_algorithm/OSGI-INF/algorithm.properties 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,14 @@ +menu_path=File/Test/additions +label=Sample Jython Algorithm +description=Demonstrates some basic Jython-based algorithm functionality. +in_data=prefuse.data.Graph +out_data=prefuse.data.Graph, file:text/plain +service.pid=org.cishell.templates.wizards.samplejythonalgorithm +remoteable=false +script_path=/donkey.py +result0.label=Exact same network that was passed in +result0.type=Network +result0.parent=arg0 +result1.label=Number of edges in provided network +result1.type=Text +result1.parent=arg0 Added: trunk/examples/test_jython_algorithm/OSGI-INF/component.xml =================================================================== --- trunk/examples/test_jython_algorithm/OSGI-INF/component.xml (rev 0) +++ trunk/examples/test_jython_algorithm/OSGI-INF/component.xml 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.templates.wizards.samplejythonalgorithm" immediate="false"> + <implementation class="org.cishell.templates.jythonrunner.JythonAlgorithmFactory"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + </service> +</component> \ No newline at end of file Added: trunk/examples/test_jython_algorithm/OSGI-INF/l10n/bundle_en.properties =================================================================== --- trunk/examples/test_jython_algorithm/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ trunk/examples/test_jython_algorithm/OSGI-INF/l10n/bundle_en.properties 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: trunk/examples/test_jython_algorithm/OSGI-INF/metatype/METADATA.XML =================================================================== --- trunk/examples/test_jython_algorithm/OSGI-INF/metatype/METADATA.XML (rev 0) +++ trunk/examples/test_jython_algorithm/OSGI-INF/metatype/METADATA.XML 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + <OCD name="Sample Jython Algorithm" id="org.cishell.templates.wizards.samplejythonalgorithm.OCD" + description="A sample jython algorithm"> + <AD name="Sample Attribute" id="sample_attr" type="Integer" description="Enter a positive integer" default="1" min="1" /> + </OCD> + <Designate pid="org.cishell.templates.wizards.samplejythonalgorithm"> + <Object ocdref="org.cishell.templates.wizards.samplejythonalgorithm.OCD" /> + </Designate> +</metatype:MetaData> Added: trunk/examples/test_jython_algorithm/README.txt =================================================================== --- trunk/examples/test_jython_algorithm/README.txt (rev 0) +++ trunk/examples/test_jython_algorithm/README.txt 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,40 @@ +Here is the minimum you need to know to integrate a jython script with +CIShell, working from what is already provided by default in this project. + +Arguments passed in from the Network Workbench Data Manager are passed +into your script by default as variables with the prefix "arg" and a +numeric suffix. The first argument is arg0, the next is arg1, and so on. +You may specify how many, and what type of data you want these to be by +editing the in_data property in the algorithm.properties file. The + +Arguments passed in from the user at the time the algorithm is run (The +kind where a dialog box pops up and the user fills things in) can have +any valid python variable name. You can define what data you need, the +type of data, and the variable names of that data by editing the +METADATA.XML file. The id provided will be the name of the variable in +the python environment. + +To return results, assign values to variables with the prefix "result". +The first result is result0, the second is result1, and so on. You +must specify the format of the data you are returning by editing the +out_data property in the algorithm.properties file. You must also +define values for the metadata of each result you return. Look at the +algorithm.properties file to see how this is done. Each result must +specify a label and type, but parent part is optional. Label can be +any text, type must be one of the pre-define types ("Network", "Text", +"Matrix", or "Other" currently), and parent must be the variable +name of one of the provided data arguments (arg0, arg1, etc...). + +Change the menu path to something sensible too. + +NOTE: There are other things that should probably be changed if you +are doing anything more than playing around with the jython algorithm +capabilities in CIShell. The plugin name, symbolic-name, all references +to the package, the service.pid, the algorithm description, and +probably a few other things should be unique for each project. This +template is currently in a rough state. It should probably have +a wizard that asks the user to specify all the stuff that +should change between projects. This should do for now though, +especially for internal use. + + \ No newline at end of file Added: trunk/examples/test_jython_algorithm/build.properties =================================================================== --- trunk/examples/test_jython_algorithm/build.properties (rev 0) +++ trunk/examples/test_jython_algorithm/build.properties 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,5 @@ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/,\ + samplealgorithm.py,\ + donkey.py Added: trunk/examples/test_jython_algorithm/donkey.py =================================================================== --- trunk/examples/test_jython_algorithm/donkey.py (rev 0) +++ trunk/examples/test_jython_algorithm/donkey.py 2010-01-26 16:34:27 UTC (rev 1024) @@ -0,0 +1,29 @@ +# To see the output printed to the console in Network Workbench, use the +# switch "-console" when opening Network Workbench from the command line. +from java import io + +print "Here is the value you gave me when you ran the algorithm..." +print sample_attr + +print "Here is what I got from CIShell (the graph you highlighted)" +print arg0 +graph = arg0 +edge_count = graph.getEdgeCount() + +print "Here is the number of edges in the graph you provided..." +print edge_count + +aFile = io.File("whatever.txt") +writer = io.BufferedWriter(io.FileWriter(aFile)) +writer.write(str(edge_count)) +writer.close() + +print "I will now return the original graph, and the edge count in a file" + +aFile = io.File("whatever.txt") +writer = io.BufferedWriter(io.FileWriter(aFile)) +writer.write(str(edge_count)) +writer.close() + +result0 = arg0 +result1 = aFile \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |