Ontimize 5.2072EN

com.ontimize.db
Class MemoryEntity

java.lang.Object
  extended bycom.ontimize.db.MemoryEntity
All Implemented Interfaces:
Entity, java.rmi.Remote

public class MemoryEntity
extends java.lang.Object
implements Entity

Implements an entity that execute all operations in the machine memory. This class must no be used in remote way

Title:

Description:

Copyright: Copyright (c) 2002

Company:

Version:
1.0

Field Summary
protected  java.util.Properties alias
           
protected  java.lang.String autonumericalColumn
           
protected  java.util.Vector columnNames
           
protected  EntityResult data
           
static boolean DEBUG
           
protected  java.util.Vector deleteKeys
           
protected  java.util.Vector descSortColumns
           
protected  java.lang.String entityName
           
protected  java.util.Vector insertColumns
           
protected  java.util.Vector insertKeys
           
protected  java.util.Vector keys
           
protected  EntityReferenceLocator locator
           
protected  java.util.Vector otherEntities
           
protected  int privilegedId
           
protected  int queryOtherEntitiesLimit
           
protected  java.util.Hashtable reverseAlias
           
protected  java.util.Vector sortColumns
           
protected  java.util.Vector updateColumns
           
protected  java.util.Vector updateKeys
           
protected  java.util.Vector wildcardColumns
           
 
Constructor Summary
MemoryEntity(EntityReferenceLocator referenceLocator)
           
 
Method Summary
 void checkDeleteKeys(java.util.Hashtable filterKeys)
           
 void checkInsertKeys(java.util.Hashtable attributesValues)
           
 void checkUpdateKeys(java.util.Hashtable filterKeys)
           
 EntityResult delete(java.util.Hashtable keys, int sessionId)
          This method must implement a standard delete operation over the set of records defined by keysValues.
 java.lang.String getAliasForColumn(java.lang.String columnName)
           
 java.lang.String getColumnForAlias(java.lang.String alias)
           
 java.util.Vector getValidAttributes(java.util.Vector attributes)
           
 java.util.Hashtable getValidDeletingKeysValues(java.util.Hashtable filterKeys)
           
 java.util.Hashtable getValidInsertingAttributesValues(java.util.Hashtable attributesValues)
           
 java.util.Hashtable getValidQueryingKeysValues(java.util.Hashtable filterKeys)
           
 java.util.Hashtable getValidUpdatingAttributesValues(java.util.Hashtable attributesValues)
           
 java.util.Hashtable getValidUpdatingKeysValues(java.util.Hashtable filterKeys)
           
 EntityResult insert(java.util.Hashtable attributes, int sessionId)
          This method must implement a standard insert operation with the data contained in attributesValues parameter.
protected  void loadAliasFile()
          Read the alias property file.
static java.util.Hashtable processReferenceDataFieldAttributes(java.util.Hashtable kv)
          Process the reference data field attributes ( ReferenceFieldAttribute).
static java.util.Vector processReferenceDataFieldAttributes(java.util.Vector referenceDataFieldAttributes)
          Process the ReferenceFieldAttribute objects.
 EntityResult query(java.util.Hashtable keys, java.util.Vector attributes, int sessionId)
          This method must implement a standard query operation returning the set of data that matches the conditions specified by the keysValues parameter.
 AdvancedEntityResult query(java.util.Hashtable keys, java.util.Vector attributes, int startIndex, int number, java.lang.String orderBy, int sessionId)
           
 void readProperties()
          Reads the property file associated to the entity.
protected  void readProperties(java.lang.String path)
           
 EntityResult replaceAliasByColumn(EntityResult res)
          This method replaces the name of the database columns with the correspondant alias, so that the result has the same names to those queried by the client.
 java.util.Hashtable replaceAliasByColumn(java.util.Hashtable hash)
           
 java.util.Vector replaceAliasByColumn(java.util.Vector vect, java.util.Vector changedColumns)
           
 EntityResult replaceColumnByAlias(EntityResult res, java.util.Vector replacedColumnNames)
           
 java.util.Hashtable replaceColumnByAlias(java.util.Hashtable hash)
           
 java.util.Vector replaceColumnByAlias(java.util.Vector vect)
           
 EntityResult replaceColumnByAliasKeepColumns(EntityResult res)
           
 EntityResult update(java.util.Hashtable attributes, java.util.Hashtable keys, int sessionId)
          This method must implement a standard update operation with the data specified in attributesValues over the set of records defined by keysValues.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

data

protected EntityResult data

columnNames

protected java.util.Vector columnNames

keys

protected java.util.Vector keys

insertKeys

protected java.util.Vector insertKeys

deleteKeys

protected java.util.Vector deleteKeys

updateKeys

protected java.util.Vector updateKeys

updateColumns

protected java.util.Vector updateColumns

autonumericalColumn

protected java.lang.String autonumericalColumn

insertColumns

protected java.util.Vector insertColumns

wildcardColumns

protected java.util.Vector wildcardColumns

sortColumns

protected java.util.Vector sortColumns

descSortColumns

protected java.util.Vector descSortColumns

otherEntities

protected java.util.Vector otherEntities

locator

protected EntityReferenceLocator locator

queryOtherEntitiesLimit

protected int queryOtherEntitiesLimit

alias

protected java.util.Properties alias

reverseAlias

protected java.util.Hashtable reverseAlias

entityName

protected java.lang.String entityName

privilegedId

protected int privilegedId
Constructor Detail

MemoryEntity

public MemoryEntity(EntityReferenceLocator referenceLocator)
             throws java.lang.Exception
Method Detail

loadAliasFile

protected void loadAliasFile()
Read the alias property file. This file has the same name as entity property file with the suffix '_alias'


readProperties

public void readProperties()
                    throws java.lang.Exception
Reads the property file associated to the entity. The name of the file must be the name of the class and it has to be located on a subfolder (relative to the class) called 'prop'.
File format:
Every name is a database column name, neither having alias or not.
- 'Columns' key: Query columns. Each column name is separated by ;
- 'InsertColumns' key: C Possible insert columns. If this parameter isn't specified, then 'Columns' value is used
- 'Keys' key: entity keys
- 'InsertKeys' key: c Valid and mandatory insert keys
- 'DeleteKeys': Valid and mandatory delete keys
- 'UpdateKeys' Valid and mandatory update keys
- 'UpdateColumns" key: Possible update columns
- 'OtherEntities' key: Specifies the names of the other entities that are going to be queried when querying this on. if the parameter isn't specified, then all entities are included.
- 'LimitQueryOtherEntities' key: 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

Throws:
java.lang.Exception

readProperties

protected void readProperties(java.lang.String path)
                       throws java.lang.Exception
Throws:
java.lang.Exception

processReferenceDataFieldAttributes

public static java.util.Hashtable processReferenceDataFieldAttributes(java.util.Hashtable kv)
Process the reference data field attributes ( ReferenceFieldAttribute).
This method is called for update and insert methods to know the name of the column associated to the ReferenceFieldAttribute

Parameters:
kv -
Returns:
This object is similar to kv paramer, but the keys of ReferenceFielAttribute type are replaced by ReferenceFieldAttribute.getAttr()

checkInsertKeys

public void checkInsertKeys(java.util.Hashtable attributesValues)
                     throws java.lang.Exception
Throws:
java.lang.Exception

checkUpdateKeys

public void checkUpdateKeys(java.util.Hashtable filterKeys)
                     throws java.lang.Exception
Throws:
java.lang.Exception

checkDeleteKeys

public void checkDeleteKeys(java.util.Hashtable filterKeys)
                     throws java.lang.Exception
Throws:
java.lang.Exception

getAliasForColumn

public java.lang.String getAliasForColumn(java.lang.String columnName)

getColumnForAlias

public java.lang.String getColumnForAlias(java.lang.String alias)

replaceAliasByColumn

public java.util.Hashtable replaceAliasByColumn(java.util.Hashtable hash)

replaceColumnByAlias

public java.util.Hashtable replaceColumnByAlias(java.util.Hashtable hash)

replaceAliasByColumn

public EntityResult replaceAliasByColumn(EntityResult res)
This method replaces the name of the database columns with the correspondant alias, so that the result has the same names to those queried by the client.
I.e. the client asks for the alias and, if possible, must receive alias..

Parameters:
res -
Returns:

replaceColumnByAlias

public EntityResult replaceColumnByAlias(EntityResult res,
                                         java.util.Vector replacedColumnNames)

replaceColumnByAliasKeepColumns

public EntityResult replaceColumnByAliasKeepColumns(EntityResult res)

replaceAliasByColumn

public java.util.Vector replaceAliasByColumn(java.util.Vector vect,
                                             java.util.Vector changedColumns)

replaceColumnByAlias

public java.util.Vector replaceColumnByAlias(java.util.Vector vect)

getValidAttributes

public java.util.Vector getValidAttributes(java.util.Vector attributes)

getValidQueryingKeysValues

public java.util.Hashtable getValidQueryingKeysValues(java.util.Hashtable filterKeys)

getValidInsertingAttributesValues

public java.util.Hashtable getValidInsertingAttributesValues(java.util.Hashtable attributesValues)

getValidUpdatingAttributesValues

public java.util.Hashtable getValidUpdatingAttributesValues(java.util.Hashtable attributesValues)

getValidUpdatingKeysValues

public java.util.Hashtable getValidUpdatingKeysValues(java.util.Hashtable filterKeys)

getValidDeletingKeysValues

public java.util.Hashtable getValidDeletingKeysValues(java.util.Hashtable filterKeys)

processReferenceDataFieldAttributes

public static java.util.Vector processReferenceDataFieldAttributes(java.util.Vector referenceDataFieldAttributes)
Process the ReferenceFieldAttribute objects. Creates a vector equals to the entry parameter and add to it the ReferenceFieldAttribute.getAttr() for all object of ReferenceFieldAttribute type.

Parameters:
referenceDataFieldAttributes -
Returns:

query

public AdvancedEntityResult query(java.util.Hashtable keys,
                                  java.util.Vector attributes,
                                  int startIndex,
                                  int number,
                                  java.lang.String orderBy,
                                  int sessionId)
                           throws java.lang.Exception
Throws:
java.lang.Exception

query

public EntityResult query(java.util.Hashtable keys,
                          java.util.Vector attributes,
                          int sessionId)
                   throws java.lang.Exception
Description copied from interface: Entity
This method must implement a standard query operation returning the set of data that matches the conditions specified by the 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.

Specified by:
query in interface Entity
Parameters:
keys - a Hashtable specifying conditions that must comply the set of records returned. Cannot be null.
attributes - a list of columns or attributes that must be recovered for each record returned. Cannot be null. If empty, all attributes should be returned.
sessionId - a integer identifying the user or session that performs the action.
Returns:
a EntityResult with the resulting set of data. This result can be empty if no results exist, and if an error has ocurred this will be indicated in the result.
Throws:
java.lang.Exception - if any exception occurs

insert

public EntityResult insert(java.util.Hashtable attributes,
                           int sessionId)
                    throws java.lang.Exception
Description copied from interface: Entity
This method must implement a standard insert operation with the data contained in attributesValues parameter.

Specified by:
insert in interface Entity
Parameters:
attributes - 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.
Returns:
a EntityResult. This result will have an error code if error has ocurred.
Throws:
java.lang.Exception - if any exception occurs

update

public EntityResult update(java.util.Hashtable attributes,
                           java.util.Hashtable keys,
                           int sessionId)
                    throws java.lang.Exception
Description copied from interface: Entity
This method must implement a standard update operation with the data specified in 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.

Specified by:
update in interface Entity
Parameters:
attributes - the data for updating the records to. The keys specify the attributes (or columns) and the values, the values for these columns.
keys - 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.
Returns:
a EntityResult. This result will have an error code if error has occurred.
Throws:
java.lang.Exception - if any exception occurs

delete

public EntityResult delete(java.util.Hashtable keys,
                           int sessionId)
                    throws java.lang.Exception
Description copied from interface: Entity
This method must implement a standard delete operation over the set of records defined by keysValues. So, only the records that comply with the conditions specified by keysValues will be deleted.

Specified by:
delete in interface Entity
Parameters:
keys - 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.
Returns:
a EntityResult. This result will have an error code if error has occurred.
Throws:
java.lang.Exception - if any exception occurs

Ontimize