Found an answer. The problem seems to be that I was sending a map of 
parameter values through the execute method:

Map<String,Object> params = new HashMap<String,Object>();

params.put("a", 3);

params.put("b", 5);

Object result = fun.execute(params);

When what I needed to do was just pass the values:
Object result = fun.execute(3,5);





On Thursday, September 25, 2014 10:14:57 AM UTC-4, Seamus Minogue wrote:
>
> Background: I do not have the studio available to me so everything I do 
> has to be in java making use of the jars included using maven.
>
> I am trying to create a JS function based on documentation found here: 
> https://github.com/orientechnologies/orientdb/wiki/Functions
>
> I have managed to create the function and it executed properly but I am 
> having problems when trying to use parameters.
>
> orientGraphFactory = new OrientGraphFactory("plocal:" + secureProperties.
> getProperty("orientdb"), "admin", "admin");
>
> OFunction fun = orientGraphFactory.getDatabase().getMetadata().
> getFunctionLibrary().createFunction("summ");
>
> fun.setLanguage("JAVASCRIPT");
>
>
> List<String> paramNames = new ArrayList<String>();
>
> paramNames.add("a");
>
> paramNames.add("b");
>
> fun.setParameters(paramNames);
>
> fun.setCode("return a + b;");
>
> Map<String,Object> params = new HashMap<String,Object>();
>
> params.put("a", 3);
>
> params.put("b", 5);
>
> Object result = fun.execute(params);
>
> ystem.out.println(result);
>
> Results in the output: {b=5, a=3}undefined
>
> When I dont use parameters and define a and b var a=3,b=5; in the function 
> code it spits out 8.0 so I know my function is being created and executes 
> as JS correctly. Most of the documentation I am finding about functions all 
> seem to make use of the studio so I am kinda feeling my way through blind.
>
> What am I doing wrong? And is there a documentation page that I am not 
> finding which details creating and using functions without the studio?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to