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 import org.opengion.fukurou.util.StringUtil; 019 import org.opengion.hayabusa.db.AbstractTableFilter; 020 import org.opengion.hayabusa.db.DBTableModel; 021 022 import java.util.Map; 023 024 /** 025 * TableFilter_SEQRESET は、TableFilter インターフェースを継承した、DBTableModel 処?の 026 * 実?ラスです? 027 * 028 * ここでは、テーブルモ?のシーケンス?の値を?セ?して?す? 029 * シーケンスの値は??常10ずつ増加しますが、BREAK_CLMが指定されており? 030 * かつ、その?の値がブレイクした場合??00増加させます? 031 * また?CLEAR_CLMが指定されて?場合?そ?カラ??値がキーブレイクした場合?? 032 * シーケンス値を?期化(10)にします? 033 * 034 * パラメータは、tableFilterタグの keys, vals にそれぞれ記述するか?BODY 部にCSS形式で記述します? 035 * 【パラメータ? 036 * { 037 * SEQ_CLM : シーケンス? 038 * BREAK_CLM : キーブレイク? (任? 039 * CLEAR_CLM : シーケンス初期化?目 040 * INCREMENT : シーケンスの増? (初期値??0) 041 * START_NO : シーケンスの初期値 (初期値??) 042 * } 043 * 044 * @og.formSample 045 * ●形式? 046 * ?<og:tableFilter classId="SEQRESET" keys="SEQ_CLM,BREAK_CLM" vals="SEQNO,DAIBNRUI" /> 047 * 048 * ② <og:tableFilter classId="SEQRESET" > 049 * { 050 * SEQ_CLM : SEQNO ; 051 * BREAK_CLM : DAIBNRUI ; 052 * } 053 * </og:tableFilter> 054 * 055 * @og.rev 5.6.6.0 (2013/07/05) keys の整合?チェ?を追? 056 * 057 * @version 0.9.0 2000/10/17 058 * @author Hiroki Nakamura 059 * @since JDK1.1, 060 */ 061 public class TableFilter_SEQRESET extends AbstractTableFilter { 062 //* こ?プログラ??VERSION??を設定します? {@value} */ 063 private static final String VERSION = "5.6.6.1 (2013/07/12)" ; 064 065 /** 066 * keys の整合?チェ?を行うための初期設定を行います? 067 * 068 * @og.rev 5.6.6.1 (2013/07/12) keys の整合?チェ?対? 069 * 070 * @param keysMap keys の整合?チェ?を行うための Map 071 */ 072 @Override 073 protected void init( final Map<String,String> keysMap ) { 074 keysMap.put( "SEQ_CLM" , "シーケンス?" ); 075 keysMap.put( "BREAK_CLM" , "キーブレイク?" ); 076 keysMap.put( "CLEAR_CLM" , "シーケンス初期化?目" ); 077 keysMap.put( "INCREMENT" , "シーケンスの増?(初期値:10)" ); 078 keysMap.put( "START_NO" , "シーケンスの初期値(初期値:0)" ); 079 } 080 081 /** 082 * DBTableModel処?実行します? 083 * 084 * @og.rev 4.3.7.0 (2009/06/01) 新規追? 085 * @og.rev 5.5.2.6 (2012/05/25) protected変数を?private化したため?getterメソ?で取得するよ?変更 086 * 087 * @return 処????ブルモ? 088 */ 089 public DBTableModel execute() { 090 DBTableModel table = getDBTableModel(); // 5.5.2.6 (2012/05/25) インターフェースにgetterメソ?追? 091 092 int seqNo = table.getColumnNo( getValue( "SEQ_CLM" ),false ); 093 int breakNo = table.getColumnNo( getValue( "BREAK_CLM" ),false ); 094 int clearNo = table.getColumnNo( getValue( "CLEAR_CLM" ),false ); 095 String increment = getValue( "INCREMENT" ); 096 String start = getValue( "START_NO" ); 097 098 if( seqNo < 0 ){ return table; } 099 100 int seq = StringUtil.nval( start, 0 ); 101 int inc = StringUtil.nval( increment, 10 ); 102 String[] data = null; 103 String preKey = ""; 104 String cleKey = ""; 105 int[] rowNo = getParameterRows(); // 5.5.2.6 (2012/05/25) インターフェースにgetterメソ?追? 106 for( int row = 0; row < rowNo.length; row ++ ) { 107 data = table.getValues( rowNo[row] ); 108 109 if( clearNo >= 0 && cleKey != null && cleKey.length() > 0 && !cleKey.equals( data[clearNo] ) ) { 110 seq = StringUtil.nval( start, 0 ); 111 } 112 113 if( breakNo >= 0 && preKey != null && preKey.length() > 0 && !preKey.equals( data[breakNo] ) ) { 114 seq += inc * 10; 115 } 116 else { 117 seq += inc; 118 } 119 120 data[seqNo] = String.valueOf( seq ); 121 122 if( breakNo >= 0 ) { 123 preKey = data[breakNo]; 124 } 125 126 if( clearNo >= 0 ) { 127 cleKey = data[clearNo]; 128 } 129 } 130 return table; 131 } 132 }