public class TokenProcedures { @Context public KernelTransaction tx; @Description( "Create a label" ) @Procedure( name = "db.createLabel", mode = WRITE ) public void createLabel( @Name( "newLabel" ) String newLabel ) throws IllegalTokenNameException, TooManyLabelsException { tx.tokenWrite().labelGetOrCreateForName( newLabel ); } @Description( "Create a RelationshipType" ) @Procedure( name = "db.createRelationshipType", mode = WRITE ) public void createRelationshipType( @Name( "newRelationshipType" ) String newRelationshipType ) throws IllegalTokenNameException { tx.tokenWrite().relationshipTypeGetOrCreateForName( newRelationshipType ); } @Description( "Create a Property" ) @Procedure( name = "db.createProperty", mode = WRITE ) public void createProperty( @Name( "newProperty" ) String newProperty ) throws IllegalTokenNameException { tx.tokenWrite().propertyKeyGetOrCreateForName( newProperty ); } }
public static class FunctionWithUnsafeAPI { @Context public MyUnsafeAPI api; @UserFunction public String listCoolPeople() { return api.listCoolPeople().toString(); } } public static class AggregationFunctionWithUnsafeAPI
public static class ProcedureWithStaticContextAnnotatedField { @Context public static GraphDatabaseService gdb; @Procedure public Stream<MyOutputRecord> test( ) { return null; } }
public static class ParentProcedure { @Context public int parentField; }
public class ClassWithSyntheticField { //this class will have a generated field: //synthetic Outer this$0; @Context public int innerField; } }
public static class FunctionWithStaticContextAnnotatedField { @Context public static GraphDatabaseService gdb; @UserFunction public Object test( ) { return null; } }
public static class FunctionWithInjectedAPI { @Context public MyAwesomeAPI api; @UserFunction public String listCoolPeople() { return api.listCoolPeople().toString(); } }
public static class ProcedureWithPrivateMemberField { @Context private boolean someState; }
public static class ChildProcedure extends ParentProcedure { @Context public int childField; }
public static class MyFunctionsUsingMyService { @Context public SomeService service; @UserFunction( "my.hello" ) public String hello() { return service.hello(); } }
public static class ProcedureWithInjectedAPI { @Context public MyAwesomeAPI api; @Procedure public Stream<MyOutputRecord> listCoolPeople() { return api.listCoolPeople().stream().map( MyOutputRecord::new ); } }
public static class ProcedureWithUnknownAPI { @Context public UnknownAPI api; @Procedure public Stream<MyOutputRecord> listCoolPeople() { return api.listCoolPeople().stream().map( MyOutputRecord::new ); } }
public static class ProcedureWithUnsafeAPI { @Context public MyUnsafeAPI api; @Procedure public Stream<MyOutputRecord> listCoolPeople() { return api.listCoolPeople().stream().map( MyOutputRecord::new ); } }
public static class FunctionWithUnknownAPI { @Context public UnknownAPI api; @UserFunction public String listCoolPeople() { return api.listCoolPeople().toString(); } }
public static class LoggingFunction { @Context public Log log; @UserFunction public long logAround() { log.debug( "1" ); log.info( "2" ); log.warn( "3" ); log.error( "4" ); return -1L; } }
public static class LoggingProcedure { @Context public Log log; @Procedure public Stream<MyOutputRecord> logAround() { log.debug( "1" ); log.info( "2" ); log.warn( "3" ); log.error( "4" ); return Stream.empty(); } }
public static class ClassWithUnsafeConfiguredComponent { @Context public UnsafeAPI api; @Procedure public Stream<Output> unsafeFullAccessProcedure() { return Stream.of( new Output( api.getNumber() ) ); } @UserFunction public long unsafeFullAccessFunction() { return api.getNumber(); } }