Class BambooStAXMappingHelperAbstractImpl<T,​I extends T>

    • 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 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 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 session
      org.hibernate.SessionFactory getSessionFactory()  
      @NotNull String getXmlRootNodeName()
      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 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.
    • Field Detail

      • transactionOperations

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

      • BambooStAXMappingHelperAbstractImpl

        protected BambooStAXMappingHelperAbstractImpl​(org.hibernate.SessionFactory sessionFactory,
                                                      org.springframework.transaction.support.TransactionOperations transactionOperations)
    • 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 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()