Groovy Imports ExampleΒΆ
Here we illustrate the use of importing in the groovy file, which applies these imports to all the function definitions.
1 2 3 4 5 6 7 8 9 | import com.thinkaurelius.titan.core.util.*;
def test_method(a1, a2) {
return a1, a2
}
def test_second_method(a1, a2) {
return (a1..a2)
}
|
Here we illustrate the use of additional imports directly on specific GremlinMethod or GremlinValue:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from mogwai.connection import setup
from mogwai.models import Vertex
from mogwai import properties
from mogwai.gremlin import GremlinMethod
setup('127.0.0.1')
class Trinket(Vertex):
element_type = 'gadget'
name = properties.String(required=True, max_length=1024)
test_method = GremlinMethod(path='example_groovy_imports.groovy', method_name='test_method',
imports=['com.thinkaurelius.titan.core.util.*'], classmethod=True)
# Call the test method:
result1, result2 = Trinket.test_method(1, 2)
assert result1 == 1
assert result2 == 2
|