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 final org.springframework.transaction.support.TransactionOperations
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BambooStAXMappingHelperAbstractImpl(org.hibernate.SessionFactory sessionFactory, org.springframework.transaction.support.TransactionOperations transactionOperations)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract I
    createItemInstance(org.codehaus.staxmate.in.SMInputCursor inputCursor)
    Creates empty instance of the imported object
    protected @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 final 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
    Get the Hibernate session
    org.hibernate.SessionFactory
     
    @NotNull String
    Returns local name of the XML parent node that will contain exported/imported object's properties
    protected void
    importProperties(I object, @NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor, @NotNull org.hibernate.Session session)
    Import properties to the object.
    protected final I
    importXml(@NotNull org.codehaus.staxmate.in.SMInputCursor inputCursor)
    Object import.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • transactionOperations

      protected final org.springframework.transaction.support.TransactionOperations transactionOperations
  • Constructor Details

    • BambooStAXMappingHelperAbstractImpl

      protected BambooStAXMappingHelperAbstractImpl(org.hibernate.SessionFactory sessionFactory, org.springframework.transaction.support.TransactionOperations transactionOperations)
  • Method Details

    • 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 interface BambooStAXMappingHelper<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 node
      object - object being exported
      session - Hibernate session object
      exportDetailsBean -
      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 data
      object - object being exported
      exportDetailsBean -
      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 interface BambooStAXMappingHelper<T,I extends T>
      Parameters:
      session - Hibernate session object
      outputElement - an element at which exporter should create a node to export data
      object - object being exported
      exportDetailsBean -
      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 wrong
      Exception
    • 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 imported
      inputCursor - input cursor pointing to the child node of node that was passed to importXml method
      session - 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
      Specified by:
      importXml in interface BambooStAXMappingHelper<T,I extends T>
      Parameters:
      session - Hibernate session object
      inputCursor - a cursor that points to the parent node containing object properties
      Returns:
      an imported object
      Throws:
      Exception - when something went wrong
    • 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 object
      object - 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()