package com.yihu.hos.crawler.model.adapter;

import com.yihu.hos.crawler.format.AdapterBase;
import com.yihu.hos.standard.model.adapter.AdapterDictEntryModel;
import com.yihu.hos.standard.model.adapter.AdapterDictModel;
import com.yihu.hos.standard.service.bo.AdapterVersion;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Air
 * @version 1.0
 * @created 2015.08.11 11:31
 */
public class AdapterDict extends AdapterBase {

    private AdapterDictModel adapterDictModel;
    private AdapterDictModel adapterDictT;
    private Map<String, String> adapterValueToCodeMap;
    private Map<String, String> adapterCodeToCodeMap;
    public AdapterDict(AdapterDictModel adapterDictModel, AdapterVersion adapterVersion, Map<Integer, List<AdapterDictEntryModel>> entryMap) {
        this.adapterDictModel = adapterDictModel;
        this.adapterDictT = adapterDictModel;
        prepareData(entryMap);
    }

    public void prepareData(Map<Integer, List<AdapterDictEntryModel>> entryMap) {
        adapterValueToCodeMap = new HashMap<>();
        adapterCodeToCodeMap = new HashMap<>();
        List<AdapterDictEntryModel> adapterDictEntryModelList = entryMap.get(adapterDictModel.getStdDictId());
        for (AdapterDictEntryModel adapterDictEntryModel : adapterDictEntryModelList) {
            adapterValueToCodeMap.put(adapterDictEntryModel.getStdEntryValue(), adapterDictEntryModel.getAdapterEntryCode());
            adapterCodeToCodeMap.put(adapterDictEntryModel.getStdEntryCode(), adapterDictEntryModel.getAdapterEntryCode());
        }
    }

    public Map<String, String> getAdapterValueToCodeMap() {
        return adapterValueToCodeMap;
    }

    public Map<String, String> getAdapterCodeToCodeMap() {
        return adapterCodeToCodeMap;
    }
}
