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
    - publication 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
        Returns:
        Previous row ID
      • getFirstRowId

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

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

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

        public ObjectDB load​(Grant grant)
        Object definition loading
        Parameters:
        grant - User rights
        Returns:
        Object definition
      • 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
        Returns:
        Object definition
      • init

        public ObjectDB init​(java.lang.String name,
                             Grant grant)
        Load the object definition from the repository
        Parameters:
        name - Object name
        grant - User rights
        Returns:
        Object definition
      • 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​(Parameters params)
        Hook called before bulk update
        Parameters:
        params - requested data
        Returns:
        Error code or null
      • preUpdateAll

        @Deprecated
        public java.lang.String preUpdateAll()
        Deprecated.
        Hook called before bulk update. This method is deprecated, use preUpdateAll(Parameters params)
        Returns:
        Error code or null
      • postUpdateAll

        public void postUpdateAll​(Parameters params)
        Hook called after bulk update
        Parameters:
        params - requested data
      • postUpdateAll

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

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

        public java.lang.String postDeleteAll()
        Hook called after bulk delete
        Returns:
        Message or a redirect statement or null
      • 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
      • getParentObject

        public ObjectDB getParentObject()
        Get the parent object for child lists
        Overrides:
        getParentObject in class ObjectCore
        Returns:
        Parent object or null
      • initSearch

        public void initSearch()
        Hook to init the search
      • initList

        public void initList​(ObjectDB parent)
        Hook to init the list
        Parameters:
        parent - Optional parent object
      • initCreate

        public void initCreate()
        Hook to init the creation
      • initCopy

        public void initCopy()
        Hook to init the copy
      • initUpdate

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

        public void initUpdateAll()
        Hook to init the blulk update
      • 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 selection
        Parameters:
        parent - Parent object (from which selection is made)
      • initAssociate

        public void initAssociate​(ObjectDB parent)
        Hook to init the association
        Parameters:
        parent - Parent object (from which association is made)
      • initDataMapSelect

        public void initDataMapSelect​(java.lang.String datamapName,
                                      ObjectDB parent)
        Hook to init the data mapping selection
        Parameters:
        datamapName - Data mapping name
        parent - Parent object (from which selection is made)
      • initGraph

        public void initGraph​(java.lang.String graphName)
        Hook to init a graph
        Parameters:
        graphName - Graph name
      • initCrosstab

        public void initCrosstab​(java.lang.String crosstabName)
        Hook to init a pivot table
        Parameters:
        crosstabName - Pivot table name
      • initPrintTemplate

        public void initPrintTemplate​(java.lang.String prtName)
        Hook to init a publication template
        Parameters:
        prtName - Publication template name
      • initAgenda

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

        public void initPlaceMap​(PlaceMap placemap)
        Hook to init a place map
        Parameters:
        placemap - Place map
      • initAction

        public void initAction​(Action action)
        Hook to init the Action fields before the confirm dialog.
        • By default field belonging to object are read only to confirm the value
        • Other fields are updatable and sent to the callback method(Map) with pairs of name:value
        Parameters:
        action - Action definition
      • 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 or a redirect statement 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
        Returns:
        Console
      • setConsole

        public void setConsole​(Console console)
        Set console
        Parameters:
        console - Console
      • clear

        public void clear()
        Clear
      • editTemplateUsage

        public boolean editTemplateUsage()
        Object is used in the template editor?
        Returns:
        true if the object is used in the template editor
      • setConstraint

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

        public void applyStaticConstraints()
        Apply all static constraints on load
      • applyConstraints

        public void applyConstraints​(int context)
        Apply all dynamic constraints
        Parameters:
        context - Context
      • applyObjectConstraints

        public void applyObjectConstraints​(int context)
        Apply all dynamic constraints on object
        Parameters:
        context - Context (one of ObjectCore.CONTEXT_*)
      • checkCreateConstraints

        public final boolean checkCreateConstraints()
        Apply all create constraints on object
        Returns:
        Constraint status
      • checkUpdateConstraints

        public final boolean checkUpdateConstraints()
        Apply all update constraints on object
        Returns:
        Constraint status
      • checkDeleteConstraints

        public final boolean checkDeleteConstraints()
        Apply all delete constraints on object
        Returns:
        Constraint status
      • checkObjectPropConstraints

        public boolean checkObjectPropConstraints​(int context,
                                                  char objectProp)
        Check object constraints for property
        Parameters:
        context - Context
        objectProp - Property
        Returns:
        Constraint status
      • hasFieldConstraints

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

        public void applyFieldConstraints​(int context)
        Apply 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)
        Apply all constraints on targets (action, link or view)
        Parameters:
        context - Context
      • isMergeMaster

        public boolean isMergeMaster()
        Hook to tell is current record the merge master ?
        Returns:
        True if is merge master
      • isMergeEnable

        public java.lang.String isMergeEnable​(java.util.List<java.lang.String> ids)
        Hook to tell if selected ids are mergeable
        Parameters:
        ids - List of row IDs
        Returns:
        Error or null by default
      • 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 publication template is available for a specific record
        This method must be called to check if the publication template is available for the user
        Parameters:
        printTemplate - Publication template name
        Returns:
        True when the publication template is granted to the user (check if publication template is enabled by default)
      • printed

        public java.lang.Object printed​(PrintTemplate pt,
                                        java.lang.String rowId,
                                        java.lang.Object printed)
        Callback hook when published. Useful to change the content or store the object before returning the publication result
        Parameters:
        pt - Publication template
        rowId - Optional row ID
        printed - Published object (html, zip, pdf...)
        Returns:
        Published 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 ActionException
        Action call without parameters
        Parameters:
        actionName - Action name
        Returns:
        Action result
        Throws:
        ActionException
      • invokeAction

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

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

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

        public final java.lang.Object invokePrint​(java.lang.String prtName)
                                           throws PrintException
        Print method call. Warning: this only applies to publication implemented as a method,
        For a publication based on a template (file or text) you should use:
        • getPrintTemplate(prtName).fillWithCurrentObject(this) for single record (form) publication
        • getPrintTemplate(prtName).fillWithCurrentList(this) for multiple record (list) publication
        Parameters:
        prtName - Publication template name
        Returns:
        Print result or null if publication template is not impemented as a method
        Throws:
        PrintException
      • invokePrint

        public java.lang.Object invokePrint​(PrintTemplate prt)
                                     throws PrintException
        Print method call. Warning: this only applies to publication implemented as a method,
        For a publication based on a template (file or text) you should use:
        • prt.fillWithCurrentObject(this) for single record (form) publication
        • prt.fillWithCurrentList(this) for multiple record (list) publication
        Parameters:
        prt - Publication template
        Returns:
        Print result or null if publication template is not impemented as a method
        Throws:
        PrintException
      • invokeMethod

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

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

        public void invokeCallback​(java.lang.String callbackName,
                                   java.util.Map<java.lang.String,​java.lang.String> params)
                            throws MethodException
        Simple callback method call
        Parameters:
        callbackName - Callback name
        params - Optional parameters
        Throws:
        MethodException
      • 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
      • getUserKeyLabel

        public java.lang.String getUserKeyLabel​(java.lang.String[] row)
        Build a custom 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 user key label based on object title or functional keys
      • 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
      • getExportFileName

        public java.lang.String getExportFileName​(java.lang.String type,
                                                  java.lang.String name,
                                                  java.lang.String[] row)
        Export file name: default is the object label or user key, this hook can be overridden to change the output name.
        Parameters:
        type - Export type: CSV, XLSX, PDF, ZIP, XML... HTTPTool.MEDIA_*
        name - Default name: print template, crosstab name or object name
        row - Optional record in case of form export
        Returns:
        File name (if no extension specified, it will be set automatically from the mime-type)
      • 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, returns true if:
        - the field (or 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 PlatformException
        UI Form wrapper
        Throws:
        PlatformException
      • displayList

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

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

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

        public java.lang.String displayDataMap​(java.lang.Object selector,
                                               java.lang.Object params,
                                               java.lang.Object nav)
                                        throws PlatformException
        UI DataMap selector wrapper
        Throws:
        PlatformException
      • 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, by default call getStyle for the field value
        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
      • getStyleTree

        public java.lang.String getStyleTree​(TreeView tv,
                                             java.lang.String[] row)
        Hook to assign a style to a treeview item
        Parameters:
        tv - Treeview
        row - Values array
        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
      • getImageTree

        public java.lang.String getImageTree​(TreeView tv,
                                             java.lang.String[] row)
        Hook to assign one icon to a treeview item
        Parameters:
        tv - Treeview
        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
      • preSavePredefinedSearch

        public java.lang.String preSavePredefinedSearch​(PredefinedSearch ps)
        Hook called before predefined-search save
        Parameters:
        ps - Predefined search
        Returns:
        Error or null
      • postSavePredefinedSearch

        public void postSavePredefinedSearch​(PredefinedSearch ps)
        Hook called after predefined-search save
        Parameters:
        ps - Predefined search
      • getTool

        public BusinessObjectTool getTool()
        Get a business object tool wrapper for the object
        Returns:
        Business object tool wrapper