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.common.HybsSystemException;
019import org.opengion.hayabusa.db.AbstractTableFilter;
020import org.opengion.hayabusa.db.DBTableModel;
021import org.opengion.hayabusa.report2.QueueManager_DB;
022
023import java.util.Map;
024
025/**
026 * TableFilter_REPORTDATA は、TableFilter インターフェースを継承した、DBTableModel 処理用の
027 * 実装クラスです。
028 *
029 * ここでは、指定された要求NOに対してGE51(帳票明細データ)をGE52(帳票レイアウトテーブル)の定義に従って、
030 * 分割し、DBTableModelを生成します。
031 *
032 * パラメータは、tableFilterタグの keys, vals にそれぞれ記述するか、BODY 部にCSS形式で記述します。
033 * 【パラメータ】
034 *  {
035 *       SYSTEM_ID  :  ;                検索対象となる、システムID(必須)
036 *       LISTID     :  ;                検索対象となる、帳票ID(必須)
037 *       YKNO       :  ;                検索対象となる、要求番号(必須)
038 *       KBTEXT     :  ;                H(ヘッダー),F(フッター),B(ボディー)のいずれかを指定(必須)
039 *  }
040 *
041 * @og.formSample
042 * ●形式:
043 *      @ <og:tableFilter classId="REPORTDATA" keys="SYSTEM_ID,LISTID,YKNO,KBTEXT" vals="GF,GF0001,111100,B" />
044 *
045 *      A <og:tableFilter classId="REPORTDATA" >
046 *               {
047 *                   SYSTEM_ID : GF ;
048 *                   LISTID    : GF0001 ;
049 *                   YKNO      : 111100 ;
050 *                   KBTEXT    : B ;
051 *               }
052 *         </og:tableFilter>
053 *
054 * @see org.opengion.hayabusa.report2.QueueManager_DB.DBTableModelCreator
055 * @og.rev 5.1.2.0 (2010/01/01) 新規作成
056 * @og.rev 5.6.6.0 (2013/07/05) keys の整合性チェックを追加
057 *
058 * @version  0.9.0  2000/10/17
059 * @author   Hiroki Nakamura
060 * @since    JDK1.1,
061 */
062public class TableFilter_REPORTDATA extends AbstractTableFilter {
063        //* このプログラムのVERSION文字列を設定します。   {@value} */
064        private static final String VERSION = "5.6.6.1 (2013/07/12)" ;
065
066        /**
067         * keys の整合性チェックを行うための初期設定を行います。
068         *
069         * @og.rev 5.6.6.1 (2013/07/12) keys の整合性チェック対応
070         *
071         * @param       keysMap keys の整合性チェックを行うための Map
072         */
073        @Override
074        protected void init( final Map<String,String> keysMap ) {
075                keysMap.put( "SYSTEM_ID"        , "検索対象となる、システムID(必須)"                                                  );
076                keysMap.put( "LISTID"           , "検索対象となる、帳票ID(必須)"                                                            );
077                keysMap.put( "YKNO"                     , "検索対象となる、要求番号(必須)"                                                            );
078                keysMap.put( "KBTEXT"           , "H(ヘッダー),F(フッター),B(ボディー)のいずれかを指定(必須)" );
079        }
080
081        /**
082         * DBTableModel処理を実行します。
083         *
084         * @og.rev 5.5.2.6 (2012/05/25) protected変数を、private化したため、getterメソッドで取得するように変更
085         *
086         * @return 処理結果のDBTableModel
087         */
088        public DBTableModel execute() {
089                String systemId = getValue( "SYSTEM_ID" );
090                String listId   = getValue( "LISTID" );
091                String ykno     = getValue( "YKNO" );
092                String kbtext   = getValue( "KBTEXT" );
093
094                if( systemId == null || systemId.length() == 0
095                        || listId == null || listId.length() == 0
096                        || ykno == null || ykno.length() == 0
097                        || kbtext == null || kbtext.length() == 0 ) {
098                        String errMsg = "SYSTEM_ID,LISTID,YKNO,KBTEXTを全て指定して下さい。";
099                        throw new HybsSystemException( errMsg );
100                }
101
102                if( kbtext.length() > 1 || "HFB".indexOf( kbtext ) < 0 ) {
103                        String errMsg = "KBTEXTは、H(ヘッダー),F(フッター),B(ボディー)のいずれかを指定して下さい";
104                        throw new HybsSystemException( errMsg );
105                }
106
107                QueueManager_DB.DBTableModelCreator creator
108//                      = new QueueManager_DB.DBTableModelCreator( systemId, listId, ykno, kbtext, resource );
109                        = new QueueManager_DB.DBTableModelCreator( systemId, listId, ykno, kbtext, getResource() );             // 5.5.2.6 (2012/05/25)
110
111                return creator.getTable();
112        }
113}