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