package com.yihu.hos.crawler.format;

import com.yihu.hos.web.framework.util.springutil.SpringBeanUtil;
import com.yihu.hos.standard.model.adapter.AdapterSchemeVersionModel;
import com.yihu.hos.standard.service.adapter.*;
import com.yihu.hos.standard.service.bo.AdapterVersion;
import com.yihu.hos.standard.service.standard.StdDictEntryService;
import com.yihu.hos.standard.service.standard.StdDictService;

import javax.annotation.Resource;

/**
 * 适配器基类,DAO缓存
 *
 * @created Created by Air on 2015/6/10.
 */
public class AdapterBase {
    @Resource(name = AdapterDatasetService.BEAN_ID)
    private AdapterDatasetService adapterDatasetService;
    @Resource(name = AdapterSchemeVersionService.BEAN_ID)
    private AdapterSchemeVersionService adapterSchemeVersionService;
    @Resource(name = AdapterMetadataService.BEAN_ID)
    private AdapterMetadataService adapterMetadataService;
    @Resource(name = AdapterDictEntryService.BEAN_ID)
    private AdapterDictEntryService adapterDictEntryService;
    @Resource(name = AdapterDictService.BEAN_ID)
    private AdapterDictService adapterDictService;
    @Resource(name =StdDictEntryService.BEAN_ID )
    private StdDictEntryService stdDictEntryService;
    @Resource(name =StdDictService.BEAN_ID )
    private StdDictService stdDictService;


    protected AdapterVersion adapterVersion;


    public AdapterVersion getAdapterVersion() {
        AdapterSchemeVersionModel adapterSchemeVersionModel = getAdapterSchemeVersionService().getEhrAdapterVersionLasted();
        if (adapterSchemeVersionModel == null) {
            adapterSchemeVersionModel=new AdapterSchemeVersionModel();
        }
        String version = adapterSchemeVersionModel.getVersion();
         adapterVersion = new AdapterVersion(version);
        return adapterVersion;
    }

    public AdapterDatasetService getAdapterDatasetService() {
        if (adapterDatasetService == null) {
            adapterDatasetService = SpringBeanUtil.getService(AdapterDatasetService.BEAN_ID);
        }
        return adapterDatasetService;
    }

    public AdapterSchemeVersionService getAdapterSchemeVersionService() {
        if (adapterSchemeVersionService == null) {
            adapterSchemeVersionService = SpringBeanUtil.getService(AdapterSchemeVersionService.BEAN_ID);
        }
        return adapterSchemeVersionService;
    }

    public AdapterMetadataService getAdapterMetadataService() {
        if (adapterMetadataService == null) {
            adapterMetadataService = SpringBeanUtil.getService(AdapterMetadataService.BEAN_ID);
        }
        return adapterMetadataService;
    }

    public AdapterDictService getAdapterDictService() {
        if (adapterDictService == null) {
            adapterDictService = SpringBeanUtil.getService(AdapterDictService.BEAN_ID);
        }
        return adapterDictService;
    }

    public AdapterDictEntryService getAdapterDictEntryService() {
        if (adapterDictEntryService == null) {
            adapterDictEntryService = SpringBeanUtil.getService(AdapterDictEntryService.BEAN_ID);
        }
        return adapterDictEntryService;
    }

    public StdDictEntryService getStdDictEntryService() {
        if (stdDictEntryService == null) {
            stdDictEntryService = SpringBeanUtil.getService(StdDictEntryService.BEAN_ID);
        }
        return stdDictEntryService;
    }

    public StdDictService getStdDictService() {
        if (stdDictService == null) {
            stdDictService = SpringBeanUtil.getService(StdDictService.BEAN_ID);
        }
        return stdDictService;
    }
}
