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.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     */
032    public 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             * ?‘.抜出アイコンを表示ã—ãªã??
106             * ?’.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             * ?‘.ãã®ã¾ã¾ã€DBTableModel ã®åˆ? ã‘を抜ã出ã™ã?
142             * ?’.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    }