/*
 * blanco Framework
 * Copyright (C) 2004-2005 IGA Tosiki
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 */
package blanco.db.expander.query;

import blanco.ig.expander.IgType;
import blanco.ig.expander.IgValue;
import blanco.ig.expander.Type;
import blanco.ig.expander.implementor.Implementor;
import blanco.ig.expander.method.IgConstructor;

/**
 * @author Yasuo Nakanishi
 */
public class QueryConstructor2DotNet extends IgConstructor {
    private IgValue _connectinonArgument = new IgValue(new IgType(
            "System.Data.SqlClient.SqlConnection"), "connection");

    private IgValue _transactionArgument = new IgValue(new IgType(
            "System.Data.SqlClient.SqlTransaction"), "transaction");

    public QueryConstructor2DotNet(final Type type) {
        super(type.getName());
    }

    public void setupSignature() {
        addArgument(_connectinonArgument);
        addArgument(_transactionArgument);

        getJavaDoc().addLine(getName() + "クラスのコンストラクタです。");
        getJavaDoc().addLine("※注意：クラスを利用後、最後に必ずClose()メソッドを呼び出す必要があります。");
        getJavaDoc().addParameter(_connectinonArgument.getName(), "データベース接続");
        getJavaDoc().addParameter(_transactionArgument.getName(),
                "データベーストランザクション");
    }

    public void implement() {
        final Implementor implementor = new Implementor(getData());

        final IgValue connectionField = new IgValue(new IgType(
                "System.Data.SqlClient.SqlConnection"), "fConnection");
        final IgValue transactionField = new IgValue(new IgType(
                "System.Data.SqlClient.SqlTransaction"), "fTransaction");
        implementor.assign(connectionField, _connectinonArgument);
        implementor.assign(transactionField, _transactionArgument);
    }
}