Interface CypherModificationProvider


public interface CypherModificationProvider
This interface can be implemented by extensions that wish to modify Cypher statements before they are being sent by corresponding OGM driver to the database.

OGM makes sure that the modification will be applied to all statements, regardless of source, but implementations of the service must not rely on the fact that the modification happens currently on the drivers level, which may change without notice.

To add your custom modification, create a separate module, implement this interface and return an arbitrary Function. As an optional step, overwrite the getOrder() method in case you have multiple modifications on the class path. The lower the value it returns, the higher it's priority. Higher priority means modification is applied first.

OGM loads implementations through Java's builtin Service Provider Interfache mechanism. Please refer to Oracle's documentation of Java's Service Provide Interface to declare your implementation. In short: Define a file called META-INF/services/org.neo4j.ogm.spi.CypherModificationProvider in your module containing the fully qualified name of your CypherModificationProvider-Implementation.

Inside the function returned by getCypherModification(Map)} the Cypher modification itself is supposed to happend. The function is called with the Cypher string generated by OGM or passed to the Session interface and is then supposed to return a non null, non empty string.

The map passed to getCypherModification(Map)} contains arbitrary properties from OGMs Configuration. Those can be set programmatically in any way necessary. Use those properties to configure your Cypher modification as needed.
Since:
3.1.4
Author:
Michael J. Simons
  • Method Details

    • getOrder

      default int getOrder()
      Get the order value of this object. Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority. Same order values will result in arbitrary sort positions for the affected objects.
      Returns:
      the order value
    • getCypherModification

      Function<String,String> getCypherModification(Map<String,Object> configuration)
      Called by OGM to retrieve the actual Cypher modification.
      Parameters:
      configuration - Map containing all custom properties from Configuration
      Returns:
      The actual cypher modification