-
Notifications
You must be signed in to change notification settings - Fork 116
Source
Kristian Karl edited this page Mar 4, 2021
·
9 revisions
Will generate source code using the provided model and a template.
Options
-
--input
,-i
This command requires an input model file, and an input template.
-
--blocked
,-b
This option enables or disables the BLOCKED feature. When
-b true
GraphWalker will filter out elements in models with the keyword BLOCKED. When-b false
GraphWalker will not filter out any elements in models with the keyword BLOCKED.
Default is true.
Generate python source code for the Login.graphml model,
java -jar graphwalker-4.3.1.jar source -i Login.graphml python.template
The template file can use the following parameters. They will be substituted during the source generation.
- The HEADER section. It will only be replaced once.
HEADER<{{
Any code or comments you would like to be first in your source code.
}}>HEADER
- All code between the HEADER and the FOOTER sections are repeated with the same number
of unique methods in the model. The parameter used here is the LABEL.
The LABEL will be replaced with the method name.
{LABEL}
- The FOOTER section. It will only be replaced once.
FOOTER<{{
Any code or comments you need at the end of your source code.
}}>FOOTER
A python template
HEADER<{{
import requests,json
##
## 1) Generate python stub source code:
## java -jar graphwalker-4.3.1-jar source -i model.graphml python.template > model.py
##
## 2) Start graphwalker:
## java -jar graphwalker-4.3.1.jar online --service RESTFUL -m model.graphml "random(edge_coverage(100))"
##
## 3) Run the python program:
## python model.py
##
}}>HEADER
def {LABEL}() :
print( "{LABEL}" )
return
FOOTER<{{
gw_url = 'http://localhost:8887/graphwalker'
while requests.get(gw_url+'/hasNext').json()['hasNext'] == 'true' :
# Get next step from GraphWalker
step = requests.get(gw_url+'/getNext').json()['currentElementName']
if step != '' :
eval( step + "()" )
}}>FOOTER
A perl template
HEADER<{{
use strict;
use warnings;
##
## 1) Generate perl stub source code:
## java -jar graphwalker-4.3.1.jar source -i model.graphml perl.template > model.perl
##
## 2) Start graphwalker:
## java -jar graphwalker-4.3.1.jar online -s RESTFUL -m model.graphml "random(edge_coverage(100))"
##
## 3) Run the perl program:
## perl login.perl http://localhost:8887/graphwalker
##
use LWP::Simple;
my $host = $ARGV[0];
while ( get $host."/hasNext" eq "true"){
# Get next step from GraphWalker
my $step = get $host."/getNext";
if ($step ne '') {
# Run the step
eval( $step ) or die;
}
}
}}>HEADER
#
# This sub routine implements: '{LABEL}'
#
sub {LABEL}()
{
print "{LABEL}\n";
}
FOOTER<{{
#End of generated source code
}}>FOOTER