Class BaseModelResourceListener
java.lang.Object
com.onenetwork.platform.integ.rest.model.BaseModelResourceListener
public class BaseModelResourceListener
extends java.lang.Object
Base class which defines event handlers for the events
inside the ModelResource; all of the methods in this class
have default implementations, so a subclass only needs to
implement the methods it needs.
Note: Subclasses need to:
- add the
ModelResourceListener
annotation at the class level and provide a modelLevelType and, optionally, a customModelName - be located under the com.onenetwork.
.rest package. They can be in any subpackage, as long as it's in your module's rest package.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
customModelName
protected javax.servlet.http.HttpServletRequest
httpRequest
protected com.onenetwork.platform.data.model.impl.ModelLevelType
modelLevelType
protected PlatformUserContext
platformUserContext
protected PlatformUserProfile
userProfile
-
Constructor Summary
Constructors Constructor Description BaseModelResourceListener()
-
Method Summary
Modifier and Type Method Description void
beforeActionExecuted(java.lang.String actionName, org.json.JSONObject modelJSON)
Called before the action is executed, right before the modelJSON converted into a Model object, so this method is called beforebeforeActionExecuted(String, JSONObject, Model)
void
beforeActionExecuted(java.lang.String actionName, org.json.JSONObject modelJSON, Model model)
Called before the action is executed, after the Model object has been created from the json that was passed from the client, so this method is called afterbeforeActionExecuted(String, JSONObject)
, and modelJSON is merely provided for reading extra fields that need to be populated on the Model; it should not be modifiedvoid
beforeDeleteExecuted(java.lang.String actionName, org.json.JSONObject modelJSON, Model model)
Called before the delete action for children is executed, after the Model object has been created from the json that was passed from the client.void
beforeModelWrite(ModelWriteRequest<? extends Model> writeRequest, PlatformUserProfile profile)
Called just before the ModelDataService.write is called, both for action execution as well as "delete" execution if child levels are being deleted.void
initialize(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String cmn)
void
initialize(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String cmn, javax.servlet.http.HttpServletRequest request)
void
onActionExecuted(java.lang.String actionName, Model model, ModelFormJSONObject jsonToReturn)
Called after the action has been executed and jsonToReturn contains a sysId property if it was successful.void
onActionScreenExecuted(java.lang.String actionName, java.lang.Long sysId, Model model)
Called after the detail action screen has been retrieved but before the Model has been converted to JSON, so values may be set on the Model (in both CREATE and WRITE actions) and they will be passed up to the UIvoid
onActionScreenExecuted(java.lang.String actionName, java.lang.Long sysId, ModelFormJSONObject jsonToReturn)
Called after the detail action screen has been retrieved and the Model has been converted to JSON, so this method is called afteronActionScreenExecuted(String, Long, Model)
, and jsonToReturn contains the fields array and model objectvoid
onActionsRetrieved(java.util.List<java.lang.Long> sysIds, ModelFormJSONObject jsonToReturn)
Called after the actions have been fetched and jsonToReturn contains the array of action names.void
onViewExecuted(java.lang.String viewName, java.lang.Long sysId, ModelFormJSONObject jsonToReturn)
Called after the detail view has been executed and jsonToReturn contains the fields array and model object
-
Field Details
-
userProfile
-
platformUserContext
-
modelLevelType
protected com.onenetwork.platform.data.model.impl.ModelLevelType modelLevelType -
customModelName
protected java.lang.String customModelName -
httpRequest
protected javax.servlet.http.HttpServletRequest httpRequest
-
-
Constructor Details
-
BaseModelResourceListener
public BaseModelResourceListener()
-
-
Method Details
-
initialize
public void initialize(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String cmn) -
initialize
public void initialize(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String cmn, javax.servlet.http.HttpServletRequest request) -
onViewExecuted
public void onViewExecuted(java.lang.String viewName, java.lang.Long sysId, ModelFormJSONObject jsonToReturn)Called after the detail view has been executed and jsonToReturn contains the fields array and model object- Parameters:
viewName
-sysId
-jsonToReturn
-
-
onActionsRetrieved
public void onActionsRetrieved(java.util.List<java.lang.Long> sysIds, ModelFormJSONObject jsonToReturn)Called after the actions have been fetched and jsonToReturn contains the array of action names. You can access thatJSONArray
by calling jsonToReturn.getActions().- Parameters:
sysIds
-jsonToReturn
-
-
onActionScreenExecuted
Called after the detail action screen has been retrieved but before the Model has been converted to JSON, so values may be set on the Model (in both CREATE and WRITE actions) and they will be passed up to the UI- Parameters:
actionName
-sysId
-model
-
-
onActionScreenExecuted
public void onActionScreenExecuted(java.lang.String actionName, java.lang.Long sysId, ModelFormJSONObject jsonToReturn)Called after the detail action screen has been retrieved and the Model has been converted to JSON, so this method is called afteronActionScreenExecuted(String, Long, Model)
, and jsonToReturn contains the fields array and model object- Parameters:
actionName
-sysId
-jsonToReturn
-
-
beforeActionExecuted
public void beforeActionExecuted(java.lang.String actionName, org.json.JSONObject modelJSON)Called before the action is executed, right before the modelJSON converted into a Model object, so this method is called beforebeforeActionExecuted(String, JSONObject, Model)
- Parameters:
actionName
-modelJSON
-
-
beforeActionExecuted
public void beforeActionExecuted(java.lang.String actionName, org.json.JSONObject modelJSON, Model model)Called before the action is executed, after the Model object has been created from the json that was passed from the client, so this method is called afterbeforeActionExecuted(String, JSONObject)
, and modelJSON is merely provided for reading extra fields that need to be populated on the Model; it should not be modified- Parameters:
actionName
-modelJSON
-model
-
-
onActionExecuted
public void onActionExecuted(java.lang.String actionName, Model model, ModelFormJSONObject jsonToReturn)Called after the action has been executed and jsonToReturn contains a sysId property if it was successful. If a DoNotWriteException is thrown from beforeActionExecuted(), then the action will NOT be executed but this method will still be called to allow modification of [jsonToReturn]. In that case, [model] will be the same Model object which was passed intobeforeActionExecuted(String, JSONObject, Model)
.- Parameters:
actionName
-model
-jsonToReturn
-
-
beforeDeleteExecuted
public void beforeDeleteExecuted(java.lang.String actionName, org.json.JSONObject modelJSON, Model model)Called before the delete action for children is executed, after the Model object has been created from the json that was passed from the client. The modelJSON is merely provided for reading extra fields that need to be populated on the Model; it should not be modified. However the model object itself can be modified, and that will be passed to the ModelDataService during deletion.- Parameters:
actionName
-modelJSON
-model
-
-
beforeModelWrite
public void beforeModelWrite(ModelWriteRequest<? extends Model> writeRequest, PlatformUserProfile profile)Called just before the ModelDataService.write is called, both for action execution as well as "delete" execution if child levels are being deleted. This gives the client a last-minute opportunity to tweak the Models and/or ModelWriteRequest before saving.- Parameters:
writeRequest
- write request for executing the action (can be a delete action if we are deleting child levels)profile
- user profile
-