Class JKWebControllerWithOrmSupport<T>

Type Parameters:
T - Specifies the type of ORM entity managed by this controller.
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JKMasterDetailWebControllerWithOrmSupport, JKRolesWebControllers, JKUserWebControllers

public abstract class JKWebControllerWithOrmSupport<T> extends JKWebControllerWithSqlDataAccess
This abstract class extends the JKWebControllerWithSqlDataAccess and provides support for working with Object-Relational Mapping (ORM) entities.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
See Also:
  • Field Details

    • mode

      protected ControllerMode mode
      Represents the current controller mode.
  • Constructor Details

    • JKWebControllerWithOrmSupport

      public JKWebControllerWithOrmSupport()
  • Method Details

    • addToDatabase

      public String addToDatabase()
      This method adds the current ORM entity to the database.
      Returns:
      null.
    • edit

      public String edit()
      This method sets the current controller mode to EDIT mode.
      Returns:
      null.
    • saveToDatabase

      public String saveToDatabase()
      This method saves the current ORM entity to the database.
      Returns:
      null.
    • beforeInsert

      protected void beforeInsert()
      This method is yet to be implemented (TBI).
    • beforeFind

      protected void beforeFind()
      This method is yet to be implemented (TBI).
    • afterFind

      protected void afterFind()
      This method is yet to be implemented (TBI).
    • afterInsert

      protected void afterInsert()
      This method is yet to be implemented (TBI).
    • beforeUpdate

      protected void beforeUpdate()
      This method is yet to be implemented (TBI).
    • afterUpdate

      protected void afterUpdate()
      This method is yet to be implemented (TBI).
    • beforeDelete

      protected void beforeDelete()
      This method is yet to be implemented (TBI).
    • find

      public String find(int id)
      This method finds and sets the ORM entity with the specified ID in the controller.
      Parameters:
      id - Specifies the ID of the entity to find.
      Returns:
      null.
    • getModelClass

      protected Class<T> getModelClass()
      This method retrieves the class type of the ORM entity.
      Returns:
      the class type of the ORM entity.
    • getModelList

      public List<T> getModelList()
      This method retrieves the list of ORM entities.
      Returns:
      the list of ORM entities.
    • deleteFromDatabase

      public String deleteFromDatabase()
      This method deletes the currently loaded ORM entity from the database.
      Returns:
      null.
    • afterDelete

      protected void afterDelete()
      This method is yet to be implemented (TBI).
    • getIdValue

      public Integer getIdValue()
      This method retrieves the value of the primary key field of the currently loaded ORM entity.
      Returns:
      the value of the primary key field of the currently loaded ORM entity.
    • getIdValue

      protected Integer getIdValue(T model)
      This method retrieves the value of the primary key field of the specified ORM entity.
      Parameters:
      model - Specifies the ORM entity from which to retrieve the primary key value.
      Returns:
      the primary key value of the entity, typically an integer.
    • getModel

      public T getModel()
      This method retrieves the current ORM entity being managed.
      Returns:
      the current ORM entity being managed.
    • createEmptyModel

      protected T createEmptyModel()
      This method creates and returns an instance of an empty model for the ORM entity associated with this controller.
      Returns:
      an empty model instance of the ORM entity.
    • setModel

      public void setModel(T model)
      This method sets the current ORM entity being managed to the provided one.
      Parameters:
      model - Specifies the new current ORM entity being managed.
    • getDataAccess

      protected JKObjectDataAccess getDataAccess()
      This method retrieves and returns the data access service responsible for handling database operations for the ORM entity associated with this controller.
      Returns:
      the data access service for the ORM entity.
    • reset

      public String reset()
      This method resets the controller's state.
      Returns:
      null.
    • resetData

      public void resetData()
      This method resets the data-related state of the controller.
    • resetWorkFlow

      protected void resetWorkFlow()
      This method resets the workflow-related state of the controller.
    • isAlwaysRefreshList

      public boolean isAlwaysRefreshList()
      This method checks whether to always refresh the list of ORM entities or not.
      Returns:
      true, if it always refresh the list of ORM entities, false otherwise.
    • setAlwaysRefreshList

      public void setAlwaysRefreshList(boolean alwaysRefreshList)
      This method sets whether to always refresh the list of ORM entities or not.
      Parameters:
      alwaysRefreshList - Indicates to always refresh the list (true) or not (false).
    • setIdValue

      public void setIdValue(Object value)
      This method sets the primary key value of the model to the provided value.
      Parameters:
      value - Specifies the new primary key value of the model.
    • duplicate

      public String duplicate()
      This method duplicates the current model.
      Returns:
      null.
    • getEmptyModel

      public T getEmptyModel()
      This method gets the empty model.
      Returns:
      the empty model.
    • fill

      public String fill()
      This method fills the fields of the current model.
      Returns:
      null.
    • isAllowAdd

      public boolean isAllowAdd()
      This method checks whether the controller is in the ADD mode to allow data addition.
      Returns:
      true, if its allowed to add new data, false otherwise.
    • isAllowEdit

      public boolean isAllowEdit()
      This method checks whether the current mode allows editing.
      Returns:
      true, if the current mode allows editing, false otherwise.
    • isAllowSave

      public boolean isAllowSave()
      This method checks whether the current mode allows saving.
      Returns:
      true, if the current mode allows saving, false otherwise.
    • isAllowDelete

      public boolean isAllowDelete()
      This method checks whether the current mode allows deleting.
      Returns:
      true, if the current mode allows deleting, false otherwise.
    • isAllowReset

      public boolean isAllowReset()
      This method checks whether the current mode allows reseting.
      Returns:
      true, if the current mode allows reseting, false otherwise.
    • isAllowFill

      public boolean isAllowFill()
      This method checks whether the current mode allows filling fields.
      Returns:
      true, if the current mode allows filling fields, false otherwise.
    • isEditMode

      public boolean isEditMode()
      This method checks whether the controller is currently in EDIT mode.
      Returns:
      true, if it is in EDIt mode, false otherwise.
    • cancelEdit

      public void cancelEdit()
      This method changes the controller mode to READONLY.
    • isReadOnlyMode

      public boolean isReadOnlyMode()
      This method checks whether the controller is currently in READONLY mode.
      Returns:
      true, if it is in READONLY mode, false otherwise.
    • getFilterList

      public List<T> getFilterList()
      This method retrieves the filtered list of ORM entities.
      Returns:
      the filtered list of ORM entities.
    • setFilterList2

      public void setFilterList2(List filterList2)
      This method sets the second filter list to the provided one.
      Parameters:
      filterList2 - Specifies the new second filter list.
    • setFilterList

      public void setFilterList(List<T> filterList)
      This method sets the filtered list of ORM entities to the provided one.
      Parameters:
      filterList - Specifies the new filtered list of ORM entities.
    • getFilterList2

      public List getFilterList2()
      This method retrieves the second filter list.
      Returns:
      the second filter list.
    • isConfirmReeset

      public boolean isConfirmReeset()
      This method checks the flag for confirming reset actions.
      Returns:
      true, if the flag is set to true, false otherwise.
    • setConfirmReeset

      public void setConfirmReeset(boolean confirmReeset)
      This method sets the flag for confirming reset actions to the provided value.
      Parameters:
      confirmReeset - Indicates the new flag value.
    • getMode

      public ControllerMode getMode()
      This method retrieves the current controller mode.
      Returns:
      the current controller mode.
    • isEditTabular

      public boolean isEditTabular()
      This method checks the flag for tabular editing mode.
      Returns:
      true, if the flag is set to true, false otherwise.
    • setEditTabular

      public void setEditTabular(boolean editTabular)
      This method sets the flag for tabular editing mode to the provided value.
      Parameters:
      editTabular - Indicates the new flag value.
    • saveAllToDatabase

      public void saveAllToDatabase()
      This method saves all the models in the current list to the database.
    • add

      public String add()
      This method adds a new model to the database or initiates a workflow approval process based on availability.
      Returns:
      null.
    • save

      public String save()
      This method saves the changes made to the current model to the database or initiates a workflow approval process based on availability.
      Returns:
      null.
    • saveAll

      public String saveAll()
      This method saves all changes made to the current model to the database or initiates a workflow approval process based on availability.
      Returns:
      null.
    • delete

      public String delete()
      This method deletes the current model from the database or initiates a workflow approval process based on availability.
      Returns:
      null.
    • getPayloads

      public List<PayloadModel> getPayloads()
      This method retrieves the list of pay-load models for work flows.
      Returns:
      the list of pay-load models for work flows.
    • setPayloads

      public void setPayloads(List<PayloadModel> payloads)
      This method sets the list of pay-load models for work flows to the provided one.
      Parameters:
      payloads - Specifies the new list of pay-load models for work flows.
    • getWorkflowEntityName

      protected String getWorkflowEntityName()
      Thie method retrieves the workflow entity name.
      Returns:
      the workflow entity name.
    • isWorkflowAvialable

      public boolean isWorkflowAvialable()
      This method checks whether workflow functionality is available.
      Returns:
      true, if it is available, false otherwise.
    • getPayload

      public PayloadModel getPayload()
      This method retrieves the pay-load model for workflow.
      Returns:
      the pay-load model for workflow.
    • setPayload

      public void setPayload(PayloadModel payload)
      This method sets the pay-load model for workflow to the provided value.
      Parameters:
      payload - Specifies the new pay-load model for workflow.
    • approvePayload

      public String approvePayload(int id)
      This method approves a workflow pay-load with the specified ID.
      Parameters:
      id - Specifies the ID of the workflow pay-load to be approved.
      Returns:
      null.
    • findPayload

      public PayloadModel findPayload(int id)
      This method finds a workflow pay-load with the specified ID.
      Parameters:
      id - Specifies the ID of the workflow pay-load to be found.
      Returns:
      the found PayloadModel object or null if not found.
    • rejectPayload

      public String rejectPayload(int id)
      This method rejects a workflow pay-load with the specified ID.
      Parameters:
      id - Specifies the ID of the workflow pay-load to be rejected.
      Returns:
      null.
    • viewPayload

      public String viewPayload(int id)
      This method displays the details of a workflow pay-load with the specified ID for viewing.
      Parameters:
      id - Specifies the ID of the workflow pay-load to be viewed.
      Returns:
      null.
    • isInputDisabled

      public boolean isInputDisabled()
      This method checks if the input fields should be disabled based on the current controller mode.
      Returns:
      true, if the input fields should be disabled, false otherwise.
    • getOriginal

      public T getOriginal()
      This method retrieves the original ORM entity for workflow purposes.
      Returns:
      the original ORM entity for workflow purposes.
    • setOriginal

      public void setOriginal(T original)
      This method sets the original ORM entity for workflow purposes to the provided value.
      Parameters:
      original - Specifies the new original ORM entity for workflow purposes.
    • isFieldModified

      public boolean isFieldModified(String name)
      This method checks if a specific field in the model has been modified.
      Parameters:
      name - Specifies the name of the field to check for modification.
      Returns:
      true, if the field has been modified, false otherwise.
    • getDataList

      public List<T> getDataList()
      This method retrieves s list of data items based on the data list filter.
      Returns:
      s list of data items based on the data list filter.
    • getDataListFilter

      public Predicate<? super T> getDataListFilter()
      This method retrieves the filter predicate for the data list.
      Returns:
      the filter predicate for the data list.
    • setDataListFilter

      public void setDataListFilter(Predicate<? super T> dataListFilter)
      This method sets the filter predicate for the data list to the provided one.
      Parameters:
      dataListFilter - Specifies the new filter predicate for the data list.
    • setDataList

      public void setDataList(List<T> dataList)
      This method sets the list of data items based on the data list filter to the provided one.
      Parameters:
      dataList - Specifies the new list of data items based on the data list filter.
    • getModelListFilter

      public Predicate<? super T> getModelListFilter()
      This method retrieves the filter predicate for the model list.
      Returns:
      the filter predicate for the model list.
    • setModelListFilter

      public void setModelListFilter(Predicate<? super T> modelListFilter)
      This method sets the filter predicate for the model list to the provided one.
      Parameters:
      modelListFilter - Specifies the new filter predicate for the model list.
    • postConstruct

      protected void postConstruct()
      This method performs post-construction initialization of the web controller.

      It initializes the model class, controller mode, and checks if workflow is available.

      Overrides:
      postConstruct in class JKWebController