package com.handong.smartservice.component;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RcTreeLocation extends RcTree {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public static List<Map<String, Object>> convertDb2RcTree(List<Map<String, Object>> listTreeDb) {
        RcTree rcTree = new RcTreeLocation();
        return rcTree.convert(listTreeDb);
    }

    @Override
    protected Map<String, Object> makeNewNode(Map<String, Object> item) {
        Map<String, Object> newNode = new LinkedHashMap<String, Object>();

        String location = item.get("location_id").toString();
        newNode.put("key", location);
        logger.debug("key(biz_group_id): " + location);

        String name = (String)item.get("name");
        newNode.put("name", name);

        String description = (String)item.get("description");
        newNode.put("description", description);            
        
        newNode.put("title", name);
        logger.debug("title: " + name);

        Timestamp reg_time = (Timestamp)item.get("reg_time");
        if (reg_time != null)
            newNode.put("reg_time", reg_time);

        String address = (String)item.get("address");
        if (address != null)
            newNode.put("address", address);

        newNode.put("isLeaf", false);
            
        return newNode;
    }
}
