"""moduł konwersji części drzewa forestDataSet
"""
import uuid
from Mapa_PU.swdl.model.scheme import TreeElement
from Mapa_PU.swdl.model.tags import Tags
from Mapa_PU.swdl.model.swdl.swdl import Swdl
"""Klasa konwertujaca obiekty ForestDataDesc, ForestData i ForestGlobalData do drzewa Xml
"""
class ForestDataSetConverter():
    
    def __init__(self,ForestDataDescConverter,ForestDataConverter,ForestGlobalDataConverter,ForestMapNoSFConverter,ForestNaturalValuesConverter):
        self.__fddc=ForestDataDescConverter
        self.__fdc=ForestDataConverter
        self.__fgdc=ForestGlobalDataConverter
        self.__fmnsfc=ForestMapNoSFConverter
        self.__fnvc=ForestNaturalValuesConverter
    
    def create_forest_data_set(self,swdl):
        try:
            
            #utworzenie drzewa forestDataSet
            fds=TreeElement(Tags.FOREST_DATA_SET.value)
            fds.set(Tags.UID.value,'_{}'.format(uuid.uuid1()))
            
            #dodanie gałezi forestDataDesc
            fds.append(self.__fddc.create_forest_data_desc(swdl.forest_data_desc))
            
            #dodanie gałęzi forestData
            fds.append(self.__fdc.create_forest_data(swdl.subarea_data_list))
            
            #dodanie gałęzi forestGlobalData
            fds.append(self.__fgdc.create_global_data(swdl.forest_global_data))
            
            #dodanie gałęzi forestMapNoSF
            fds.append(self.__fmnsfc.create_forest_map_no_sf(swdl.forest_map_no_sf))
            
            #dodanie gałęzi forestNaturalValues
            fds.append(self.__fnvc.create_forest_natural_values(swdl.forest_natural_values))
            
            return fds
        except Exception as e:
            raise e