package com.yihu.hos.standard.match.matchModel;

import com.yihu.hos.standard.model.adapter.AdapterMetadataModel;
import com.yihu.hos.standard.model.standard.StdMetaDataModel;
import com.yihu.hos.standard.util.GetChineseFirst;

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

/**
 * Created by Administrator on 2016/6/29.
 */
public class MetadataMatchVO {
    private Map<String, List<AdapterMetadataModel>> codeAdapter = new HashMap<String, List<AdapterMetadataModel>>();

    private Map<String, StdMetaDataModel> orgMetadata = new HashMap<String, StdMetaDataModel>();

    public Map<String, List<AdapterMetadataModel>> getCodeAdapter() {
        return codeAdapter;
    }

    public void setCodeAdapter(Map<String, List<AdapterMetadataModel>> codeAdapter) {
        this.codeAdapter = codeAdapter;
    }

    /**
     * 根据name的首字母分组
     *
     * @param stdeAdapterMetadatas
     * @return
     */
    public Map<String, List<AdapterMetadataModel>> geNameGroup(List<AdapterMetadataModel> stdeAdapterMetadatas) {
        Map<String, List<AdapterMetadataModel>> returnMap = new HashMap<String, List<AdapterMetadataModel>>();
        for (AdapterMetadataModel stdeAdapterMetadata : stdeAdapterMetadatas) {
            String firstCode = GetChineseFirst.cn2py(stdeAdapterMetadata.getStdMetadataName());
            List<AdapterMetadataModel> temp = returnMap.get(firstCode);
            if (temp != null) {
                temp.add(stdeAdapterMetadata);
            } else {
                temp = new ArrayList<AdapterMetadataModel>();
                temp.add(stdeAdapterMetadata);
            }
            returnMap.put(firstCode, temp);
        }
        return returnMap;
    }

    public Map<String, StdMetaDataModel> getOrgMetadata() {
        return orgMetadata;
    }

    public void setOrgMetadata(Map<String, StdMetaDataModel> orgMetadata) {
        this.orgMetadata = orgMetadata;
    }
}
