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 */
016 package org.opengion.plugin.table;
017
018 /**
019 * TableFilter_INDEX_FIREBIRD は、TableUpda インターフェースを継承した、DBTableModel 処?の
020 * 実?ラスです?とくに、FireBird用のイン?クス作?スクリプトを作?します?
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 5.1.1.0 (2009/12/01) 新規作?
029 *
030 * @version 0.9.0 2000/10/17
031 * @author Kazuhiko Hasegawa
032 * @since JDK1.1,
033 */
034 public class TableFilter_INDEX_FIREBIRD extends TableFilter_INDEX {
035 //* こ?プログラ??VERSION??を設定します? {@value} */
036 private static final String VERSION = "5.6.9.2 (2013/10/18)" ;
037
038 /**
039 * イン?クス作?の処?実行します?
040 *
041 * @og.rev 5.6.9.2 (2013/10/18) プライマリキーの?があった時の処?追?
042 *
043 * @param clmNo カラ?号配?
044 * @param data ?行?の??タ配?
045 * @param clms カラ?(CSV形?
046 *
047 * @return イン?クス作?
048 */
049 @Override
050 protected String makeLineList( final int[] clmNo,final String[] data,final String clms ) {
051 String tableName = data[clmNo[TABLE_NAME]];
052 String indexName = data[clmNo[INDEX_NAME]];
053 String idxtype = data[clmNo[INDTYPE]];
054
055 StringBuilder buf = new StringBuilder();
056
057 buf.append( CR ); // 先?に、改行を入れておきます?
058 if( isXml ) { buf.append( EXEC_START_TAG ).append( CR ); }
059
060 // 5.6.9.2 (2013/10/18) プライマリキーの??今まで、else に飛んで??
061 // if( "1".equals( idxtype ) ) { // ユニ?クキー
062 if( "0".equals( idxtype ) || "1".equals( idxtype ) ) { // 0:プライマリキー?:ユニ?クキー
063 buf.append( "CREATE UNIQUE INDEX " ).append( indexName ).append( " ON " );
064 buf.append( tableName ).append( "( " ).append( clms );
065 buf.append( " )" );
066 }
067 // 5.6.9.2 (2013/10/18) INDTYPE で、その他ではなく?2:通常 で判断する?
068 else if( "2".equals( idxtype ) ) { // 2:通常
069 buf.append( "CREATE INDEX " ).append( indexName ).append( " ON " );
070 buf.append( tableName ).append( "( " ).append( clms );
071 buf.append( " )" );
072 }
073 else {
074 String errMsg = "INDTYPE が?0,1,2 以外?値が使われて?す?INDTYPE=[" + idxtype + "]"
075 + " TABLE_NAME=[" + tableName + "] INDEX_NAME=[" + indexName + "]" ;
076 System.out.println( errMsg );
077 }
078
079 return buf.toString();
080 }
081
082 /**
083 * 定義の??部??処?実行します?
084 *
085 * @param clmNo カラ?号配?
086 * @param data ?行?の??タ配?
087 *
088 * @return 定義の??部?
089 */
090 @Override
091 protected String makeEndLine( final int[] clmNo,final String[] data ) {
092 // return ";";
093 return ( isXml ? EXEC_END_TAG : ";" );
094 }
095 }