テンプレートファイルインポートサービスの実装クラス。 
package service.impl;
import java.util.ArrayList;
import java.util.List;
import service.DomainDrivenService;
import service.ImportTemplateFileService;
import service.param.ServiceInputParameter;
import service.param.ServiceOutputParameter;
import service.param.SipImportTemplateFileService;
import service.param.SopImportTemplateFileService;
import util.CopyUtil;
import domain.TextConvertDefDomain;
import domain.TextConvertDefRepository;
import dto.TextConvertDefDto;
import entity.TextConvertDef;
/**
 * テンプレートファイルインポートサービス(実装)
 */
public class ImportTemplateFileServiceImpl implements DomainDrivenService,
        ImportTemplateFileService {
    /** テキスト変換定義リポジトリ */
    private TextConvertDefRepository textConvertDefRepository = null;
    public TextConvertDefRepository getTextConvertDefRepository() {
        return textConvertDefRepository;
    }
    public void setTextConvertDefRepository(
            TextConvertDefRepository textConvertDefRepository) {
        this.textConvertDefRepository = textConvertDefRepository;
    }
    @Override
    public ServiceOutputParameter doService(ServiceInputParameter sip) {
        // 入力パラメータからメタデータDTOを取得する
        TextConvertDefDto textConvertDefDto = ((SipImportTemplateFileService) sip)
                .getTextConvertDefDto();
        // サービスを実行する
        List<Integer> textConvertDevIdList = doService(textConvertDefDto);
        // サービス出力パラメータを作成する
        SopImportTemplateFileService sop = new SopImportTemplateFileService(
                textConvertDevIdList);
        // 出力パラメータを作成し、呼び出し側に戻す
        return sop;
    }
    /*
     * (非 Javadoc)
     * 
     * @see service.ImportTemplateFileService#doService(dto.TextConvertDefDto)
     */
    @Override
    public List<Integer> doService(TextConvertDefDto textConvertDefDto) {
        // テンプレートファイルの内容をインポートする
        TextConvertDef textConvertDef = new TextConvertDef();
        CopyUtil.copy(textConvertDefDto, textConvertDef);
        List<TextConvertDefDomain> textConvertDefDomainList = textConvertDefRepository
                .importTemplateFile(textConvertDef);
        // 新規作成されたテキスト変換定義のテキスト変換定義IDを呼び出し側に戻す
        List<Integer> idList = new ArrayList<Integer>();
        for (TextConvertDefDomain textConvertDefDomain : textConvertDefDomainList) {
            idList.add(textConvertDefDomain.getEntity().getTextConvertDefId());
        }
        return idList;
    }
}
0 件のコメント:
コメントを投稿