Package com.atlassian.crowd.migration
Class GenericMapper
java.lang.Object
com.atlassian.crowd.migration.GenericMapper
- Direct Known Subclasses:
ApplicationSamlConfigurationEntityMapper
,DatabaseMapper
,GenericLegacyImporter
,SAMLTrustEntityMapper
,XmlMapper
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
protected static interface
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final CrowdBackupDateConverter
static final String
protected final org.slf4j.Logger
protected static final String
-
Constructor Summary
ConstructorDescriptionGenericMapper
(org.hibernate.SessionFactory sessionFactory, BatchProcessor batchProcessor) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> void
addEntities
(List<T> entitiesToPersist, HibernateOperation<org.hibernate.Session> hibernateOperation) Replicates a collection of Hibernate persistable entities using the batch processor.protected <T> void
addEntitiesViaMerge
(List<T> entitiesToPersist) Replicates a collection of Hibernate persistable entities using the batch processor.protected <T> void
addEntitiesViaReplicate
(List<T> entitiesToPersist) Replicates a collection of Hibernate persistable entities using the batch processor.protected <T extends Serializable,
E extends Serializable>
voidaddEntity
(TransactionGroup<T, E> entitiesToPersist) Replicates a collection of Hibernate persistable entities using the batch processor.protected void
Replicates a Hibernate persistable entity.protected Object
addEntityViaMerge
(Object entityToPersist) Replicates a Hibernate persistable entity.protected Object
addEntityViaSave
(Object entityToPersist) Replicates a Hibernate persistable entity.protected void
protected <T> org.dom4j.Element
exportXml
(List<T> elements, String collectionName, String elementName, GenericMapper.Exporter<T> exporter) protected String
protected Boolean
getBoolean
(org.dom4j.Element parent, String name) protected boolean
getBoolean
(org.dom4j.Element parent, String name, boolean defaultValue) getDateConverterForXml
(org.dom4j.Element root) protected Date
getDateFromTimestamp
(org.dom4j.Element parent, String name) protected DirectoryType
getDirectoryTypeFromLegacyCode
(int code) protected Long
protected String
getNameFromLegacyCode
(String codeName) protected OperationType
protected <T> Optional<T>
getOptionalValue
(org.dom4j.Element parent, String name, Function<String, T> transformer) org.hibernate.SessionFactory
protected String
protected <T> T
<T> List<T>
importXml
(org.dom4j.Element root, String collectionName, GenericMapper.Importer<T> importer) protected void
protected <T> void
protected void
setTimestamp
(org.dom4j.Element parent, String name, Date date)
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
LEGACY_XML_DATE_FORMAT
- See Also:
-
DATABASE_DATE_FORMAT
- See Also:
-
PLUGIN_KEY_PREFIX
- See Also:
-
DATE_CONVERTER_FOR_EXPORT
-
-
Constructor Details
-
GenericMapper
-
-
Method Details
-
getDateConverterForXml
- Parameters:
root
- the root element of the XML- Returns:
- the appropriate date parser for the dates used across the given XML
-
addEntity
Replicates a Hibernate persistable entity.- Parameters:
entityToPersist
- entity to replicate.- Throws:
ImportException
-
addEntities
protected <T> void addEntities(List<T> entitiesToPersist, HibernateOperation<org.hibernate.Session> hibernateOperation) throws org.hibernate.HibernateException Replicates a collection of Hibernate persistable entities using the batch processor.- Parameters:
entitiesToPersist
- entity to replicate.hibernateOperation
- the operation to perform on the entities- Throws:
org.hibernate.HibernateException
-
addEntitiesViaReplicate
protected <T> void addEntitiesViaReplicate(List<T> entitiesToPersist) throws org.hibernate.HibernateException Replicates a collection of Hibernate persistable entities using the batch processor.- Parameters:
entitiesToPersist
- entity to replicate.- Throws:
org.hibernate.HibernateException
-
addEntitiesViaMerge
protected <T> void addEntitiesViaMerge(List<T> entitiesToPersist) throws org.hibernate.HibernateException Replicates a collection of Hibernate persistable entities using the batch processor.- Parameters:
entitiesToPersist
- entity to replicate.- Throws:
org.hibernate.HibernateException
-
addEntity
protected <T extends Serializable,E extends Serializable> void addEntity(TransactionGroup<T, E> entitiesToPersist) throws org.hibernate.HibernateExceptionReplicates a collection of Hibernate persistable entities using the batch processor.- Parameters:
entitiesToPersist
- transaction group containing primary and dependent entities.- Throws:
org.hibernate.HibernateException
-
addEntityViaMerge
Replicates a Hibernate persistable entity.- Parameters:
entityToPersist
- entity to replicate.- Throws:
ImportException
- error persisting.
-
addEntityViaSave
Replicates a Hibernate persistable entity.- Parameters:
entityToPersist
- entity to replicate.- Throws:
ImportException
- error persisting.
-
getDateFromTimestamp
-
getLong
-
setTimestamp
-
setCDATA
-
setText
-
getValue
-
getOptionalValue
-
getBoolean
-
getBoolean
-
getString
-
exportXml
protected <T> org.dom4j.Element exportXml(List<T> elements, String collectionName, String elementName, GenericMapper.Exporter<T> exporter) throws ExportException - Throws:
ExportException
-
importXml
public <T> List<T> importXml(org.dom4j.Element root, String collectionName, GenericMapper.Importer<T> importer) throws ImportException - Throws:
ImportException
-
getSessionFactory
public org.hibernate.SessionFactory getSessionFactory() -
getOperationTypeFromLegacyPermissionName
-
getAttributeValue
-
getDirectoryTypeFromLegacyCode
-
getNameFromLegacyCode
-
clearSession
protected void clearSession()
-