com.atlassian.crowd.migration
Class GenericMapper

java.lang.Object
  extended by com.atlassian.crowd.migration.GenericMapper
Direct Known Subclasses:
ApplicationMapper, CrowdPropertiesMapper, DirectoryMapper, GroupMapper, MembershipMapper, PropertyMapper, UserMapper

public class GenericMapper
extends java.lang.Object

A generic mapper that contains helper methods and attributes to map domain objects to database objects and vice-versa.


Field Summary
protected static java.lang.String DATE_FORMAT
           
static java.lang.String GENERIC_XML_ACTIVE
           
static java.lang.String GENERIC_XML_ATTRIBUTE
           
static java.lang.String GENERIC_XML_ATTRIBUTE_NAME
           
static java.lang.String GENERIC_XML_ATTRIBUTE_VALUE
           
static java.lang.String GENERIC_XML_ATTRIBUTES
           
static java.lang.String GENERIC_XML_CREATED_DATE
           
static java.lang.String GENERIC_XML_ID
           
static java.lang.String GENERIC_XML_NAME
           
static java.lang.String GENERIC_XML_UPDATED_DATE
           
static java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_ID
           
static java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_KEY
           
static java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_VALUE
           
static java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_VALUES
           
static java.lang.String LEGACY_GENERIC_XML_CONCEPTION
           
static java.lang.String LEGACY_GENERIC_XML_LASTMODIFIED
           
protected  org.apache.log4j.Logger logger
           
 
Constructor Summary
GenericMapper()
           
 
Method Summary
protected
<T extends java.io.Serializable>
void
addEntities(java.util.List<T> entitiesToPersist)
          Replicates a collection of Hiberanate persistable entities using the batch processor.
protected  void addEntity(java.lang.Object entityToPersist)
          Replicates a Hiberanate persistable entity.
protected  void exportInternalEntity(InternalEntity entity, org.dom4j.Element element)
          Exports an internal entity to an XML element.
protected  void exportSingleValuedAttributes(AttributeAware entity, org.dom4j.Element element)
          Exports Map to an XML element.
protected  java.util.List<Directory> findAllExportableDirectories()
          Finds all directories that have user/group/membership data that need to be exported (ie.
 BatchProcessor getBatchProcessor()
           
protected  java.lang.String getDateAsFormattedString(java.util.Date date)
          Serialises a date/time to String in a standard format.
protected  java.util.Date getDateFromFormattedString(java.lang.String dateString)
          Obtains a date object from a serialised string.
 DirectoryManager getDirectoryManager()
           
protected  InternalEntityTemplate getInternalEntityTemplateFromXml(org.dom4j.Element element)
          Constructs an InternalEntityTemplate from an XML element.
 org.hibernate.SessionFactory getSessionFactory()
           
protected  java.util.Map<java.lang.String,java.lang.String> getSingleValuedAttributesMapFromXml(org.dom4j.Element element)
          Constructs an Map of attributes from an XML element.
 void setBatchProcessor(BatchProcessor batchProcessor)
           
 void setDirectoryManager(DirectoryManager directoryManager)
           
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.log4j.Logger logger

DATE_FORMAT

protected static final java.lang.String DATE_FORMAT
See Also:
Constant Field Values

GENERIC_XML_ID

public static final java.lang.String GENERIC_XML_ID
See Also:
Constant Field Values

GENERIC_XML_NAME

public static final java.lang.String GENERIC_XML_NAME
See Also:
Constant Field Values

GENERIC_XML_CREATED_DATE

public static final java.lang.String GENERIC_XML_CREATED_DATE
See Also:
Constant Field Values

GENERIC_XML_UPDATED_DATE

public static final java.lang.String GENERIC_XML_UPDATED_DATE
See Also:
Constant Field Values

GENERIC_XML_ACTIVE

public static final java.lang.String GENERIC_XML_ACTIVE
See Also:
Constant Field Values

GENERIC_XML_ATTRIBUTES

public static final java.lang.String GENERIC_XML_ATTRIBUTES
See Also:
Constant Field Values

GENERIC_XML_ATTRIBUTE

public static final java.lang.String GENERIC_XML_ATTRIBUTE
See Also:
Constant Field Values

GENERIC_XML_ATTRIBUTE_NAME

public static final java.lang.String GENERIC_XML_ATTRIBUTE_NAME
See Also:
Constant Field Values

GENERIC_XML_ATTRIBUTE_VALUE

public static final java.lang.String GENERIC_XML_ATTRIBUTE_VALUE
See Also:
Constant Field Values

LEGACY_GENERIC_XML_CONCEPTION

public static final java.lang.String LEGACY_GENERIC_XML_CONCEPTION
See Also:
Constant Field Values

LEGACY_GENERIC_XML_LASTMODIFIED

public static final java.lang.String LEGACY_GENERIC_XML_LASTMODIFIED
See Also:
Constant Field Values

LEGACY_GENERIC_XML_ATTRIBUTE_ID

public static final java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_ID
See Also:
Constant Field Values

LEGACY_GENERIC_XML_ATTRIBUTE_VALUES

public static final java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_VALUES
See Also:
Constant Field Values

LEGACY_GENERIC_XML_ATTRIBUTE_VALUE

public static final java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_VALUE
See Also:
Constant Field Values

LEGACY_GENERIC_XML_ATTRIBUTE_KEY

public static final java.lang.String LEGACY_GENERIC_XML_ATTRIBUTE_KEY
See Also:
Constant Field Values
Constructor Detail

GenericMapper

public GenericMapper()
Method Detail

getDateAsFormattedString

protected java.lang.String getDateAsFormattedString(java.util.Date date)
Serialises a date/time to String in a standard format.

Parameters:
date - date to serialise.
Returns:
serialised date.

getDateFromFormattedString

protected java.util.Date getDateFromFormattedString(java.lang.String dateString)
Obtains a date object from a serialised string.

Parameters:
dateString - serialised string.
Returns:
date object.

exportInternalEntity

protected void exportInternalEntity(InternalEntity entity,
                                    org.dom4j.Element element)
Exports an internal entity to an XML element.

This exports: id, name, createdDate, updatedDate and active.

Parameters:
entity - entity to export.
element - XML element to export to.

exportSingleValuedAttributes

protected void exportSingleValuedAttributes(AttributeAware entity,
                                            org.dom4j.Element element)
Exports Map to an XML element.

Only use this for entities with simple attributes (Directory, Application) and not complex attributes (User, Group).

Parameters:
entity - entity with single valued attributes.
element - XML element to export to.

getInternalEntityTemplateFromXml

protected InternalEntityTemplate getInternalEntityTemplateFromXml(org.dom4j.Element element)
Constructs an InternalEntityTemplate from an XML element.

This imports: id, name, createdDate, updatedDate and active.

Parameters:
element - XML element to import from.
Returns:
InternalEntityTemplate holding the values.

getSingleValuedAttributesMapFromXml

protected java.util.Map<java.lang.String,java.lang.String> getSingleValuedAttributesMapFromXml(org.dom4j.Element element)
Constructs an Map of attributes from an XML element.

This imports attributes with single values.

Parameters:
element - XML element to import from.
Returns:
Map holding the attributes.

findAllExportableDirectories

protected java.util.List<Directory> findAllExportableDirectories()
Finds all directories that have user/group/membership data that need to be exported (ie. Internal + Delegating).

Returns:
list of directories that require exporting internal data.

addEntity

protected void addEntity(java.lang.Object entityToPersist)
                  throws java.sql.SQLException
Replicates a Hiberanate persistable entity.

Parameters:
entityToPersist - entity to replicate.
Throws:
java.sql.SQLException - error persisting.

addEntities

protected <T extends java.io.Serializable> void addEntities(java.util.List<T> entitiesToPersist)
                    throws java.sql.SQLException
Replicates a collection of Hiberanate persistable entities using the batch processor.

Parameters:
entitiesToPersist - entity to replicate.
Throws:
java.sql.SQLException - error persisting.

getDirectoryManager

public DirectoryManager getDirectoryManager()

setDirectoryManager

public void setDirectoryManager(DirectoryManager directoryManager)

getSessionFactory

public org.hibernate.SessionFactory getSessionFactory()

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)

getBatchProcessor

public BatchProcessor getBatchProcessor()

setBatchProcessor

public void setBatchProcessor(BatchProcessor batchProcessor)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.