001/*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016package org.opengion.plugin.table;
017
018/**
019 * TableFilter_INDEX_HSQLDB は、TableUpda インターフェースを継承した、DBTableModel 処理用の
020 * 実装クラスです。とくに、HSQLDB用のインデックス作成スクリプトを作成します。
021 *
022 * ここでは、テーブル一覧の検索結果より、GF07 のインデックスカラム定義テーブルから
023 * 必要な情報を取得し、テーブル作成スクリプトを作成します。
024 * 出力ファイルは、テーブル名+"I.sql" という命名規則で作成します。
025 * 検索では、(SYSTEM_ID,TBLSYU,TABLE_NAME,NAME_JA,TABLESPACE_NAME,INITIAL_EXTENT,NEXT_EXTENT,COMMENTS)
026 * の項目を取得する必要があります。
027 *
028 * @og.rev 4.0.0.0 (2005/08/31) 新規作成
029 *
030 * @version  0.9.0  2000/10/17
031 * @author   Kazuhiko Hasegawa
032 * @since    JDK1.1,
033 */
034public class TableFilter_INDEX_HSQLDB extends TableFilter_INDEX {
035        //* このプログラムのVERSION文字列を設定します。   {@value} */
036        private static final String VERSION = "5.7.2.0 (2014/01/10)" ;
037
038        // 5.7.2.0 (2014/01/10) 特別処理 isXml=true の時に、UNIQ のため、処理しなかった場合は、EXEC_END_TAG を出さない。
039        private boolean useUniq = false;
040
041        /**
042         * インデックス作成の処理を実行します。
043         *
044         * ただし、UNIQ と UNIQSEQ には、IDENTITY を付けている為、PRIMARY KEY 制約を付けません。
045         *
046         * @og.rev 5.7.2.0 (2014/01/10) テーブル作成時に、IDENTITY を付けている場合は、PRIMARY KEY 制約を付けない。
047         *
048         * @param       clmNo   カラム番号配列
049         * @param       data    1行分のデータ配列
050         * @param   clms        カラム名(CSV形式)
051         *
052         * @return      作成された1行分の文字列
053         */
054        @Override
055        protected String makeLineList( final int[] clmNo,final String[] data,final String clms ) {
056
057                // 5.7.2.0 (2014/01/10) IDENTITY を付ける条件と同じ判定基準を使います。
058                // ※ useUniq フラグは、makeEndLine メソッドの条件判定にも使います。
059                useUniq = ( "UNIQ".equalsIgnoreCase( clms ) || "UNIQSEQ".equalsIgnoreCase( clms ) );
060
061                return (useUniq) ? "" : super.makeLineList( clmNo,data,clms );
062        }
063
064        /**
065         * 定義の最後の部分の処理を実行します。
066         *
067         * @og.rev 5.7.2.0 (2014/01/10) UNIQ カラムで、処理しなかった場合は、EXEC_END_TAG を出さない。
068         *
069         * @param       clmNo   カラム番号配列
070         * @param       data    1行分のデータ配列
071         *
072         * @return      定義の最後の部分
073         */
074        @Override
075        protected String makeEndLine( final int[] clmNo,final String[] data ) {
076//              return ";";
077//              return ( isXml ? EXEC_END_TAG : ";" );
078
079                return (useUniq) ? "" : ( isXml ? EXEC_END_TAG : ";" );
080
081        }
082}