"""Modul pomocniczy do tworzenia obiektu forestDataDesc
"""
from Mapa_PU.swdl.model.swdl.forest_data_desc import InventoryData,ForestDataDesc
from Mapa_PU.swdl.model.swdl.supervisor_info import SupervisorInfo

"""klasa pomocnicza forestDataDesc
"""
class ForestDataDescHelper():
    
    def __init__(self,database_helper):
        self.__database_helper=database_helper
        
    
    def create_inventory_data(self):
        try:
            ##obiekt z danymi inventaryzacyjnymi
            sql='SELECT ObjectFullName, TAXATION_YEAR, S_OrgName, S_Street, S_City, S_Code, S_Country, S_Phone, S_Fax, S_Email, DS_OrgName, DS_Street, DS_City, DS_Code, DS_Country, DS_Phone, DS_Fax, DS_Email FROM F_PARAMETER'
            self.__database_helper.open()
            data=self.__database_helper.get_data(sql)
            supervisor=[SupervisorInfo(s[2],None,s[3],s[4],s[5],s[6],s[7],s[8],s[9]) for s in data]
            delegated_supervisor=[SupervisorInfo(s[10],None,s[11],s[12],s[13],s[14],s[15],s[16],s[17]) for s in data]
            
            inventory_data=[InventoryData(ObjectFullName,TAXATION_YEAR,supervisor[0],delegated_supervisor[0]) for ObjectFullName,TAXATION_YEAR,*arg in data][0]
            return inventory_data
        except Exception as e:
            raise e
        finally:
            self.__database_helper.close()
    
         
    def create_forest_data_desc(self,address_forest,state_date,invent_executor=None):
        ##Obiekt ForestDataDesc
        #invent_executor nie wystepuje w module uruchamianym przez mapa pu. Ten element idzie z maina ?
        return ForestDataDesc(address_forest,state_date,invent_executor,self.create_inventory_data())    