Class BaseTemplateResourceListener

java.lang.Object
com.onenetwork.platform.integ.rest.template.BaseTemplateResourceListener

public class BaseTemplateResourceListener
extends java.lang.Object
Base class which defines event handlers for the events inside the TemplateResource; 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 TemplateResourceListener annotation at the class level and provide a modelLevelType
  • 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 extraType  
    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
    BaseTemplateResourceListener()  
  • Method Summary

    Modifier and Type Method Description
    void beforeEdit​(Model templateJaxb, org.json.JSONObject additionalInfo)
    Called before updating template in the system.
    void beforeSave​(Model templateJaxb, org.json.JSONObject additionalInfo)
    Called before saving a new template in the system.
    boolean beforeTemplateRetrieved​(java.lang.Long creationTemplateId, boolean isDetailTemplate, org.json.JSONObject jsonToReturn)
    Called before the template is fetched for the user.
    static void convertTemplateSQLToJSON​(org.json.JSONObject retObj, SqlRow sqlRow, PlatformUserContext platformUserContext)
    Helper method that converts a Template instance in the form of a SqlRow to a JSONObject that can be passed to the client.
    void initialize​(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String type)  
    void initialize​(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String type, javax.servlet.http.HttpServletRequest request)  
    void onAllTemplatesRetrieved​(org.json.JSONArray templatesArray)
    Called after the list of templates have been retrieved for the Switch Template dialog in the UI.
    void onTemplateRetrieved​(org.json.JSONObject jsonToReturn)
    Called after the template has been fetched for the user.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • initialize

      public void initialize​(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String type)
    • initialize

      public void initialize​(PlatformUserProfile up, com.onenetwork.platform.data.model.impl.ModelLevelType mlt, java.lang.String type, javax.servlet.http.HttpServletRequest request)
    • beforeTemplateRetrieved

      public boolean beforeTemplateRetrieved​(java.lang.Long creationTemplateId, boolean isDetailTemplate, org.json.JSONObject jsonToReturn)
      Called before the template is fetched for the user. You can override this to provide your own implementation for fetching a create/detail template. If this function returns false, it will skip the default implementation for fetching the template and will just return jsonToReturn, but onTemplateRetrieved will be called regardless of the return value.

      See onTemplateRetrieved for details on what properties should be included in jsonToReturn.

      Parameters:
      creationTemplateId - The creation template id for the model instance. If this is a create page or the model instance was not created with a template, this will be null.
      isDetailTemplate -
      jsonToReturn -
      Returns:
    • onTemplateRetrieved

      public void onTemplateRetrieved​(org.json.JSONObject jsonToReturn)
      Called after the template has been fetched for the user. jsonToReturn can be populated using a SqlRow by calling convertTemplateSQLToJSON.
    • onAllTemplatesRetrieved

      public void onAllTemplatesRetrieved​(org.json.JSONArray templatesArray)
      Called after the list of templates have been retrieved for the Switch Template dialog in the UI. templatesArray is a JSONArray of JSONObjects, each having the structure returned by convertTemplateSQLToJSON.
    • beforeSave

      public void beforeSave​(Model templateJaxb, org.json.JSONObject additionalInfo)
      Called before saving a new template in the system.
    • beforeEdit

      public void beforeEdit​(Model templateJaxb, org.json.JSONObject additionalInfo)
      Called before updating template in the system.
    • convertTemplateSQLToJSON

      public static void convertTemplateSQLToJSON​(org.json.JSONObject retObj, SqlRow sqlRow, PlatformUserContext platformUserContext)
      Helper method that converts a Template instance in the form of a SqlRow to a JSONObject that can be passed to the client. The SqlRow should have values from the following database columns:
      • TEMPLATE.SYS_TEMPLATE_ID
      • TEMPLATE.NAME (as TEMPLATE_NAME)
      • TEMPLATE.DESCRIPTION
      • TEMPLATE.SYS_OWNING_ORG_ID
      • TEMPLATE.SYS_OWNING_USER_ID
      • TEMPLATE.IS_DEFAULT_FOR_OWNER
      • TEMPLATE.DATA_CONFIG
      • TEMPLATE.VIEW_CONFIG
      • BASE_TEMPLATE.NAME (as BASE_TEMPLATE_NAME)
      • BASE_TEMPLATE.JS_CLASS
      • BASE_TEMPLATE.LEVEL_TYPE
      The resulting JSONObject will contain the following properties:
      • id
      • templateName
      • description
      • baseTemplateName
      • belongsToOrg
      • belongsToUser
      • isDefault
      • modelLevelType
      • jsClass
      • dataConfig
      • viewConfig