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_SEQUENCE_POSGRE は、TableUpda インターフェースを継承した、DBTableModel 処理用の 020 * 実装クラスです。 021 * 022 * ここでは、シーケンス一覧の検索結果より、GF09 のシーケンス定義テーブルから 023 * 必要な情報を取得し、シーケンス作成スクリプトを作成します。 024 * 025 * この処理を実行するには、DBTableModelのカラムとして、 026 * SEQNAME,INCREBY,STARTVAL,MINVAL,MAXVAL,FGCYCLE,SUCACHE 027 * が必要です。 028 * 029 * ※PostgreSQLに対して生成されるスクリプトでは、SUCACHEは無視されます。 030 * 031 * @og.rev 5.1.9.0 (2010/08/01) DB定義DB・シーケンス定義追加 032 * @version 0.9.0 2010/08/01 033 * @author Hiroki Nakamura 034 * @since JDK1.1, 035 */ 036public class TableFilter_SEQUENCE_POSGRE extends TableFilter_SEQUENCE { 037 //* このプログラムのVERSION文字列を設定します。 {@value} */ 038 private static final String VERSION = "5.1.9.0 (2010/08/01)" ; 039 040 041 /** 042 * ヘッダー部分の処理を実行します。 043 * 044 * @og.rev 5.10.25.0 (2020/10/02) 先頭にencodingを付加するために作成 045 * 046 * @param clmNo カラム番号配列 047 * @param data 1行分のデータ配列 048 * 049 * @return ヘッダー部分の文字列 050 */ 051 @Override 052 protected String makeHeadLine( final int[] clmNo,final String[] data ) { 053 String str = isXml ? "" : "\\encoding UTF8;" + CR; 054 String rtn = super.makeHeadLine( clmNo,data ); 055 return str + ( rtn!=null ? rtn.toLowerCase() : rtn ); 056 } 057 058 /** 059 * シーケンス作成の処理を実行します。 060 * 061 * @og.rev 5.10.25.0 (2020/10/02) スクリプトを小文字にしておく 062 * 063 * @param clmNo カラム番号配列 064 * @param data 1行分のデータ配列 065 * 066 * @return シーケンス作成 067 */ 068 @Override 069 protected String makeLineList( final int[] clmNo,final String[] data ) { 070 StringBuilder buf = new StringBuilder(); 071 072 if( isXml ) { buf.append( EXEC_START_TAG ).append( CR ); } 073 074 buf.append( "CREATE SEQUENCE " ).append( data[clmNo[SEQNAME]] ).append( CR ); 075 buf.append( " INCREMENT " ).append( data[clmNo[INCREBY]] ); 076 buf.append( " MINVALUE " ).append( data[clmNo[MINVAL]] ); 077 buf.append( " MAXVALUE " ).append( data[clmNo[MAXVAL]] ); 078 buf.append( " START " ).append( data[clmNo[STARTVAL]] ); 079 080// buf.append( "INCREMENT " ).append( data[clmNo[INCREBY]] ).append( CR ); 081// buf.append( "MINVALUE " ).append( data[clmNo[MINVAL]] ).append( CR ); 082// buf.append( "MAXVALUE " ).append( data[clmNo[MAXVAL]] ).append( CR ); 083// buf.append( "START " ).append( data[clmNo[STARTVAL]] ).append( CR ); 084 085 if( "1".equals( data[clmNo[FGCYCLE]] ) ) { 086 buf.append( " CYCLE" ); 087// buf.append( "CYCLE" ).append( CR ); 088 } 089 090 if( isXml ) { buf.append( CR ).append( EXEC_END_TAG ); } 091 else { buf.append( " ;" ); } 092 093// return buf.toString(); 094 return buf.toString().toLowerCase(); // 5.10.25.0 (2020/10/02) 小文字化してしまう 095 } 096}