Package org.compiere.model
Class MTable
java.lang.Object
org.compiere.model.PO
org.compiere.model.X_AD_Table
org.compiere.model.MTable
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparator<Object>
,I_AD_Table
,I_Persistent
,Evaluatee
,ImmutablePOSupport
Persistent Table Model
Change log:
- 2007-02-01 - teo_sarca - [ 1648850 ] MTable.getClass works incorrect for table "Fact_Acct"
- 2007-08-30 - vpj-cd - [ 1784588 ] Use ModelPackage of EntityType to Find Model Class
- Version:
- $Id: MTable.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
- Author:
- Jorg Janke, Teo Sarca, teo.sarca@gmail.com
- BF [ 3017117 ] MTable.getClass returns bad class https://sourceforge.net/p/adempiere/bugs/2433/
- See Also:
-
Field Summary
Fields inherited from class org.compiere.model.X_AD_Table
ACCESSLEVEL_AD_Reference_ID, ACCESSLEVEL_All, ACCESSLEVEL_ClientOnly, ACCESSLEVEL_ClientPlusOrganization, ACCESSLEVEL_Organization, ACCESSLEVEL_SystemOnly, ACCESSLEVEL_SystemPlusClient, ENTITYTYPE_AD_Reference_ID, REPLICATIONTYPE_AD_Reference_ID, REPLICATIONTYPE_Broadcast, REPLICATIONTYPE_Local, REPLICATIONTYPE_Merge, REPLICATIONTYPE_Reference
Fields inherited from class org.compiere.model.PO
ACCESSLEVEL_ALL, ACCESSLEVEL_CLIENT, ACCESSLEVEL_CLIENTORG, ACCESSLEVEL_ORG, ACCESSLEVEL_SYSTEM, ACCESSLEVEL_SYSTEMCLIENT, ENTITYTYPE_Dictionary, ENTITYTYPE_UserMaintained, I_ZERO, LOCAL_TRX_PREFIX, log, p_ctx, p_info, UUID_NEW_RECORD, XML_ATTRIBUTE_AD_Table_ID, XML_ATTRIBUTE_Record_ID
Fields inherited from interface org.compiere.model.I_AD_Table
accessLevel, COLUMNNAME_AccessLevel, COLUMNNAME_AD_Client_ID, COLUMNNAME_AD_Org_ID, COLUMNNAME_AD_Table_ID, COLUMNNAME_AD_Table_UU, COLUMNNAME_AD_Val_Rule_ID, COLUMNNAME_AD_Window_ID, COLUMNNAME_CopyColumnsFromTable, COLUMNNAME_CopyComponentsFromView, COLUMNNAME_Created, COLUMNNAME_CreatedBy, COLUMNNAME_CreatePartition, COLUMNNAME_CreateWindowFromTable, COLUMNNAME_DatabaseViewDrop, COLUMNNAME_Description, COLUMNNAME_EntityType, COLUMNNAME_Help, COLUMNNAME_ImportTable, COLUMNNAME_IsActive, COLUMNNAME_IsCentrallyMaintained, COLUMNNAME_IsChangeLog, COLUMNNAME_IsDeleteable, COLUMNNAME_IsHighVolume, COLUMNNAME_IsPartition, COLUMNNAME_IsSecurityEnabled, COLUMNNAME_IsShowInDrillOptions, COLUMNNAME_IsView, COLUMNNAME_LoadSeq, COLUMNNAME_Name, COLUMNNAME_PO_Window_ID, COLUMNNAME_Processing, COLUMNNAME_ReplicationType, COLUMNNAME_TableName, COLUMNNAME_Updated, COLUMNNAME_UpdatedBy, Model, Table_ID, Table_Name
-
Constructor Summary
ConstructorDescriptionMTable
(Properties ctx, int AD_Table_ID, String trxName) Standard ConstructorMTable
(Properties ctx, String AD_Table_UU, String trxName) UUID based ConstructorMTable
(Properties ctx, ResultSet rs, String trxName) Load ConstructorMTable
(Properties ctx, MTable copy) Copy constructorMTable
(Properties ctx, MTable copy, String trxName) Copy constructorCopy constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
afterSave
(boolean newRecord, boolean success) After Saveprotected boolean
beforeSave
(boolean newRecord) Before Saveboolean
columnExistsInDB
(String ColumnName) Is column exists and is not virtual ?boolean
columnExistsInDictionary
(String ColumnName) Column exists?createQuery
(String whereClause, String trxName) Create new query for whereClausecreateTablePartition
(String name, String expression, String trxName, MColumn column) Create and save new X_AD_TablePartition record.createTablePartition
(String name, String expression, String trxName, MColumn column, X_AD_TablePartition parentPartition) Create and save new X_AD_TablePartition record.static MTable
get
(int AD_Table_ID) Get MTable from Cache (immutable)static MTable
get
(Properties ctx, int AD_Table_ID) Get MTable from Cache (immutable)static MTable
get
(Properties ctx, int AD_Table_ID, String trxName) Get MTable from Cache (immutable)static MTable
get
(Properties ctx, String tableName) Get MTable from Cachestatic MTable
get
(Properties ctx, String tableName, String trxName) Get MTable from Cachestatic Class<?>
Get Java Model Class for TableGet Column via column nameint
getColumnIndex
(int AD_Column_ID) Get Column Indexint
getColumnIndex
(String ColumnName) Get Column Index via column nameMColumn[]
getColumns
(boolean requery) Get Columnsstatic MTable
getCopy
(Properties ctx, int AD_Table_ID, String trxName) Get updateable copy of MTable from cacheString[]
Get Identifier Columns of Table (IsIdentifier=Y)String[]
Get Key Columns of TablegetPartitionKeyColumns
(boolean requery) static String
getPartitionName
(Properties ctx, String tableName, boolean primaryLevelOnly, String trxName) Get Partition Name of the table of the given levelGet PO Instance for this tableGet PO instanceGet PO InstanceGet PO Instance from result setGet PO InstanceGet Create table DDLstatic int
getTable_ID
(String tableName) Get AD_Table_ID via table namestatic int
getTable_ID
(String tableName, String trxName) Get AD_Table_ID via table namestatic String
getTableName
(Properties ctx, int AD_Table_ID) Get Table NamegetTablePartitionNames
(String trxName) getTablePartitions
(boolean requery, String trxName) Get the UUID of Zero ID recordstatic String
getUUIDIndexName
(String tableName) Get the Unique UU Index namegetViewComponent
(boolean reload) Get active view componentsint
Get first AD_Window that's using this table from AD_Menu.boolean
If the table has a custom tree definedboolean
boolean
boolean
Table is with single primary keyboolean
static boolean
isZeroIDTable
(String tablename) Verify if the table has record with ID=0mark PO as immutabletoString()
String RepresentationMethods inherited from class org.compiere.model.X_AD_Table
get_AccessLevel, getAccessLevel, getAD_Table_ID, getAD_Table_UU, getAD_Val_Rule, getAD_Val_Rule_ID, getAD_Window, getAD_Window_ID, getCopyColumnsFromTable, getCopyComponentsFromView, getCreatePartition, getCreateWindowFromTable, getDatabaseViewDrop, getDescription, getEntityType, getHelp, getImportTable, getKeyNamePair, getLoadSeq, getName, getPO_Window, getPO_Window_ID, getReplicationType, getTableName, initPO, isCentrallyMaintained, isChangeLog, isDeleteable, isHighVolume, isPartition, isProcessing, isSecurityEnabled, isShowInDrillOptions, isView, setAccessLevel, setAD_Table_ID, setAD_Table_UU, setAD_Val_Rule_ID, setAD_Window_ID, setCopyColumnsFromTable, setCopyComponentsFromView, setCreatePartition, setCreateWindowFromTable, setDatabaseViewDrop, setDescription, setEntityType, setHelp, setImportTable, setIsCentrallyMaintained, setIsChangeLog, setIsDeleteable, setIsHighVolume, setIsPartition, setIsSecurityEnabled, setIsShowInDrillOptions, setIsView, setLoadSeq, setName, setPO_Window_ID, setProcessing, setReplicationType, setTableName
Methods inherited from class org.compiere.model.PO
afterDelete, beforeDelete, buildInsertSQL, checkImmutable, clearCrossTenantSafe, clone, columnExists, columnExists, compare, copyPO, copyValues, copyValues, createAttachment, delete, delete, delete_Accounting, delete_Tree, deleteEx, deleteEx, dump, dump, equals, get_Attribute, get_Attributes, get_ColumnCount, get_ColumnDescription, get_ColumnDisplayType, get_ColumnIndex, get_ColumnLabel, get_ColumnLookup, get_ColumnName, get_DisplayValue, get_HashMap, get_ID, get_IDOld, get_KeyColumns, get_Logger, get_OptimisticLockingColumns, get_Table_ID, get_TableName, get_Translation, get_Translation, get_Translation, get_Translation, get_Translation, get_TrxName, get_UUID, get_Value, get_Value, get_ValueAsBoolean, get_ValueAsInt, get_ValueAsInt, get_ValueAsString, get_ValueAsString, get_ValueDifference, get_ValueDifference, get_ValueE, get_ValueOfColumn, get_ValueOld, get_ValueOld, get_ValueOldAsInt, get_WhereClause, get_WhereClause, get_xmlDocument, get_xmlString, getAD_Client_ID, getAD_Org_ID, getAllIDs, getAttachment, getAttachment, getAttachmentData, getCreated, getCreatedBy, getCtx, getDoc, getFindParameter, getPdfAttachment, getUpdated, getUpdatedBy, getUUIDColumnName, getUUIDColumnName, hashCode, insert_Accounting, insert_Tree, insert_Tree, is_Changed, is_Immutable, is_new, is_UseOptimisticLocking, is_ValueChanged, is_ValueChanged, isActive, isAttachment, isColumnMandatory, isColumnUpdateable, isMandatoryOK, isPdfAttachment, isReplication, load, load, load, load, loadByUU, loadComplete, loadDefaults, loadPO, loadSpecial, lock, makeImmutable, postDelete, retrieveIdOfParentValue, retrieveIdOfParentValue, save, save, saveCrossTenantSafe, saveCrossTenantSafeEx, saveCrossTenantSafeEx, saveEx, saveEx, saveNew_afterSetID, saveNew_getID, saveNewSpecial, saveReplica, saveUpdate, set_Attribute, set_ColumnUpdateable, set_CustomColumn, set_CustomColumnReturningBoolean, set_OptimisticLockingColumns, set_TrxName, set_TrxName, set_UseOptimisticLocking, set_Value, set_Value, set_Value, set_Value, set_ValueE, set_ValueNoCheck, set_ValueNoCheckE, set_ValueOfColumn, set_ValueOfColumn, set_ValueOfColumnReturningBoolean, set_ValueOfColumnReturningBoolean, setAD_Client_ID, setAD_Org_ID, setClientOrg, setClientOrg, setCrossTenantSafe, setDoc, setDocWorkflowMgr, setIsActive, setProcessedOn, setReplication, setStandardDefaults, setUpdateable, setUpdatedBy, toInsertSQL, unlock, update_Tree, validForeignKeys
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Methods inherited from interface org.compiere.model.I_AD_Table
getAD_Client_ID, getAD_Org_ID, getCreated, getCreatedBy, getUpdated, getUpdatedBy, isActive, setAD_Org_ID, setIsActive
Methods inherited from interface org.compiere.model.I_Persistent
save
-
Field Details
-
MAX_OFFICIAL_ID
public static final int MAX_OFFICIAL_ID- See Also:
-
-
Constructor Details
-
MTable
UUID based Constructor- Parameters:
ctx
- ContextAD_Table_UU
- UUID keytrxName
- Transaction
-
MTable
Standard Constructor- Parameters:
ctx
- contextAD_Table_ID
- idtrxName
- transaction
-
MTable
Load Constructor- Parameters:
ctx
- contextrs
- result settrxName
- transaction
-
MTable
Copy constructor- Parameters:
copy
-
-
MTable
Copy constructor- Parameters:
ctx
-copy
-
-
MTable
Copy constructor- Parameters:
ctx
-copy
-trxName
-
-
-
Method Details
-
get
Get MTable from Cache (immutable)- Parameters:
AD_Table_ID
- id- Returns:
- MTable
-
get
Get MTable from Cache (immutable)- Parameters:
ctx
- contextAD_Table_ID
- id- Returns:
- MTable
-
get
Get MTable from Cache (immutable)- Parameters:
ctx
- contextAD_Table_ID
- idtrxName
- transaction- Returns:
- MTable
-
getCopy
Get updateable copy of MTable from cache- Parameters:
ctx
-AD_Table_ID
-trxName
-- Returns:
- MTable
-
get
Get MTable from Cache- Parameters:
ctx
- contexttableName
- case insensitive table name- Returns:
- MTable
-
get
Get MTable from Cache- Parameters:
ctx
- contexttableName
- case insensitive table nametrxName
-- Returns:
- MTable
-
getTableName
Get Table Name- Parameters:
ctx
- contextAD_Table_ID
- table- Returns:
- table name
-
getClass
Get Java Model Class for Table- Parameters:
tableName
- table name- Returns:
- Java model class or null
-
getColumns
Get Columns- Parameters:
requery
- true to re-query from DB- Returns:
- array of column
-
getColumn
Get Column via column name- Parameters:
columnName
- (case insensitive)- Returns:
- MColumn if found, null otherwise
-
getColumnIndex
Get Column Index via column name- Parameters:
ColumnName
- column name (case insensitive)- Returns:
- index of column with ColumnName or -1 if not found
-
columnExistsInDB
Is column exists and is not virtual ?- Parameters:
ColumnName
- column name (case insensitive)- Returns:
- true if column exists and is not virtual
-
columnExistsInDictionary
Column exists?- Parameters:
ColumnName
- column name (case insensitive)- Returns:
- true if column exists in dictionary
-
getColumnIndex
public int getColumnIndex(int AD_Column_ID) Get Column Index- Parameters:
AD_Column_ID
- column id- Returns:
- index of column with AD_Column_ID or -1 if not found
-
isSingleKey
public boolean isSingleKey()Table is with single primary key- Returns:
- true if table has single primary key column
-
getKeyColumns
Get Key Columns of Table- Returns:
- array of key column name
-
isIDKeyTable
public boolean isIDKeyTable()- Returns:
- true if table has single key column and the key column name is the same as the table name plus _ID.
-
isUUIDKeyTable
public boolean isUUIDKeyTable()- Returns:
- true if table has single key column and the key column name ends with _UU.
-
hasUUIDKey
public boolean hasUUIDKey()- Returns:
- true if table has a UUID column (column name ends with _UU)
-
getIdentifierColumns
Get Identifier Columns of Table (IsIdentifier=Y)- Returns:
- array of identifier column name
-
getPO
Get PO Instance for this table- Parameters:
Record_ID
- record id. 0 to create new record instance, > 0 to load existing record instance.trxName
-- Returns:
- PO for Record_ID or null
-
getPO
Get PO Instance from result set- Parameters:
rs
- result settrxName
- transaction- Returns:
- PO instance
-
getPOByUU
Get PO Instance- Parameters:
uuID
- UUID. Throw IllegalArgumentException if this is null or empty string.trxName
- transaction- Returns:
- PO for uuID
-
getPO
Get PO Instance- Parameters:
whereClause
- SQL where clausetrxName
- transaction- Returns:
- PO for whereClause or null
-
getPO
Get PO instance- Parameters:
whereClause
- SQL where clauseparams
- parameters for whereClausetrxName
-- Returns:
- PO instance or null
-
beforeSave
protected boolean beforeSave(boolean newRecord) Before Save- Overrides:
beforeSave
in classPO
- Parameters:
newRecord
- new- Returns:
- true
-
afterSave
protected boolean afterSave(boolean newRecord, boolean success) After Save -
getSQLCreate
Get Create table DDL- Returns:
- create table DDL
-
getTable_ID
Get AD_Table_ID via table name- Parameters:
tableName
-- Returns:
- AD_Table_ID
-
getTable_ID
Get AD_Table_ID via table name- Parameters:
tableName
- StringtrxName
-- Returns:
- AD_Table_ID
-
createQuery
Create new query for whereClause- Parameters:
whereClause
- SQL whereClausetrxName
-- Returns:
- new Query instance
-
getViewComponent
Get active view components- Parameters:
reload
- true to reload from DB- Returns:
- array of view component
-
toString
String Representation- Overrides:
toString
in classX_AD_Table
- Returns:
- info
-
isZeroIDTable
Verify if the table has record with ID=0- Returns:
- true if table has record with ID=0
-
markImmutable
Description copied from interface:ImmutablePOSupport
mark PO as immutable- Specified by:
markImmutable
in interfaceImmutablePOSupport
- Returns:
- PO
-
getWindowIDFromMenu
public int getWindowIDFromMenu()Get first AD_Window that's using this table from AD_Menu.- Returns:
- AD_Window_ID or -1 if not found
-
getUUIDFromZeroID
Get the UUID of Zero ID record- Returns:
- UUID or null
-
getPartitionKeyColumns
- Parameters:
requery
- true to reload from DB- Returns:
- partition key columns
-
getPartitionKeyColumnNames
- Returns:
- partition key column names
-
createTablePartition
public X_AD_TablePartition createTablePartition(String name, String expression, String trxName, MColumn column) Create and save new X_AD_TablePartition record.- Parameters:
name
-expression
-trxName
-column
-- Returns:
- new X_AD_TablePartition record
-
createTablePartition
public X_AD_TablePartition createTablePartition(String name, String expression, String trxName, MColumn column, X_AD_TablePartition parentPartition) Create and save new X_AD_TablePartition record.- Parameters:
name
-expression
-trxName
-column
-parentPartition
-- Returns:
- new X_AD_TablePartition record
-
getTablePartitions
- Parameters:
requery
- true to reload from DBtrxName
-- Returns:
- X_AD_TablePartition records of this table
-
getTablePartitionNames
- Parameters:
trxName
-- Returns:
- list of table partition name
-
getUUIDIndexName
Get the Unique UU Index name- Returns:
- indexName
-
hasCustomTree
public boolean hasCustomTree()If the table has a custom tree defined- Returns:
-
getPartitionName
public static String getPartitionName(Properties ctx, String tableName, boolean primaryLevelOnly, String trxName) Get Partition Name of the table of the given level- Parameters:
tableName
-primaryLevelOnly
- - if true, ignore the sub-partition, if exists- Returns:
- table partition name, or empty
-