use of org.neo4j.kernel.api.proc.QualifiedName in project neo4j by neo4j.
the class ProcedureRegistry method register.
/**
* Register a new function.
*
* @param function the function.
*/
public void register(CallableUserFunction function, boolean overrideCurrentImplementation) throws ProcedureException {
UserFunctionSignature signature = function.signature();
QualifiedName name = signature.name();
CallableUserFunction oldImplementation = functions.get(name);
if (oldImplementation == null) {
functions.put(name, function);
} else {
if (overrideCurrentImplementation) {
functions.put(name, function);
} else {
throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "Unable to register function, because the name `%s` is already in use.", name);
}
}
}
use of org.neo4j.kernel.api.proc.QualifiedName in project neo4j by neo4j.
the class ProcedureRegistry method register.
/**
* Register a new function.
*
* @param function the function.
*/
public void register(CallableUserAggregationFunction function, boolean overrideCurrentImplementation) throws ProcedureException {
UserFunctionSignature signature = function.signature();
QualifiedName name = signature.name();
CallableUserFunction oldImplementation = functions.get(name);
if (oldImplementation == null) {
aggregationFunctions.put(name, function);
} else {
if (overrideCurrentImplementation) {
aggregationFunctions.put(name, function);
} else {
throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "Unable to register aggregation function, because the name `%s` is already in use.", name);
}
}
}
use of org.neo4j.kernel.api.proc.QualifiedName in project neo4j by neo4j.
the class ProceduresKernelIT method shouldCallReadOnlyProcedure.
@Test
public void shouldCallReadOnlyProcedure() throws Throwable {
// Given
kernel.registerProcedure(procedure);
// When
RawIterator<Object[], ProcedureException> found = procedureCallOpsInNewTx().procedureCallRead(new QualifiedName(new String[] { "example" }, "exampleProc"), new Object[] { 1337 });
// Then
assertThat(asList(found), contains(equalTo(new Object[] { 1337 })));
}
use of org.neo4j.kernel.api.proc.QualifiedName in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldSetAllowedToConfigSetting.
@Test
public void shouldSetAllowedToConfigSetting() throws Throwable {
configuredSetup(stringMap(SecuritySettings.default_allowed.name(), "nonEmpty"));
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
assertThat(Arrays.asList(numNodes.allowed()), containsInAnyOrder("nonEmpty"));
}
use of org.neo4j.kernel.api.proc.QualifiedName in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldSetAllowedToConfigSettingForUDF.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void shouldSetAllowedToConfigSettingForUDF() throws Throwable {
configuredSetup(stringMap(SecuritySettings.default_allowed.name(), "nonEmpty"));
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
UserFunctionSignature funcSig = procedures.function(new QualifiedName(new String[] { "test" }, "nonAllowedFunc")).get();
assertThat(Arrays.asList(funcSig.allowed()), containsInAnyOrder("nonEmpty"));
}
Aggregations