public abstract class TableEntity extends UnicastRemoteObject implements AdvancedEntity, SecureEntity, PrivilegedSecurityEntity, FileManagementEntity, EntityDataChangeNotifier, TransactionalEntity, AdvancedQueryEntity, IdentifiedEntity, UtilEntity, MetadataEntity
Entity that represents a
database table.
This class provides basic functionalities and configuration parameters for automating database tables mapping.
readProperties(),
Entity,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected class |
TableEntity.AttachmentReceiving
Object of this class are used internally for storing information for
current transfers (attachments).
|
protected static class |
TableEntity.FileInfo
Objects of this class contain information about columns of this entity
that will be used for storing Files (a column for the filename and a
column for the file contents).
|
protected static class |
TableEntity.FileInfoList
Object of this class store a list of FileInfo objects.
|
protected class |
TableEntity.Receiving
Object of this class are used internally for storing information for
current transfers (attachments).
|
| Modifier and Type | Field and Description |
|---|---|
protected Properties |
alias
Alias properties for this entity, if defined.
|
protected static AliasPropertiesParser |
aliasPropertiesParser |
protected Hashtable |
aliasReverse
Reverse Alias properties for this entity, if defined.
|
static char |
ASTERISK
The '*' character.
|
static String |
ATTACHMENT_FILE_DESCRIPTION_COLUMN
AttachmentFileDescriptionColumn property.
|
static String |
ATTACHMENT_FILE_NAME_COLUMN
AttachmentFileNameColumn property.
|
static String |
ATTACHMENT_FILE_NAME_KEYS
AttachmentFileNameKeys property.
|
static String |
ATTACHMENT_FILE_ORIGINAL_NAME_COLUMN
AttachmentFileOriginalNameColumn property.
|
static String |
ATTACHMENT_FILE_ORIGINAL_PATH_COLUMN
AttachmentFileOriginalPathColumn property.
|
static String |
ATTACHMENT_FILE_PATH
AttachmentFilePath property.
|
static String |
ATTACHMENT_FILE_SIZE_COLUMN
AttachmentFileSizeColumn property.
|
static String |
ATTACHMENT_SEPARATOR
Character used for joining the keys while generating names for
attachments in this entity.
|
static String |
ATTACHMENT_TABLE
AttachmentTable property.
|
protected String |
attachmentFileNameColumn
Column in the database table for storing the attachment filename.
|
protected Vector |
attachmentFileNameKeys
Defines which column values are used when generating filenames for
attachments, by calling
getAttachmentFileNameForKeys()
method. |
protected String |
attachmentFilePath
Path in the file system in which the attached files for this entity will
be stored.
|
protected String |
attachmentFileSizeColumn
Defines which column in the table will store the file size.
|
protected String |
attachTable
Table name, used for query StandardAttachmentEntity to classify
attachments by 'table name'+'table keys'.
|
IAuditorLogger |
auditorLog |
static String |
AUTOCONFIGURATION
Autoconfiguration property.
|
static String |
AUTONUMERICAL
Autonumerical property.
|
protected String |
autonumericalColumn
Column in which numbers provided by Autonumerical object will be inserted
in insert operations.
|
protected static Calendar |
calendar
Calendar object used internally.
|
static boolean |
checkOperationResult |
protected Vector |
columnNames
List of columns defined by 'Columns' parameter.
|
static String |
COLUMNS
Columns property.
|
protected int |
connectionRequestTime
Deprecated.
|
static String |
COUNT_COLUMNS
Count Columns property.
|
protected Vector |
countColumns
List of columns to perform count operations E.g.
|
protected Vector |
dataChangeListeners
Contains registered DataChangeListeners.
|
protected DBLocalErrorMessages |
dBLocalErrorMessage
Used for customizing this entity's error messages.
|
static String |
defaultEntityScriptManagerClassName |
static String |
DELETE_ACTION
Key string used for checking action permissions for delete operations.
|
static String |
DELETE_KEYS
DeleteKeys property.
|
protected Vector |
deleteKeys
List of columns required as Keys-Values to perform delete operations.
|
protected Vector |
descendantColumnsOrder
Columns used for specifying 'ORDER BY' SQL clause.
|
protected String |
descriptionAttachmentFileColumn
Column in the database table for storing the attachment user description.
|
static boolean |
enableScripting |
protected static EntitiesPropertiesParser |
entitiesPropertiesParser |
protected Vector |
entitiesTableAttribute
List of entity names for which the TableAttribute information (keys,
attributes, ...) will be used when this entity queries another entities.
|
protected String |
entityName
This entity name.
|
protected IEntityScriptManager |
entityScripting |
static String |
FETCH_SIZE
FetchSize property.
|
protected int |
fetchSize
Defines the JDBC statement fetch size.
|
static String |
FILE_COLUMNS
FileColumns property.
|
protected TableEntity.FileInfoList |
fileInfoList
List of FileInfo objects as defined by the 'file_columns' parameter.
|
static String |
FORCE_DISTINCT
ForceDistinct property.
|
protected boolean |
forceDistinct
If true, a DISTINCT keyword will be added to all queries performed by
this entity.
|
static String |
GENERATED_KEY
GeneratedKey property
|
protected List<String> |
generatedKeyList
List of columns autogenerated by database
|
Hashtable |
hOtherLocaleTablesColumns
Hashtable of locale tables attributes
|
LinkedHashMap |
hOtherLocaleTablesKey
Hashtable of locale tables key
|
static String |
INSERT_ACTION
Key string used for checking action permissions for insert operations.
|
static String |
INSERT_AUTOMATICLY_ATTACHMENT
InsertAutomaticlyAttachment property.
|
static String |
INSERT_COLUMNS
InsertColumns property.
|
static String |
INSERT_KEYS
InsertKeys property.
|
protected boolean |
insertAttachmentAutomatically
Defines if attachment records are inserted automatically.
|
protected Vector |
insertColumn
List of columns valid insert operations.
|
protected Vector |
insertKeys
List of columns required (not null) to perform insert operations.
|
static char |
INTERROG
The '?'
|
protected Vector |
keys
List of columns that define the primary key for this entity.
|
static String |
KEYS
Keys property.
|
static String |
LIMIT_QUERY_OTHERS_ENTITIES
LimitQueryOtherEntities property.
|
protected int |
limitQueryOthersEntities
Maximum number of results of queries in this entity, for which related
entities will be queried.
|
static String |
LOCALE_COLUMNS
Constant for locale columns
|
static String |
LOCALE_TABLE
Constant for locale table.
|
String |
localeTable
String of locale table
|
protected EntityReferenceLocator |
locator
The EntityReferenceLocator for this entity.
|
static String |
LOG_KEYS
LogKeys property.
|
protected boolean |
logDelete
Defines if delete operations will be logged using the default LogWriter,
if defined, or log writers specified by 'log_keys'.
|
protected boolean |
logInsert
Defines if insert operations will be logged using the default LogWriter,
if defined, or log writers specified by 'log_keys'.
|
protected Vector |
logkeys
String keys for logging in this entity.
|
protected boolean |
logQuery
Defines if query operations will be logged using the default LogWriter,
if defined, or log writers specified by 'log_keys'.
|
protected boolean |
logUpdate
Defines if update operations will be logged using the default LogWriter,
if defined, or log writers specified by 'log_keys'.
|
static String |
M_ERROR_OPERATION
Operation error messsage key.
|
static String |
M_IT_HAS_NOT_CHANGED_ANY_RECORD
No records changed message key.
|
static String |
M_LICENSE_PERMISSION_ERROR
License permission error mesage key.
|
static String |
M_TEMPORALY_RESTRICTED_BY_PERMISSION_ACTION
Operation restricted by time constraints message key.
|
static String |
M_YOU_DO_NOT_HAVE_PERMISSION_TO_EXECUTE_ACTION
User has not rights to perfom action message key.
|
protected DatabaseConnectionManager |
manager
The DatabaseConnectionManager object, which provides DatabaseConnections
to this entity.
|
protected int |
maxConnectionWaitTime
Deprecated.
|
protected boolean |
oneToOneMode
This mode is activated when the Entity models a 1-1 relation (One to
One).
|
protected Vector |
orderColumns
Columns used for specifying 'ORDER BY' SQL clause.
|
protected String |
originalAttachmentFileNameColumn
Column in the database table for storing the attachment original
filename.
|
protected String |
originalAttachmentFilePathColumn
Column in the database table for storing the attachment original file
path.
|
static String |
OTHER_ENTITIES
OtherEntities property.
|
static String |
OTHER_LOCALE_TABLES
Constant for locale tables
|
static String |
OTHER_LOCALE_TABLES_COLUMNS
Constant for locale tables AV
|
static String |
OTHER_LOCALE_TABLES_KEY
Constant for locale tables key
|
protected Vector |
othersEntities
Entities (by name) that will be queried for data related with records of
this entity, when specified in attribute list.
|
static char |
PERCENT
The '%' character.
|
static String |
PRINCIPAL_COLUMNS
principal_columns property.
|
static String |
PRINCIPAL_KEYS
principal_keys property.
|
static String |
PRINCIPAL_TABLE
principal_table property.
|
protected Vector |
principalColumnNames
Column list for principal table when one2one mode is enabled.
|
protected Vector |
principalKeyName
Columns that make the primary key for this entity's principal table.
|
protected String |
principalTable
principal table when one2one mode is enabled.
|
protected int |
privilegedId
Privileged Id used for performing operations without checking
permissions.
|
protected Properties |
properties
Object for storing the properties of this entity.
|
protected static String |
propertiesPath
Default path used for looking properties file for this entity.
|
static String |
QUERY_ACTION
Key string used for checking action permissions for query operations.
|
static String |
QUERY_TABLE
QueryTable property.
|
protected String |
queryTable
The database table/view that this entity queries for data.
|
protected Hashtable |
receivedAttachmentFile
Used internally for storing temporal AttachmentReceiving objects for
current transfers.
|
protected Hashtable |
receivedTempFiles
Used internally.
|
static boolean |
RECORD_OPERATIONS
Specifies if standard operations are recorded by calling
OperationRecorder.addOperation().
|
protected static Hashtable |
registeredDispatcher |
static String |
REPORT_ADVANCED_QUERY_COLUMNS
ReportAdvancedQueryColumns property.
|
static String |
REPORT_ADVANCED_QUERY_TYPES
report_advanced_query_types property.
|
protected Vector |
reportAvancedQueryColumns
List of columns for making advanced queries.
|
protected Vector |
reportAvancedQueryTypes
List of column types corresponding to columns defined in
reportAvancedQueryColumns field. |
static String |
SECONDARY_COLUMNS
secondary_columns property.
|
static String |
SECONDARY_KEYS
secondary_keys property.
|
static String |
SECONDARY_TABLE
secondary_table property.
|
protected Vector |
secondaryColumnsNames
Column list for secondary table when one2one mode is enabled.
|
protected Vector |
secondaryKeyName
Columns that make the primary key for this entity's secondary table.
|
protected String |
secondaryTable
secondary table when one2one mode is enabled.
|
protected Hashtable |
sendAttachmentFile
Used internally for storing temporal AttachmentReceiving objects for
current transfers.
|
static String |
SORT
Sort property.
|
static String |
SORT_DESC
SortDesc property.
|
protected String |
table
The database table this entity performs operations with.
|
static String |
TABLE
Table property.
|
static String |
TABLE_ATTRIBUTE_ENTITIES
Deprecated.
|
protected Hashtable |
tempFiles
Used internally.
|
static boolean |
TRUNCATE_DATE_DEFAULT_VALUE
Default value for truncate_date parameter.
|
static String |
TRUNCATE_DATES
TruncateDates property.
|
protected boolean |
truncateDates
If true, Date objects will be set to 00:00:00 when calling to setObject
method of this class.
|
static char |
UNDERSCORE
The '_' character.
|
static String |
UPDATE_ACTION
Key string used for checking action permissions for update operations.
|
static String |
UPDATE_COLUMNS
UpdateColumns property.
|
static String |
UPDATE_KEYS
UpdateKeys property.
|
protected Vector |
updateColumn
List of columns in which update operations are allowed.
|
protected Vector |
updateKeys
List of columns required as Keys-Values to perform update operations.
|
static boolean |
USE_SETSTRING_LONG_STRINGS
Sets which method will be used in JDBC prepared statements for setting
parameters of type string and length > 255.
|
static boolean |
useAlwaysTableAttributeEntities |
Vector<String> |
vLocaleColumns
Vector of locale columns
|
Vector<String> |
vOtherLocaleTables
Vector of locale tables
|
static String |
WILDCARD_COLUMNS
WildcardColumns property.
|
protected Vector |
wildcardColumns
List of columns in which special metacharacters ('%' and '?')
|
ref| Constructor and Description |
|---|
TableEntity(EntityReferenceLocator locator,
DatabaseConnectionManager dbConnectionManager,
int port)
Constructor for objects of this class.
|
TableEntity(EntityReferenceLocator locator,
DatabaseConnectionManager dbConnectionManager,
int port,
Properties prop,
Properties aliasProp) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEntityDataChangeListener(EntityDataChangeListener listener)
Registers a EntityDataChangeListener to this entity.
|
String |
buildConditionsString(Hashtable conditions,
Vector values)
Returns a string containing the conditions to use after the WHERE
keyword in the SQL sentence.
|
void |
cancelReceiving(String receivingId,
int sessionId)
Cancells the transfer identified by
receivingId. |
protected Vector |
checkAmbiguousColumns(Vector attrWihtoutLocales,
String principalTable) |
protected Vector |
checkAvailableLocaleTables(String principalTable) |
protected boolean |
checkBasicExpresionLocalesInKv(Object actValue,
Hashtable gethOtherLocaleTablesColumns) |
protected boolean |
checkBasicExpresionLocalesInKv(Object actValue,
Vector getvLocaleColumns) |
protected SQLStatementBuilder.BasicExpression |
checkConditionsWithTablePreffix(SQLStatementBuilder.BasicExpression filter,
Vector attrWihtoutLocales,
SQLStatementBuilder.BasicExpression toRet) |
void |
checkDeleteKeys(Hashtable keysValues)
Checks if
keysValues contains a value for all columns
defined in 'delete_keys' parameter. |
void |
checkFinishedSession(int sessionId)
Checks if the sessionId has an associated session.
|
void |
checkInsertKeys(Hashtable attributesValues)
Checks if
attributesValues contains a value for all columns
defined in 'insert_keys' parameter. |
protected boolean |
checkLocalesInKV(Vector kvKeys,
Hashtable conditions,
Vector vLocaleColumns) |
protected Vector |
checkOrderColumns(Vector order) |
protected boolean |
checkOtherLocaleTables(Vector attributes) |
void |
checkPermissions(int sessionId,
String action)
Checks if the user/session identified by
sessionId has the
permission defined by action
This method calls ServerManager.getServerSecurityManager()
and then, if a manager exists, calls
manager.checkActionPermission(int, String, String) |
void |
checkUpdateKeys(Hashtable keysValues)
Checks if
keysValues contains a value for all columns
defined in 'update_keys' parameter. |
protected void |
configureReverseAlias() |
OntimizeConnection |
connect()
Returns an OntimizeConnection by asking the DatabaseConnectionManager.
|
OntimizeConnection |
connect(int userId)
Returns an OntimizeConnection by asking the DatabaseConnectionManager.
|
AdvancedEntityResult |
createAdvancedEntityResultForSessionId(int cod,
int type,
int sessionId)
Utility method for creating an AdvancedEntityResult for the session
identified by
sessionId
. |
AdvancedEntityResult |
createAdvancedEntityResultForSessionId(int cod,
int type,
String message,
int sessionId)
Utility method for creating an AdvancedEntityResult for the session
identified by
sessionId
. |
static EntityResult |
createEntityResultForSessionId(EntityReferenceLocator locator,
int cod,
int type,
String message,
int sessionId)
Utility method for creating an EntityResult for the session identified by
sessionId
. |
EntityResult |
createEntityResultForSessionId(int sessionId)
Utility method for creating an EntityResult for the session identified by
sessionId
. |
EntityResult |
createEntityResultForSessionId(int cod,
int type,
int sessionId)
Utility method for creating an EntityResult for the session identified by
sessionId
. |
EntityResult |
createEntityResultForSessionId(int cod,
int type,
String message,
int sessionId)
Utility method for creating an EntityResult for the session identified by
sessionId
. |
EntityResult |
createEntityResultForSessionId(int sessionId,
String operationId)
Utility method for creating an EntityResult for the session identified by
sessionId
. |
protected void |
createEntityScriptManager() |
EntityResult |
delete(Hashtable keysValues,
int sessionId)
This method must implement a standard delete operation over the set of
records defined by
keysValues. |
EntityResult |
delete(Hashtable keysValues,
int sessionId,
Connection con)
Executes a delete operation with the provided Connection.
|
boolean |
deleteAttachmentFile(Hashtable keysValues,
int sessionId)
This method calls
deleteAttachmentFile(Hashtable, int, Connection) |
boolean |
deleteAttachmentFile(Hashtable kv,
int sessionId,
Connection con)
If
attachmentFilePath is not null, this method executes a
query with conditions keysValues and then if one record is
found, searchs the column named attachmentFileNameColumn and
uses the file name found to delete the file in the file system. |
protected Vector |
deleteHOtherLocaleTablesAlias(Vector vValidAttributes) |
protected void |
deleteLocaleColumns(String localeTableName,
Hashtable hValidKeysValues,
int sessionId,
Connection con) |
protected EntityResult |
deleteMultipleTableAttributesColumns(EntityResult result,
Vector originalAttributes,
Vector processedMultipleAttributes)
Processes the EntityResult
res creating TableMultipleValue
objects . |
void |
disconnect(OntimizeConnection connection)
Returns the connection to the DatabaseConnectionManager, by calling
unlock(connection) method. |
void |
disconnect(OntimizeConnection connection,
String lockKey)
Returns the connection to the DatabaseConnectionManager, by calling
unlock(connection) method. |
protected void |
dispatcherAttribute(Object attribute,
EntityResult result,
int sessionId) |
EntityResult |
executePreparedStatement(String sqlSentence,
Vector values)
Executes a prepared statement defined by
sqlSentence and
values. |
EntityResult |
executePreparedStatement(String sqlSentence,
Vector values,
Connection con,
int sessionId)
Executes the SQL sentence
sqlSentence with the parameter
list values. |
EntityResult |
executePreparedStatement(String sqlSentence,
Vector values,
int sessionId)
Executes a prepared statement defined by
sqlSentence and
values. |
EntityResult |
executePreparedStatement(String sqlSentence,
Vector values,
int recordNumber,
int offset,
boolean delimited,
int sessionId)
Executes a prepared statement defined by
sqlSentence and
values. |
EntityResult |
executePreparedStatement(String sqlSentence,
Vector values,
int recordNumber,
int offset,
boolean delimited,
OntimizeConnection con,
int sessionId)
Executes the SQL sentence
sqlSentence with the parameter
list values. |
EntityResult |
executePreparedStatement(String sqlSentence,
Vector values,
OntimizeConnection con)
Executes a prepared statement defined by
sqlSentence and values. |
EntityResult |
executePreparedStatement(String sqlSentence,
Vector values,
OntimizeConnection con,
int sessionId)
Executes the SQL sentence
sqlSentence with the parameter
list values. |
protected EntityResult |
executeStatement(String sqlSentence,
Connection con)
Executes the query defined by the SQL sentence
sqlSentence
using the connection con |
protected Vector |
filterAttributes(Vector attributes,
Vector secondarykeys,
Vector primarykeys) |
protected Hashtable |
filterKeys(Hashtable values,
Vector secondarykeys,
Vector primarykeys) |
boolean |
finishReceiving(String receivingId,
int sessionId)
Indicates to this entity that the transfer identified by
receivingId has finished. |
protected void |
fireDataChangeEvent(int type,
Hashtable keysValues,
Hashtable attributesValues)
Deprecated.
|
protected void |
fireDataChangeEvent(int type,
Hashtable keysValues,
Hashtable attributesValues,
int sessionId)
Notifies all EntityDataChangeListener objects registered as listeners of
this entity, with a new DataChangeEvent with the type, keysValues and
attributesValues information.
|
protected void |
fireTransactionDataChangeEvent(int type,
Hashtable kv,
Hashtable av,
Connection con)
|
protected void |
fireTransactionDataChangeEvent(int type,
Hashtable kv,
Hashtable av,
int sessionId,
Connection con)
Notifies all TransactionEntityDataChangeListener objects registered as
listeners of this entity, with a new DataChangeEvent with the type,
keysValues and attributesValues information.
|
void |
generatedKeysToEntityResult(ResultSet resultSet,
EntityResult entityResult,
List generatedKeys) |
static int |
generateRandomId()
Generates a negative random int.
|
Vector |
getActions()
Returns the actions that this entity can perform.
|
String |
getAliasForColumn(String column)
Returns an alias for the column
column if it has been
specified. |
protected String |
getAttachmentFileNameForKeys(String fileName,
Hashtable keysValues)
Returns the attachment file name associated to the record identified by
keysValues. |
protected String |
getAttachmentFilePath(Hashtable kv,
int sessionId) |
protected String |
getAttachmentFilePath(Hashtable kv,
int sessionId,
Connection con) |
String |
getAutonumericalColumn()
Returns the autonumerical column name or null if nof defined
|
protected String |
getBaseEntityName(Class<?> entityClass) |
BytesBlock |
getBytes(String transferId,
int offset,
int length,
int sessionId)
Returns a BytesBlock object containing a byte array of length
lengthstarting in offset offset for the
attachment identified by transferId
If offset+length is greater than the file size only file size-offset
bytes are returned. |
String |
getColumnForAlias(String alias)
Returns the column for the alias
alias if alias have been
defined and the alias specified corresponds to a column. |
Map |
getColumnListForAvancedQuery(int sessionId)
Returns a map structure with the columns and sql types of this entity's
table.
|
Vector |
getColumns()
Returns the list of columns (by name) that may be used in operations in
this entity.
|
protected Vector |
getColumnsWithoutLocale(Vector validColumns) |
protected Hashtable |
getConditionsWithTablePreffix(Hashtable conditions,
Vector attrWihtoutLocales) |
protected Hashtable |
getContidionsWithoutFilterKeys(Hashtable conditions) |
DatabaseConnectionManager |
getDatabaseConnectionManager() |
Vector |
getDeleteKeys() |
Vector |
getDescOrderColumns()
Returns the list of columns (by name) to use in ORDER BY DESC clause
|
String |
getDescription()
Returns a description for this entity.
|
static int |
getEntityPrivilegedId(Entity ent)
Gets the privileged identifier for the entity
ent. |
Entity |
getEntityReference(String entityName)
Returns a reference to an Entity with name
entityName. |
String |
getErrorMessage(SQLException e)
Returns an error message corresponding to the exception e.
|
protected String |
getExtendedAliasPropertiesName()
Gets the extended alias property file path.
|
protected String |
getExtendedPropertiesName()
Gets the extended property file path.
|
String |
getExtension(String transferId)
This method returns
null |
Hashtable |
gethOtherLocaleTablesColumns() |
Vector |
getInsertKeys() |
protected Hashtable |
getJoinConditions(Vector principalKeyName,
String principalTable,
Vector secondaryKeyName,
String secondaryTable) |
Vector |
getKeys() |
protected Vector |
getKeysVector(Hashtable hValidKeysValues) |
protected Vector |
getLocaleColumnsFromTable(Vector validColumns) |
protected LocalePair<String,Object> |
getLocaleIdFromSession(int sessionId) |
protected String |
getLocaleTableName() |
protected String |
getLocaleTableName(String table) |
Hashtable |
getMetadata(int sessionId) |
String |
getName()
Returns this entity's name.
|
Vector |
getOrderColumns()
Returns the list of columns (by name) to use in ORDER BY clause
|
int |
getPrivilegedId()
Returns the privileged identifier of this entity.
|
static String |
getPropertiesPath(String className) |
int |
getQueryRecordNumber(Hashtable keysValues,
int sessionId)
This method executes a count query against this entity's query table with
the given conditions and for the session
sessionId. |
protected int |
getQueryRecordNumber(String stSQL,
Vector vVector,
Hashtable validKeysValues,
int sessionId,
boolean localeInKV,
boolean localeTables)
This method executes a count query against this entity's query table with
the given conditions and for the session
sessionId. |
String |
getQueryTable()
Returns the name of the table/view used when performing queries, if
defined.
|
protected String |
getSchemaQueryTable() |
protected String |
getSchemaTable() |
protected Vector |
getSecondaryColumnsWithoutKey(Vector secondaryColumnsNames,
Vector secondaryKeyName) |
long |
getSize(String transferId)
Returns the size of the attachment associated with the identifier
transferId. |
protected Map |
getSQLTypesFromMetaData(List columns,
int sessionId)
Obtains the DB Column metadata
|
static Vector |
getStringsOn(String s,
String separator)
Parses the String
s splitting it using
separator as delimiter. |
Hashtable |
getSubGroupValues(Hashtable fieldsValues,
Vector columns)
Deprecated.
|
Hashtable |
getSubGroupValues(Hashtable fieldsValues,
Vector columns,
int sessionid)
Creates a hashtable with the keys-values contained in
fieldsValues that satisfy the condition that key is
contained in columns. |
String |
getTable()
Returns the name of the table used when performing the four standard
operations.
|
protected Map |
getTypeFromMetadata(Vector columns,
int sessionId)
Returns the data type for the specified columns.
|
Vector |
getUpdateColumns()
Returns the list of columns (by name) that can be updated in update
operations
|
Vector |
getUpdateKeys() |
protected String |
getUser(int sessionId)
Returns the user name associated to the session identified by
sessionId. |
Vector |
getValidAttributes(Vector attributes)
Returns a list containing the valid attributes of those included in the
vector
attributes
If column names have been specified for this entity, only attributes
matching (case-sensitive) any of this column names are considered valid. |
Hashtable |
getValidDeletingKeysValues(Hashtable keysValues)
Returns a hashtable containing a list of valid key-value pairs from those
contained in the
keysValues argument. |
Hashtable |
getValidInsertingAttributesValues(Hashtable attributesValues)
Returns a hashtable containing a list of valid key-value pairs from those
contained in the
attributesValues argument. |
Hashtable |
getValidQueryingKeysValues(Hashtable keysValues)
Returns a hashtable containing a list of valid key-value pairs from those
contained in the
keysValues argument. |
Hashtable |
getValidUpdatingAttributesValues(Hashtable attributesValues)
Returns a hashtable containing a list of valid key-value pairs from those
contained in the
attributesValues argument. |
Hashtable |
getValidUpdatingKeysValues(Hashtable keysValues)
Returns a hashtable containing a list of valid key-value pairs from those
contained in the
keysValues argument. |
Vector<String> |
getvLocaleColumns() |
Vector |
getWildCardColumns()
Returns the list of columns (by name) which are allowed to use LIKE
conditions in queries
|
EntityResult |
insert(Hashtable attributesValues,
int sessionId)
This method implements a standard database insert operation with the data
contained in
attributesValues parameter. |
EntityResult |
insert(Hashtable attributesValues,
int sessionId,
Connection con)
Executes an insert operation with the provided Connection.
|
protected EntityResult |
insertAutonumericalAlias(EntityResult res)
Inserts the autonumerical/generatedkey column alias and the
autonumerical/generatedkey value as key-value into the EntityResult
res. |
protected void |
insertInLocaleTableLocaleColumns(EntityResult erResult,
Hashtable hLocaleColumns,
Vector vLocaleColumns,
Hashtable hTableLocaleColumns,
String table,
int sessionId,
Connection con) |
protected void |
insertInLocaleTablesForOneToOne(Hashtable hLocaleColumns,
EntityResult erResult,
int sessionId,
Connection con) |
protected void |
insertLocaleColumn(EntityResult res,
Hashtable avInterLocalColumns,
String table,
int sessionId,
Connection con) |
protected void |
insertOtherEntities(Hashtable attributes,
EntityResult result,
int sessionId,
Connection con) |
protected boolean |
isBinaryType(int type) |
protected void |
loadAliasFile()
Loads the alias properties.
|
protected void |
loadAliasFile(String path)
Loads the alias properties file in
path. |
protected void |
logToLogKeys(String s)
Logs the String
s to the corresponding LogWriter. |
protected void |
logUpdate(Hashtable attributesValues,
Hashtable keysValues,
int sessionId)
Logs an update operation with keys-values
keysValues and
attributes-values attributesValues
The log is only performed if logUpdate is true. |
Hashtable |
modifyBexpWithOtherLocaleTableAlias(Hashtable hashtableWithBExp,
Vector validAttributes) |
SQLStatementBuilder.BasicExpression |
modifyBexpWithOtherLocaleTableAlias(SQLStatementBuilder.BasicExpression bexp,
Vector validAttributes) |
protected Vector |
parseProperties(String propertyName) |
static boolean |
parseStringValue(String v,
boolean defaultValue)
Parses the string
value as a boolean. |
protected Hashtable |
particularizeConditions(Hashtable conditions,
Vector vValidAttributes) |
protected Properties |
performExtendedAliasProperties(Properties prop)
Performs the extended operation of alias property file.
|
protected Properties |
performExtendedProperties(Properties prop)
Performs the extended operation of entity property file.
|
void |
postDelete(EntityResult deleteResult,
Hashtable keysValues,
int sessionId,
Connection con) |
protected void |
postInsert(EntityResult insertResult,
Hashtable attributesValues,
int sessionId,
Connection con) |
void |
postUpdate(EntityResult updateResult,
Hashtable attributesValues,
Hashtable keysValues,
int sessionId,
Connection con) |
void |
preDelete(Hashtable keysValues,
int sessionId,
Connection con) |
protected void |
preInsert(Hashtable attributesValues,
int sessionId,
Connection con) |
String |
prepareToReceive(Hashtable kv,
String fileName,
String fileDescription,
int sessionId)
This method calls
prepareToReceive(Hashtable, String, String, String, int) with
null argument for originalFilePath |
String |
prepareToReceive(Hashtable keysValues,
String fileName,
String originalFilePath,
String fileDescription,
int sessionId)
Indicates to this entity that must be ready for receiving the contents of
a file.
|
String |
prepareToReceive(String column,
Hashtable keysValues,
int sessionId)
Indicates to this entity that must be ready for receiving the contents of
a file.
|
String |
prepareToTransfer(Hashtable keysValues,
int sessionId)
Indicates to this entity that a transfer process is going to start.
|
String |
prepareToTransfer(String column,
Hashtable keysValues,
int sessionId)
Indicates to this entity that a transfer process is going to start.
|
void |
preUpdate(Hashtable attributesValues,
Hashtable keysValues,
int sessionId,
Connection con) |
protected Hashtable |
processColumnsWithoutLocale(Hashtable hValidAttributesValues) |
protected Hashtable |
processFileColumnsAttributes(Hashtable av)
Processes the Hashtable
av using the
fileInfoList information in this entity. |
protected Vector |
processFileColumnsAttributes(Vector list)
Processes the Vector
list using the information in
fileInfoList. |
protected EntityResult |
processFileResults(EntityResult result)
Processes the
result object using the information in
fileInfoList. |
static Hashtable |
processingMultipleValueAttributes(Hashtable keysValues)
Processes the MultipleValue objects contained in
keysValues. |
static Hashtable |
processingReferenceDataFieldAttributes(Hashtable keysValues)
Processes the ReferenceFieldAttribute objects contained in
keysValues. |
static Vector |
processingReferenceDataFieldAttributes(Vector list)
Processes the ReferenceFieldAttribute objects contained in
list. |
Vector |
processMultipleAttributeKey(Vector list)
Processes MultipleReferenceDataFieldAttribute objects contained in
list. |
protected Hashtable |
processMultipleTableAttribute(Hashtable av)
Processes all the MultipleTableAttribute contained as keys ih the
Hashtable
av. |
protected Vector |
processMultipleTableAttribute(Vector list,
Vector processedMultipleAttributes)
Processes all the MultipleTableAttribute contained in the Vector
list. |
protected Hashtable |
processOtherEntities(Hashtable attributes) |
protected Hashtable |
processValidLocaleColumnsValues(Hashtable hValidAttributesValues,
Vector vLocaleColumns) |
void |
putBytes(String receivingId,
BytesBlock bytesBlock,
int sessionId)
Adds the bytes contained in the
bytesBlock object at the end
of the file associated with the transfer identified by
receivingId
. |
EntityResult |
query(Hashtable keysValues,
Vector attributes,
int sessionId)
This method implements a standard query operation returning the set of
data that matches the conditions specified by the
keysValues
parameter. |
EntityResult |
query(Hashtable keysValues,
Vector attributes,
int sessionId,
Connection con)
Executes a query operation using the provided Connection, with the
conditions and attributes required.
|
EntityResult |
query(Hashtable keysValues,
Vector attributes,
int sessionId,
Connection con,
Vector orderColumns,
boolean ascending)
Executes a query using the provided connection.
|
AdvancedEntityResult |
query(Hashtable filterKeys,
Vector attributes,
int sessionId,
int recordCounter,
int startIndex,
String sortBy,
boolean desc)
Deprecated.
|
AdvancedEntityResult |
query(Hashtable filterKeys,
Vector attributes,
int sessionId,
int recordNumber,
int startIndex,
Vector orderBy) |
EntityResult |
queryOtherEntities(Vector attributes,
EntityResult result,
int sessionId)
This method performs a query for each object of any of the following
types contained in the Vector
attributes:
ReferenceFieldAttribute
TableAttribute
MultipleReferenceDataFieldAttribute
A query is performed for each record in the argument result. |
protected void |
readProperties()
Loads the properties file for this entity.
|
protected void |
readProperties(Properties prop,
URL uRLProp)
Loads and analyzes the properties
prop. |
protected void |
readProperties(String path)
Loads a Properties object located in
path using
this.getClass().getClassLoader().getResource(path). |
static void |
registerAttributeDispatcher(Class key,
AttributeDispatcher dispatcher) |
void |
reloadScripts(boolean reloadNow) |
void |
removeEntityDataChangeListener(EntityDataChangeListener listener)
Unregisters a EntityDataChangeListener to this entity.
|
EntityResult |
replaceAliasByColumn(EntityResult res)
This method loops through the keys of the EntityResult assuming that this
keys are alias, and replacing this alias by the associated column if
exists or leaving them unmodified if not.
|
Hashtable |
replaceAliasByColumn(Hashtable hash)
This method loops through the keys of the hashtable assuming that this
keys are alias, and replacing this alias by the associated column if
exists or leaving them unmodified if not.
|
protected void |
replaceAliasByColumn(SQLStatementBuilder.BasicExpression bex) |
Vector |
replaceAliasByColumn(Vector columns,
Hashtable changedColumns)
Replaces the aliases contained in the list
columns by the
corresponding columns. |
Vector |
replaceAliasByColumn(Vector columns,
Vector changedColumns)
Replaces the alias contained in the list
columns by the
corresponding columns. |
EntityResult |
replaceColumnByAlias(EntityResult res,
Hashtable replaceColumns)
This method loops through the keys of the EntityResult and replaces them
accordingly to the mapping defined by
replaceColumns. |
EntityResult |
replaceColumnByAlias(EntityResult res,
Vector replaceColumns)
This method loops through the keys of the EntityResult assuming that this
keys are columns, and replacing this columns by the associated alias if
exists or leaving them unmodified if not.
|
Hashtable |
replaceColumnByAlias(Hashtable hash)
This method loops through the keys of the hashtable assuming that this
keys are columns, and replacing this columns by the associated alias if
exists or leaving them unmodified if not.
|
Vector |
replaceColumnByAlias(Vector columns)
Replaces the columns contained in the vector
columns by the
corresponding aliases. |
EntityResult |
replaceColumnByAliasKeepColumns(EntityResult res)
This method loops through the keys of the EntityResult assuming that this
keys are alias, and replacing this alias by the associated column if
exists or leaving them unmodified if not.
|
static void |
resultSetToEntityResult(ResultSet resultSet,
EntityResult entityResult)
Deprecated.
You must use the resultSetToEntityResult for the specific
statement handler instead (@see
SQLStatementHandler |
void |
resultSetToEntityResult(ResultSet resultSet,
EntityResult entityResult,
int recordNumber,
int offset,
boolean delimited) |
void |
resultSetToEntityResult(ResultSet resultSet,
EntityResult entityResult,
List columnNames) |
protected EntityResult |
retrieveDataToInsert(EntityResult result,
int sessionId,
Connection con) |
void |
setLimitQueryOthersEntities(int lim)
Sets the
limitQueryOthersEntities variable to
lim. |
void |
setName(String name) |
static void |
setObject(int index,
Object value,
PreparedStatement preparedStatement)
Deprecated.
You must use the setObject for the specific statement handler
instead (@see
SQLStatementHandler |
static void |
setObject(int index,
Object value,
PreparedStatement preparedStatement,
boolean truncDates)
Deprecated.
You must use the setObject for the specific statement handler
instead (@see
SQLStatementHandler |
void |
setPrivilegedId(int id)
Establishes the privileged identifier for this entity
|
protected Vector |
tagAttributes(Vector attributes,
String table,
Vector tableColumns) |
protected Vector |
tagAttributesWithoutAlias(Vector attributes,
String table,
Vector tableColumns,
String table2,
Vector tableColumns2) |
protected Hashtable |
tagKeysValues(Hashtable values,
String table,
Vector tableColumns) |
static Vector |
toVectorOfBooleans(Vector list)
This method returns a vector of Boolean objects corresponding to the
objects contained in the vector
list. |
static Timestamp |
truncateDataToHour_00_00_00(Date date)
Sets the following fields of the object
date to zero:
Calendar.MILLISECOND,Calendar.SECOND,Calendar.MINUTE,Calendar.HOUR_OF_DAY
The default calendar (for the default locale and timezone) is used. |
static Timestamp |
truncateDateToMinutes(Date date)
Sets the following fields of the object
date to zero:
Calendar.MILLISECOND,Calendar.SECOND
The default calendar (for the default locale and timezone) is used. |
EntityResult |
update(Hashtable attributesValues,
Hashtable keysValues,
int sessionId)
This method implements a standard update operation with the data
specified in
attributesValues over the set of records
defined by keysValues. |
EntityResult |
update(Hashtable attributesValues,
Hashtable keysValues,
int sessionId,
Connection con)
Executes an update operation with the provided Connection.
|
protected void |
updateAttachmentValues(Hashtable keysValues,
Hashtable attributesValues,
int sessionId,
Connection connection) |
protected void |
updateInLocaleTablesForOneToOne(Hashtable hLocaleColumns,
Hashtable hValidKeysValues,
EntityResult erResult,
int sessionId,
Connection con) |
protected void |
updateLocaleColumns(Hashtable avLocaleColumns,
Hashtable kv,
String table,
int sessionId,
Connection con) |
static String |
vectorToStringSeparateBySemicolon(Vector list)
Generates a string containing the toString version of all the objects
contained in the list
list, separated by the ';' character |
clone, exportObject, exportObject, exportObject, unexportObjectgetClientHost, getLog, setLogpublic static boolean checkOperationResult
public static final String LIMIT_QUERY_OTHERS_ENTITIES
public static final String REPORT_ADVANCED_QUERY_TYPES
public static final String REPORT_ADVANCED_QUERY_COLUMNS
public static final String ATTACHMENT_FILE_DESCRIPTION_COLUMN
public static final String ATTACHMENT_FILE_ORIGINAL_PATH_COLUMN
public static final String ATTACHMENT_FILE_ORIGINAL_NAME_COLUMN
public static final String ATTACHMENT_FILE_NAME_COLUMN
public static final String INSERT_AUTOMATICLY_ATTACHMENT
public static final String ATTACHMENT_FILE_NAME_KEYS
public static final String ATTACHMENT_FILE_SIZE_COLUMN
@Deprecated public static final String TABLE_ATTRIBUTE_ENTITIES
public static boolean useAlwaysTableAttributeEntities
public static final String ATTACHMENT_FILE_PATH
public static final String FILE_COLUMNS
public static final String LOG_KEYS
public static final String AUTONUMERICAL
public static final String GENERATED_KEY
public static final String OTHER_ENTITIES
public static final String SORT_DESC
public static final String SORT
public static final String WILDCARD_COLUMNS
public static final String INSERT_COLUMNS
public static final String UPDATE_COLUMNS
public static final String UPDATE_KEYS
public static final String DELETE_KEYS
public static final String INSERT_KEYS
public static final String KEYS
public static final String COLUMNS
public static final String COUNT_COLUMNS
public static final String AUTOCONFIGURATION
public static final String TRUNCATE_DATES
public static final String FORCE_DISTINCT
public static final String ATTACHMENT_TABLE
public static final String QUERY_TABLE
public static final String FETCH_SIZE
public static final String TABLE
public static char ASTERISK
public static char INTERROG
public static char PERCENT
public static char UNDERSCORE
public static String ATTACHMENT_SEPARATOR
public static boolean TRUNCATE_DATE_DEFAULT_VALUE
public static boolean RECORD_OPERATIONS
public static final String M_IT_HAS_NOT_CHANGED_ANY_RECORD
public static final String M_ERROR_OPERATION
public static boolean USE_SETSTRING_LONG_STRINGS
setCharacterStream() will be used instead of
setString()protected static EntitiesPropertiesParser entitiesPropertiesParser
protected static AliasPropertiesParser aliasPropertiesParser
public static final String QUERY_ACTION
public static final String INSERT_ACTION
public static final String UPDATE_ACTION
public static final String DELETE_ACTION
public static String M_YOU_DO_NOT_HAVE_PERMISSION_TO_EXECUTE_ACTION
public static String M_TEMPORALY_RESTRICTED_BY_PERMISSION_ACTION
public static String M_LICENSE_PERMISSION_ERROR
protected Vector dataChangeListeners
protected String table
queryTable variable is defined, it is used
instead of tableprotected String queryTable
protected String attachTable
table.protected Vector columnNames
protected Vector keys
protected Vector insertKeys
protected Vector deleteKeys
protected Vector updateKeys
protected Vector updateColumn
protected DatabaseConnectionManager manager
protected String autonumericalColumn
protected Vector insertColumn
columnNames will be used instead. Defined in
'insert_columns' parameter.protected Vector countColumns
protected Vector wildcardColumns
protected Vector orderColumns
protected Vector descendantColumnsOrder
protected Vector othersEntities
protected EntityReferenceLocator locator
protected int limitQueryOthersEntities
protected Properties alias
protected Hashtable aliasReverse
protected String entityName
protected int privilegedId
protected boolean forceDistinct
protected boolean truncateDates
protected static Calendar calendar
protected String attachmentFilePath
protected String attachmentFileNameColumn
protected String originalAttachmentFileNameColumn
protected String originalAttachmentFilePathColumn
protected String descriptionAttachmentFileColumn
protected boolean insertAttachmentAutomatically
prepareToReceive method. These values will
be used in the insert operation that is done in this method. Defined in
'insert_automatically_attachment' parameter. Default is false.protected Vector attachmentFileNameKeys
getAttachmentFileNameForKeys()
method. Defined in 'attachment_file_name_keys' parameter. By default,
this variable is null.protected String attachmentFileSizeColumn
protected Hashtable receivedAttachmentFile
protected Hashtable sendAttachmentFile
protected Vector reportAvancedQueryColumns
protected Vector reportAvancedQueryTypes
reportAvancedQueryColumns field. Defined in
'report_advanced_query_types' parameter.protected Vector logkeys
protected int fetchSize
public static final String PRINCIPAL_TABLE
public static final String SECONDARY_TABLE
public static final String PRINCIPAL_COLUMNS
public static final String SECONDARY_COLUMNS
public static final String PRINCIPAL_KEYS
public static final String SECONDARY_KEYS
protected String principalTable
protected String secondaryTable
protected Vector principalColumnNames
protected Vector secondaryColumnsNames
protected Vector principalKeyName
protected Vector secondaryKeyName
protected DBLocalErrorMessages dBLocalErrorMessage
protected boolean oneToOneMode
protected Hashtable tempFiles
protected Hashtable receivedTempFiles
@Deprecated protected int maxConnectionWaitTime
DatabaseConnectionManager.connectionWaitTime.@Deprecated protected int connectionRequestTime
DatabaseConnectionManager.connectionRequestTime.protected boolean logQuery
protected boolean logInsert
protected boolean logUpdate
protected boolean logDelete
protected Properties properties
protected static String propertiesPath
entityName
.properties, relative to this entity class file.protected TableEntity.FileInfoList fileInfoList
protected Vector entitiesTableAttribute
If an entity name is in this list, the columns of this entity defined as parentkeys in the TableAttribute, will be passed to the queried entity as filters.
Defined in 'TableAttributeEntities' parameter.
Default is null.
public static boolean enableScripting
public static String defaultEntityScriptManagerClassName
protected IEntityScriptManager entityScripting
public static final String LOCALE_COLUMNS
public LinkedHashMap hOtherLocaleTablesKey
public Hashtable hOtherLocaleTablesColumns
public static final String OTHER_LOCALE_TABLES
public static final String OTHER_LOCALE_TABLES_KEY
public static final String OTHER_LOCALE_TABLES_COLUMNS
public static final String LOCALE_TABLE
public String localeTable
public IAuditorLogger auditorLog
protected static Hashtable registeredDispatcher
public TableEntity(EntityReferenceLocator locator, DatabaseConnectionManager dbConnectionManager, int port) throws Exception
locator - The EntityReferenteLocator that this entity will use for
getting references to other entitiesdbConnectionManager - The DatabaseConnectionManager that provides database
connectionsport - The RMI port this object listens onException - If creation of this object failspublic TableEntity(EntityReferenceLocator locator, DatabaseConnectionManager dbConnectionManager, int port, Properties prop, Properties aliasProp) throws Exception
Exceptionprotected void createEntityScriptManager()
public void reloadScripts(boolean reloadNow)
public OntimizeConnection connect() throws Exception
maxConnectionWaitTime if the
DatabaseConnectionManager don´t provide a connection in the first
attemps.Exception - if the DatabaseConnectionManager can´t provide a connectionpublic OntimizeConnection connect(int userId) throws Exception
maxConnectionWaitTime if the
DatabaseConnectionManager don´t provide a connection in the first
attemps.userId - The userId to which the connection is relatedException - if the DatabaseConnectionManager can´t provide a connectionpublic void disconnect(OntimizeConnection connection, String lockKey)
unlock(connection) method.
The lockKey parameter must be equal to the connection lock key
connection - The connection to unlocklockKey - May be nullpublic void disconnect(OntimizeConnection connection)
unlock(connection) method.connection - public void resultSetToEntityResult(ResultSet resultSet, EntityResult entityResult, int recordNumber, int offset, boolean delimited) throws Exception
Exceptionpublic void resultSetToEntityResult(ResultSet resultSet, EntityResult entityResult, List columnNames) throws Exception
Exceptionpublic void generatedKeysToEntityResult(ResultSet resultSet, EntityResult entityResult, List generatedKeys) throws Exception
Exception@Deprecated public static void resultSetToEntityResult(ResultSet resultSet, EntityResult entityResult) throws Exception
SQLStatementHandlerEntityResult. The columns in the ResultSet are the keys in the
EntityResult, and the values for the columns are stored in Vector objects
corresponding to the keys in the EntityResult.
The following getxxxxx ResulSet methods are used for getting column data:
resultSet - the source ResultSetentityResult - the destination EntityResult. It has a Hashtable of Vectors
structure.Exception - if any error (database, etc.) occurs@Deprecated public static void setObject(int index, Object value, PreparedStatement preparedStatement) throws SQLException
SQLStatementHandlerindexindex - the index of the parametervalue - the value to setpreparedStatement - the prepared statementSQLExceptionsetObject@Deprecated public static void setObject(int index, Object value, PreparedStatement preparedStatement, boolean truncDates) throws SQLException
SQLStatementHandlerindex
The methods used are:
index - value - preparedStatement - truncDates - SQLExceptionprotected void loadAliasFile()
protected void loadAliasFile(String path)
path.
If file does not exist, no error is produced. If file exists, resulting
alias are loaded in alias and aliasReverse
fields.
path - the file location, relative to this entity's class file.protected void configureReverseAlias()
protected void readProperties()
throws Exception
propertiesPath (by default 'prop') relative to this entity's
class file, and named entityName.properties.
All the names specified in this file are considered database table columns, that is, should match exactly (case-sensitive) the columns of the database table/view.
The following table shows the parameters that can be defined in the properties file. For all parameters that define a list, the ';' character is used as separator.
| Parameter | Meaning | Required |
| Table | The database table name that this entity uses for query, insert, update, delete operations | yes |
| QueryTable | The database table or view name that this entity uses for query operations | no |
| Columns | Columns of the table specified in table parameter.
Tipically it should be exactly all the table columns, but this is not
strictly neccessary. These colums can be used in query, update, delete
and insert operations (unless insert_columns parameter is
defined) |
yes |
| CountColumns | Columns of the table specified to apply sql count operations over the
data. This parameter improves performance to determine total record count
in limited queries (e.g Table component when is paged). When not
specified, operation will be count(*) since 5.2080EN |
no |
| InsertColumns | Columns allowed in insert, update, delete operations. If not defined,
columns is used instead |
no |
| Keys | Columns that make the primary key for this entity. Usually matches the table primary key. | yes |
| InsertKeys | Columns required (non null) in insert operations. | no |
| UpdateKeys | Columns required in keysvalues (update method parameter). These
columns, and only these, will be used in the WHERE clause of UPDATE SQL
sentences. If not specified, keys is used. |
no |
| DeleteKeys | Columns required in keysvalues (delete method parameter). These
columns, and only these, will be used in the WHERE clause of DELETE SQL
sentences. If not specified, keys is used. |
|
| UpdateColumns | Columns that can be modified by update operations, calling
update method. If not specified, no columns can be modified.
|
no |
| Autonumerical | Column that stores an integer generated by Autonumerical object when
insert operations are performed. This column should never be specified in
insert_keys parameter as is not provided to the method
insert but is generated internally in the method. |
no |
| GeneratedKey | Autogenetared columns by database when insert operations are performed. | no |
| WildcardColumns | Columns in which special search characters are allowed for LIKE queries. If not specified, all columns are allowed. | no |
| OtherEntities | Entities (by name) that will be queried for data related with records of this entity, when specified in attribute list. If not specified, all entities will be queried. | no |
| LimitQueryOtherEntities | If there are multiple results for this entity, and other entity data is asked, then this entity will limit the number of records for which other entities are queried to this parameter. By default this value is 100 | no |
| Sort | List of column names to use in the ORDER BY clause, in the same order
as they appear in this parameter. Since 5.2056EN-0.2, for specifying
ascendant (ASC) and descendant (DESC) order individually for each column
is accepted the syntax: ASC[col1];DESC[col2];...;ASC[coln] |
no |
Deprecated since 5.2056EN-0.2 (See Sort). sort and sort_desc are specified,
sort is used |
no | |
| FetchSize | The JDBC statement fetch size. By default this value is 0 | no |
| LogKeys | Specifies the keys for logging in this entity. These keys will be used for calling LogManager.getLogWriter(key) and then use resulting LogWriter for logging update, query, insert and delete operations | no |
| FileColumns | Specifies a list of columns for storing filename and file contents
pairs, that this entity receives as com.ontimize.gui.DataFile objects. This parameter is specified as a list of: attribute associated to file+':'+filename column+':'+file contents column, for each file to be stored. e.g, your form contains two FileDataField with attr file1 and file2 and columns in database to store content for these ones are filecolumn1 and filecolumn2 and columns to store names are filenamecolumn1 and filenamecolumn2. So, configuration for this parameter would be: FileColumns=file1:filenamecolumn1:filecolumn1;file2:filenamecolumn2: filecolumn2 |
no |
| ForceDistinct | If this parameter is 'yes', then a DISTINCT keyword will be used in all queries performed by this entity. By default this value is 'no' | no |
| TruncateDates | If this value is 'yes' then the java.util.Date values will be set to 00:00:00 before being set in the statements. By default this value is 'no'. Default value can be configured with TRUNCATE_DATE_DEFAULT_VALUE field | no |
| AttachmentFilePath | Path in the file system in which the attached files for this entity will be stored. If this parameter is specified, then the parameter 'AttachmentFileNameColumn' also must be specified | no |
| AttachmentFileNameColumn | Column that stores the name of attached files. Must be String type. | no |
| AttachmentFileOriginalNameColumn | Column that stores original file names for attachments. | no |
| AttachmentFileOriginalPathColumn | Column that stores original file location (path) for attachments. This parameter is useful for custom code in the client | no |
| AttachmentFileDescriptionColumn | Column that stores optional attachment description. | no |
| InsertAutomaticallyAttachment | Defines if attachment records are inserted automatically. If false, a
value for each key of this entity is required in the keysValues argument
when calling to prepareToReceive method. These values will
be used in the insert operation that is done in this method. Defined in
'InsertAutomaticallyAttachment' parameter. Default is false. |
no |
| AttachmentFileNameKeys | Defines which column values are used when generating filenames for
attachments, by calling getAttachmentFileNameForKeys()
method. If this parameter is not specified, the columns defined in 'keys'
are used. |
no |
| AttachmentFileSizeColumn | Defines which column of the table is used for storing the attachment file size in bytes. Optional. | no |
| TableAttributeEntities | List of entity names for which the TableAttribute information (keys,
attributes, ...) will be used when this entity queries another entities.
If an entity name is in this list, the columns of this entity defined as parentkeys in the TableAttribute, will be passed to the queried entity as filters. |
no |
| Autoconfiguration | If this parameter value is 'yes' then the configuration for this entity is automatically generated using the database metadata. Using this method, only a basic configuration can be obtained, and if possible, a properties file will be generated. | no |
When using attachments, the following basic actions must be granted for this entity:
Also, it is possible to define specific error messages for this entity
when SQLExceptions ocurr. This can be done defining properties with the
following format:
err_nnnn=error_message where nnnn is the SQLState
associated with the exception. This method calls
readProperties(String) with the standard location for this
entity's properties file.
Exceptionprotected void readProperties(String path) throws Exception
path using
this.getClass().getClassLoader().getResource(path).readProperties(Properties, URL)path - path from which the properties will be loadedExceptionprotected String getExtendedPropertiesName()
String with the file path.protected String getExtendedAliasPropertiesName()
String with the file path.protected Properties performExtendedProperties(Properties prop)
prop - Entity property file.protected Properties performExtendedAliasProperties(Properties prop)
prop - Alias property file.protected void readProperties(Properties prop, URL uRLProp) throws Exception
prop. The parameters for
this entity are read from the properties and this entity is configured
according to them.uRLProp protocol is 'file', then a properties file is
generated located in uRLProp.getPath()prop - the properties objectuRLProp - the properties file URLExceptionpublic EntityResult query(Hashtable keysValues, Vector attributes, int sessionId) throws Exception
keysValues
parameter. The attributes defines which attributes (or
columns if data is obtained from a database) must be recovered, and
keysValues specifies which set of records must be recovered.
This entity maps a table in the database, so all the hashtable keys must correspond to table columns, generally using column names as strings, but also other objects are processed.
This method ask for a connection and calls the following methods:
#processMultipleTableAttribute(Vector)processMultipleAttributeKey(Vector)query(Hashtable , Vector , int , Connection)
Then, if the result returned by query has no error, the
queryOtherEntities(Vector , EntityResult , int ) method is
called.
After that, this entity logs the operation if logQuery is
true.
If an SQLException is thrown, the getErrorMessage(SQLException)
method is called and the resulting messsage is set as the message in the
EntityResult returned by this entity.
The result returned by query(Hashtable , Vector , int , Connection)
method is returned by this method if no error ocurrs.
query in interface EntitykeysValues - a Hashtable specifying conditions that must comply the set of
records returned. Cannot be null.attributes - a list of columns that must be recovered for each record
returned. Cannot be null. If empty, all attributes will be
returned.sessionId - a integer identifying the user or session that performs the
action.Exception - if any non handled exception occursquery(Hashtable, Vector, int, Connection)public AdvancedEntityResult query(Hashtable filterKeys, Vector attributes, int sessionId, int recordNumber, int startIndex, Vector orderBy) throws Exception
query in interface AdvancedEntityfilterKeys - a Hashtable specifying conditions that must
comply the set of records returned. Cannot be null.attributes - a list of columns that must be recovered for each record
returned. Cannot be null. If empty, all attributes will be
returned.sessionId - a integer identifying the user or session that performs the
action.recordNumber - a integer establishing the number of records that will be
returned.startIndex - a integer establishing the position of the first record that
will be returned.orderBy - a Vector of String or
SQLStatementBuilder.SQLOrder objects in where the
column orderer is established.Exceptionprotected Hashtable particularizeConditions(Hashtable conditions, Vector vValidAttributes)
protected LocalePair<String,Object> getLocaleIdFromSession(int sessionId) throws Exception
Exception@Deprecated public AdvancedEntityResult query(Hashtable filterKeys, Vector attributes, int sessionId, int recordCounter, int startIndex, String sortBy, boolean desc) throws Exception
query in interface AdvancedEntityExceptionpublic EntityResult insert(Hashtable attributesValues, int sessionId) throws Exception
attributesValues parameter.This entity maps a table in the database, so all the hashtable keys must correspond to table columns, generally using column names as strings, but also other objects are processed.
This method ask for a connection, set autocommit to false, so operations are processed in a transaction, and calls the following methods:
After this, commit is executed and if no error is produced a DataChangeEvent.INSERT_EVENT is thrown.
If an SQLException is thrown, the getErrorMessage(SQLException)
method is called and the resulting message is set as the message in the
EntityResult returned by this entity.
The result returned by insert(Hashtable , int , Connection)
method is returned by this method if no error occurs.
If an autonumerical is defined for this entity and no error occurs, the value used in the insert operation is returned in the result as a pair or key-value where key is the column name, and value is the value used in the insert operation.
insert in interface EntityattributesValues - a Hashtable specifying pairs of key-value corresponding to the
attribute (or column of a table in a database) and the value
that must be stored.sessionId - a integer identifying the user or session that performs the
action.sessionId - Exceptioninsert(Hashtable , int , Connection)public EntityResult update(Hashtable attributesValues, Hashtable keysValues, int sessionId) throws Exception
attributesValues over the set of records
defined by keysValues. So, only the records that comply with
the conditions specified by keysValues will be updated to
the new values specified by attributesValues.
This entity maps a table in the database, so all the hashtable keys must correspond to table columns, generally using column names as strings, but also other objects are processed.
This method ask for a connection, set autocommit to false, so operations are processed in a transaction, and calls the following methods:
After this, commit is executed and if no error is produced a DataChangeEvent.UPDATE_EVENT is thrown.
If an SQLException is thrown, the getErrorMessage(SQLException)
method is called and the resulting message is set as the message in the
EntityResult returned by this entity.
update in interface EntityattributesValues - the data for updating the records to. The keys specify the
attributes (or columns) and the values, the values for these
columns.keysValues - the conditions that the records to be updated must fulfill.
The keys specify the attributes (or columns) and the values,
the values for these columns.sessionId - a integer identifying the user or session that performs the
action.Exception - if any exception occursupdate(Hashtable, Hashtable , int , Connection)public EntityResult delete(Hashtable keysValues, int sessionId) throws Exception
keysValues. So, only the records that
comply with the conditions specified by keysValues will be
deleted.
This entity maps a table in the database, so all the hashtable keys must correspond to table columns, generally using column names as strings, but also other objects are processed.
This method ask for a connection, set autocommit to false, so operations are processed in a transaction, and calls the following methods:
After this, commit is executed and if no error is produced a DataChangeEvent.DELETE_EVENT is thrown.
If an SQLException is thrown, the getErrorMessage(SQLException)
method is called and the resulting message is set as the message in the
EntityResult returned by this entity.
delete in interface EntitykeysValues - the conditions that the records to be deleted must fulfill.
The keys specify the attributes (or columns) and the values,
the values for these columns.sessionId - a integer identifying the user or session that performs the
action.Exception - if any exception occursdelete(Hashtable, int , Connection)public String getErrorMessage(SQLException e)
e.getMessage() is
returned.e - the exceptionpublic String buildConditionsString(Hashtable conditions, Vector values)
processingReferenceDataFieldAttributes(Hashtable)processingMultipleValueAttributes(Hashtable)getValidQueryingKeysValues(Hashtable)SQLStatementBuilder.createQueryConditionsWithoutWhere(Hashtable, Vector,
Vector)conditions - values - public static Vector toVectorOfBooleans(Vector list)
list.
For each position in the vector:
The list must contain only Boolean objects, Number objects
or nulls.
list - public void setLimitQueryOthersEntities(int lim)
limitQueryOthersEntities variable to
lim.lim - limitQueryOthersEntitiespublic Vector getValidAttributes(Vector attributes)
attributes
If column names have been specified for this entity, only attributes matching (case-sensitive) any of this column names are considered valid.
If no columns have been defined, all attributes will be considered valid.
attributes - public Hashtable getValidQueryingKeysValues(Hashtable keysValues)
keysValues argument.
A key-value pair is valid if the key is valid.
If column names have been specified for this entity, only keys matching
(case-sensitive) any of this column names are considered valid. Also, the
special key
SQLStatementBuilder.ExtendedSQLConditionValuesProcessor.EXPRESSION_KEY
and
SQLStatementBuilder.ExtendedSQLConditionValuesProcessor.FILTER_KEY
is always considered valid.
If no columns have been defined, all keys will be considered valid.
keysValues - public Hashtable getValidInsertingAttributesValues(Hashtable attributesValues)
attributesValues argument.
A key-value pair is valid if the key is valid.
If insert columns have not been specified for this entity,
getValidQueryingKeysValues(Hashtable) method is called and
result is returned.
If not, the following is used:
Only keys matching (case-sensitive) any of this insert column names are considered valid.
attributesValues - public Hashtable getValidUpdatingAttributesValues(Hashtable attributesValues)
attributesValues argument.
A key-value pair is valid if the key is valid.
If column names have been specified for this entity, only keys matching (case-sensitive) any of this column names and any of the columns defined by the 'update_columns' parameter are considered valid.
If no columns have been defined, all keys contained in the update columns defined for this entity, will be considered valid.
attributesValues - public Hashtable getValidUpdatingKeysValues(Hashtable keysValues)
keysValues argument.
A key-value pair is valid if the key is valid.
Only keys matching (case-sensitive) any of the columns defined by the 'update_keys' parameter are considered valid.
keysValues - public Hashtable getValidDeletingKeysValues(Hashtable keysValues)
keysValues argument.
A key-value pair is valid if the key is valid.
Only keys matching (case-sensitive) any of the columns defined by the 'delete_keys' parameter are considered valid.
keysValues - public EntityResult executePreparedStatement(String sqlSentence, Vector values) throws Exception
sqlSentence and
values.
This method ask for a connection and then calls
executePreparedStatement(String, Vector, OntimizeConnection)
returning the result.
sqlSentence - the SQL sentencevalues - a list of values for the parameters in the SQL sentenceExceptionpublic EntityResult executePreparedStatement(String sqlSentence, Vector values, int sessionId) throws Exception
sqlSentence and
values.
This method ask for a connection, calling connect(int) with
sessionId, and then calls
executePreparedStatement(String, Vector, OntimizeConnection)
returning the result.
sqlSentence - the SQL sentencevalues - a list of values for the parameters in the SQL sentencesessionId - Exceptionpublic EntityResult executePreparedStatement(String sqlSentence, Vector values, int recordNumber, int offset, boolean delimited, int sessionId) throws Exception
sqlSentence and
values.
This method ask for a connection, calling connect(int) with
sessionId, and then calls
executePreparedStatement(String, Vector, OntimizeConnection)
returning the result.
sqlSentence - the SQL sentencevalues - a list of values for the parameters in the SQL sentencerecordNumber - number of record to retrieveoffset - index of the record to retrievesessionId - Exceptionpublic EntityResult executePreparedStatement(String sqlSentence, Vector values, OntimizeConnection con) throws Exception
sqlSentence and values.This method calls {@link #executePreparedStatement(String, Vector, OntimizeConnection, int) returning the result.
sqlSentence - the SQL sentencevalues - a list of values for the parameters in the SQL sentencecon - Exceptionpublic EntityResult executePreparedStatement(String sqlSentence, Vector values, int recordNumber, int offset, boolean delimited, OntimizeConnection con, int sessionId) throws Exception
sqlSentence with the parameter
list values.
This method uses the supplied connection con but does not
disconnect it.
Creates a PreparedStatement, sets the parameters by calling
setObject(int, Object, PreparedStatement, boolean), and executes
the statement.
If the operation produces a ResultSet, then this ResultSet is read by
calling resultSetToEntityResult(ResultSet, EntityResult) and the
EntityResult is returned.
If the sessionId has a compression threshold associated, then it is set in the returned result.
If the operation does not produce a ResultSet the statement is queried for update count and if the result is zero, a warning message (M_IT_HAS_NOT_CHANGED_ANY_RECORD) is set in an empty EntityResult that is returned.
Finally this method closes the PreparedStatement.
sqlSentence - the sentence to executevalues - the corresponding parameter valuescon - the connection to use when creating the PreparedStatementsessionId - the user identifierException - if an error occurspublic EntityResult executePreparedStatement(String sqlSentence, Vector values, OntimizeConnection con, int sessionId) throws Exception
sqlSentence with the parameter
list values.
This method uses the supplied connection con but does not
disconnect it.
Creates a PreparedStatement, sets the parameters by calling
setObject(int, Object, PreparedStatement, boolean), and executes
the statement.
If the operation produces a ResultSet, then this ResultSet is read by
calling resultSetToEntityResult(ResultSet, EntityResult) and the
EntityResult is returned.
If the sessionId has a compression threshold associated, then it is set in the returned result.
If the operation does not produce a ResultSet the statement is queried for update count and if the result is zero, a warning message (M_IT_HAS_NOT_CHANGED_ANY_RECORD) is set in an empty EntityResult that is returned.
Finally this method closes the PreparedStatement.
sqlSentence - the sentence to executevalues - the corresponding parameter valuescon - the connection to use when creating the PreparedStatementsessionId - the user identifierException - if an error ocurrspublic EntityResult executePreparedStatement(String sqlSentence, Vector values, Connection con, int sessionId) throws Exception
sqlSentence with the parameter
list values.
This method uses the supplied connection con but does not
disconnect it.
Creates a PreparedStatement, sets the parameters by calling
setObject(int, Object, PreparedStatement, boolean), and executes
the statement.
If the operation produces a ResultSet, then this ResultSet is read by
calling resultSetToEntityResult(ResultSet, EntityResult) and the
EntityResult is returned.
If the sessionId has a compression threshold associated, then it is set in the returned result.
If the operation does not produce a ResultSet the statement is queried for update count and if the result is zero, a warning message (M_IT_HAS_NOT_CHANGED_ANY_RECORD) is set in an empty EntityResult that is returned.
Finally this method closes the PreparedStatement.
sqlSentence - the sentence to executevalues - the corresponding parameter valuescon - the connection to use when creating the PreparedStatementsessionId - the user identifierException - if an error ocurrspublic EntityResult queryOtherEntities(Vector attributes, EntityResult result, int sessionId)
attributes:
A query is performed for each record in the argument result.
For ReferenceFieldAttribute and MultipleReferenceDataFieldAttribute objects, the object information (entity, columns, cods, attrs) is used to perform the query.
For TableAttribute objects, if the entity specified in the object is
defined in this entity's 'TableAttributeEntities' parameter, then the
TableAttribute object information ( parentkeys) is used when performed
the query, that is, the keysValues passed to the Entity's query method
will contain for each record in result the values for each
column in the parentkeys.
If the entity specified in the TableAttribute object is not defined in 'TableAttributeEntities', then the keys of this entity are used.
Also, for TableAttribute objects, if 'other_entities' parameter is
defined, only those objects with entity name matches any of the names
defined by this parameter, will lead to a query execution. If the
result contains more records than the value of
limitQueryOthersEntities field, only the first
limitQueryOthersEntities will be queried.
When querying other entities, if this and these entities are instances of PrivilegedSecurityEntity, and this entity is queried with a privileged Id, a privileged Id is set and used with other entities when querying.
The resulting data is added to the result object using as
keys, the associated objects in attributes.
So, if a ReferenteFieldAttribute is found, a query is performed and the
result is added to result using as key the
ReferenceFieldAttribute.
attributes - result - With the column names without the alias. If there is no data
for column names then use the alias values.sessionId - result object received as argument with
additional dataTableAttribute,
ReferenceFieldAttributepublic static void registerAttributeDispatcher(Class key, AttributeDispatcher dispatcher)
protected void dispatcherAttribute(Object attribute, EntityResult result, int sessionId)
protected void insertOtherEntities(Hashtable attributes, EntityResult result, int sessionId, Connection con) throws Exception
Exceptionprotected EntityResult retrieveDataToInsert(EntityResult result, int sessionId, Connection con) throws Exception
Exceptionpublic void checkInsertKeys(Hashtable attributesValues) throws Exception
attributesValues contains a value for all columns
defined in 'insert_keys' parameter.
attributesValues - Exception - if any of the columns defined in 'insert_keys' is not found
as key in attributesValuespublic void checkUpdateKeys(Hashtable keysValues) throws Exception
keysValues contains a value for all columns
defined in 'update_keys' parameter.
keysValues - Exception - if any of the columns defined in 'update_keys' is not found
as key in keysValuespublic void checkDeleteKeys(Hashtable keysValues) throws Exception
keysValues contains a value for all columns
defined in 'delete_keys' parameter.
keysValues - Exception - if any of the columns defined in 'delete_keys' is not found
as key in keysValuespublic String getAliasForColumn(String column)
column if it has been
specified.
column - public String getColumnForAlias(String alias)
alias if alias have been
defined and the alias specified corresponds to a column.
alias - alias or null if no
column has this alias.public Hashtable replaceAliasByColumn(Hashtable hash)
hash - protected void replaceAliasByColumn(SQLStatementBuilder.BasicExpression bex)
public Hashtable replaceColumnByAlias(Hashtable hash)
hash - public EntityResult replaceAliasByColumn(EntityResult res)
res - public EntityResult replaceColumnByAlias(EntityResult res, Vector replaceColumns)
Only the columns contained in replaceColumns are replaced in
the result.
res - replaceColumns - public EntityResult replaceColumnByAlias(EntityResult res, Hashtable replaceColumns)
replaceColumns.
So, if any of the keys of result is found in
replaceColumns, it is replaced by the value associated
(replaceColumns.get(key))
res - replaceColumns - public EntityResult replaceColumnByAliasKeepColumns(EntityResult res)
The original keys (and values) are also copied to the result.
res - public Vector replaceAliasByColumn(Vector columns, Vector changedColumns)
columns by the
corresponding columns.
The replaced columns (not the alias) are added to the vector
changedColumns
columns - changedColumns - columns and the columns
corresponding to alias contained in columns, if
any.public Vector replaceAliasByColumn(Vector columns, Hashtable changedColumns)
columns by the
corresponding columns.
The replaced columns and alias are added to the hashtable
changedColumns as a key-value pair in the form
column-alias
columns - changedColumns - columns and the columns
corresponding to alias contained in columns, if
any.public Vector replaceColumnByAlias(Vector columns)
columns by the
corresponding aliases.
The objects with no corresponding aliases are added with no changes.
columns - public void checkFinishedSession(int sessionId)
throws GeneralSecurityException
sessionId - the identifier to checkGeneralSecurityException - if a session is not found for identifier
sessionIdpublic void checkPermissions(int sessionId,
String action)
throws NotInPeriodException,
GeneralSecurityException,
SessionNotFoundException
sessionId has the
permission defined by action
This method calls ServerManager.getServerSecurityManager()
and then, if a manager exists, calls
manager.checkActionPermission(int, String, String)
sessionId - the identifier to checkaction - the action to checkNotInPeriodException - if the action is restricted by time constraintsGeneralSecurityException - it the action is not allowedSessionNotFoundException - if the identifier sessionId has not an
associated session.public void setPrivilegedId(int id)
setPrivilegedId in interface PrivilegedSecurityEntityid - the identifier that will be the privileged one. Must be < 0,
but this is not imposed in this method.public int getPrivilegedId()
getPrivilegedId in interface PrivilegedSecurityEntitypublic Vector getActions() throws Exception
getActions in interface SecureEntityExceptionpublic String getName() throws Exception
entityNamegetName in interface SecureEntityExceptionpublic String getDescription() throws Exception
getName()getDescription in interface SecureEntityExceptionpublic String getQueryTable()
public String getTable()
public static Hashtable processingReferenceDataFieldAttributes(Hashtable keysValues)
keysValues.
Returns a hashtable containing all the objects contained in the argument
keysValues except in the case of keys that are
ReferenceFieldAttribute objects, which are replaced by
((ReferenceFieldAttribute)object).getAttr()
keysValues - the keysValues to processpublic static Vector processingReferenceDataFieldAttributes(Vector list)
list.
Returns a Vector containing all the objects in the argument
list except in the case of keys that are
ReferenceFieldAttribute objects, which are maintained but also
((ReferenceFieldAttribute)object).getAttr() is added
list - the list to processpublic int getQueryRecordNumber(Hashtable keysValues, int sessionId) throws Exception
sessionId.keysValues - the conditions that the records must fulfillsessionId - the session identifierException - if a database error ocurrsprotected int getQueryRecordNumber(String stSQL, Vector vVector, Hashtable validKeysValues, int sessionId, boolean localeInKV, boolean localeTables) throws Exception
sessionId.vVector - validKeysValues - keysValues - the conditions that the records must fulfillsessionId - the session identifierlocaleInKV - Exception - if a database error ocurrspublic long getSize(String transferId) throws Exception
transferId.
getSize in interface FileManagementEntityException - if a transfer for the identifier is not foundpublic String getExtension(String transferId) throws Exception
nullgetExtension in interface FileManagementEntityExceptionpublic String prepareToTransfer(Hashtable keysValues, int sessionId) throws Exception
keysValues identify the record that has associated the file,
and the sessionId identifies the caller user/session.
A checkPermissions() with TableEntity.QUERY_ACTION is
executed, so this action must be granted to the caller.
prepareToTransfer in interface FileManagementEntitykeysValues - the keys-values that identify the record to which the file is
linkedsessionId - the session identifierException - if an error ocurrspublic String prepareToTransfer(String column, Hashtable keysValues, int sessionId) throws Exception
keysValues identify the record that will have associated the
transferred object, and the sessionId identifies the caller
user/session.
A checkPermissions() with TableEntity.QUERY_ACTION is
executed, so this action must be granted to the caller.
prepareToTransfer in interface FileManagementEntitycolumn - the table column that stores the file contents. Must be
VARBINARY or LONGVARBINARY typekeysValues - the keys-values that identify the record to which the file
must be linkedsessionId - the session identifierException - if an error ocurrsprotected boolean isBinaryType(int type)
public String prepareToReceive(String column, Hashtable keysValues, int sessionId) throws Exception
keysValues. The method returns a String identifier for use
when sending new bytes.
prepareToReceive in interface FileManagementEntitycolumn - the table column that will store the file, if it must be
stored in the database, or null if it must be stored in file
systemkeysValues - the keys-values that identify the record to which the file is
linkedsessionId - the caller idException - in an error ocurrs.protected String getAttachmentFileNameForKeys(String fileName, Hashtable keysValues) throws Exception
keysValues.
The file name is generated concatenating the values of this entity's keys
(in the same order as they were defined) in the record identified by
keysValues separated by ATTACHMENT_SEPARATOR
plus a '.' and the extension part of the name fileName.
fileName - the base file name. Cannot be nullkeysValues - the keys-values that identify a recordException - if fileName is null, keysValues is null or empty or a key has
not value in the recordpublic String prepareToReceive(Hashtable kv, String fileName, String fileDescription, int sessionId) throws Exception
prepareToReceive(Hashtable, String, String, String, int) with
null argument for originalFilePathprepareToReceive in interface FileManagementEntityExceptionpublic String prepareToReceive(Hashtable keysValues, String fileName, String originalFilePath, String fileDescription, int sessionId) throws Exception
keysValues. The method returns a String identifier for use
when sending new bytes.
This method performs a query, so QUERY_ACTION must be granted to the caller.
If insertAttachmentAutomatically is true, then a new record
is automatically inserted using the values contained in
keysValues. (So, INSERT_ACTION must be granted.)
The supplied fileName, originalFilePath and
fileDescription will be used when inserting if not null and
attachmentFileNameColumn,
originalAttachmentFileNameColumn and
descriptionAttachmentFileColumn are not null.
If insertAttachmentAutomatically is false, a record must
exist.
prepareToReceive in interface FileManagementEntitykeysValues - the keys-values that identify the record or the new values for
the new recordfileName - the attachment file name. The resulting file name will be the
generated by a call to getAttachmentFileNameForKeys. May be
nulloriginalFilePath - may be nullfileDescription - an optional file description. May be nullsessionId - the caller idException - if attachment file path or attachment filename column are
null for this entity, or an error ocurrspublic BytesBlock getBytes(String transferId, int offset, int length, int sessionId) throws Exception
lengthstarting in offset offset for the
attachment identified by transferId
If offset+length is greater than the file size only file size-offset bytes are returned.
getBytes in interface FileManagementEntitytransferId - the transfer identifieroffset - the start offsetlength - the number of bytes to returnsessionId - the caller identifierException - if a transfer for transferId is not found.public void putBytes(String receivingId, BytesBlock bytesBlock, int sessionId) throws Exception
bytesBlock object at the end
of the file associated with the transfer identified by
receivingId
. If a write error ocurrs, the transfer identified by
receivingId is cancelled.
putBytes in interface FileManagementEntityreceivingId - bytesBlock - sessionId - Exception - if a transfer for receivingId is not found or a
transfer or write error ocurrspublic boolean finishReceiving(String receivingId, int sessionId) throws Exception
receivingId has finished.
This means that the file is complete and the table record associated to this transfer must be updated with the file information (file name, size, etc.)
The transfer identifier is removed from current transfers. If an error ocurrs, the transfer is cancelled.
If the file must be stored in the table this update operation will include also the file contents.
If the record has a previous attachment, this attachment is deleted.
An UPDATE_ACTION must be granted to the caller.
finishReceiving in interface FileManagementEntityreceivingId - the transfer identifiersessionId - the caller identifierException - if an error ocurrs.protected void updateAttachmentValues(Hashtable keysValues, Hashtable attributesValues, int sessionId, Connection connection) throws Exception
Exceptionpublic void cancelReceiving(String receivingId, int sessionId) throws Exception
receivingId.
An UPDATE_ACTION and DELETE_ACTION (if record was created when the transfer started) must be granted to the caller.
The temporal file is deleted and if a record was created is also deleted
cancelReceiving in interface FileManagementEntityreceivingId - the transfer identifierException - if an error ocurrs or if the user has not the rights to
perform the actionprotected String getUser(int sessionId)
sessionId.
This method calls the SecureReferenceLocator getUser(int) method if the locator for this entity is a SecureReferenceLocator. If not, if locator is ReferenceLocator, getUser() is called.
sessionId - public AdvancedEntityResult createAdvancedEntityResultForSessionId(int cod, int type, int sessionId)
sessionId
. Basically this method creates an AdvancedEntityResult and sets its compression threshold.
cod - type - sessionId - public AdvancedEntityResult createAdvancedEntityResultForSessionId(int cod, int type, String message, int sessionId)
sessionId
. Basically this method creates an AdvancedEntityResult and sets its compression threshold.
cod - type - message - sessionId - public EntityResult createEntityResultForSessionId(int cod, int type, String message, int sessionId)
sessionId
. Basically this method creates an EntityResult and sets its compression threshold.
createEntityResultForSessionId in interface UtilEntitycod - type - message - sessionId - public static EntityResult createEntityResultForSessionId(EntityReferenceLocator locator, int cod, int type, String message, int sessionId)
sessionId
. Basically this method creates an EntityResult and sets its compression threshold.
This method uses the suppied EntityReferenceLocator for getting the
compression threshold for the session sessionId
locator - cod - type - message - sessionId - public EntityResult createEntityResultForSessionId(int cod, int type, int sessionId)
sessionId
. Basically this method creates an EntityResult and sets its compression threshold.
createEntityResultForSessionId in interface UtilEntitycod - type - sessionId - public EntityResult createEntityResultForSessionId(int sessionId)
sessionId
. Basically this method creates an EntityResult and sets its compression threshold.
createEntityResultForSessionId in interface UtilEntitysessionId - public EntityResult createEntityResultForSessionId(int sessionId, String operationId)
sessionId
. Basically this method creates an EntityResult and sets its compression threshold.
Also, this method sets the operationId of the EntityResult.
sessionId - public static int generateRandomId()
public static boolean parseStringValue(String v, boolean defaultValue)
value as a boolean.
If the string is 'yes' or 'true', then true is returned, and if is 'no' or 'false', false is returned.
Otherwise, defaultValue is returned.
v - defaultValue - public static String vectorToStringSeparateBySemicolon(Vector list)
list, separated by the ';' characterlist - public Entity getEntityReference(String entityName) throws Exception
entityName.
This method checks if locator for this entity is an instance
of ServerReferenceLocator. If true,
getEntityReferenceFromServer(String) is used instead
getEntityReference(String)
getEntityReference in interface UtilEntityentityName - the entityNameentityNameException - if an error ocurrspublic static int getEntityPrivilegedId(Entity ent)
ent.
For this method to work, ent must be a
PrivilegedSecurityEntity.
In this case, the privileged identifier is got from the Entity object. If it has not been set, a new privileged identifier is generated ramdomly and set in the Entity object. Then, this identifier is returned.
ent - public static Timestamp truncateDateToMinutes(Date date)
date to zero:
Calendar.MILLISECOND,Calendar.SECOND
The default calendar (for the default locale and timezone) is used.
date - date
except the fields set to zero.public static Timestamp truncateDataToHour_00_00_00(Date date)
date to zero:
Calendar.MILLISECOND,Calendar.SECOND,Calendar.MINUTE,Calendar.HOUR_OF_DAY
The default calendar (for the default locale and timezone) is used.
date - date
except the fields set to zero.public static Vector getStringsOn(String s, String separator)
s splitting it using
separator as delimiter. A Vector of Strings is generated.s - the String to parse. May be null. In this case, an empty
Vector is returnedseparator - the delimiter. May be null. In this case, a Vector with only
the String s is returnedprotected void logUpdate(Hashtable attributesValues, Hashtable keysValues, int sessionId)
keysValues and
attributes-values attributesValues
The log is only performed if logUpdate is true.
attributesValues - keysValues - sessionId - protected void logToLogKeys(String s)
s to the corresponding LogWriter. If
logkeys field is null the
LogManager.getDefaultLogWriter() is used to log, if not null.
If logkeys field is not null, for each of the
logkeys, LogManager.getLogWriter(String) is used to log the String
s
s - protected Vector processMultipleTableAttribute(Vector list, Vector processedMultipleAttributes)
list. All other objects are added to the resulting Vector
with no changes. The MultipleTableAttribute objects are replaced by their
attribute plus a list of ExtendedTableAttribute objects corresponding to
the keys of the MultipleTableAttribute object.list - protected EntityResult deleteMultipleTableAttributesColumns(EntityResult result, Vector originalAttributes, Vector processedMultipleAttributes)
res creating TableMultipleValue
objects .result - originalAttributes - protected Hashtable processMultipleTableAttribute(Hashtable av)
av. All other objects are added to the resulting
Vector with no changes. The MultipleTableAttribute objects are replaced
by their attribute.av - protected Hashtable processFileColumnsAttributes(Hashtable av)
av using the
fileInfoList information in this entity.
The DataFile objects contained in av are splitted in
filename and file contents (bytes) as values in the resulting Hashtable
and using the filename column and the file contents column as keys.
If fileInfoList is null in this entity, a clone
of the Hashtable av is returned.
av - protected Vector processFileColumnsAttributes(Vector list)
list using the information in
fileInfoList.
For each object in list that has an associated FileInfo
object, the FileInfo.getColumName() and FileInfo.getFileColumn() strings
are added to the resulting Vector.
If fileInfoList is null in this entity, a clone
of the Hashtable av is returned.
list - a Vectos with a list of attributesprotected EntityResult processFileResults(EntityResult result)
result object using the information in
fileInfoList.
For each TableEntity.FileInfo in fileInfoList, if the columns
that correspond to filenames and to file contents are found in
result, a new DataFile object is added to the result using
as key the FileInfo object's key.
If fileInfoList is null in this entity, a clone
of the Hashtable result is returned.
result - public void addEntityDataChangeListener(EntityDataChangeListener listener)
addEntityDataChangeListener in interface EntityDataChangeNotifierlistener - public void removeEntityDataChangeListener(EntityDataChangeListener listener)
removeEntityDataChangeListener in interface EntityDataChangeNotifierlistener - @Deprecated protected void fireDataChangeEvent(int type, Hashtable keysValues, Hashtable attributesValues)
fireDataChangeEvent(int, Hashtable, Hashtable, int)If a registered listener is an instance of TransactionEntityDataChangeListener, then it is NOT notified.
type - keysValues - attributesValues - protected void fireDataChangeEvent(int type,
Hashtable keysValues,
Hashtable attributesValues,
int sessionId)
If a registered listener is an instance of TransactionEntityDataChangeListener, then it is NOT notified.
type - keysValues - attributesValues - sessionId - identifier of the sessionId of the user that executes the
operation@Deprecated protected void fireTransactionDataChangeEvent(int type, Hashtable kv, Hashtable av, Connection con)
con is provided to the listener.
If a registered listener is NOT an instance of TransactionEntityDataChangeListener, then it is NOT notified.
type - kv - av - con - protected void fireTransactionDataChangeEvent(int type,
Hashtable kv,
Hashtable av,
int sessionId,
Connection con)
con is provided to the listener.
If a registered listener is NOT an instance of TransactionEntityDataChangeListener, then it is NOT notified.
type - kv - av - sessionId - con - public EntityResult query(Hashtable keysValues, Vector attributes, int sessionId, Connection con) throws Exception
This method calls
query(Hashtable, Vector, int, Connection, Vector, boolean) using
null and true as the last two parameters.
query in interface TransactionalEntitykeysValues - attributes - sessionId - con - Exception - if an error ocurrspublic EntityResult query(Hashtable keysValues, Vector attributes, int sessionId, Connection con, Vector orderColumns, boolean ascending) throws Exception
The keysValues object determines the conditions that the
records must fulfill, that is, the WHERE clause.
The attributes object determines the columns for each record
that must be returned, that is, the asked columns.
The sessionId number identifies the session.
The orderColumns object determines the order columns, that
is, the columns to use in the ORDER BY clause.
The ascending boolean determines if the order is ascending
or descending.
When overriding, this method must suppose that the connection provided is not in autocommit mode, so all operations are executed in a transaction. This means that in an error ocurrs this method should throw an Exception to ensure that the calling method is properly notified.
The following methods of this class are called:
keysValues - the conditions. The key-value pairs will be interpreted as
column-value conditions.attributes - if empty, all columns will be returnedsessionId - the caller session identifier. Use privileged identifier for
bypassing restrictions.con - the connection to use when executing the queryorderColumns - the order columns. Can be null.ascending - the ascending/descending orderException - if an error ocurrs or the caller has not permission to
execute the action.protected Vector deleteHOtherLocaleTablesAlias(Vector vValidAttributes)
protected boolean checkLocalesInKV(Vector kvKeys, Hashtable conditions, Vector vLocaleColumns)
protected boolean checkBasicExpresionLocalesInKv(Object actValue, Hashtable gethOtherLocaleTablesColumns)
protected boolean checkBasicExpresionLocalesInKv(Object actValue, Vector getvLocaleColumns)
public Hashtable modifyBexpWithOtherLocaleTableAlias(Hashtable hashtableWithBExp, Vector validAttributes)
public SQLStatementBuilder.BasicExpression modifyBexpWithOtherLocaleTableAlias(SQLStatementBuilder.BasicExpression bexp, Vector validAttributes)
protected Vector checkAvailableLocaleTables(String principalTable) throws Exception
Exceptionprotected boolean checkOtherLocaleTables(Vector attributes)
protected Hashtable getJoinConditions(Vector principalKeyName, String principalTable, Vector secondaryKeyName, String secondaryTable)
protected Vector getSecondaryColumnsWithoutKey(Vector secondaryColumnsNames, Vector secondaryKeyName)
public EntityResult insert(Hashtable attributesValues, int sessionId, Connection con) throws Exception
The attributesValues object determines the columns and
values that will be inserted.
The sessionId number identifies the session.
When overriding, this method must suppose that the connection provided is not in autocommit mode, so all operations are executed in a transaction. This means that in an error ocurrs this method should throw an Exception to ensure that the calling method is properly notified.
The following methods of this class are called:
attributesValues no insert is performed and no error is
produced.
If there is no error, a TransactionDataChangeEvent is fired and all listeners are notified.
insert in interface TransactionalEntityattributesValues - the table columns and corresponding values to insertsessionId - the session identifiercon - the Connection to use when executing the PreparedStatementException - if an error ocurrs or the caller has not permission to
execute the action.protected void insertInLocaleTablesForOneToOne(Hashtable hLocaleColumns, EntityResult erResult, int sessionId, Connection con) throws Exception
Exceptionprotected void insertInLocaleTableLocaleColumns(EntityResult erResult, Hashtable hLocaleColumns, Vector vLocaleColumns, Hashtable hTableLocaleColumns, String table, int sessionId, Connection con) throws Exception
Exceptionprotected Hashtable processColumnsWithoutLocale(Hashtable hValidAttributesValues)
protected Hashtable processValidLocaleColumnsValues(Hashtable hValidAttributesValues, Vector vLocaleColumns)
protected EntityResult insertAutonumericalAlias(EntityResult res)
res.
This is only done if the autonumericalColumn for this entity
is not null and res contains a pair key-value where key is
the autonumerical column and the value is an Integer.
res - res object with a new key-value pair if the
conditions above are metpublic EntityResult update(Hashtable attributesValues, Hashtable keysValues, int sessionId, Connection con) throws Exception
The attributesValues object determines the columns that will
be updated and to which values.
The keysValues object determines the conditions that the
records that will be updated must fulfill, that is, the WHERE clause.
The sessionId number identifies the session.
When overriding, this method must suppose that the connection provided is not in autocommit mode, so all operations are executed in a transaction. This means that in an error ocurrs this method should throw an Exception to ensure that the calling method is properly notified.
The following methods of this class are called:
attributesValues no update is performed and no error is
produced.
If there is no error, a TransactionDataChangeEvent is fired and all listeners are notified.
update in interface TransactionalEntitykeysValues - the table columns and corresponding values to use as
conditions that the records to be updated must fulfillattributesValues - the table columns and corresponding values to insertsessionId - the session identifiercon - the Connection to use when executing the PreparedStatementException - if an error ocurrs or the caller has not permission to
execute the action.protected void updateInLocaleTablesForOneToOne(Hashtable hLocaleColumns, Hashtable hValidKeysValues, EntityResult erResult, int sessionId, Connection con) throws Exception
Exceptionpublic EntityResult delete(Hashtable keysValues, int sessionId, Connection con) throws Exception
The keysValues object determines the conditions that the
records that will be deleted must fulfill, that is, the WHERE clause.
The sessionId number identifies the session.
When overriding, this method must suppose that the connection provided is not in autocommit mode, so all operations are executed in a transaction. This means that in an error ocurrs this method should throw an Exception to ensure that the calling method is properly notified.
The following methods of this class are called:
keysValues no
delete is performed and no error is produced.
If the records to be deleted have attachments, these attachments will
also be deleted. If these attachments are stored on the file system, a
query is performed with keysValues to determine which files
must be deleted.
If there is no error, a TransactionDataChangeEvent is fired and all listeners are notified.
delete in interface TransactionalEntitykeysValues - the table columns and corresponding values to use as
conditions that the records to be deleted must fulfillsessionId - the session identifiercon - the Connection to use when executing the PreparedStatementException - if an error ocurrs or the caller has not permission to
execute the action.protected void deleteLocaleColumns(String localeTableName, Hashtable hValidKeysValues, int sessionId, Connection con) throws Exception
Exceptionprotected void preInsert(Hashtable attributesValues, int sessionId, Connection con) throws Exception
Exceptionprotected void postInsert(EntityResult insertResult, Hashtable attributesValues, int sessionId, Connection con) throws Exception
Exceptionpublic void preUpdate(Hashtable attributesValues, Hashtable keysValues, int sessionId, Connection con) throws Exception
Exceptionpublic void postUpdate(EntityResult updateResult, Hashtable attributesValues, Hashtable keysValues, int sessionId, Connection con) throws Exception
Exceptionpublic void preDelete(Hashtable keysValues, int sessionId, Connection con) throws Exception
Exceptionpublic void postDelete(EntityResult deleteResult, Hashtable keysValues, int sessionId, Connection con) throws Exception
Exceptionpublic Vector getWildCardColumns()
public Vector getUpdateColumns()
public Vector getOrderColumns()
public Vector getDescOrderColumns()
public Vector getColumns()
public String getAutonumericalColumn()
protected EntityResult executeStatement(String sqlSentence, Connection con) throws Exception
sqlSentence
using the connection consqlSentence - the sentence to executecon - the connection to useException - if an error ocurrsprotected Map getSQLTypesFromMetaData(List columns, int sessionId)
columns - sessionId - public Map getColumnListForAvancedQuery(int sessionId) throws Exception
getColumnListForAvancedQuery in interface AdvancedQueryEntitysessionId - the session identifierExceptionprotected Map getTypeFromMetadata(Vector columns, int sessionId)
columns - VectorsessionId - int@Deprecated public Hashtable getSubGroupValues(Hashtable fieldsValues, Vector columns)
getSubGroupValues(Hashtable, Vector, int)fieldsValues that satisfy the condition that key is
contained in columns.fieldsValues - columns - public Hashtable getSubGroupValues(Hashtable fieldsValues, Vector columns, int sessionid)
fieldsValues that satisfy the condition that key is
contained in columns.fieldsValues - columns - sessionid - protected Vector tagAttributesWithoutAlias(Vector attributes, String table, Vector tableColumns, String table2, Vector tableColumns2)
protected Vector filterAttributes(Vector attributes, Vector secondarykeys, Vector primarykeys)
protected Hashtable filterKeys(Hashtable values, Vector secondarykeys, Vector primarykeys)
protected Hashtable tagKeysValues(Hashtable values, String table, Vector tableColumns)
public static Hashtable processingMultipleValueAttributes(Hashtable keysValues)
keysValues.
Returns a new Hashtable with the same data as keysValues
except that MultipleValue objects are deleted and the key-value pairs of
these objects are added to the new Hashtable.keysValues - public boolean deleteAttachmentFile(Hashtable keysValues, int sessionId) throws Exception
deleteAttachmentFile(Hashtable, int, Connection)deleteAttachmentFile in interface FileManagementEntitykeysValues - sessionId - Exceptionpublic boolean deleteAttachmentFile(Hashtable kv, int sessionId, Connection con) throws Exception
attachmentFilePath is not null, this method executes a
query with conditions keysValues and then if one record is
found, searchs the column named attachmentFileNameColumn and
uses the file name found to delete the file in the file system.
This method requires grants for UPDATE_ACTION to session
sessionId
If more than one record is found an Exception is thrown.
After deleting the file, the following fields (if exist) of the database
table are set to null:
attachmentFileNameColumn,originalAttachmentFileNameColumn,descriptionAttachmentFileColumn,attachmentFileSizeColumn
kv - the conditions that identify the record for which the
attachment must be deletedsessionId - the session identifiercon - the connection to use for executing queriesException - if an error ocurrspublic Vector processMultipleAttributeKey(Vector list)
list.
For each MultipleReferenceDataFieldAttribute found, the objects in MultipleReferenceDataFieldAttribute.getCods() are added to the resulting Vector
list - protected String getAttachmentFilePath(Hashtable kv, int sessionId) throws Exception
Exceptionprotected String getAttachmentFilePath(Hashtable kv, int sessionId, Connection con) throws Exception
Exceptionpublic void setName(String name)
setName in interface IdentifiedEntitypublic DatabaseConnectionManager getDatabaseConnectionManager()
protected String getSchemaTable()
protected String getSchemaQueryTable()
public Vector getKeys()
public Vector getInsertKeys()
public Vector getDeleteKeys()
public Vector getUpdateKeys()
protected String getLocaleTableName(String table) throws Exception
Exceptionprotected void insertLocaleColumn(EntityResult res, Hashtable avInterLocalColumns, String table, int sessionId, Connection con) throws Exception
Exceptionprotected void updateLocaleColumns(Hashtable avLocaleColumns, Hashtable kv, String table, int sessionId, Connection con) throws Exception
Exceptionpublic Hashtable getMetadata(int sessionId) throws Exception
getMetadata in interface MetadataEntityExceptionpublic Hashtable gethOtherLocaleTablesColumns()
protected Vector checkAmbiguousColumns(Vector attrWihtoutLocales, String principalTable) throws Exception
Exceptionprotected Hashtable getContidionsWithoutFilterKeys(Hashtable conditions)
protected Hashtable getConditionsWithTablePreffix(Hashtable conditions, Vector attrWihtoutLocales)
protected SQLStatementBuilder.BasicExpression checkConditionsWithTablePreffix(SQLStatementBuilder.BasicExpression filter, Vector attrWihtoutLocales, SQLStatementBuilder.BasicExpression toRet)
Copyright © 2016 Imatia Innovation S.L.. All rights reserved.