org.jlf.dataMap
Class DataLocation

java.lang.Object
  |
  +--org.jlf.dataMap.DataLocation
Direct Known Subclasses:
HTTPRequestDataLocation

public class DataLocation
extends java.lang.Object

This class is used as the base of all data locations in the data mapping framework. A data location could be a JDBC data source, an XML file, a properties file, or any other source/sink of data. Data Locations are configured in a separate property file with the same name as the data location alias. You can override the name of the property file in the main application property file with a key of org.jlf.dataMap.DataLocation..DataMapPropertyFile and a value equal to the property file name. For example, if you want to hard-code the property file name for the default data location, use an entry like the following in the main application property file:

 org.jlf.dataMap.DataLocation.DefaultDataLocation.DataMapPropertyFile=c:\properties\DefaultDataLocation.properties
 
An example data map property file for a JDBC data mapper to an Oracle database follows:
 ##########################################################
 # Properties to connect to a default data location
 # using a JDBC Data Source/Sink.
 # Using an Oracle database, the thin type 4 driver, on
 # machine testHost, database SID testdb
 # user scott, password tiger

 # Identify which framework class will create this type of mapper
 DataMapperClass=org.jlf.dataMap.JDBCDataMapper

 # Identify properties to connect to that location
 ConnectionProperties.DriverClass=oracle.jdbc.driver.OracleDriver
 ConnectionProperties.DatabaseURL=jdbc:oracle:thin:@testhost:1521:testdb
 ConnectionProperties.user=scott
 ConnectionProperties.password=tiger

 # Add properties here to map attributes and relationships to the data location

 

See Also:
DataMapper, DataMappedObject

Field Summary
protected static java.lang.String ATTRIBUTE_ALIAS_PROPERTY_QUALIFIER
          Property qualifier to find an attribute alias if one is defined for a specific DataMappedObject class.
protected static boolean CASCADE_WRITE_RELATIONSHIP_PROPERTY_DEFAULT
           
protected static java.lang.String CASCADE_WRITE_RELATIONSHIP_PROPERTY_QUALIFIER
          Property qualifier to see if, when writing a data mapped object, that a particular relationship of that data mapped object should be written in the same unit of work.
protected  java.util.Properties connectionProperties
          Holds properties used to configure a connection to the data location.
static java.lang.String DATA_LOCATION_PROPERTY_FILE_PREFIX_PROPERTY
          All properties in the main property file must have this property file prefix in order to get connection information to the data location.
protected static java.lang.String DATA_MAP_CONNECTION_PROPERTY_PREFIX
          Property qualifier to find all of the connection properties in the data map property file.
static java.lang.String DATA_MAP_PROPERTY_FILE_SUFFIX_PROPERTY
          Property suffix for retrieving the DataLocation subclass of the requested data location.
protected static java.lang.String DATA_MAPPER_CLASS_PROPERTY
          Property key for the subclass of DataMapper which implements the data mapping capabilities for this data location.
protected static boolean INLINE_RELATIONSHIP_PROPERTY_DEFAULT
           
protected static java.lang.String INLINE_RELATIONSHIP_PROPERTY_QUALIFIER
          Property qualifier to find relationship inline read mapping information for a specific DataMappedObject class/relationship.
protected static boolean LAZY_READ_RELATIONSHIP_PROPERTY_DEFAULT
           
protected static java.lang.String LAZY_READ_RELATIONSHIP_PROPERTY_QUALIFIER
          Property qualifier to find relationship lazy read information for a specific DataMappedObject class/relationship.
protected  DataLocationProperties mappingProperties
          Holds properties used to map objects to/from the data location.
protected  java.lang.String name
          Name of the data location, used as the key into the main properties file to find the location's set of properties.
static java.lang.String RELATIONSHIP_PROPERTY_QUALIFIER
          Property qualifier to find relationship mapping information for a specific DataMappedObject class.
 
Constructor Summary
protected DataLocation()
          Please use the parameterized constructor!
  DataLocation(java.lang.String name, DataLocationProperties mappingProperties)
          Typical constructor for a new DataLocation, taking the name of the DataLocation and a property file containing all of its properties.
 
Method Summary
 java.lang.String getAttributeAlias(DataMappedObject dmo, java.lang.String attributeName, Relationship relationship)
          Retrieves an attribute alias if one is defined in the data location mapping properties under the context of a particular relationship if available.
 java.util.Properties getConnectionProperties()
          Retrieves properties used to configure a connection to the data location.
 DataMapper getDataMapper()
          Obtains a DataMapper so data can be mapped back and forth to DataMappedObjects.
 DataLocationProperties getMappingProperties()
          Retrieves properties used to configure a connection to the data location.
 java.lang.String getName()
          Retrieves the key name of the data location.
 boolean isInlineReadRelationship(DataMappedObject dmo, Relationship relationship)
          Retrieves boolean flag telling whether the relationship is to be read inline (that is, in the same query) as the parent object governing the relationship.
 boolean isRelationshipLazyRead(DataMappedObject dmo, Relationship relationship)
          Retrieves a boolean flag as to whether the data mapped object relationship is to be lazy read or not.
static DataLocation retrieveLocationForKey(java.lang.String locationKey)
          Retrieves a DataLocation for a key, looking at the main properties file to see what type it is, then instantiating based on that type.
protected  void setConnectionProperties(java.util.Properties connectionProperties)
          Sets the key name of the data location.
protected  void setMappingProperties(DataLocationProperties mappingProperties)
          Sets the key name of the data location.
protected  void setName(java.lang.String name)
          Sets the key name of the data location.
 boolean shouldCascadeWriteRelationship(DataMappedObject dmo, Relationship relationship)
          Retrieves boolean flag telling whether the relationship should do an automatic cascade write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_LOCATION_PROPERTY_FILE_PREFIX_PROPERTY

public static final java.lang.String DATA_LOCATION_PROPERTY_FILE_PREFIX_PROPERTY
All properties in the main property file must have this property file prefix in order to get connection information to the data location. This prefix is concatenated with to the data location key to find its properties.

See Also:
Constant Field Values

DATA_MAP_PROPERTY_FILE_SUFFIX_PROPERTY

public static final java.lang.String DATA_MAP_PROPERTY_FILE_SUFFIX_PROPERTY
Property suffix for retrieving the DataLocation subclass of the requested data location.

See Also:
Constant Field Values

DATA_MAPPER_CLASS_PROPERTY

protected static final java.lang.String DATA_MAPPER_CLASS_PROPERTY
Property key for the subclass of DataMapper which implements the data mapping capabilities for this data location.

See Also:
Constant Field Values

DATA_MAP_CONNECTION_PROPERTY_PREFIX

protected static final java.lang.String DATA_MAP_CONNECTION_PROPERTY_PREFIX
Property qualifier to find all of the connection properties in the data map property file.

See Also:
Constant Field Values

ATTRIBUTE_ALIAS_PROPERTY_QUALIFIER

protected static final java.lang.String ATTRIBUTE_ALIAS_PROPERTY_QUALIFIER
Property qualifier to find an attribute alias if one is defined for a specific DataMappedObject class.

See Also:
Constant Field Values

RELATIONSHIP_PROPERTY_QUALIFIER

public static final java.lang.String RELATIONSHIP_PROPERTY_QUALIFIER
Property qualifier to find relationship mapping information for a specific DataMappedObject class.

See Also:
Constant Field Values

name

protected java.lang.String name
Name of the data location, used as the key into the main properties file to find the location's set of properties.


connectionProperties

protected java.util.Properties connectionProperties
Holds properties used to configure a connection to the data location.


mappingProperties

protected DataLocationProperties mappingProperties
Holds properties used to map objects to/from the data location.


INLINE_RELATIONSHIP_PROPERTY_QUALIFIER

protected static final java.lang.String INLINE_RELATIONSHIP_PROPERTY_QUALIFIER
Property qualifier to find relationship inline read mapping information for a specific DataMappedObject class/relationship. If this property is set to false (the default), this relationship will be read as a separate query. If true, the relationship will be populated from information in the same query as the primary object.

See Also:
Constant Field Values

INLINE_RELATIONSHIP_PROPERTY_DEFAULT

protected static final boolean INLINE_RELATIONSHIP_PROPERTY_DEFAULT
See Also:
Constant Field Values

LAZY_READ_RELATIONSHIP_PROPERTY_QUALIFIER

protected static final java.lang.String LAZY_READ_RELATIONSHIP_PROPERTY_QUALIFIER
Property qualifier to find relationship lazy read information for a specific DataMappedObject class/relationship. This property only takes effect if the above property, inline reads, is set to false. If the relationship requires a new read from the data location, for performance you may wish to do this read lazy (unless the object is cached). If this property is set to true (the default), this relationship will be read in the first time it is accessed. If false, the relationship will be populated before the object holding the relationship is returned as being read.

See Also:
Constant Field Values

LAZY_READ_RELATIONSHIP_PROPERTY_DEFAULT

protected static final boolean LAZY_READ_RELATIONSHIP_PROPERTY_DEFAULT
See Also:
Constant Field Values

CASCADE_WRITE_RELATIONSHIP_PROPERTY_QUALIFIER

protected static final java.lang.String CASCADE_WRITE_RELATIONSHIP_PROPERTY_QUALIFIER
Property qualifier to see if, when writing a data mapped object, that a particular relationship of that data mapped object should be written in the same unit of work.

See Also:
Constant Field Values

CASCADE_WRITE_RELATIONSHIP_PROPERTY_DEFAULT

protected static final boolean CASCADE_WRITE_RELATIONSHIP_PROPERTY_DEFAULT
See Also:
Constant Field Values
Constructor Detail

DataLocation

protected DataLocation()
Please use the parameterized constructor!


DataLocation

public DataLocation(java.lang.String name,
                    DataLocationProperties mappingProperties)
Typical constructor for a new DataLocation, taking the name of the DataLocation and a property file containing all of its properties.

Method Detail

retrieveLocationForKey

public static DataLocation retrieveLocationForKey(java.lang.String locationKey)
Retrieves a DataLocation for a key, looking at the main properties file to see what type it is, then instantiating based on that type.


getName

public java.lang.String getName()
Retrieves the key name of the data location.


setName

protected void setName(java.lang.String name)
Sets the key name of the data location.


getConnectionProperties

public java.util.Properties getConnectionProperties()
Retrieves properties used to configure a connection to the data location.


setConnectionProperties

protected void setConnectionProperties(java.util.Properties connectionProperties)
Sets the key name of the data location.


getMappingProperties

public DataLocationProperties getMappingProperties()
Retrieves properties used to configure a connection to the data location.


setMappingProperties

protected void setMappingProperties(DataLocationProperties mappingProperties)
Sets the key name of the data location.


getDataMapper

public DataMapper getDataMapper()
Obtains a DataMapper so data can be mapped back and forth to DataMappedObjects. Uses a data mapped location property file setting to determine which subclass of DataMapper is the correct class to retrieve a mapper to the data location.


getAttributeAlias

public java.lang.String getAttributeAlias(DataMappedObject dmo,
                                          java.lang.String attributeName,
                                          Relationship relationship)
Retrieves an attribute alias if one is defined in the data location mapping properties under the context of a particular relationship if available. If the relationship is null, the data is read directly from the array with mapping properties taken into account. If no alias is found, returns the attribute name given as input.


isInlineReadRelationship

public boolean isInlineReadRelationship(DataMappedObject dmo,
                                        Relationship relationship)
Retrieves boolean flag telling whether the relationship is to be read inline (that is, in the same query) as the parent object governing the relationship.


isRelationshipLazyRead

public boolean isRelationshipLazyRead(DataMappedObject dmo,
                                      Relationship relationship)
Retrieves a boolean flag as to whether the data mapped object relationship is to be lazy read or not. This flag only makes sense if the relationship is not read inline (see isInlineReadRelationship() method). If the relationship is not read inline, then it will require another read from the data location to populate. This read can be done in the context of reading the data mapped object, or it can be done lazy, or read in the first time the relationship is accessed.


shouldCascadeWriteRelationship

public boolean shouldCascadeWriteRelationship(DataMappedObject dmo,
                                              Relationship relationship)
Retrieves boolean flag telling whether the relationship should do an automatic cascade write.