Package com.onenetwork.platform.restapi
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 Summary
Modifier and Type Method Description void
afterReadByKey(ReadByKeyParams params, org.json.JSONObject readByKeyResult, PlatformUserContext context)
This method is called after the readByKey is processed.void
afterSearch(SearchParams params, org.json.JSONObject searchResult, PlatformUserContext context)
This method is called after the search is processed.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.void
beforeWrite(org.json.JSONArray valid, org.json.JSONArray errors, PlatformUserContext context)
This method is called before the write is happened on model.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.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.
-
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
This method is called before the write is happened on model.- Parameters:
valid
- JSONArray containing valid records, i.e. All required fields presenterrors
- JSONArray containing invalid records, i.e. Required fields missing or data is not as per the defined data typecontext
- 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 toModelAPI
to persist the records in DB- Parameters:
params
-WriteParams
containing valid records (i.e. All required fields present), resourceName and resourceActionNameerrors
- JSONArray containing invalid records, i.e. Required fields missing or data is not as per the defined data typemodelAPI
- implementation for processing model rest resourcecontext
- contextual user information return response as JSONObject containing error records
-
afterWrite
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 emptycontext
- contextual user information
-