Class ObjectDB

  • All Implemented Interfaces:
    CacheInterface, java.io.Serializable
    Direct Known Subclasses:
    ScriptedObjectDB

    public class ObjectDB
    extends ObjectCore
    Business object stored in database

    The object definition is loaded from repository using user language and rights
    The object is associated to a physical storage in the database (table in general)

    By default, the object has a unique 'row_id' field which is always the first of them
    Before the creation, the row ID must be set to 0
    After creation, the row_id is always greater than 0

    The object may have a timestamp, in this case 4 fields are added:
    - 'created_dt' creation datetime
    - 'created_by' creation user login
    - 'updated_dt' last update datetime
    - 'updated_by' last update user login

    The object must have:

    - a functional key based on one or more fields
    - translation in each language with online helps
    - function for CRUD to grant actions to the user groups

    The object also may have:
    - some graphs and crosstables based on the fields
    - print templates to many output formats
    - scripted hooks to override some core methods
    - constraints to change the object/fields rules on the fly
    - etc.
    See Also:
    Serialized Form
    • Constructor Detail

      • ObjectDB

        public ObjectDB()
        Default constructor, may not be used
        Object instantiation must be done using the Grant.getXXXObject methods (Main, Temp, Panel, Batch, Ref...).
        Use this method to construct manually the object (add fields...)
      • ObjectDB

        public ObjectDB​(Grant grant,
                        java.lang.String name,
                        java.lang.String instanceName)
        Constructor, may not be used
        Grant.getXXXObject methods should be preferred to benefit from cache mechanisms
        Parameters:
        grant - Grant
        name - Object name (e.g. "DummyObject")
        instanceName - Object instance name (e.g. "my_DummyObject")
    • Method Detail

      • getInterface

        public ObjectInterface getInterface()
        Get the interface to manipulate objects (Local EJB, Remote EJB, WebService, Direct)
        Accessing context updates the last usage of object
        Returns:
        Interface context
      • getPreviousRowId

        public java.lang.String getPreviousRowId()
        The method gives the previous row ID of the current record in a search context
      • getFirstRowId

        public java.lang.String getFirstRowId()
        The method gives the first row ID in a search context
      • getNextRowId

        public java.lang.String getNextRowId()
        The method gives the next row ID of the current record in a search context
      • getLastRowId

        public java.lang.String getLastRowId()
        The method gives the last row ID in a search context
      • load

        public ObjectDB load​(Grant grant)
        Object definition loading
        Parameters:
        grant - User rights
      • load

        public final ObjectDB load​(Grant grant,
                                   java.lang.String obj)
        Default object definition loading, called by load(Grant)
        Parameters:
        grant - User rights
        obj - Object name
      • init

        public ObjectDB init​(java.lang.String name,
                             Grant grant)
        Load the object definition from the repository
        Parameters:
        name - Object name
        grant - User rights
      • initFromTable

        public void initFromTable​(java.lang.String table,
                                  Grant grant)
        Load the object definition from the database table (beta)
        Parameters:
        table - Table name
        grant - User rights
      • preLoad

        public void preLoad()
        Hook called before loading the object definition
      • postLoad

        public void postLoad()
        Hook called after loading the object definition
      • getSearchSpec

        public java.lang.String getSearchSpec​(java.lang.String s)
        Eval the search specification
      • getFieldDefaultValue

        public java.lang.String getFieldDefaultValue​(ObjectField fld)
        Eval a default value
      • populate

        public void populate​(boolean complete)
        Populate all fields with the references, parent or default values
        Parameters:
        complete - True to try to solve/complete the missing referenced data with the known fields
      • populate

        public final void populate​(ObjectField field)
        Populate a field with the reference, the contextual or its default value
        This method is not supposed to be overridden
        Parameters:
        field - Object field
      • populate

        public void populate​(ObjectField field,
                             boolean complete)
        Populate a field with the reference, the contextual or its default value
        Parameters:
        field - Object field
        complete - True to try to solve/complete the missing referenced data with the known fields
      • populateForeignKey

        public boolean populateForeignKey​(java.lang.String refField,
                                          java.lang.String refId,
                                          boolean useSearchSpec,
                                          boolean reset)
        Populate all fields joined to a foreign key
        Parameters:
        refField - Foreign key field
        refId - Referenced object id
        useSearchSpec - False to disable any search spec on referenced object
        reset - Reset related fields if not found
        Returns:
        true if the field is a foreign key and has been correctly set
      • completeForeignKeys

        public final java.util.List<java.lang.String> completeForeignKeys()
        Try to complete the references (ids of foreign keys) with the field values
      • completeForeignKeys

        public java.util.List<java.lang.String> completeForeignKeys​(boolean err)
        Try to complete the references (ids of foreign keys) with the field values
        Parameters:
        err - trace errors?
      • preUpdateAll

        public java.lang.String preUpdateAll()
        Hook called before bulk update
        Returns:
        Error code or null
      • postUpdateAll

        public void postUpdateAll()
        Hook called after bulk update
      • preDeleteAll

        public java.lang.String preDeleteAll()
        Hook called before bulk delete
        Returns:
        Error code or null
      • postDeleteAll

        public void postDeleteAll()
        Hook called after bulk delete
      • preValidate

        public java.util.List<java.lang.String> preValidate()
        Hook called before system validation
        It may be useful to force/calculate mandatory values
        Returns:
        Error list, or empty/null when no business error
      • isStateTransitionEnable

        public boolean isStateTransitionEnable​(java.lang.String fromStatus,
                                               java.lang.String toStatus)
        Hook called when building the list of possible state transition
        It may be useful to implement specific state transition condition rules
        Parameters:
        fromStatus - From status
        toStatus - To status
        Returns:
        True when the state transition condition is fulfilled (true by default)
      • preStateTransition

        public java.util.List<java.lang.String> preStateTransition​(java.lang.String fromStatus,
                                                                   java.lang.String toStatus)
        Hook called just before pre validate hook in case of a state transition
        It may be useful to isolate specific state transition pre validation rules from other pre validation rules
        Parameters:
        fromStatus - From status
        toStatus - To status
        Returns:
        Error list, or empty/null when no business error
      • postValidate

        public java.util.List<java.lang.String> postValidate()
        Hook called after system validation
        It may be useful to check specific rules before update
        Returns:
        Error list, or empty/null when no business error
      • validate

        public final java.util.List<java.lang.String> validate()
        Core system validation (unicity, field format, mandatory...)
        Must be called before any creation or update
        It calls the preValidate and the postValidate methods
        This method is not supposed to be overriden
        Returns:
        Message list or empty/null when no business info or error
      • validate

        public java.util.List<java.lang.String> validate​(boolean onlyErrors)
        Core system validation (unicity, field format, mandatory...)
        Must be called before any creation or update
        It calls the preValidate and the postValidate methods
        Parameters:
        onlyErrors - True to retrieve only error level
        Returns:
        Info, Warn, Error, Fatal lists or empty/null when no business message
      • count

        public final long count()
        Alias to getCount
      • getCount

        public final long getCount()
        Return the records count with the current search specification and filters
        This method is not supposed to be overridden
        Returns:
        Number of records of object search
      • getCount

        public long getCount​(int maxRows)
        Return the records count with the current search specification and filters
        Parameters:
        maxRows - Explicit maximum nb of rows when paginated, to be set to 0 for user's min/max row setting usage
        Returns:
        Number of records of object search
      • getCountGroupBy

        public long getCountGroupBy​(int maxRows)
        Return the grouped records count with the current search specification and filters
        Parameters:
        maxRows - Explicit maximum nb of rows when paginated, to be set to 0 for user's min/max row setting usage
        Returns:
        Number of grouped records
      • getRefCount

        public long getRefCount​(java.lang.String refname,
                                java.lang.String field)
        Return the records count of a linked object (relation 0,n)
        Parameters:
        refname - Linked object name
        field - Foreign key field (containing the row ID value of current object)
        Returns:
        Number of linked records
      • searchRowId

        public final java.lang.String searchRowId()
        Search with the current fields a matching record in the database
        This method is not supposed to be overriden
        Returns:
        null if not found, otherwise the row ID
      • searchRowId

        public java.lang.String searchRowId​(java.lang.String notId)
        Search with the current fields a matching record in the database>
        Parameters:
        notId - The row ID to exclude
        Returns:
        null if not found, otherwise the row ID
      • preExport

        public void preExport()
        Hook called before search in export of data
        It may be useful to add some specific filters
      • postExport

        public java.util.List<java.lang.String[]> postExport​(java.util.List<java.lang.String[]> rows)
        Hook called after search in export of data.
        It may be useful to calculate fields or to change the records
        Parameters:
        rows - The database result
        Returns:
        The search result
      • preImport

        public java.lang.String preImport()
        Hook called before processing object import
        It may be useful to add data to imported data

        (attention : imported data cannot be changed here)
        or to execute business rules before actually processing the import
        Returns:
        Error
      • postImport

        public java.lang.String postImport()
        Hook called after processing object import
        It may be useful to execute business rules after actually processing the import
        Returns:
        Error
      • preObjectSearch

        public void preObjectSearch()
        Hook called before search of object reference
        It may be useful to add some specific filters
      • postObjectSearch

        public java.util.List<java.lang.String[]> postObjectSearch​(java.util.List<java.lang.String[]> rows)
        Hook called after search of object reference
        It may be useful to calculate fields or to change the records
        Parameters:
        rows - The database result
        Returns:
        The search result
      • preValidateSearch

        public java.util.List<java.lang.String> preValidateSearch()
        Hook called before search validation with the fields filters
        It may be useful to check filters
      • postValidateSearch

        public java.util.List<java.lang.String> postValidateSearch()
        Hook called after search validation with the fields filters
        It may be useful to check filters
      • validateSearch

        public final java.util.List<java.lang.String> validateSearch()
        Core system search validation (mandatory...)
        Must be called before any search
        It calls the preValidateSearch and the postValidateSearch methods
        This method is not supposed to be overridden
        Returns:
        Message list or empty/null when no business info or error
      • preSearch

        public void preSearch()
        Hook called before search with the fields filters
        It may be useful to add some specific filters
      • postSearch

        public java.util.List<java.lang.String[]> postSearch​(java.util.List<java.lang.String[]> rows)
        Hook called after search with the fields filters
        It may be useful to calculate fields or to change the records
        Parameters:
        rows - The database result
        Returns:
        The search result for the GUI
      • getQuery

        public java.lang.String getQuery​(java.util.List<ObjectField> host)
        Return the SQL select statement with current filter
        Parameters:
        host - Valued hosts
        Returns:
        SQL select of object
      • search

        public final java.util.List<java.lang.String[]> search()
        Retrieve the database records with the currents search specification
        and the field filters (without pagination)
        Returns:
        Records: ArrayList of table of Strings, ordered with the sort context
      • search

        public final java.util.List<java.lang.String[]> search​(boolean pagine)
        Retrieve the database records with the currents search specification and the field filters
        Parameters:
        pagine - True to limit the search size (with min/max user properties)
        Returns:
        Records: ArrayList of table of Strings, ordered with the sort context
      • search

        public java.util.List<java.lang.String[]> search​(boolean pagine,
                                                         int maxRows)
        Retrieve the database records with the currents search specification
        and the field filters. Load the result in the object current list
        Parameters:
        pagine - True to limit the search size (with min/max user properties)
        maxRows - Limit to avoid a full table loading
        Returns:
        Records: List of table of Strings, ordered with the sort context
      • searchExport

        public java.util.List<java.lang.String[]> searchExport()
        Same as a search but for the export of data
      • searchGroupBy

        public final java.util.List<java.lang.String[]> searchGroupBy​(boolean pagine)
        Search with group by and count
      • searchGroupBy

        public java.util.List<java.lang.String[]> searchGroupBy​(boolean pagine,
                                                                int maxRows)
        Search with group by and count
      • searchCrosstab

        public java.util.List<java.lang.String[]> searchCrosstab​(Crosstab c)
        Same as a search but for a crosstab calculation and optimization
        Parameters:
        c - The crosstable definition
        Returns:
        Records
      • preSelect

        public void preSelect​(java.lang.String rowId,
                              boolean copy)
        Hook called before a single row selection
        Parameters:
        rowId - The unique row ID to select
        copy - Indicate if it's a select for a future copy
      • postSelect

        public void postSelect​(java.lang.String rowId,
                               boolean copy)
        Hook called after a single row selection
        Parameters:
        rowId - The unique selected row ID
        copy - Indicate if it's a select for a future copy
      • select

        public boolean select​(java.lang.String rowId,
                              boolean copy)
        Selects a single record and loads the values into the object fields (either for simple selection or for copy)
        Parameters:
        rowId - Unique row ID of the record
        copy - Indicate whether the select is done for a future copy
        Returns:
        True if the record exists
      • selectWithoutFilters

        public final boolean selectWithoutFilters​(java.lang.String rowId,
                                                  boolean copy)
        Same as a select without filters (only defaultSearchSpec is applied). The previous filters and current SearcSspec are restored after selection.
      • select

        public final boolean select​(java.lang.String rowId)
        Selects a single record and loads the values into the object fields
        Parameters:
        rowId - Unique row ID of the record
        Returns:
        True if the record exists
      • select

        public boolean select​(ObjectField[] fields,
                              boolean copy)
        Selects a single record and loads the specified valued fields into the object fields (either for simple selection or for copy)
        Parameters:
        fields - Valued fields
        copy - Indicate whether the select is done for a future copy
        Returns:
        True if the record exists
      • initSearch

        public void initSearch()
        Hook to init the Search before user dialog
      • initList

        public void initList​(ObjectDB parent)
        Hook to init the List before user dialog
      • initCreate

        public void initCreate()
        Hook to init the Creation before user dialog
      • initCopy

        public void initCopy()
        Hook to init the Copy before user dialog
      • initUpdate

        public void initUpdate()
        Hook to init the Update before update dialog
      • initUpdateAll

        public void initUpdateAll()
        Hook to init the Update before bulk update dialog
      • initDelete

        public void initDelete()
        Hook to init the Delete before delete dialog
      • initExport

        public void initExport()
        Hook to init the Export before export dialog
      • initRefSelect

        public void initRefSelect​(ObjectDB parent)
        Hook to init the reference select before select dialog
      • initAssociate

        public void initAssociate​(ObjectDB parent)
        Hook to init the association before associate dialog
      • initDataMapSelect

        public void initDataMapSelect​(java.lang.String datamapName,
                                      ObjectDB parent)
        Hook to init the data map select before user dialog
      • initGraph

        public void initGraph​(java.lang.String graphName)
        Hook to init a graph
      • initCrosstab

        public void initCrosstab​(java.lang.String crosstabName)
        Hook to init a crosstable
      • initPrintTemplate

        public void initPrintTemplate​(java.lang.String printTemplateName)
        Hook to init a print templates
      • initAgenda

        public void initAgenda​(Agenda agenda)
        Hook to init an agenda
      • initPlaceMap

        public void initPlaceMap​(PlaceMap placemap)
        Hook to init a place map
      • evalNextRowId

        public java.lang.String evalNextRowId​(java.lang.String table)
        Hook called before the database creation to send a specific unique id
        (i.e. database sequence, String algorithm, timestamp...)
        Parameters:
        table - Table name
        Returns:
        Specific next row ID or null (to use the default behavior max+1)
      • preCreate

        public java.lang.String preCreate()
        Hook called before the database creation
        Returns:
        Message code or null
      • postCreate

        public java.lang.String postCreate()
        Hook called after the database creation
        Returns:
        Message code or null
      • create

        public java.lang.String create()
        Insert the object field values in the database Call the pre/postCreation.
        Returns:
        Message code or null
      • preUpdate

        public java.lang.String preUpdate()
        Hook called before the database update
        Returns:
        Message code or null
      • postUpdate

        public java.lang.String postUpdate()
        Hook called after the database update
        Returns:
        Message code or null
      • update

        public final java.lang.String update()
        Update the field values in the database
        Call the pre/postUpdate methods
        Returns:
        Message code or null
      • update

        public java.lang.String update​(boolean timestamp)
        Update the field values in the database
        Call the pre/postUpdate methods
        Parameters:
        timestamp - check and update the timestamp if any
        Returns:
        Message code or null
      • preSave

        public java.lang.String preSave()
        Hook called before the database save
        Returns:
        Message code or null
      • postSave

        public java.lang.String postSave()
        Hook called after the database save
        Returns:
        Message code or null
      • save

        public final java.lang.String save()
        This method calls the preSave first,
        then if the row ID is equals to '0', it calls the create method,
        otherwise it calls the update method
        Finally the method calls the postSave method
        Returns:
        Message code or null
      • save

        public java.lang.String save​(boolean timestamp)
        This method calls the preSave first,
        then if the row ID is equals to '0', it calls the create method,
        otherwise it calls the update method
        Finally the method calls the postSave method
        Parameters:
        timestamp - check and update the timestamp if any
        Returns:
        Message code or null
      • preSaveTimesheet

        public java.util.List<java.lang.String> preSaveTimesheet​(Timesheet ts)
        Hook called before Timesheet save
        Returns:
        Message codes or null
      • postSaveTimesheet

        public java.util.List<java.lang.String> postSaveTimesheet​(Timesheet ts)
        Hook called after Timesheet save
        Returns:
        Message codes or null
      • canReference

        public boolean canReference​(java.lang.String target,
                                    java.lang.String foreignKey)
        Hook called to check if a referenced object can be displayed
        Parameters:
        target - Linked object name or view name
        foreignKey - Field name of foreign key (optional in case of object view)
        Returns:
        True if the Link has been set to visible
      • preDelete

        public java.lang.String preDelete()
        Hook called before the database deletion
        Returns:
        Message code or null
      • postDelete

        public java.lang.String postDelete()
        Hook called after the database deletion
        Returns:
        Message code or null
      • isOpenEnable

        public boolean isOpenEnable​(java.lang.String[] row)
        Hook to check if the open action is available for a specific record
        This method must be called to check if the action is available for the user
        Parameters:
        row - Current record
        Returns:
        True if open is granted to the user (by default read visibilities are checked, true is no visibility)
      • checkCreateVisibilities

        public final boolean checkCreateVisibilities()
        Check create visibilities
      • isCreateEnable

        public boolean isCreateEnable()
        Hook to check if the create action is available
        This method must be called to check if the action is available for the user
        Returns:
        True if creation is granted to the user (not readonly, create constraints and visibilities are checked)
      • checkUpdateVisibilities

        public final boolean checkUpdateVisibilities​(java.lang.String[] row)
        Check update visibilities
      • isUpdateEnable

        public boolean isUpdateEnable​(java.lang.String[] row)
        Hook to check if the update action is available for a specified record
        This method must be called to check if the action is available for the user and the specified record
        Parameters:
        row - Current record
        Returns:
        True if update is granted to the user for the specified record (not readonly, update constraints and visibilities are checked)
      • checkDeleteVisibilities

        public final boolean checkDeleteVisibilities​(java.lang.String[] row)
        Check delete visibilities
      • isDeleteEnable

        public boolean isDeleteEnable​(java.lang.String[] row)
        Hook to check if the delete action is available for a specified record
        This method must be called to check if the action is available for the user and the specified record
        Parameters:
        row - Current record
        Returns:
        True if deletion is granted to the user for the specified record (not readonly, delete constraints and visibilities are checked)
      • isCopyEnable

        public boolean isCopyEnable​(java.lang.String[] row)
        Hook to check if the copy action is available for a specified record
        This method must be called to check if the action is available for the user and the specified record
        Parameters:
        row - Current record
        Returns:
        True if copy is granted to the user for the specified record (by default isCreateEnabled is called)
      • getConsole

        public Console getConsole()
        Get console
      • setConsole

        public void setConsole​(Console console)
        Set console
      • clear

        public void clear()
      • setConstraint

        public void setConstraint​(Constraint c)
        Prepare the constraint
      • applyStaticConstraints

        public void applyStaticConstraints()

        Applies static constraints on load

      • applyConstraints

        public void applyConstraints​(int context)

        Applies all dynamic constraints

        Parameters:
        context - Context
      • applyObjectConstraints

        public void applyObjectConstraints​(int context)

        Applies all dynamic constraints on object

        Parameters:
        context - Context (one of ObjectCore.CONTEXT_*)
      • checkCreateConstraints

        public final boolean checkCreateConstraints()

        Applies all create constraints on object

      • checkUpdateConstraints

        public final boolean checkUpdateConstraints()

        Applies all update constraints on object

      • checkDeleteConstraints

        public final boolean checkDeleteConstraints()

        Applies all delete constraints on object

      • checkObjectPropConstraints

        public boolean checkObjectPropConstraints​(int context,
                                                  char objectProp)
      • hasFieldConstraints

        public boolean hasFieldConstraints​(char effect)
        Object contains fields impact ?
        Parameters:
        effect - constraint side effect Constraint.EFFECT_*
      • applyFieldConstraints

        public void applyFieldConstraints​(int context)

        Applies all constraints on fields

        Parameters:
        context - Context
      • hasTargetConstraints

        public boolean hasTargetConstraints​(char effect)
        Object contains target (action, view, area) impact ?
        Parameters:
        effect - constraint side effect Constraint.EFFECT_*
      • applyTargetConstraints

        public void applyTargetConstraints​(int context)

        Applies all constraints on targets (action, link or view)

        Parameters:
        context - Context
      • isMergeMaster

        public boolean isMergeMaster()
        Hook to tell is current record the merge master ?
      • isActionEnable

        public boolean isActionEnable​(java.lang.String[] row,
                                      java.lang.String action)
        Hook to check if one action is available for a specific record
        This method must be called to check if the action is available for the user
        Parameters:
        row - Current record
        action - Action name
        Returns:
        True when the action is granted to the user (checks visibility if any)
      • isCrosstabEnable

        public boolean isCrosstabEnable​(java.lang.String crosstab)
        Hook to check if crosstab is available
        This method must be called to check if the crosstab is available for the user
        Parameters:
        crosstab - Crosstab name
        Returns:
        True when the crosstab is granted to the user (check if crosstab is enabled by default)
      • isGraphEnable

        public boolean isGraphEnable​(java.lang.String graph)
        Hook to check if chart is available
        This method must be called to check if the chart is available for the user
        Parameters:
        graph - Chart name
        Returns:
        True when the chart is granted to the user (check if graph is enabled by default)
      • isPrintTemplateEnable

        public boolean isPrintTemplateEnable​(java.lang.String[] row,
                                             java.lang.String printTemplate)
        Hook to check if print template is available for a specific record
        This method must be called to check if the print template is available for the user
        Parameters:
        printTemplate - Print template name
        Returns:
        True when the print template is granted to the user (check if print template is enabled by default)
      • printed

        public java.lang.Object printed​(PrintTemplate pt,
                                        java.lang.String rowId,
                                        java.lang.Object printed)
        Callback hook when printed. Useful to change the content or store the object before displaying the print
        Parameters:
        pt - Print Template
        rowId - Optional row ID
        printed - Printed object (html, zip, pdf...)
        Returns:
        Printed object (the same by default)
      • checkDelete

        @Deprecated
        public final java.util.List<java.lang.String>[] checkDelete()
        Deprecated.
        Use delete() method only
      • delete

        @Deprecated
        public final java.lang.String delete​(java.util.List<java.lang.String> request)
        Deprecated.
        Use delete() method only
      • delete

        public java.lang.String delete()
        Delete the current row and dependencies
        This version use all the ObjectDB hooks
        checkDelete() has not to be called first
        Returns:
        Message code or null
      • del

        public final java.lang.String del()
        Delete the current row and dependencies (same as delete but for scripting usage)
      • merge

        public java.util.List<java.lang.String> merge​(java.util.List<java.lang.String> ids,
                                                      java.util.Map<java.lang.String,​java.util.List<java.lang.Integer>> map)
        Merge all records and links
        Parameters:
        ids - Row IDs to merge in the current object
        map - Id indexes per field (keep current value when absent) and per link (removed if absent, moved if present)
        Returns:
        Error codes or null
      • getFileName

        public java.lang.String getFileName​(java.lang.String docId)
        Get the filename of a document stored in m_document
        Parameters:
        docId - Document ID
        Returns:
        Document name
      • getFilePath

        public java.lang.String getFilePath​(java.lang.String docId)
        Get the relative path (from DOCDIR) of a document stored in m_document
        Parameters:
        docId - Document ID
        Returns:
        Document full path
      • getMappedFilePath

        public java.lang.String getMappedFilePath​(ObjectField f)
        Get mapped file path for specified field
        Parameters:
        f - Document field
        Returns:
        Document mapped file path or null
      • preAlert

        public java.lang.String preAlert​(Alert a)
        Hook before before sending the alert
        Returns:
        Error code or null
      • postAlert

        public java.lang.String postAlert​(Alert a)
        Hook before after sending the alert
        Returns:
        Error code or null
      • spamEmail

        public boolean spamEmail​(java.lang.String alert,
                                 java.lang.String group,
                                 java.lang.String email)
        Hook called to check if the email is a recipient of the alert
        Parameters:
        alert - Alert name
        group - Optional user group
        email - Email
        Returns:
        True by default
      • spamGroup

        public boolean spamGroup​(java.lang.String alert,
                                 java.lang.String name)
        Hook called to check if the group is a recipient of the alert
        Parameters:
        alert - Alert name
        name - Group name
        Returns:
        True by default
      • getEmailRecipientType

        public char getEmailRecipientType​(java.lang.String alert,
                                          java.lang.String email,
                                          char type)
        Hook to override the recipient type (TO/CC/BCC)
        Parameters:
        alert - Alert name
        email - Email
        type - Default designed type
        Returns:
        Recipient type
      • getGroupEmailRecipientType

        public char getGroupEmailRecipientType​(java.lang.String alert,
                                               java.lang.String group,
                                               char type)
        Hook to override the recipient type (TO/CC/BCC) of a group
        Parameters:
        alert - Alert name
        group - Group name
        type - Default designed type
        Returns:
        Recipient type
      • getDeadlineDate

        public java.util.Date getDeadlineDate​(java.lang.String rowId,
                                              java.lang.String state,
                                              java.lang.String update_dt,
                                              int timeout)
        Eval the timeout date of the object state (can be overrided with a specific rule)
        Parameters:
        rowId - Row ID (to select the record if needed)
        state - Current state
        update_dt - Last update date in service format yyyy-MM-dd HH:mm:ss
        timeout - Default designed delay in seconds
        Returns:
        A date = update_dt+timeout
      • getAlert

        public Alert getAlert​(java.lang.String name,
                              int type)
        Get the Alert definition
        Parameters:
        name - Alert name
        type - Warn or Info
        Returns:
        The alert or null if unknown or disabled
      • prepareActionURL

        public java.lang.String prepareActionURL​(java.lang.String url,
                                                 java.lang.String[] row)
        Prepare action URL (substitute [object], [inst] and optionally [row_id] tags)
        Parameters:
        url - URL to prepare
        row - Optional row
        Returns:
        Prepared URL
      • invokeAction

        public final java.lang.String invokeAction​(java.lang.String actionName)
                                            throws java.lang.Exception
        Action call without parameters
        Parameters:
        actionName - Action name
        Returns:
        Action result
        Throws:
        java.lang.Exception
      • invokeAction

        public final java.lang.String invokeAction​(java.lang.String actionName,
                                                   java.util.Map<java.lang.String,​java.lang.String> params)
                                            throws java.lang.Exception
        Action call with optional parameters
        Parameters:
        actionName - Action name
        params - Optional parameters
        Returns:
        Action result
        Throws:
        java.lang.Exception
      • invokeAction

        public final java.lang.String invokeAction​(Action action)
                                            throws java.lang.Exception
        Action call without parameters
        Parameters:
        action - Action
        Returns:
        Action result
        Throws:
        java.lang.Exception
      • invokeAction

        public java.lang.String invokeAction​(Action action,
                                             java.util.Map<java.lang.String,​java.lang.String> params)
                                      throws java.lang.Exception
        Action call with optional parameters
        Parameters:
        action - Action
        params - Optional parameters
        Returns:
        Action result
        Throws:
        java.lang.Exception
      • invokePrint

        public final java.lang.Object invokePrint​(java.lang.String prtName)
                                           throws java.lang.Exception
        Print method call
        Parameters:
        prtName - Print template name
        Returns:
        Print result or null if print template is not a method type
        Throws:
        java.lang.Exception
      • invokePrint

        public java.lang.Object invokePrint​(PrintTemplate prt)
                                     throws java.lang.Exception
        Print method call
        Parameters:
        prt - Print template
        Returns:
        Print result (String or byte array) or null if print template is not a method type
        Throws:
        java.lang.Exception
      • invokeMethod

        public java.lang.Object invokeMethod​(java.lang.String methodName,
                                             java.lang.Class<?>[] paramTypes,
                                             java.lang.Object[] paramValues)
                                      throws java.lang.Exception
        Method call with args
        Parameters:
        methodName - Method name
        paramTypes - Table of class types
        paramValues - Table of values
        Returns:
        Method result
        Throws:
        java.lang.Exception
      • invokeCallback

        public void invokeCallback​(java.lang.String callbackName)
                            throws java.lang.Exception
        Simple callback method call
        Parameters:
        callbackName - Callback name
        Throws:
        java.lang.Exception
      • getAgendaLabel

        @Deprecated
        public java.lang.String getAgendaLabel​(Agenda a,
                                               ObjectField f)
        Deprecated.
      • getAgendaValue

        @Deprecated
        public java.lang.String getAgendaValue​(Agenda a,
                                               ObjectField f,
                                               java.lang.String val)
        Deprecated.
      • getAgendaDay

        @Deprecated
        public java.lang.String getAgendaDay​(Agenda a,
                                             java.util.Date d)
        Deprecated.
      • getAgendaWeek

        @Deprecated
        public java.lang.String getAgendaWeek​(Agenda a,
                                              java.util.List<java.lang.String> days)
        Deprecated.
      • getAgendaSelector

        @Deprecated
        public java.lang.String getAgendaSelector​(Agenda a,
                                                  java.lang.String selector)
        Deprecated.
      • evalCalculatedFields

        public void evalCalculatedFields​(int context)
        Persistent field evaluations
      • evalObjectCalculatedFields

        public void evalObjectCalculatedFields()
        Other object field evaluations
      • evalCalculatedFields

        public void evalCalculatedFields​(int context,
                                         java.lang.String[] row)
        Non persistent field evaluations
        Parameters:
        row - a record (null for current item)
      • getUserKeyLabel

        public java.lang.String getUserKeyLabel​(java.lang.String[] row)
        Build a label to represent the user key of the record
        If row is null, the selected fields are used. May be overrided to implement specific label
        Parameters:
        row - Any record, if row is null, the selected fields are used
        Returns:
        The userkey label based on object title or functional ids
      • getUserKeySearch

        public java.lang.String getUserKeySearch​(java.lang.String[] row)
        Build a label to represent the searchable fields
        If row is null, the selected fields are used. May be overrided to implement specific label
        Parameters:
        row - Any record, if row is null, the selected fields are used
        Returns:
        The object summary with search values
      • getUserKeyList

        public java.lang.String getUserKeyList​(java.lang.String[] row,
                                               boolean excludeUserKey,
                                               int maxLength)
        Build a label based on list fields
        Parameters:
        row - Any record, if row is null, the selected fields are used
        excludeUserKey - Exclude user-key fields ?
        maxLength - to truncate text
        Returns:
        The object summary with list values
      • isUndoable

        @Deprecated
        public final boolean isUndoable()
        Deprecated.
      • isUndoable

        public boolean isUndoable​(java.lang.String action)
        Hook to allow undo/redo on the object
        Parameters:
        action - Optional action ObjectXML.ACTION_*
        Returns:
        true by default for creation/deletion and update except status field (must use a valid transition)
      • preUndo

        public boolean preUndo()
        Hook called before undo
        Returns:
        true by default, return false to cancel the undo
      • postUndo

        public void postUndo()
        Hook called after undo
      • preRedo

        public boolean preRedo()
        Hook called before redo
        Returns:
        true by default, return false to cancel the redo
      • postRedo

        public void postRedo()
        Hook called after redo
      • canUpdateAll

        public boolean canUpdateAll​(ObjectField f)
        True if the field is bulk updatable, to override for specific behavior
        By default, return true if:
        - the field (and its foreign key) is visible and updatable,
        - not the single functional key in the object,
        - for status field, if the selection is in a same status
      • canUpdateAllStatus

        @Deprecated
        public boolean canUpdateAllStatus​(ObjectField f)
        Deprecated.
      • canUpdateAllEnum

        public boolean canUpdateAllEnum​(ObjectField f)
        Enable status/enum for bulk update only if all the status/parent linked values are the same in the current search/selection
        Parameters:
        f - Object field
        Returns:
        true if status/parent enum is constant
      • storeParentContext

        public static ObjectDB storeParentContext​(java.lang.String prefix,
                                                  ObjectDB parent,
                                                  java.lang.String childObject,
                                                  java.lang.String childField,
                                                  java.lang.String[] values)
        Store parent object context / must be called before any count/search of child list
        Parameters:
        prefix - Object prefix for child (e.g. "panel_")
        parent - Parent object
        childObject - Child object name
        childField - Foreign key name
        values - Values (if null current parent values are used)
      • storeParentContext

        public ObjectDB storeParentContext​(ObjectDB parent,
                                           java.lang.String refField,
                                           java.lang.String[] values)
        Store parent object context / must be called before any count/search of child list
        Parameters:
        parent - Parent object
        refField - Foreign key name
        values - Values (if null current parent values are used)
      • prepareTemplate

        public void prepareTemplate()
        Build the template hierarchy
      • getTemplateRoot

        public ObjectTemplate.Node getTemplateRoot()
        Get the root of the template hierarchy
      • makeTree

        public void makeTree​(ObjectNode root,
                             java.lang.String parentId,
                             java.util.List<java.lang.String[]> rows,
                             int depth)
        Build the partial tree
        Parameters:
        root - Tree root
        parentId - Node row ID
        rows - List of records to add to parent
        depth - Deep search depth
      • insertTree

        public void insertTree​(ObjectNode parent,
                               int depth)
        Search and add children to parent node
        Parameters:
        parent - Parent node
        depth - Deep search depth
      • deleteTree

        public void deleteTree​(ObjectNode tree,
                               java.lang.String id)
      • fieldCompletion

        public java.util.List<java.lang.String> fieldCompletion​(java.lang.String input,
                                                                java.lang.String query,
                                                                java.lang.String context)
        Hook to override the default field completion (Lucene or SQL search on field)
        - Usefull to implement an editable select-box, to call a WebService and/or to populate a specific list of choice
        - On client-side, use the field_completed(value) hook in the template to handle the selected value by user
        Parameters:
        input - Field to search
        query - User query/filter
        context - Field context = form, search or list
        Returns:
        null to use the default behavior (lucene or sql), empty list to ignore completion, or a list with values to display
      • addLink

        @Deprecated
        public Link addLink​(ObjectDB object,
                            ObjectField fk,
                            java.lang.String display,
                            java.lang.String help,
                            java.lang.String card,
                            int order,
                            boolean copy,
                            char associate,
                            boolean visible,
                            boolean inline,
                            char cascad)
        Deprecated.
      • addLink

        public Link addLink​(ObjectDB object,
                            ObjectField fk,
                            java.lang.String display,
                            java.lang.String help,
                            java.lang.String card,
                            int order,
                            boolean copy,
                            char associate,
                            boolean visible,
                            boolean inline,
                            char cascad,
                            java.lang.String icon)
        Add dynamically a link (ant its single view) to the object
        Parameters:
        object - Child object with a reference to this object
        fk - Foreign key field in the child object
        display - View display
        help - Optional help
        card - Cardinality 0,n
        order - View ordering
        copy - Allows cascad copy ?
        associate - Alows bulk associations ?
        visible - View is visible ?
        inline - In inline (in case of 0,1 ou 1,1)
        cascad - From ObjectDB.DEL_*
        icon - Optional icon code
        Returns:
        Created link
      • addLinkMetaObject

        public Link addLinkMetaObject​(ObjectDB object,
                                      int order)
        Add dynamically a meta-object link (ant its single view) to the object
        Parameters:
        object - Child object with a meta-objet field (reference to this object)
        order - View ordering
        Returns:
        Created link
      • displayForm

        public java.lang.String displayForm​(java.lang.Object params,
                                            java.lang.Object nav,
                                            java.lang.Object page)
                                     throws java.lang.Exception
        UI Form wrapper
        Throws:
        java.lang.Exception
      • displayList

        public java.lang.String displayList​(java.lang.Object list,
                                            java.lang.Object params,
                                            java.lang.Object nav,
                                            ObjectDB parent)
                                     throws java.lang.Exception
        UI List wrapper
        Throws:
        java.lang.Exception
      • displaySearch

        public java.lang.String displaySearch​(java.lang.Object search,
                                              java.lang.Object params,
                                              java.lang.Object nav)
                                       throws java.lang.Exception
        UI Search wrapper
        Throws:
        java.lang.Exception
      • displayRefSelect

        public java.lang.String displayRefSelect​(java.lang.Object selector,
                                                 java.lang.Object params,
                                                 java.lang.Object nav)
                                          throws java.lang.Exception
        UI Reference selector wrapper
        Throws:
        java.lang.Exception
      • displayDataMap

        public java.lang.String displayDataMap​(java.lang.Object selector,
                                               java.lang.Object params,
                                               java.lang.Object nav)
                                        throws java.lang.Exception
        UI DataMap selector wrapper
        Throws:
        java.lang.Exception
      • getStyle

        public java.lang.String getStyle​(ObjectField f,
                                         java.lang.String val)
        Gets specified field style for single value
        May be override to change the style with specific business rules
        Parameters:
        f - Field
        val - Value
        Returns:
        CSS class(es) empty by default
      • getStyle

        public java.lang.String getStyle​(ObjectField f,
                                         java.lang.String[] row)
        Gets specified field style from values array
        May be override to change the style with specific business rules
        Parameters:
        f - Field
        row - Values array
        Returns:
        CSS class(es) empty by default
      • getStyle

        public java.lang.String getStyle​(ObjectField f,
                                         double val)
        Hook to specify field style for a crosstab value
        Parameters:
        f - Field
        val - Value
        Returns:
        CSS class(es), null by default
      • getImage

        public java.lang.String getImage​(ObjectField f,
                                         java.lang.String val)
        Get the field icon from single value. May be override to change the style with specific business rules
        Parameters:
        f - Field
        val - Image value
        Returns:
        Icon name
      • getImage

        public java.lang.String getImage​(ObjectField f,
                                         java.lang.String[] row)
        Get the field icon from values array. May be override to change the style with specific business rules
        Parameters:
        f - Field
        row - Values array
        Returns:
        Icon name
      • sendRedirect

        public java.lang.String sendRedirect​(java.lang.String url)

        Generate a redirect statement to be returned by an action method

        Parameters:
        url - URL to redirect to
      • redirect

        public java.lang.String redirect​(java.lang.String url)
        Alias to sendRedirect
      • sendJavaScript

        public java.lang.String sendJavaScript​(java.lang.String js)

        Generate a JavaScript statement to be returned by an action method

        Parameters:
        js - JavaScript statement
      • javascript

        public java.lang.String javascript​(java.lang.String js)
        Alias to sendJavaScript
      • toXML

        public java.lang.String toXML()
        Publish to upsert XML
      • unitTests

        public java.lang.String unitTests()
        Unit tests
        Returns:
        Unit tests results
      • docuSign

        public void docuSign​(DocuSignTool.DocuSignStatus doc)
        DocuSign web-hook https://developers.docusign.com/esign-rest-api/code-examples/webhook-status
      • getDirectURL

        public java.lang.String getDirectURL​(boolean form)
        Get external access URL to object
        Parameters:
        form - form or list
        Returns:
        Absolute URL
      • getSocialShareData

        public SocialShareData getSocialShareData()
        Hook to override share information to send to social medias. By default returns the user-key with a deep link to object (and the first image URL if any)
        Returns:
        Share data