Package com.atlassian.bamboo.migration
Class BambooStAXMappingHelperAbstractImpl<T,I extends T>
- java.lang.Object
-
- com.atlassian.bamboo.migration.BambooStAXMappingHelperAbstractImpl<T,I>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
BambooStAXMappingHelper<T,I>
- Direct Known Subclasses:
BambooStAXMappingListHelperAbstractImpl
,BuildDefinitionMapper
,BuildNumberMapper
,DeploymentProjectPropertiesMapper
,DeploymentResultPropertiesMapper
,DeploymentVersionPropertiesMapper
,EnvironmentCustomConfigMapper
,EnvironmentPropertiesMapper
,NotificationRuleMapper
,NotificationSetMapper
,RequirementMapper
,RequirementSetMapper
,ServerIDMapper
,SharedCapabilityMapper
,VariableContextBaselinePropertiesMapper
,VersionNamingSchemeMapper
public abstract class BambooStAXMappingHelperAbstractImpl<T,I extends T> extends Object implements BambooStAXMappingHelper<T,I>
Skeleton implementation of StAX based export-import helper class The XML representation of such an object is:valueOfPropertyA valueOfPropertyB ...
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.migration.BambooStAXMappingHelper
BambooStAXMappingHelper.None
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.transaction.support.TransactionOperations
transactionOperations
-
Constructor Summary
Constructors Modifier Constructor Description protected
BambooStAXMappingHelperAbstractImpl(org.hibernate.SessionFactory sessionFactory, org.springframework.transaction.support.TransactionOperations transactionOperations)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract I
createItemInstance(org.codehaus.staxmate.in.SMInputCursor inputCursor)
Creates empty instance of the imported objectprotected @NotNull org.codehaus.staxmate.out.SMOutputElement
createRootElement(@NotNull org.codehaus.staxmate.out.SMOutputElement outputElement)
Create root node for the exported object.protected void
exportProperties(@NotNull org.codehaus.staxmate.out.SMOutputElement outputElement, T object, @NotNull org.hibernate.Session session, ExportDetailsBean exportDetailsBean)
Export object properties.protected void
exportXml(@NotNull org.codehaus.staxmate.out.SMOutputElement outputElement, T object, ExportDetailsBean exportDetailsBean)
Implementation of object export.void
exportXml(@NotNull org.hibernate.Session session, @NotNull org.codehaus.staxmate.out.SMOutputElement outputElement, T object, ExportDetailsBean exportDetailsBean)
Implementation of object export.protected org.hibernate.Session
getSession()
Get the Hibernate sessionorg.hibernate.SessionFactory
getSessionFactory()
@NotNull String
getXmlRootNodeName()
Returns local name of the XML parent node that will contain exported/imported object's propertiesprotected void
importProperties(I object, @NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor, @NotNull org.hibernate.Session session)
Import properties to the object.protected I
importXml(@NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor)
Object import.I
importXml(@NotNull org.hibernate.Session session, @NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor)
Implementation of object import.boolean
isShouldExport(@NotNull ExportDetailsBean exportDetailsBean)
protected void
saveBambooObject(@NotNull org.hibernate.Session session, @NotNull BambooIdProvider object)
Save object without regenerating the id if already assigned.
-
-
-
Method Detail
-
getXmlRootNodeName
@NotNull public @NotNull String getXmlRootNodeName()
Description copied from interface:BambooStAXMappingHelper
Returns local name of the XML parent node that will contain exported/imported object's properties- Specified by:
getXmlRootNodeName
in interfaceBambooStAXMappingHelper<T,I extends T>
- Returns:
- local name of the XML parent node
-
isShouldExport
public boolean isShouldExport(@NotNull @NotNull ExportDetailsBean exportDetailsBean)
-
exportProperties
protected void exportProperties(@NotNull @NotNull org.codehaus.staxmate.out.SMOutputElement outputElement, @NotNull T object, @NotNull @NotNull org.hibernate.Session session, ExportDetailsBean exportDetailsBean) throws Exception
Export object properties. Implementing classed should override this method to export custom properties.- Parameters:
outputElement
- the parent nodeobject
- object being exportedsession
- Hibernate session objectexportDetailsBean
-- Throws:
Exception
- when something went wrong
-
exportXml
protected final void exportXml(@NotNull @NotNull org.codehaus.staxmate.out.SMOutputElement outputElement, @NotNull T object, ExportDetailsBean exportDetailsBean) throws Exception
Implementation of object export. This base implementation is usually sufficient: it creates the root node and calls exportProperties.- Parameters:
outputElement
- an element at which exporter should create a node to export dataobject
- object being exportedexportDetailsBean
-- Throws:
Exception
- when something went wrong
-
exportXml
public void exportXml(@NotNull @NotNull org.hibernate.Session session, @NotNull @NotNull org.codehaus.staxmate.out.SMOutputElement outputElement, @NotNull T object, ExportDetailsBean exportDetailsBean) throws Exception
Implementation of object export. This base implementation is usually sufficient: it creates the root node and calls exportProperties.- Specified by:
exportXml
in interfaceBambooStAXMappingHelper<T,I extends T>
- Parameters:
session
- Hibernate session objectoutputElement
- an element at which exporter should create a node to export dataobject
- object being exportedexportDetailsBean
-- Throws:
Exception
- when something went wrong
-
createItemInstance
@NotNull protected abstract I createItemInstance(org.codehaus.staxmate.in.SMInputCursor inputCursor) throws Exception
Creates empty instance of the imported object- Parameters:
inputCursor
- input cursor that points to the parent node containing object properties- Returns:
- empty instance of the imported object
- Throws:
XMLStreamException
- when something went wrongException
-
importProperties
protected void importProperties(@NotNull I object, @NotNull @NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor, @NotNull @NotNull org.hibernate.Session session) throws Exception
Import properties to the object. Due to nature of XML parsing this method is called for each child node in the node that was passed to importXml method- Parameters:
object
- object being importedinputCursor
- input cursor pointing to the child node of node that was passed to importXml methodsession
- Hibernate session object- Throws:
Exception
- when something went wrong
-
importXml
@NotNull protected final I importXml(@NotNull @NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor) throws Exception
Object import.- Parameters:
inputCursor
- input cursor that points to the parent node containing object properties- Returns:
- an imported object
- Throws:
Exception
- when something went wrong
-
importXml
@NotNull public I importXml(@NotNull @NotNull org.hibernate.Session session, @NotNull @NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor) throws Exception
Implementation of object import. This base implementation is usually sufficient: - create the imported object instance - iterate over child nodes on input node and for each of them call importProperties method
-
createRootElement
@NotNull protected @NotNull org.codehaus.staxmate.out.SMOutputElement createRootElement(@NotNull @NotNull org.codehaus.staxmate.out.SMOutputElement outputElement) throws XMLStreamException
Create root node for the exported object.- Parameters:
outputElement
- parent node for the object's root node- Returns:
- SMOutputElement representing newly created object's root node
- Throws:
XMLStreamException
- when something went wrong
-
saveBambooObject
protected void saveBambooObject(@NotNull @NotNull org.hibernate.Session session, @NotNull @NotNull BambooIdProvider object) throws org.hibernate.HibernateException
Save object without regenerating the id if already assigned.- Parameters:
session
- Hibernate session objectobject
- object to be saved- Throws:
org.hibernate.HibernateException
- when save operation failed
-
getSession
protected org.hibernate.Session getSession()
Get the Hibernate session- Returns:
- Hibernate session object
-
getSessionFactory
public org.hibernate.SessionFactory getSessionFactory()
-
-