I'm trying to create a user defined procedure and it compiles okay but Neo4j fails to re-start after introducing the jar file. I'm trying to convert a string of 0's and 1's representing a base 2 number to a base 10 number which is returned as a long integer. I don't understand how to get the long output required by Neo4j. The error message in the log file is:
Caused by: org.neo4j.internal.kernel.api.exceptions.ProcedureException: Argument
radix
at position 1 inbaseConvert
with typeInteger
cannot be converted to a Neo4j type: Don't know how to mapjava.lang.Integer
to the Neo4j Type System.
The code is:
package genealogy;
import org.neo4j.procedure.Description;
import org.neo4j.procedure.Name;
import org.neo4j.procedure.UserFunction;
/**
* This is an example of a simple user-defined function for Neo4j to perform a baseConvert
*/
public class base2to10 {
@UserFunction
@Description("example.baseConvert('1101', 2) - Convert the provided base 2 string to a base 10 integer.")
public Integer baseConvert(
@Name("s")
String s,
@Name(value = "radix")
Integer radix
)
{
if (s == null || radix == null) {
return null;
}
return Integer.parseInt(s, radix);
}
}