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.hayabusa.db.AbstractTableFilter; 019import org.opengion.hayabusa.db.DBTableModel; 020 021/** 022 * TableFilter_REPORTLAYOUT は、TableFilter インターフェースを継承した、DBTableModel 処理用の 023 * 実装クラスです。 024 * 025 * ここでは、GE52(帳票レイアウトテーブル)の変更時に、 026 * GE52のSEQ,開始位置 027 * (GE54のSQLの再定義) 廃止 028 * を行うための情報を生成しています。 029 * 030 * この処理を実行するには、DBTableModelのカラムとして、 031 * SYSTEM_ID,LISTID,KBTEXT,CLM,SEQ,USE_LENGTH,START_POS 032 * が必要です。 033 * 034 * パラメータは、tableFilterタグの keys, vals にそれぞれ記述するか、BODY 部にCSS形式で記述します。 035 * 【パラメータ】 036 * { 037 * なし 038 * } 039 * 040 * @og.formSample 041 * ●形式: 042 * select SYSTEM_ID,LISTID,KBTEXT,CLM,SEQ,USE_LENGTH,START_POS from GE52 043 * 044 * ① <og:tableFilter classId="REPORTLAYOUT " /> 045 * 046 * @og.rev 4.3.7.0 (2009/06/01) 新規作成 047 * 048 * @version 0.9.0 2000/10/17 049 * @author Hiroki Nakamura 050 * @since JDK1.1, 051 */ 052public class TableFilter_REPORTLAYOUT extends AbstractTableFilter { 053 /** このプログラムのVERSION文字列を設定します。 {@value} */ 054 private static final String VERSION = "6.4.2.0 (2016/01/29)" ; 055 056 /** 057 * デフォルトコンストラクター 058 * 059 * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor. 060 */ 061 public TableFilter_REPORTLAYOUT() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 062 063 /** 064 * DBTableModel処理を実行します。 065 * 066 * @og.rev 4.3.7.0 (2009/06/01) 新規追加 067 * @og.rev 5.1.0.0 (2009/11/04) TEXT ⇒ TEXT_DATA , COLUMN_NAME ⇒ CLM 068 * @og.rev 5.1.2.0 (2010/01/01) データ分割のためのSQL文の生成を廃止します。(帳票クラス内で直接分割) 069 * @og.rev 5.5.2.6 (2012/05/25) protected変数を、private化したため、getterメソッドで取得するように変更 070 * 071 * @return 処理結果のDBTableModel 072 */ 073 public DBTableModel execute() { 074 final DBTableModel table = getDBTableModel(); // 5.5.2.6 (2012/05/25) インターフェースにgetterメソッド追加 075 076 final int systemIdNo= table.getColumnNo( "SYSTEM_ID" ); 077 final int listIdNo = table.getColumnNo( "LISTID" ); 078 final int kbtextNo = table.getColumnNo( "KBTEXT" ); 079 // final int clmNo = table.getColumnNo( "CLM" ); // 5.1.0.0 (2009/11/04) COLUMN_NAME ⇒ CLM 080 final int seqNo = table.getColumnNo( "SEQ" ); 081 final int lengthNo = table.getColumnNo( "USE_LENGTH" ); 082 final int strposNo = table.getColumnNo( "START_POS" ); 083 // final int sqlTypeNo = table.getColumnNo( "SQL_TYPE" ); 084 // final int sqlBodyNo = table.getColumnNo( "SQL_BODY" ); 085 // final String substrb= getValue( "SUBSTRB" ); 086 087 // 6.3.9.1 (2015/11/27) A method should have only one exit point, and that should be the last statement in the method.(PMD) 088 // DBTableModel#getColumnNo( String ) で、キーが無ければ、HybsSystemException が throw されます。 089 // たぶん、やりたかったのは、DBTableModel#getColumnNo( String,false ) で、なければ、-1 が返るメソッドだと思います。 090 // その場合、帳票レイアウトの作成ができないハズなので、ロジック的には、このままにしておきます。 091 092 // if( systemIdNo < 0 || listIdNo < 0 || kbtextNo < 0 || clmNo < 0 093 // || seqNo < 0 || lengthNo < 0 || strposNo < 0 ) { 094 // return table; 095 // } 096 097 int seq = 0; 098 int strpos = 1; 099 // 6.3.9.1 (2015/11/27) Found 'DD'-anomaly for variable(PMD) 100 String preKey = null; 101 final int[] rowNo = getParameterRows(); // 5.5.2.6 (2012/05/25) インターフェースにgetterメソッド追加 102 for( int row=0; row<rowNo.length; row ++ ) { 103 final String[] data = table.getValues( rowNo[row] ); 104 final String resetKey = data[systemIdNo] + "__" + data[listIdNo] + "__" + data[kbtextNo]; 105 106 if( preKey != null && !(preKey.equals( resetKey ) ) ) { 107 seq = 0; 108 strpos = 1; 109 } 110 111 seq += 10; 112 data[seqNo] = String.valueOf( seq ); 113 data[strposNo] = String.valueOf( strpos ); 114 115 // 5.1.0.0 (2009/11/04) TEXT ⇒ TEXT_DATA 116 strpos += Integer.parseInt( data[lengthNo] ); // 6.0.2.4 (2014/10/17) メソッド間違い 117 118 preKey = resetKey; 119 } 120 121 return table; 122 } 123}