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_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     */
036    public 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             * @param       clmNo   カラ?号配?
044             * @param       data    ?行?の??タ配?
045             *
046             * @return      シーケンス作?
047             */
048            @Override
049            protected String makeLineList( final int[] clmNo,final String[] data ) {
050                    StringBuilder buf = new StringBuilder();
051    
052                    if( isXml ) { buf.append( EXEC_START_TAG ).append( CR ); }
053    
054                    buf.append( "CREATE SEQUENCE " ).append( data[clmNo[SEQNAME]] ).append( CR );
055                    buf.append( "  INCREMENT " ).append( data[clmNo[INCREBY]] );
056                    buf.append( " MINVALUE " ).append( data[clmNo[MINVAL]] );
057                    buf.append( " MAXVALUE " ).append( data[clmNo[MAXVAL]] );
058                    buf.append( " START " ).append( data[clmNo[STARTVAL]] );
059    
060    //              buf.append( "INCREMENT " ).append( data[clmNo[INCREBY]] ).append( CR );
061    //              buf.append( "MINVALUE " ).append( data[clmNo[MINVAL]] ).append( CR );
062    //              buf.append( "MAXVALUE " ).append( data[clmNo[MAXVAL]] ).append( CR );
063    //              buf.append( "START " ).append( data[clmNo[STARTVAL]] ).append( CR );
064    
065                    if( "1".equals( data[clmNo[FGCYCLE]] ) ) {
066                            buf.append( " CYCLE" );
067    //                      buf.append( "CYCLE" ).append( CR );
068                    }
069    
070                    if( isXml )     { buf.append( CR ).append( EXEC_END_TAG ); }
071                    else            { buf.append( " ;" ); }
072    
073                    return buf.toString();
074            }
075    }