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.
CONTEXT_ACTION, CONTEXT_AGENDA, CONTEXT_ASSOCIATE, CONTEXT_COPY, CONTEXT_CREATE, CONTEXT_CROSSTAB, CONTEXT_DATAMAPSELECT, CONTEXT_DELETE, CONTEXT_EXPORT, CONTEXT_GRAPH, CONTEXT_IMPORT, CONTEXT_LIST, CONTEXT_NONE, CONTEXT_PANELLIST, CONTEXT_PLACEMAP, CONTEXT_POSTVALIDATE, CONTEXT_PREVALIDATE, CONTEXT_PRINTTMPL, CONTEXT_REFSELECT, CONTEXT_SEARCH, CONTEXT_STATETRANSITION, CONTEXT_UPDATE, CONTEXT_UPDATEALL, DB_DERBY, DB_H2, DB_HSQLDB, DB_MSSQL, DB_MYSQL, DB_ORACLE, DB_POSTGRESQL, DB_UNKNOWN, DEL_CASCAD, DEL_IGNORE, DEL_NULL, DEL_RESTRICT, FORM_LAYOUT_COMPACT, FORM_LAYOUT_DEFAULT, LIST_ADD, LIST_EDIT, LIST_READ, TYPE_QUERY, TYPE_SERVICE, TYPE_SERVICE_OPENDATASOFT, TYPE_SERVICE_SALESFORCE, TYPE_SERVICE_SIMPLICITE, VIEW_MODE_ACCORDION, VIEW_MODE_COLLAPSED, VIEW_MODE_EXTENDED, VIEW_MODE_TABS
Constructor and Description |
---|
ObjectDB()
Default constructor, may not be used.
Object instantiation must be done using the Grant.getXXXObject methods (Main, Temp, Panel, Batch, Ref...). |
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 |
Modifier and Type | Method and Description |
---|---|
Link |
addLink(ObjectDB object,
ObjectField fk,
java.lang.String display,
java.lang.String help,
java.lang.String card,
int order,
boolean copy,
boolean associate,
boolean visible,
boolean inline,
char cascad)
Add dynamically a link (ant its single view) to the object
|
Link |
addLinkMetaObject(ObjectDB object,
int order)
Add dynamically a meta-object link (ant its single view) to the object
|
void |
buildTreeList(ObjectNode node,
java.util.Vector<ObjectNode> v) |
boolean |
canReference(java.lang.String target,
java.lang.String foreignKey)
Hook called to check if a referenced object can be displayed
|
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. |
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
|
boolean |
canUpdateAllStatus(ObjectField f)
Deprecated.
|
boolean |
checkCreateVisibilities()
Check create visibilities
|
java.util.Vector<java.lang.String>[] |
checkDelete()
Deprecated.
|
boolean |
checkDeleteVisibilities(java.lang.String[] row)
Check delete visibilities
|
boolean |
checkUpdateVisibilities(java.lang.String[] row)
Check update visibilities
|
java.util.Vector<java.lang.String> |
completeForeignKeys()
Try to complete the references (ids of foreign keys) with the field values
|
long |
count()
Alias to getCount
|
java.lang.String |
create()
Insert the object field values in the DB.
|
java.lang.String |
del()
Delete the current row and dependencies (same as delete but for scripting usage)
|
java.lang.String |
delete()
Delete the current row and dependencies
This version use all the ObjectDB hooks.
|
java.lang.String |
delete(java.util.Vector<java.lang.String> request)
Deprecated.
|
void |
deleteTree(ObjectNode tree,
java.lang.String id) |
java.lang.String |
displayDataMap(java.lang.Object selector,
java.lang.Object params,
java.lang.Object nav)
UI DataMap selector wrapper
|
java.lang.String |
displayForm(java.lang.Object params,
java.lang.Object nav,
java.lang.Object page)
UI Form wrapper
|
java.lang.String |
displayList(java.lang.Object list,
java.lang.Object params,
java.lang.Object nav,
ObjectDB parent)
UI List wrapper
|
java.lang.String |
displayRefSelect(java.lang.Object selector,
java.lang.Object params,
java.lang.Object nav)
UI Reference selector wrapper
|
java.lang.String |
displaySearch(java.lang.Object search,
java.lang.Object params,
java.lang.Object nav)
UI Search wrapper
|
void |
evalCalculatedFields(int context)
Persistent field evaluations
|
void |
evalCalculatedFields(int context,
java.lang.String[] row)
Non persistent field evaluations
|
java.lang.String |
evalNextRowId(java.lang.String table)
Hook called before the DB creation to send a specific unique id
(i.e.
|
void |
evalObjectCalculatedFields()
Other object field evaluations
|
java.util.ArrayList<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 |
java.lang.String |
getAgendaDay(Agenda a,
java.util.Date d)
Hook to override agenda displayed date, usefull to add specific actions at the day header
|
java.lang.String |
getAgendaLabel(Agenda a,
ObjectField f)
Hook to customize agenda displayed field
|
java.lang.String |
getAgendaSelector(Agenda a,
java.lang.String selector)
Hook to override agenda displayed selector, usefull to mask or list specific users/groups at the agenda header
|
java.lang.String |
getAgendaValue(Agenda a,
ObjectField f,
java.lang.String val)
Hook to customize agenda displayed value
|
java.lang.String |
getAgendaWeek(Agenda a,
java.util.Vector<java.lang.String> days)
Hook to override agenda displayed week, usefull to add specific actions at the agenda header
|
Alert |
getAlert(java.lang.String name,
int type)
Get the Alert definition
|
ObjectInterface |
getContext()
Get the interface to manipulate objects (Local EJB, Remote EJB, WebService, Direct).
|
long |
getCount()
Return the records count with the current search specification and filters.
|
long |
getCount(int maxRows)
Return the records count with the current search specification and filters.
|
java.util.Date |
getDeadlineDate(java.lang.String row_id,
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)
|
char |
getEmailRecipientType(java.lang.String alert,
java.lang.String email,
char type)
Hook to override the recipient type (TO/CC/BCC)
|
java.lang.String |
getFieldDefaultValue(ObjectField fld)
Eval a default value
|
java.lang.String |
getFileName(java.lang.String id)
Get the filename of a document stored in m_document
|
java.lang.String |
getFilePath(java.lang.String id)
Get the relative path (from DOCDIR) of a document stored in m_document
|
java.lang.String |
getFirstRowId()
The method gives the first row_id in a search context
|
char |
getGroupEmailRecipientType(java.lang.String alert,
java.lang.String group,
char type)
Hook to override the recipient type (TO/CC/BCC) of a group
|
java.lang.String |
getLastRowId()
The method gives the last row_id in a search context
|
java.lang.String |
getNextRowId()
The method gives the next row_id of the current record in a search context
|
ObjectDB |
getParentObject()
Get the parent object for child lists
|
java.lang.String |
getPreviousRowId()
The method gives the previous row_id of the current record in a search context
|
java.lang.String |
getQuery(java.util.Vector<ObjectField> host)
Return the SQL select statement with current filter
|
long |
getRefCount(java.lang.String refname,
java.lang.String field)
Return the records count of a linked object (relation 0,n).
|
java.lang.String |
getSearchSpec(java.lang.String s)
Eval the search specification
|
ObjectTemplate.Node |
getTemplateRoot()
Get the root of the template hierarchy
|
java.lang.String |
getUserKeyLabel(java.lang.String[] row)
Build a label to represent the user key of the record.
|
java.lang.String |
getUserKeySearch(java.lang.String[] row)
Build a label to represent the searchable fields.
|
void |
init(int context,
java.lang.String[] params)
Deprecated.
|
ObjectDB |
init(java.lang.String name,
Grant grant)
Load the object definition from the repository
|
void |
initAgenda(Agenda agenda)
Hook to init an agenda
|
void |
initAssociate(ObjectDB parent)
Hook to init the association before associate dialog
|
void |
initCopy()
Hook to init the Copy before user dialog
|
void |
initCreate()
Hook to init the Creation before user dialog
|
void |
initCrosstab(java.lang.String crosstabName)
Hook to init a crosstable
|
void |
initDataMapSelect(java.lang.String datamapName,
ObjectDB parent)
Hook to init the data map select before user dialog
|
void |
initDelete()
Hook to init the Delete before delete dialog
|
void |
initExport()
Hook to init the Export before export dialog
|
void |
initFromTable(java.lang.String table,
Grant grant)
Load the object definition from the DB table (beta)
|
void |
initGraph(java.lang.String graphName)
Hook to init a graph
|
void |
initList(ObjectDB parent)
Hook to init the List before user dialog
|
void |
initPlaceMap(PlaceMap placemap)
Hook to init a place map
|
void |
initPrintTemplate(java.lang.String printTemplateName)
Hook to init a print templates
|
void |
initRefSelect(ObjectDB parent)
Hook to init the reference select before select dialog
|
void |
initSearch()
Hook to init the Search before user dialog
|
void |
initUpdate()
Hook to init the Update before update dialog
|
void |
initUpdateAll()
Hook to init the Update before bulk update dialog
|
void |
initWebService(int context,
java.lang.String[] params)
Object init switch for use by webservices (and related APIs : Ajax, ...)
|
java.lang.String |
invokeAction(Action action)
Action call
|
java.lang.String |
invokeAction(java.lang.String actionName)
Action call
|
void |
invokeCallback(java.lang.String callbackName)
Simple callback method call
|
java.lang.Object |
invokeMethod(java.lang.String methodName,
java.lang.Class<?>[] paramTypes,
java.lang.Object[] paramValues)
Method call with args
|
java.lang.Object |
invokePrint(PrintTemplate prt)
Print method call
|
java.lang.Object |
invokePrint(java.lang.String prtName)
Print method call
|
boolean |
isActionEnable(java.lang.String[] row,
java.lang.String action)
Hook to check if one action is available for a specific record.
|
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.
|
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.
|
boolean |
isCrosstabEnable(java.lang.String crosstab)
Hook to check if crosstab is available.
|
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.
|
boolean |
isGraphEnable(java.lang.String graph)
Hook to check if chart is available.
|
boolean |
isMergeMaster()
Hook to tell is current record the merge master ?
|
boolean |
isOpenEnable(java.lang.String[] row)
Hook to check if the open action is available for a specific record.
|
boolean |
isPrintTemplateEnable(java.lang.String[] row,
java.lang.String printTemplate)
Hook to check if print template is available for a specific record.
|
boolean |
isStateTransitionEnable(java.lang.String fromStatus,
java.lang.String toStatus)
Hook called when building the list of possible state transition.
|
boolean |
isUndoable()
Hook to allow undo/redo on the object
|
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.
|
ObjectDB |
load(Grant grant)
Object definition loading
|
ObjectDB |
load(Grant grant,
java.lang.String obj)
Default object definition loading, called by load(Grant).
|
ObjectNode |
makeTree()
Build the tree view
|
java.util.Vector<java.lang.String> |
merge(java.util.List<java.lang.String> ids,
java.util.HashMap<java.lang.String,java.util.List<java.lang.Integer>> map)
Merge all records and links
|
void |
populate(boolean complete)
Populate all fields with the references, parent or default values
|
void |
populate(ObjectField field)
Populate a field with the reference, the contextual or its default value
This method is not supposed to be overridden |
void |
populate(ObjectField field,
boolean complete)
Populate a field with the reference, the contextual or its default value
|
boolean |
populateForeignKey(java.lang.String refField,
java.lang.String refId,
boolean useSearchSpec,
boolean reset)
Populate all fields joined to a foreign key
|
java.lang.String |
postAlert(Alert a)
Hook before after sending the alert
|
java.lang.String |
postCreate()
Hook called after the DB creation
|
java.lang.String |
postDelete()
Hook called after the DB deletion.
|
void |
postDeleteAll()
Hook called after bulk delete.
|
java.util.Vector<java.lang.String[]> |
postExport(java.util.Vector<java.lang.String[]> rows)
Hook called after search in export of data.
|
java.lang.String |
postImport()
Hook called after processing object import.
|
void |
postLoad()
Hook called after loading the object definition.
|
java.util.Vector<java.lang.String[]> |
postObjectSearch(java.util.Vector<java.lang.String[]> rows)
Hook called after search of object reference.
|
void |
postRedo()
Hook called after redo
|
java.lang.String |
postSave()
Hook called after the DB save
|
java.util.Vector<java.lang.String> |
postSaveTimesheet(Timesheet ts)
Hook called after Timesheet save
|
java.util.Vector<java.lang.String[]> |
postSearch(java.util.Vector<java.lang.String[]> rows)
Hook called after search with the fields filters.
|
void |
postSelect(java.lang.String row_id,
boolean copy)
Hook called after a single row selection
|
void |
postUndo()
Hook called after undo
|
java.lang.String |
postUpdate()
Hook called after the DB update
|
void |
postUpdateAll()
Hook called after bulk update.
|
java.util.Vector<java.lang.String> |
postValidate()
Hook called after system validation.
|
java.util.Vector<java.lang.String> |
postValidateSearch()
Hook called after search validation with the fields filters.
|
java.lang.String |
preAlert(Alert a)
Hook before before sending the alert
|
java.lang.String |
preCreate()
Hook called before the DB creation
|
java.lang.String |
preDelete()
Hook called before the DB deletion
|
java.lang.String |
preDeleteAll()
Hook called before bulk delete.
|
void |
preExport()
Hook called before search in export of data.
|
java.lang.String |
preImport()
Hook called before processing object import.
|
void |
preLoad()
Hook called before loading the object definition.
|
void |
preObjectSearch()
Hook called before search of object reference.
|
void |
prepareTemplate()
Build the template hierarchy
|
boolean |
preRedo()
Hook called before redo
|
java.lang.String |
preSave()
Hook called before the DB save
|
java.util.Vector<java.lang.String> |
preSaveTimesheet(Timesheet ts)
Hook called before Timesheet save
|
void |
preSearch()
Hook called before search with the fields filters.
|
void |
preSelect(java.lang.String row_id,
boolean copy)
Hook called before a single row selection
|
java.util.Vector<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.
|
boolean |
preUndo()
Hook called before undo
|
java.lang.String |
preUpdate()
Hook called before the DB update
|
java.lang.String |
preUpdateAll()
Hook called before bulk update.
|
java.util.Vector<java.lang.String> |
preValidate()
Hook called before system validation.
|
java.util.Vector<java.lang.String> |
preValidateSearch()
Hook called before search validation with the fields filters.
|
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.
|
java.util.Vector<java.lang.String[]> |
search()
Retrieve the database records with the currents search specification
and the field filters (without pagination).
|
java.util.Vector<java.lang.String[]> |
search(boolean pagine)
Retrieve the database records with the currents search specification
and the field filters.
|
java.util.Vector<java.lang.String[]> |
search(boolean pagine,
int maxRows)
Retrieve the database records with the currents search specification
and the field filters.
|
java.util.Vector<java.lang.String[]> |
searchCrosstab(Crosstab c)
Same as a search but for a crosstab calculation and optimization
|
java.util.Vector<java.lang.String[]> |
searchExport()
Same as a search but for the export of data
|
java.lang.String |
searchRowId()
Search with the current fields a matching record in the DB
This method is not supposed to be overriden |
java.lang.String |
searchRowId(java.lang.String notId)
Search with the current fields a matching record in the DB
|
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).
|
boolean |
select(java.lang.String row_id)
Selects a single record and loads the values into the object fields.
|
boolean |
select(java.lang.String row_id,
boolean copy)
Selects a single record and loads the values into the object fields (either for simple selection or for copy).
|
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
|
boolean |
spamGroup(java.lang.String alert,
java.lang.String name)
Hook called to check if the group is a recipient of the alert
|
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
|
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
|
java.lang.String |
update()
Update the field values in the DB.
|
java.util.Vector<java.lang.String> |
validate()
Core system validation (unicity, field format, mandatory...)
Must be called before any creation or update.
|
java.util.Vector<java.lang.String> |
validate(boolean onlyErrors)
Core system validation (unicity, field format, mandatory...)
Must be called before any creation or update.
|
java.util.Vector<java.lang.String> |
validateSearch()
Core system search validation (mandatory...)
Must be called before any search.
|
addAgenda, addConstraint, addCrosstab, addDataMap, addDefaultValues, addGraph, addHook, addLinkDataMap, addListOperationField, addPlaceMap, addPredefinedSearch, addPrintTemplate, addScript, addSharedScript, addTimesheet, applyConstraints, applyFieldConstraints, applyObjectConstraints, applyTargetConstraints, buildInsertSQL, canClose, canCopy, canCreateOnLink, canCreateOnLinks, canDeleteAll, canExport, canFollowLink, canFollowLink, canFollowLinks, canListAccessNewForm, canListAccessNewLine, canListAccessNewLoop, canPrint, canSave, canSelectRow, canUpdateAll, checkCreateConstraints, checkDeleteConstraints, checkExpression, checkUpdateConstraints, convertFilterToService, convertGuiToService, convertServiceToFilter, convertServiceToGui, enableGC, evalExpression, evalExpression, evalExpression, evalExpression, evalInputOldValue, evalInputValue, fieldsToListRow, fieldsToListRow, freeListTree, garbageCollection, genAction, genCommonActions, getAction, getActions, getAgenda, getAgendas, getBooleanParameter, getCacheFrom, getCacheKey, getCacheSelect, getCode, getCodes, getContextTitle, getCopyId, getCreatedBy, getCreatedDate, getCrosstab, getCrosstabs, getCtxHelp, getCtxHelps, getCurrentAction, getCurrentItem, getCurrentList, getCurrentPage, getCurrentPos, getCurrentRowId, getCurrentView, getData, getDataMap, getDataSource, getDataSourceVendor, getDbField, getDBField, getDbIndex, getDBIndex, getDBName, getDefaultLink, getDefaultSearchSpec, getDisplay, getDisplay, getDocFields, getDoubleParameter, getField, getField, getField, getField, getFieldArea, getFieldArea, getFieldAreas, getFieldAtIndex, getFieldByTranslation, getFieldFilter, getFieldIndex, getFieldIndex, getFieldOldValue, getFieldOrder, getFields, getFields, getFieldValue, getFieldValues, getFieldValues, getFilters, getFilters, getFlagParameter, getFloatParameter, getFonctId, getForeignKeys, getFormLayout, getFullInput, getFullInput, getFullInputIndex, getFullInputIndex, getFunctId, getGrant, getGraph, getGraphs, getHelp, getHistoricDBName, getHistoricName, getHook, getHooks, getIconCode, getId, getImage, getImage, getImageField, getIndex, getIndex, getInheritedObjects, getInput, getInput, getInputAtIndex, getInputIndex, getInputIndex, getInstanceName, getIntParameter, getLastUpdatedBy, getLastUpdatedDate, getLink, getLinkDataMap, getLinks, getListEditMode, getListOperationFields, getListSize, getListTree, getLongParameter, getMaxPage, getName, getObjectId, getObjectName, getObjectParameter, getOldStatus, getOldValues, getOldValues, getParameter, getParameter, getParentField, getParentIdx, getParentObjectRefField, getParentValues, getPlaceMap, getPlaceMaps, getPredefinedSearch, getPredefinedSearchIndex, getPrintTemplate, getPrintTemplates, getRefField, getRootField, getRowId, getRowIdField, getScripts, getSearchLimit, getSearchSpec, getSelectedIds, getSharedScripts, getStatus, getStatusField, getStatusIndex, getStyle, getStyle, getStyle, getTable, getTargetObject, getTemplate, getTimesheet, getTimesheets, getTitle, getTitle, getValues, getValues, getView, getView, getViewMode, getViews, hasChanged, hasField, hasFieldType, hasFullInput, hasInput, hasMoreOnForm, hasMoreOnList, hasMoreOnSearch, hasSearchLimitError, haveMore, initLists, isAgendaInstance, isAreaVisible, isBatchInstance, isChildOf, isChildOf, isCopied, isCopy, isDataMapInstance, isDataMappedFrom, isDate, isDistinct, isExport, isFieldForbidden, isFieldSearchable, isFieldUpdatable, isFieldVisible, isFiltered, isForm, isHistoric, isHomeInstance, isIndexable, isInstanceOf, isLimit, isListEditable, isListSearch, isListSearchVisible, isListTree, isLoaded, isMainInstance, isMenuSearch, isMergeable, isModelerInstance, isMoreForm, isMoreFormEnable, isMoreListEnable, isMoreOnForm, isMoreOnList, isMoreRows, isMoreSearch, isNew, isPanelInstance, isPanelOf, isPanelOf, isPredefSearch, isProcessInstance, isQuerySpecific, isReadOnly, isReadOnlyFields, isRefCount, isRefCountEnable, isReferencedFrom, isReferencedFrom, isRefInstance, isScripted, isServiceSpecific, isSocial, isTmpInstance, isTreeviewInstance, isUIInstance, isUpdateAll, isWebServiceInstance, lastUsage, listRowToFields, listRowToFields, listRowToFields, listSelectAll, listSelectId, listSelectPage, listUnselectAll, listUnselectId, oldFieldsToListRow, oldFieldsToListRow, parseDataSourceName, parseTableName, prepareExpression, preparePagination, prepareSQL, removeField, removeParameter, removeParameters, resetAllFields, resetAllFieldsRequired, resetAllFieldsSearch, resetAllFieldsSearchRequired, resetAllFieldsUpdatable, resetContextDefaultValues, resetFilter, resetFilters, resetFilters, resetFiltersOrdersAndCalcDefaults, resetOrder, resetOrder, resetOrders, resetOrders, resetRequireds, resetSearchables, resetSelectedIds, resetUpdatables, resetValues, resetValues, resetVisibilities, selectCurrentItemFromList, selectItemFromList, setAllFieldsUpdatable, setAllFieldUpdatable, setCacheFrom, setCacheSelect, setClose, setCopy, setCopyId, setCreateOnLinks, setCrosstabVisibility, setCtxHelps, setCurrentAction, setCurrentList, setCurrentPage, setCurrentPos, setCurrentPos, setCurrentView, setData, setDataSource, setDataSourceVendor, setDBName, setDefaultLink, setDefaultSearchSpec, setDeleteAll, setDisplay, setDistinct, setExport, setFieldFilter, setFieldOldValue, setFieldOrder, setFields, setFieldValue, setFilters, setFilters, setFilters, setFollowLinks, setForm, setFormLayout, setFunctId, setGrant, setHaveMore, setHelp, setHistoric, setIconCode, setId, setIndexable, setInheritedObject, setInstanceName, setLimit, setListAccessNewForm, setListAccessNewLine, setListAccessNewLine, setListEdit, setListEditable, setListEditMode, setListSearch, setListSearchVisible, setListSize, setListTree, setMaxPage, setMenuSearch, setMergeable, setMoreForm, setMoreOnForm, setMoreOnList, setMoreRows, setMoreSearch, setName, setOldValues, setOldValues, setOldValues, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParentObject, setParentObjectRefField, setParentValues, setPredefinedSearchIndex, setPredefSearch, setPrint, setPrintTemplateVisibility, setQuerySpecific, setReadOnly, setRefCount, setRowId, setSave, setSearchLimit, setSearchLimitError, setSearchSpec, setSearchSpec, setSelectRow, setServiceSpecific, setSocial, setStatus, setStatus, setStatus, setStatusField, setTable, setTemplate, setTimeStamp, setTitle, setUpdateAll, setValues, setValues, setValues, setValues, setValues, setValues, setValues, setViewMode, stateUpdated, toHTML, toHTML, toJSON, toJSON, toJSON, toJSON, toJSON, toJSON, toJSON, toJSON, toJSON, toString, toString, updateState, useForm, useLimit, useTimeStamp
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...)
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
grant
- Grantname
- Object name (e.g. "DummyObject")instanceName
- Object instance name (e.g. "my_DummyObject")public ObjectInterface getContext()
public java.lang.String getPreviousRowId()
The method gives the previous row_id of the current record in a search context
public java.lang.String getFirstRowId()
The method gives the first row_id in a search context
public java.lang.String getNextRowId()
The method gives the next row_id of the current record in a search context
public java.lang.String getLastRowId()
The method gives the last row_id in a search context
public final ObjectDB load(Grant grant, java.lang.String obj)
Default object definition loading, called by load(Grant).
grant
- User rightsobj
- Object namepublic ObjectDB init(java.lang.String name, Grant grant)
Load the object definition from the repository
name
- Object namegrant
- User rightspublic void initFromTable(java.lang.String table, Grant grant)
Load the object definition from the DB table (beta)
table
- Table namegrant
- User rightspublic void preLoad()
Hook called before loading the object definition.
public void postLoad()
Hook called after loading the object definition.
public java.lang.String getSearchSpec(java.lang.String s)
Eval the search specification
public java.lang.String getFieldDefaultValue(ObjectField fld)
Eval a default value
public void populate(boolean complete)
Populate all fields with the references, parent or default values
complete
- True to try to solve/complete the missing referenced data with the known fieldspublic 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
field
- Object fieldpublic void populate(ObjectField field, boolean complete)
Populate a field with the reference, the contextual or its default value
field
- Object fieldcomplete
- True to try to solve/complete the missing referenced data with the known fieldspublic boolean populateForeignKey(java.lang.String refField, java.lang.String refId, boolean useSearchSpec, boolean reset)
refField
- Foreign key fieldrefId
- Referenced object iduseSearchSpec
- False to disable any search spec on referenced objectreset
- Reset related fields if not foundpublic java.util.Vector<java.lang.String> completeForeignKeys()
Try to complete the references (ids of foreign keys) with the field values
public java.lang.String preUpdateAll()
Hook called before bulk update.
public void postUpdateAll()
Hook called after bulk update.
public java.lang.String preDeleteAll()
Hook called before bulk delete.
public void postDeleteAll()
Hook called after bulk delete.
public java.util.Vector<java.lang.String> preValidate()
Hook called before system validation. It may be useful to force/calculate mandatory values.
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.
fromStatus
- From statustoStatus
- To statuspublic java.util.Vector<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.
fromStatus
- From statustoStatus
- To statuspublic java.util.Vector<java.lang.String> postValidate()
Hook called after system validation. It may be useful to check specific rules before update.
public final java.util.Vector<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
public java.util.Vector<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.
onlyErrors
- True to retrieve only error levelpublic final long count()
Alias to getCount
public final long getCount()
Return the records count with the current search specification and filters.
This method is not supposed to be overridden
public long getCount(int maxRows)
Return the records count with the current search specification and filters.
maxRows
- Explicit maximum nb of rows when paginated, to be set to 0 for user's min/max row setting usagepublic long getRefCount(java.lang.String refname, java.lang.String field)
Return the records count of a linked object (relation 0,n).
refname
- Linked object namefield
- Foreign key field (containing the row_id value of current object)public final java.lang.String searchRowId()
Search with the current fields a matching record in the DB
This method is not supposed to be overriden
public java.lang.String searchRowId(java.lang.String notId)
Search with the current fields a matching record in the DB
notId
- The row_id to excludepublic void preExport()
Hook called before search in export of data. It may be useful to add some specific filters.
public java.util.Vector<java.lang.String[]> postExport(java.util.Vector<java.lang.String[]> rows)
Hook called after search in export of data. It may be useful to calculate fields or to change the records.
rows
- The database resultpublic 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
public java.lang.String postImport()
Hook called after processing object import. It may be useful to execute business rules after actually processing the import
public void preObjectSearch()
Hook called before search of object reference. It may be useful to add some specific filters.
public java.util.Vector<java.lang.String[]> postObjectSearch(java.util.Vector<java.lang.String[]> rows)
Hook called after search of object reference. It may be useful to calculate fields or to change the records.
rows
- The database resultpublic java.util.Vector<java.lang.String> preValidateSearch()
Hook called before search validation with the fields filters. It may be useful to check filters.
public java.util.Vector<java.lang.String> postValidateSearch()
Hook called after search validation with the fields filters. It may be useful to check filters.
public final java.util.Vector<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 overriden
public void preSearch()
Hook called before search with the fields filters. It may be useful to add some specific filters.
public java.util.Vector<java.lang.String[]> postSearch(java.util.Vector<java.lang.String[]> rows)
Hook called after search with the fields filters. It may be useful to calculate fields or to change the records.
rows
- The database resultpublic java.lang.String getQuery(java.util.Vector<ObjectField> host)
Return the SQL select statement with current filter
host
- Valued hostspublic final java.util.Vector<java.lang.String[]> search()
Retrieve the database records with the currents search specification and the field filters (without pagination).
public final java.util.Vector<java.lang.String[]> search(boolean pagine)
Retrieve the database records with the currents search specification and the field filters.
pagine
- True to limit the search size (with min/max user properties)public java.util.Vector<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.
pagine
- True to limit the search size (with min/max user properties)maxRows
- Limit to avoid a full table loadingpublic java.util.Vector<java.lang.String[]> searchExport()
Same as a search but for the export of data
public java.util.Vector<java.lang.String[]> searchCrosstab(Crosstab c)
Same as a search but for a crosstab calculation and optimization
c
- The crosstable definitionpublic void preSelect(java.lang.String row_id, boolean copy)
Hook called before a single row selection
row_id
- The unique row_id to selectcopy
- Indicate if it's a select for a future copypublic void postSelect(java.lang.String row_id, boolean copy)
Hook called after a single row selection
row_id
- The unique selected row_idcopy
- Indicate if it's a select for a future copypublic boolean select(java.lang.String row_id, boolean copy)
Selects a single record and loads the values into the object fields (either for simple selection or for copy).
row_id
- Unique row ID of the recordcopy
- Indicate whether the select is done for a future copypublic final boolean select(java.lang.String row_id)
Selects a single record and loads the values into the object fields.
row_id
- Unique row ID of the recordpublic 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).
fields
- Valued fieldscopy
- Indicate whether the select is done for a future copypublic ObjectDB getParentObject()
getParentObject
in class ObjectCore
@Deprecated public final void init(int context, java.lang.String[] params)
Use initWebService
public void initWebService(int context, java.lang.String[] params)
Object init switch for use by webservices (and related APIs : Ajax, ...)
context
- Init contextparams
- Parameters for panel lists, reference select, associate, datamap select, graph, crosstab, print template contextspublic void initSearch()
Hook to init the Search before user dialog
public void initList(ObjectDB parent)
Hook to init the List before user dialog
public void initCreate()
Hook to init the Creation before user dialog
public void initCopy()
Hook to init the Copy before user dialog
public void initUpdate()
Hook to init the Update before update dialog
public void initUpdateAll()
Hook to init the Update before bulk update dialog
public void initDelete()
Hook to init the Delete before delete dialog
public void initExport()
Hook to init the Export before export dialog
public void initRefSelect(ObjectDB parent)
Hook to init the reference select before select dialog
public void initAssociate(ObjectDB parent)
Hook to init the association before associate dialog
public void initDataMapSelect(java.lang.String datamapName, ObjectDB parent)
Hook to init the data map select before user dialog
public void initGraph(java.lang.String graphName)
Hook to init a graph
public void initCrosstab(java.lang.String crosstabName)
Hook to init a crosstable
public void initPrintTemplate(java.lang.String printTemplateName)
Hook to init a print templates
public void initAgenda(Agenda agenda)
Hook to init an agenda
public void initPlaceMap(PlaceMap placemap)
Hook to init a place map
public java.lang.String evalNextRowId(java.lang.String table)
Hook called before the DB creation to send a specific unique id (i.e. DB sequence, String algorithm, timestamp...)
table
- Table namepublic java.lang.String preCreate()
Hook called before the DB creation
public java.lang.String postCreate()
Hook called after the DB creation
public java.lang.String create()
Insert the object field values in the DB.
Call the pre/postCreation.public java.lang.String preUpdate()
Hook called before the DB update
public java.lang.String postUpdate()
Hook called after the DB update
public java.lang.String update()
Update the field values in the DB. Call the pre/postUpdate methods.
public java.lang.String preSave()
Hook called before the DB save
public java.lang.String postSave()
Hook called after the DB save
public 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.
public java.util.Vector<java.lang.String> preSaveTimesheet(Timesheet ts)
Hook called before Timesheet save
public java.util.Vector<java.lang.String> postSaveTimesheet(Timesheet ts)
Hook called after Timesheet save
public boolean canReference(java.lang.String target, java.lang.String foreignKey)
Hook called to check if a referenced object can be displayed
target
- Linked object name or view nameforeignKey
- Field name of foreign key (optional in case of object view)public java.lang.String preDelete()
Hook called before the DB deletion
public java.lang.String postDelete()
Hook called after the DB deletion.
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.
row
- Current recordpublic final boolean checkCreateVisibilities()
Check create visibilities
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.
public final boolean checkUpdateVisibilities(java.lang.String[] row)
Check update visibilities
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.
row
- Current recordpublic final boolean checkDeleteVisibilities(java.lang.String[] row)
Check delete visibilities
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.
row
- Current recordpublic 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.
row
- Current recordpublic boolean isMergeMaster()
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.
row
- Current recordaction
- Action namepublic 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.
crosstab
- Crosstab namepublic 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.
graph
- Chart namepublic 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.
printTemplate
- Print template name@Deprecated public final java.util.Vector<java.lang.String>[] checkDelete()
Use delete() method only
@Deprecated public final java.lang.String delete(java.util.Vector<java.lang.String> request)
Use delete() method only
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.
public final java.lang.String del()
Delete the current row and dependencies (same as delete but for scripting usage)
public java.util.Vector<java.lang.String> merge(java.util.List<java.lang.String> ids, java.util.HashMap<java.lang.String,java.util.List<java.lang.Integer>> map)
Merge all records and links
ids
- Row IDs to merge in the current objectmap
- Id indexes per field (keep current value when absent) and per link (removed if absent, moved if present)public java.lang.String getFileName(java.lang.String id)
Get the filename of a document stored in m_document
id
- Document row_idpublic java.lang.String getFilePath(java.lang.String id)
Get the relative path (from DOCDIR) of a document stored in m_document
id
- Document row_idpublic java.lang.String preAlert(Alert a)
Hook before before sending the alert
public java.lang.String postAlert(Alert a)
Hook before after sending the alert
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
alert
- Alert namegroup
- User groupemail
- Emailpublic boolean spamGroup(java.lang.String alert, java.lang.String name)
Hook called to check if the group is a recipient of the alert
alert
- Alert namename
- Group namepublic char getEmailRecipientType(java.lang.String alert, java.lang.String email, char type)
Hook to override the recipient type (TO/CC/BCC)
alert
- Alert nameemail
- Emailtype
- Default designed typepublic char getGroupEmailRecipientType(java.lang.String alert, java.lang.String group, char type)
Hook to override the recipient type (TO/CC/BCC) of a group
alert
- Alert namegroup
- Group nametype
- Default designed typepublic java.util.Date getDeadlineDate(java.lang.String row_id, 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)
row_id
- row_id (to select the record if needed)state
- Current stateupdate_dt
- Last update date in service format yyyy-MM-dd HH:mm:sstimeout
- Default designed delay in secondspublic Alert getAlert(java.lang.String name, int type)
Get the Alert definition
name
- Alert nametype
- Warn or Infopublic final java.lang.String invokeAction(java.lang.String actionName) throws java.lang.Exception
Action call
actionName
- Action namejava.lang.Exception
public java.lang.String invokeAction(Action action) throws java.lang.Exception
Action call
action
- Actionjava.lang.Exception
public final java.lang.Object invokePrint(java.lang.String prtName) throws java.lang.Exception
Print method call
prtName
- Print template namejava.lang.Exception
public java.lang.Object invokePrint(PrintTemplate prt) throws java.lang.Exception
Print method call
prt
- Print templatejava.lang.Exception
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
methodName
- Method nameparamTypes
- Table of class typesparamValues
- Table of valuesjava.lang.Exception
public void invokeCallback(java.lang.String callbackName) throws java.lang.Exception
Simple callback method call
callbackName
- Callback namejava.lang.Exception
public java.lang.String getAgendaLabel(Agenda a, ObjectField f)
Hook to customize agenda displayed field
a
- Agenda definitionf
- Agenda field to displaypublic java.lang.String getAgendaValue(Agenda a, ObjectField f, java.lang.String val)
Hook to customize agenda displayed value
a
- Agenda definitionf
- Agenda field to displayval
- Value to displaypublic java.lang.String getAgendaDay(Agenda a, java.util.Date d)
Hook to override agenda displayed date, usefull to add specific actions at the day header
a
- Agenda definitiond
- Any datepublic java.lang.String getAgendaWeek(Agenda a, java.util.Vector<java.lang.String> days)
Hook to override agenda displayed week, usefull to add specific actions at the agenda header
a
- Agenda definitiondays
- Days of the week in service format yyyy-MM-ddpublic java.lang.String getAgendaSelector(Agenda a, java.lang.String selector)
Hook to override agenda displayed selector, usefull to mask or list specific users/groups at the agenda header
a
- Agenda definitionselector
- Generated selector based on the agenda linkspublic void evalCalculatedFields(int context)
Persistent field evaluations
public void evalObjectCalculatedFields()
Other object field evaluations
public void evalCalculatedFields(int context, java.lang.String[] row)
Non persistent field evaluations
row
- a record (null for current item)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.
row
- Any record, if row is null, the selected fields are usedpublic 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.
row
- Any record, if row is null, the selected fields are usedpublic boolean isUndoable()
Hook to allow undo/redo on the object
public boolean preUndo()
Hook called before undo
public void postUndo()
Hook called after undo
public boolean preRedo()
Hook called before redo
public void postRedo()
Hook called after redo
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.
@Deprecated public boolean canUpdateAllStatus(ObjectField f)
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
f
- Object fieldpublic 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
prefix
- Object prefix for child (e.g. "panel_")parent
- Parent objectchildObject
- Child object namechildField
- Foreign key namevalues
- Values (if null current parent values are used)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
parent
- Parent objectrefField
- Foreign key namevalues
- Values (if null current parent values are used)public void prepareTemplate()
Build the template hierarchy
public ObjectTemplate.Node getTemplateRoot()
Get the root of the template hierarchy
public ObjectNode makeTree()
Build the tree view
public void deleteTree(ObjectNode tree, java.lang.String id)
public void buildTreeList(ObjectNode node, java.util.Vector<ObjectNode> v)
public java.util.ArrayList<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
input
- Field to searchquery
- User query/filtercontext
- Field context = form, search or listpublic Link addLink(ObjectDB object, ObjectField fk, java.lang.String display, java.lang.String help, java.lang.String card, int order, boolean copy, boolean associate, boolean visible, boolean inline, char cascad)
object
- Child object with a reference to this objectfk
- Foreign key field in the child objectdisplay
- View displayhelp
- Optional helpcard
- Cardinality 0,norder
- View orderingcopy
- 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_*public Link addLinkMetaObject(ObjectDB object, int order)
object
- Child object with a meta-objet field (reference to this object)order
- View orderingpublic java.lang.String displayForm(java.lang.Object params, java.lang.Object nav, java.lang.Object page) throws java.lang.Exception
java.lang.Exception
public java.lang.String displayList(java.lang.Object list, java.lang.Object params, java.lang.Object nav, ObjectDB parent) throws java.lang.Exception
java.lang.Exception
public java.lang.String displaySearch(java.lang.Object search, java.lang.Object params, java.lang.Object nav) throws java.lang.Exception
java.lang.Exception
public java.lang.String displayRefSelect(java.lang.Object selector, java.lang.Object params, java.lang.Object nav) throws java.lang.Exception
java.lang.Exception
public java.lang.String displayDataMap(java.lang.Object selector, java.lang.Object params, java.lang.Object nav) throws java.lang.Exception
java.lang.Exception
Copyright (c)2006-2014 Simplicite Software. All Rights Reserved.