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.hayabusa.db;
017
018/**
019 * ファイルダウンロードアイコン処理に必要な情報を格納しておく
020 * データ管理クラスです。
021 * fileUD タグから、common/fileDownload.jsp に処理が遷移しますが、
022 * その間、DBTableModel が指定の画面で作成されたか、また、view で
023 * 指定されたカラムのみを抜き出しているか、スコープは、などの
024 * チェックを行います。
025 *
026 * @og.rev 4.3.0.0 (2008/07/04) 新規追加
027 *
028 * @version  4.0
029 * @author   Kazuhiko Hasegawa
030 * @since    JDK5.0,
031 */
032public class DBLastSql  {
033        private String  scope   = null;
034        private final String  guikey ;          // 4.3.1.1 (2008/08/23) final化
035        private final boolean overflow ;        // 4.3.1.1 (2008/08/23) final化
036        private String  tableId = null;
037        private String  clmNames= null;
038        private String  viewClmNames= null;     // 5.1.6.0 (2010/05/01) 画面項目並べ替え対応
039        private String  orgClmNames = null; // 5.8.2.0 (2014/12/05) 
040
041//      private boolean isViewEditable  =       true;   // 5.1.6.0 (2010/05/01) 画面項目並べ替え対応
042        private boolean useViewEditable =       true;   // 5.1.6.0 (2010/05/01) 画面項目並べ替え対応 (変数名変更)
043
044        /**
045         * 初期情報を含んだ新規オブジェクトを作成します。
046         *
047         * @param    scope     スコープ [session/request]
048         * @param    guikey    画面ID
049         * @param    overflow  検索時にオーバーフローしたかどうか
050         * @param    tableId   テーブルID(DBTableModelの格納キー)
051         */
052        public DBLastSql( final String scope,
053                                                final String guikey,
054                                                final boolean overflow,
055                                                final String tableId ) {
056                this.scope              = scope;
057                this.guikey             = guikey;
058                this.overflow   = overflow;
059                this.tableId    = tableId;
060        }
061
062        /**
063         * DBTableModel を出力するときのカラム名(CSV形式)をセットします。
064         *
065         * ファイルダウンロード時に、view で表示した分だけ抜き出す場合は、
066         * このカラム名を指定します。
067         *
068         * @param    clmNames カラム名(CSV形式)
069         */
070        public void setClmNames( final String clmNames ) {
071                this.clmNames = clmNames;
072        }
073
074        /**
075         *  DBTableModel を出力するときのカラム名(CSV形式)を返します。
076         *
077         * ファイルダウンロード時に、view で表示した分だけ抜き出す場合は、
078         * このカラム名を指定します。
079         *
080         * @return      カラム名(CSV形式)
081         */
082        public String getClmNames() { return clmNames; }
083
084        /**
085         * スコープ(session/request)をセットします。
086         *
087         * @param scope スコープ [session/request]
088         */
089        public void setScope( final String scope ) { this.scope = scope; }
090
091        /**
092         * スコープ(session/request)を返します。
093         *
094         * @og.rev 5.3.6.0 (2011/06/01) 新規作成
095         *
096         * @return      スコープ(session/request)
097         */
098        public String getScope() { return scope; }
099
100        /**
101         * スコープ(session/request)が、requestかどうかを返します。
102         *
103         * scope=="request" の場合は、DBTableModel は
104         * メモリに残っていませんので、
105         * 1.抜出アイコンを表示しない。
106         * 2.lastSql を利用してフルのDBTableModelを作成しなおす。
107         * 方法が考えられます。
108         *
109         * @return      スコープが、requestなら、true
110         */
111        public boolean isRequest() { return "request".equals( scope ); }
112
113        /**
114         * 画面IDを返します。
115         *
116         * この画面IDは、ファイルダウンロードアイコンの存在している
117         * 画面と同じ箇所で、作成されたかをチェックする為に使用されます。
118         *
119         * @return      画面ID
120         */
121        public String getGuiKey() { return guikey; }
122
123        /**
124         * 内部画面IDと等しいか判定します。
125         *
126         * gamenId != null && gamenId.equals( lastSql.getGuikey() )
127         * 処理と同等です。
128         *
129         * @param  gamenId 画面ID
130         *
131         * @return      引数が null でなく、且つ内部画面キーと同じ場合は、true
132         */
133        public boolean isGuiMatch( final String gamenId ) {
134                return ( gamenId != null && gamenId.equals( guikey ) );
135        }
136
137        /**
138         * 検索時にオーバーフローしたかどうかを返します。
139         *
140         * 検索時にオーバーフローした場合、ファイルダウンロードとして、
141         * 1.そのまま、DBTableModel の分だけを抜き出す。
142         * 2.lastSql を利用してフルのDBTableModelを作成しなおす。
143         * 方法が考えられます。
144         *
145         * @return  オーバーフローしたかどうか
146         */
147        public boolean isOverflow() { return overflow; }
148
149        /**
150         *  テーブルID(DBTableModelの格納キー)をセットします。
151         *
152         * DBTableModel を取り出すときに使用します。
153         *
154         * @param       tableId テーブルID(DBTableModelの格納キー)
155         */
156        public void setTableId( final String tableId ) { this.tableId = tableId; }
157
158        /**
159         *  テーブルID(DBTableModelの格納キー)を返します。
160         *
161         * DBTableModel を取り出すときに使用します。
162         *
163         * @return      テーブルID(DBTableModelの格納キー)
164         */
165        public String getTableId() { return tableId; }
166
167        /**
168         * 内部テーブルID、スコープと等しいか判定します。
169         *
170         * tableId != null && tableId.equals( lastSql.getTableId() ) &&
171         * scope   != null && scope.equals( lastSql.scope )
172         * 処理と同等です。
173         *
174         * @param  tableId 画面ID
175         * @param  scope   スコープ
176         *
177         * @return      引数が null でなく、且つ内部テーブルID、スコープと同じ場合は、true
178         */
179        public boolean isTableMatch( final String tableId, final String scope ) {
180                return ( tableId != null && tableId.equals( this.tableId ) ) &&
181                                ( scope != null && scope.equals( this.scope ) );
182        }
183
184        /**
185         * DBTableModel を出力するときのカラム名(CSV形式)をセットします。
186         *
187         * 画面項目並び替え時に、view で表示した分だけ抜き出す場合は、
188         * このカラム名を指定します。
189         *
190         * 左右分割などでViewが複数存在する場合は、'|'を区切り文字としてそれぞれのViewの
191         * カラム一覧がセットします。
192         *  例) AAA,BBB,CCC|DDD,EEE
193         *
194         * @og.rev 5.1.6.0 (2010/05/01) 新規作成
195         *
196         * @param    clmNames カラム名(CSV形式+|)
197         */
198        public void setViewClmNames( final String clmNames ) {
199                this.viewClmNames = clmNames;
200        }
201
202        /**
203         *  DBTableModel を出力するときのカラム名(CSV形式)を返します。
204         *
205         * 画面項目並び替え時に、view で表示した分だけ抜き出す場合は、
206         * このカラム名を指定します。
207         *
208         * 左右分割などでViewが複数存在する場合は、'|'を区切り文字としてそれぞれのViewの
209         * カラム一覧がセットされています。
210         *  例) AAA,BBB,CCC|DDD,EEE
211         *
212         * @og.rev 5.1.6.0 (2010/05/01) 新規作成
213         *
214         * @return      カラム名(CSV形式+|)
215         */
216        public String getViewClmNames() { return viewClmNames; }
217
218        /**
219         * DBTableModel を出力するときのオリジナルのカラム名(CSV形式)をセットします。
220         *
221         * 画面項目並び替え時に、view で表示した分だけ抜き出すカラムと比較することで、
222         * カラムの変動をチェックできます。
223         *
224         * 書式は、(!)や、(|)を含まない、カラムのCSV形式です。
225         *
226         * @og.rev 5.8.2.0 (2014/12/05)
227         *
228         * @param       clmNames オリジナルのカラム名(CSV形式)
229         * @see         #getOrgClmNames()
230         */
231        public void setOrgClmNames( final String clmNames ) {
232                this.orgClmNames = clmNames;
233        }
234
235        /**
236         *  DBTableModel を出力するときのオリジナルのカラム名(CSV形式)を返します。
237         *
238         * 画面項目並び替え時に、view で表示した分だけ抜き出すカラムと比較することで、
239         * カラムの変動をチェックできます。
240         *
241         * 書式は、(!)や、(|)を含まない、カラムのCSV形式です。
242         *
243         * @og.rev 5.8.2.0 (2014/12/05)
244         *
245         * @return      オリジナルのカラム名(CSV形式)
246         * @see         #setOrgClmNames( String )
247         */
248        public String getOrgClmNames() { return orgClmNames; }
249        
250        /**
251         * ユーザーによる画面項目の並び替えを禁止します。
252         */
253        public void setViewNotEditable() { this.useViewEditable = false; }
254
255        /**
256         * ユーザーによる画面項目の並び替えをが禁止されているかどうかを返します。
257         *
258         * @return      ユーザーによる画面項目の並び替えをが禁止されているかどうか
259         */
260        public boolean isViewEditable() { return useViewEditable; }
261}