use of org.neo4j.kernel.impl.proc.OutputMappers.OutputMapper in project neo4j by neo4j.
the class OutputMappersTest method shouldSkipStaticFields.
@Test
public void shouldSkipStaticFields() throws Throwable {
// When
OutputMapper mapper = mapper(RecordWithStaticFields.class);
// Then
assertThat(mapper.signature(), contains(new FieldSignature("includeMe", Neo4jTypes.NTString)));
assertThat(asList(mapper.apply(new RecordWithStaticFields("hello, world!"))), contains("hello, world!"));
}
use of org.neo4j.kernel.impl.proc.OutputMappers.OutputMapper in project neo4j by neo4j.
the class OutputMappersTest method shouldMapSimpleRecordWithString.
@Test
public void shouldMapSimpleRecordWithString() throws Throwable {
// When
OutputMapper mapper = mapper(SingleStringFieldRecord.class);
// Then
assertThat(mapper.signature(), contains(new FieldSignature("name", Neo4jTypes.NTString)));
assertThat(asList(mapper.apply(new SingleStringFieldRecord("hello, world!"))), contains("hello, world!"));
}
use of org.neo4j.kernel.impl.proc.OutputMappers.OutputMapper in project neo4j by neo4j.
the class ReflectiveProcedureCompiler method compileProcedure.
private CallableProcedure compileProcedure(Class<?> procDefinition, MethodHandle constructor, Method method, Optional<String> warning, boolean fullAccess, QualifiedName procName) throws ProcedureException, IllegalAccessException {
MethodHandle procedureMethod = lookup.unreflect(method);
List<FieldSignature> inputSignature = inputSignatureDeterminer.signatureFor(method);
OutputMapper outputMapper = outputMappers.mapper(method);
Optional<String> description = description(method);
Procedure procedure = method.getAnnotation(Procedure.class);
Mode mode = procedure.mode();
if (method.isAnnotationPresent(PerformsWrites.class)) {
if (!procedure.mode().equals(org.neo4j.procedure.Mode.DEFAULT)) {
throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "Conflicting procedure annotation, cannot use PerformsWrites and mode");
} else {
mode = Mode.WRITE;
}
}
Optional<String> deprecated = deprecated(method, procedure::deprecatedBy, "Use of @Procedure(deprecatedBy) without @Deprecated in " + procName);
List<FieldInjections.FieldSetter> setters = allFieldInjections.setters(procDefinition);
if (!fullAccess && !config.fullAccessFor(procName.toString())) {
try {
setters = safeFieldInjections.setters(procDefinition);
} catch (ComponentInjectionException e) {
description = Optional.of(procName.toString() + " is not available due to having restricted access rights, check configuration.");
log.warn(description.get());
ProcedureSignature signature = new ProcedureSignature(procName, inputSignature, outputMapper.signature(), Mode.DEFAULT, Optional.empty(), new String[0], description, warning);
return new FailedLoadProcedure(signature);
}
}
ProcedureSignature signature = new ProcedureSignature(procName, inputSignature, outputMapper.signature(), mode, deprecated, config.rolesFor(procName.toString()), description, warning);
return new ReflectiveProcedure(signature, constructor, procedureMethod, outputMapper, setters);
}
Aggregations