There is no procedure with the name "apoc.refactor.mergeNodes"

apoc

(Fsportelli0) #1

Hello.
I'm using Apoc Procedures in my Java app. I'm interested into XML import and the function mergeNodes.
The first one works fine, but the problem is only on the second one: mergeNodes.
I know how to register APOC procedures, so here my code:

private static void registerApocProcedure(GraphDatabaseService graphDB) throws IllegalArgumentException {
    //Register APOC procedures
    Procedures procedures = ((GraphDatabaseAPI) graphDB).getDependencyResolver().resolveDependency(Procedures.class);
    List<Class<?>> apocProcedures = Arrays.asList(Xml.class, Merge.class, RefactorConfig.class, RefactorResult.class, RelationshipRefactorResult.class, NodeRefactorResult.class);
    apocProcedures.forEach((proc) -> {
        try {
            procedures.registerProcedure(proc);
        } catch (KernelException e) {
            throw new RuntimeException("Error registering "+proc,e);
        }
    });
}

As you can see I also included some procedures that recalls the name of apoc.refactor.mergeNodes, but when I run my app I got the error:

There is no procedure with the name apoc.refactor.mergeNodes registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

It seems to me that I'm not using the right APOC procedure. If this is the problem, which is the right APOC procedure which implements the mergeNodes?
Thanks!


(Stefan Armbruster) #2

Looks like you're missing GraphRefactoring, see https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/3.4/src/main/java/apoc/refactor/GraphRefactoring.java#L119

On a different notice: if you're using apoc procedures from within your java code, you can directly instantiate the class implementing the apoc procedure like this (pseudo code)

GraphRefactoring graphRefactoring = new GraphRefactoring();
graphRefactoring.db = myGraphDb;
graphRefactoring.log = myLog;
graphRefactoring.mergeNodes(params)

This way you don't have to register anything.