"""Konwertuje plik xml do obiektu root i root do obiektu xml
"""
from Mapa_PU.swdl.model.scheme import RootElement
from Mapa_PU.swdl.kontroler.header_converter import HeaderConverter
from Mapa_PU.swdl.kontroler.forest_data_set_converter import ForestDataSetConverter
from Mapa_PU.swdl.kontroler.forest_global_data_converter import ForestGlobalDataConverter
from Mapa_PU.swdl.model.swdl.swdl import Swdl


"""Klasa budująca dzrzewo Xml
"""
class SwdlObjectConverter():
    
    def __init__(self,HeaderConverter,ForestDataSetConverter):
        self.__hc=HeaderConverter
        self.__fdsc=ForestDataSetConverter
        
    
    def create_swdl(self,swdl):
        ##Generuje drzewo xml na podstawie obiektu swdl
        try:
            root=RootElement()
            #header_converter=HeaderConverter()
            
            #dodanie naglówka
            root.append(self.__hc.create_header(swdl.header))
            
            #dodanie danych
            root.append(self.__fdsc.create_forest_data_set(swdl))
           
            return root
        except Exception as e:
            raise e
#             print(e)