Interface ModelAPIPlugin


public interface ModelAPIPlugin
Interface for processing model rest resource. Developer who is overriding ModelRestResource in studio can choose to provide plugin to customize the behaviour of model rest resource.
  • Method Details

    • afterReadByKey

      void afterReadByKey​(ReadByKeyParams params, org.json.JSONObject readByKeyResult, PlatformUserContext context)
      This method is called after the readByKey is processed. Using this method, developer can add or remove the level and field in readByKeyResult JSONObject
      Parameters:
      params - ReadByKeyParams
      readByKeyResult - JSONObject
      context - contextual user information
    • getSearchWhereClauseContribution

      WhereClauseContribution getSearchWhereClauseContribution​(SearchParams params, PlatformUserContext context)
      This method is called before executing search if the search doesn't belong to the owning module level model rest resource. Expected to return a where clause contributino consistent with the sql being used by the native module's impl
      Parameters:
      params - SearchParams
      context - contextual user information
      Returns:
      the sql for the overriden search
    • afterSearch

      void afterSearch​(SearchParams params, org.json.JSONObject searchResult, PlatformUserContext context)
      This method is called after the search is processed. Using this method, developer can add or remove the level and field in readByKeyResult JSONObject
      Parameters:
      params - SearchParams
      searchResult - JSONObject
      context - contextual user information
    • beforeWrite

      void beforeWrite​(org.json.JSONArray valid, org.json.JSONArray errors, PlatformUserContext context)
      This method is called before the write is happened on model.
      Parameters:
      valid - JSONArray containing valid records, i.e. All required fields present
      errors - JSONArray containing invalid records, i.e. Required fields missing or data is not as per the defined data type
      context - contextual user information
    • write

      org.json.JSONObject write​(WriteParams params, org.json.JSONArray errors, ModelAPI modelAPI, PlatformUserContext context)
      This method is only called if the provided resource action name doesn't belong to owning model rest resource. Developer can choose to provide their own implementation or delegate to ModelAPI to persist the records in DB
      Parameters:
      params - WriteParams containing valid records (i.e. All required fields present), resourceName and resourceActionName
      errors - JSONArray containing invalid records, i.e. Required fields missing or data is not as per the defined data type
      modelAPI - implementation for processing model rest resource
      context - contextual user information return response as JSONObject containing error records
    • afterWrite

      void afterWrite​(WriteParams params, org.json.JSONObject writeResult, PlatformUserContext context)
      This method is called after the models are persisted to the DB to perform any additional operation by module, i.e. write related model
      Parameters:
      params - WriteParams
      writeResult - JSONObject containing error records or empty
      context - contextual user information