Class N8nService

java.lang.Object
org.bgerp.plugin.ai.aixflow.service.N8nService

public class N8nService extends Object
Service for communicating with n8n external service
  • Constructor Details

    • N8nService

      public N8nService()
      Constructor
  • Method Details

    • sendFileToN8n

      public FileN8nTask sendFileToN8n(Connection con, int fileId, String secret) throws Exception
      Send a file to n8n for processing
      Parameters:
      con - database connection
      fileId - the file ID to send
      secret - the file secret
      Returns:
      the created task
      Throws:
      Exception - if an error occurs
    • handleN8nCallback

      public boolean handleN8nCallback(Connection con, String taskId, String status, String result, String errorMessage) throws SQLException
      Handle a callback from n8n with task results
      Parameters:
      con - database connection
      taskId - the task ID
      status - the task status
      result - the task result
      errorMessage - the error message (if any)
      Returns:
      true if the task was updated, false if not found
      Throws:
      SQLException - if a database error occurs
    • requestTaskDataFromN8n

      public String requestTaskDataFromN8n(Connection con, String taskId) throws Exception
      Request task data from n8n
      Parameters:
      con - database connection
      taskId - the task ID to request data for
      Returns:
      the response from n8n as a JSON string
      Throws:
      Exception - if an error occurs
    • deleteTask

      public boolean deleteTask(Connection con, String taskId) throws Exception
      Delete a task from n8n and from the database
      Parameters:
      con - database connection
      taskId - the task ID to delete
      Returns:
      true if the task was deleted, false if not found
      Throws:
      Exception - if an error occurs