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 018import org.opengion.fukurou.system.OgBuilder ; // 6.4.4.1 (2016/03/18) 019 020/** 021 * TableFilter_INDEX_FIREBIRD は、TableUpda インターフェースを継承した、DBTableModel 処理用の 022 * 実装クラスです。とくに、FireBird用のインデックス作成スクリプトを作成します。 023 * 024 * ここでは、テーブル一覧の検索結果より、GF07 のインデックスカラム定義テーブルから 025 * 必要な情報を取得し、テーブル作成スクリプトを作成します。 026 * 出力ファイルは、テーブル名+"I.sql" という命名規則で作成します。 027 * 検索では、(SYSTEM_ID,TBLSYU,TABLE_NAME,TABLE_LABEL,INDEX_NAME,NAME_JA,INDTYPE,TABLESPACE_NAME,INITIAL_EXTENT) 028 * の項目を取得する必要があります。 029 * 030 * @og.rev 5.1.1.0 (2009/12/01) 新規作成 031 * 032 * @version 0.9.0 2000/10/17 033 * @author Kazuhiko Hasegawa 034 * @since JDK1.1, 035 */ 036public class TableFilter_INDEX_FIREBIRD extends TableFilter_INDEX { 037 /** このプログラムのVERSION文字列を設定します。 {@value} */ 038 private static final String VERSION = "6.4.4.1 (2016/03/18)" ; 039 040 /** 041 * デフォルトコンストラクター 042 * 043 * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor. 044 */ 045 public TableFilter_INDEX_FIREBIRD() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 046 047 /** 048 * インデックス作成の処理を実行します。 049 * 050 * @og.rev 5.6.9.2 (2013/10/18) プライマリキーの指定があった時の処理を追加 051 * @og.rev 6.4.4.1 (2016/03/18) StringBuilderの代わりに、OgBuilderを使用する。 052 * 053 * @param clmNo カラム番号配列 054 * @param data 1行分のデータ配列 055 * @param clms カラム名(CSV形式) 056 * 057 * @return インデックス作成 058 * @og.rtnNotNull 059 */ 060 @Override 061 protected String makeLineList( final int[] clmNo,final String[] data,final String clms ) { 062 final String tableName = data[clmNo[TABLE_NAME]]; 063 final String indexName = data[clmNo[INDEX_NAME]]; 064 final String idxtype = data[clmNo[INDTYPE]]; 065 066 return new OgBuilder() 067 .appendCR() // 先頭に、改行を入れておきます。 068 .appendIfCR( isXml , EXEC_START_TAG ) 069 .appendCase( "0".equals( idxtype ) || "1".equals( idxtype ) // 0:プライマリキー、1:ユニークキー 070 , "CREATE UNIQUE INDEX " // true : 0:プライマリキー、1:ユニークキー 071 , "CREATE INDEX " ) // false: 2:通常 072 .append( indexName , " ON " , tableName , "( " , clms , " )" ) 073 .toString(); 074 } 075 076 /** 077 * 定義の最後の部分の処理を実行します。 078 * 079 * @og.rev 6.0.2.3 (2014/10/10) EXEC_END_TAG を追加。キャッシュします。 080 * 081 * @param clmNo カラム番号配列 082 * @param data 1行分のデータ配列 083 * 084 * @return 定義の最後の部分 085 */ 086 @Override 087 protected String makeEndLine( final int[] clmNo,final String[] data ) { 088 return execEndTag ; 089 } 090}