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.fukurou.business;
017
018 import org.opengion.fukurou.util.ErrorMessage;
019
020 /**
021 * é…å?型テーブルモãƒ?ƒ«ã‚’メインカーソルã¨ã—ãŸæ¥å‹™ãƒã‚¸ãƒ?‚¯ã®æ§‹é?を定義ã—ã¾ã™ã?
022 *
023 * é…å?型テーブルモãƒ?ƒ«ã«ã¤ã?¦ã¯ã€setTable( ArrayTableModel )ã«ã‚ˆã‚Šã‚»ãƒ?ƒˆã—ã¾ã™ã?
024 * é…å?型テーブルモãƒ?ƒ«ãŒå®šç¾©ã•れã¦ã?ªã??åˆã?エラーã¨ãªã‚Šã¾ã™ã?
025 *
026 * ã“ã?クラスã§ã¯ã€ä»¥ä¸‹ã«ç¤ºã™ãƒ¡ã‚½ãƒ?ƒ‰ãŒå‘¼ã³å‡ºã•れるタイミングã®ã¿ã‚’定義ã—ã¦ã?¾ã™ã?
027 * メソãƒ?ƒ‰ã®ä¸èº«ã«ã¤ã?¦ã¯ã€ã‚µãƒ–クラスã§ã‚ªãƒ¼ãƒã?ライドã—実è£?—ã¦ä¸‹ã•ã??
028 *
029 * 処ç?Œé€”ä¸ã§ä¸æ–ã•れるæ¡ä»¶ã¯ã€ä»¥ä¸‹ã?3ã¤ã§ã™ã?
030 * â‘?„メソãƒ?ƒ‰ã®æˆ»ã‚Šå?ãŒfalseã®å ´å?
031 * â‘¡ãƒã‚§ãƒ?‚¯ãƒ¡ã‚½ãƒ?ƒ‰(chk***())ãŒå?ã¦ã®è¡Œã§å®Ÿè¡Œã•れãŸå¾Œã?エラーメãƒ?‚»ãƒ¼ã‚¸ã«"エラー"ãŒå«ã¾ã‚Œã¦ã?‚‹å ´å?
032 * ③実行時エラーãŒç™ºç”Ÿã—ãŸå?å?
033 *
034 * fstchk() 変更区åˆ?«é–¢ã‚らã? 処ç?‚’å§‹ã‚ã‚‹å‰ã«å‘¼ã³å‡ºã?
035 * befchk( int row ) 変更区åˆ?«é–¢ã‚らã? å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?insert,modify,deleteã®å‰ã«å‘¼ã³å‡ºã?
036 * inschk( int row ) 変更区åˆ?Œ"A"ã®å ´å?å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?
037 * modchk( int row ) 変更区åˆ?Œ"C"ã®å ´å?å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?
038 * delchk( int row ) 変更区åˆ?Œ"D"ã®å ´å?å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?
039 * allchk( int row ) 変更区åˆ?«é–¢ã‚らã? å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?insert,modify,deleteã®å¾Œã«å‘¼ã³å‡ºã?
040 * first() 変更区åˆ?«é–¢ã‚らã? æœ??ã®è¡Œã§ã®ã¿å‘¼ã³å‡ºã?
041 * befall( int row ) 変更区åˆ?«é–¢ã‚らã? å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?insert,modify,deleteã®å‰ã«å‘¼ã³å‡ºã?
042 * insert( int row ) 変更区åˆ?Œ"A"ã®å ´å?å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?
043 * modify( int row ) 変更区åˆ?Œ"C"ã®å ´å?å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?
044 * delete( int row ) 変更区åˆ?Œ"D"ã®å ´å?å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?
045 * allrow( int row ) 変更区åˆ?«é–¢ã‚らã? å?¡Œã«ã¤ã?¦å‘¼ã³å‡ºã?insert,modify,deleteã®å¾Œã«å‘¼ã³å‡ºã?
046 * last() 変更区åˆ?«é–¢ã‚らã? æœ?¾Œã?行ã§ã®ã¿å‘¼ã³å‡ºã?
047 *
048 * ※ インãƒ?ƒƒã‚¯ã‚¹(row)ã¨ã¯ã€ã“ã®ArrayTableModel ã«æŒã¤ vals é…å?ã®è¡Œã?インãƒ?ƒƒã‚¯ã‚¹ã§ã™ã?
049 * よã£ã¦ã€ã‚ªãƒªã‚¸ãƒŠãƒ«ã®DBTableModelã®è¡Œç•ªå·ã§ã¯ã‚りã¾ã›ã‚“ã€?
050 *
051 * @og.rev 5.1.1.0 (2009/12/01) æ–°è¦ä½œæ?
052 * @og.group æ¥å‹™ãƒã‚¸ãƒ?‚¯
053 *
054 * @version 5.0
055 * @author Hiroki Nakamura
056 * @since JDK1.6,
057 */
058 public class BizLogic_TABLE extends AbstractBizLogic {
059
060 /**
061 * 処ç??メインãƒã‚¸ãƒ?‚¯ã®å‰å?ç?‚’記述ã—ã¾ã™ã?
062 * (ã“ã“ã§ã¯ä½•ã‚‚ã—ã¾ã›ã‚“)
063 *
064 * ã“ã?メソãƒ?ƒ‰è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
065 * ä½?—ã€ã“れã?ã€å„æ¥å‹™ãƒã‚¸ãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
066 * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
067 * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
068 * ã“ã?ãŸã‚ã€æ¥å‹™ãƒã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
069 */
070 @Override
071 protected void init() {
072 // Document empty method ãƒã‚§ãƒ?‚¯å¯¾ç?
073 }
074
075 /**
076 * 処ç??メインãƒã‚¸ãƒ?‚¯ã‚’記述ã—ã¾ã™ã?
077 *
078 * ã“ã?メソãƒ?ƒ‰è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
079 * ä½?—ã€ã“れã?ã€å„æ¥å‹™ãƒã‚¸ãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
080 * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
081 * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
082 * ã“ã?ãŸã‚ã€æ¥å‹™ãƒã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
083 *
084 * @og.rev 5.1.8.0 (2010/07/01) first,lastã¯è¡Œãƒ«ãƒ¼ãƒ—ã?ä¸ã§å‘¼ã³å‡ºã?
085 * @og.rev 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
086 *
087 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
088 */
089 @Override
090 protected boolean main() {
091 if( table == null ) {
092 // 5.6.7.0 (2013/07/27) Exception ã‚?throw ã™ã‚‹ã¨ãã?ä¸?—¦ã€errMsg 変数ã«ã‚»ãƒ?ƒˆã—ã¾ã™ã?
093 // throw new RuntimeException( "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã›ã‚“ã€? );
094 String errMsg = "é…å?型テーブルモãƒ?ƒ«ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã›ã‚“ã€? ;
095 throw new RuntimeException( errMsg );
096 }
097
098 String modType = null;
099
100 row = 0;
101 if( !fstchk() ) { return false; }
102 for( int i = 0; i < table.getRowCount(); i++ ) {
103 if( !befchk( row ) ) { return false; }
104
105 modType = table.getModifyType( row );
106 if( "A".equals( modType ) ) {
107 if( !inschk( row ) ) { return false; }
108 }
109 else if( "C".equals( modType ) ) {
110 if( !modchk( row ) ) { return false; }
111 }
112 else if( "D".equals( modType ) ) {
113 if( !delchk( row ) ) { return false; }
114 }
115
116 if( !allchk( row ) ) { return false; }
117
118 row++;
119 }
120 if( getKekka() >= ErrorMessage.NG ) { return false; }
121
122 row = 0;
123 // if( !first() ) { return false; }
124 for( int i = 0; i < table.getRowCount(); i++ ) {
125 // 5.1.8.0 (2010/07/01) firstã¯è¡Œãƒ«ãƒ¼ãƒ—ã?ä¸ã§å‘¼ã³å‡ºã?
126 if( row == 0 ) {
127 if( !first() ) { return false; }
128 }
129
130 if( !befall( row ) ) { return false; }
131
132 modType = table.getModifyType( row );
133 if( "A".equals( modType ) ) {
134 if( !insert( row ) ) { return false; }
135 }
136 else if( "C".equals( modType ) ) {
137 if( !modify( row ) ) { return false; }
138 }
139 else if( "D".equals( modType ) ) {
140 if( !delete( row ) ) { return false; }
141 }
142
143 if( !allrow( row ) ) { return false; }
144
145 // 5.1.8.0 (2010/07/01) lastã¯è¡Œãƒ«ãƒ¼ãƒ—ã?ä¸ã§å‘¼ã³å‡ºã?
146 if( row == table.getRowCount() - 1 ) {
147 if( !last() ) { return false; }
148 }
149 row++;
150 }
151 // if( !last() ) { return false; }
152
153 return true;
154 }
155
156 /**
157 * ã“ã?クラスã¯ã€ãƒ†ãƒ¼ãƒ–ルモãƒ?ƒ«ãŒå¤–部ã‹ã‚‰æŒ?®šã•れã¦ã?‚‹å¿?¦ãŒã‚りã¾ã™ã?
158 *
159 * ã“ã?メソãƒ?ƒ‰è‡ªä½“ã?ã€protected属æ?ã§ã‚ã‚‹ãŸã‚ã€ã‚µãƒ–クラスã‹ã‚‰ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
160 * ä½?—ã€ã“れã?ã€å„æ¥å‹™ãƒã‚¸ãƒ?‚¯ã§ç›´æŽ¥å‚ç?ã™ã‚‹ã“ã¨ã‚’想定ã—ãŸã‚‚ã®ã§ã¯ãªãã?BizLogicã®
161 * メイン構é?ã‚’æ‹¡å¼µã™ã‚‹ã‚µãƒ–クラスを定義ã™ã‚‹éš›ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã?¾ã™ã?
162 * (ã“ã?想定ãŒãªã‘れã°ã€æœ¬æ¥ã¯ã€package privateã«ã™ã¹ãã§ã?
163 * ã“ã?ãŸã‚ã€æ¥å‹™ãƒã‚¸ãƒ?‚¯ã‚’å„実è£?‚¯ãƒ©ã‚¹ã§ã¯ç›´æŽ¥å‚ç?ã—ãªã?§ä¸‹ã•ã??
164 *
165 * @see AbstractBizLogic#isRequireTable()
166 *
167 * @return ãƒ??ブルモãƒ?ƒ«ãŒå¤–部ã‹ã‚‰æŒ?®šã•れã¦ã?‚‹å¿?¦ãŒã‚ã‚‹ã‹ã©ã?‹(常ã«true)
168 */
169 @Override
170 protected boolean isRequireTable() {
171 return true;
172 }
173
174 /**
175 * メインカーソルã®ä¸?•ªåˆã‚ã§å‘¼ã°ã‚Œã‚‹ãƒã‚§ãƒ?‚¯ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
176 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
177 *
178 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
179 */
180 protected boolean fstchk() {
181 return true;
182 }
183
184 /**
185 * メインカーソルã®å?¡?変更区åˆ??å??ç??å‰?ã§å‘¼ã°ã‚Œã‚‹ãƒã‚§ãƒ?‚¯ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
186 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
187 *
188 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
189 *
190 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
191 */
192 protected boolean befchk( final int row ) {
193 return true;
194 }
195
196 /**
197 * メインカーソルã®å?¡?変更区åˆ??å??ç??å¾?ã§å‘¼ã°ã‚Œã‚‹ãƒã‚§ãƒ?‚¯ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
198 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
199 *
200 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
201 *
202 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
203 */
204 protected boolean allchk( final int row ) {
205 return true;
206 }
207
208 /**
209 * メインカーソルã®å?¡?変更区åˆ?"A")ã§å‘¼ã°ã‚Œã‚‹ãƒã‚§ãƒ?‚¯ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
210 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
211 *
212 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
213 *
214 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
215 */
216 protected boolean inschk( final int row ) {
217 return true;
218 }
219
220 /**
221 * メインカーソルã®å?¡?変更区åˆ?"C")ã§å‘¼ã°ã‚Œã‚‹ãƒã‚§ãƒ?‚¯ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
222 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
223 *
224 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
225 *
226 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
227 */
228 protected boolean modchk( final int row ) {
229 return true;
230 }
231
232 /**
233 * メインカーソルã®å?¡?変更区åˆ?"D")ã§å‘¼ã°ã‚Œã‚‹ãƒã‚§ãƒ?‚¯ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
234 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
235 *
236 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
237 *
238 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
239 */
240 protected boolean delchk( final int row ) {
241 return true;
242 }
243
244 /**
245 * メインカーソルã®ä¸?•ªåˆã‚ã§å‘¼ã°ã‚Œã‚‹ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
246 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
247 *
248 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
249 */
250 protected boolean first() {
251 return true;
252 }
253
254 /**
255 * メインカーソルã®ä¸?•ªæœ?¾Œã§å‘¼ã°ã‚Œã‚‹ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
256 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
257 *
258 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
259 */
260 protected boolean last() {
261 return true;
262 }
263
264 /**
265 * メインカーソルã®å?¡?変更区åˆ??å??ç??å‰?ã§å‘¼ã°ã‚Œã‚‹ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
266 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
267 *
268 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
269 *
270 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
271 */
272 protected boolean befall( final int row ) {
273 return true;
274 }
275
276 /**
277 * メインカーソルã®å?¡?変更区åˆ??å??ç??å¾?ã§å‘¼ã°ã‚Œã‚‹ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
278 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
279 *
280 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
281 *
282 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
283 */
284 protected boolean allrow( final int row ) {
285 return true;
286 }
287
288 /**
289 * メインカーソルã®å?¡?変更区åˆ?"A")ã§å‘¼ã°ã‚Œã‚‹ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
290 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
291 *
292 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
293 *
294 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
295 */
296 protected boolean insert( final int row ) {
297 return true;
298 }
299
300 /**
301 * メインカーソルã®å?¡?変更区åˆ?"C")ã§å‘¼ã°ã‚Œã‚‹ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
302 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
303 *
304 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
305 *
306 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
307 */
308 protected boolean modify( final int row ) {
309 return true;
310 }
311
312 /**
313 * メインカーソルã®å?¡?変更区åˆ?"D")ã§å‘¼ã°ã‚Œã‚‹ãƒã‚¸ãƒ?‚¯ã‚’定義ã—ã¾ã™ã?
314 * ã“ã“ã§ã¯ä½•も実è£?•れã¦ã?¾ã›ã‚“ã€?
315 *
316 * @param row 行番å·(インãƒ?ƒƒã‚¯ã‚¹)
317 *
318 * @return 処ç?Œæ£å¸¸çµ‚äº?—ãŸã‹
319 */
320 protected boolean delete( final int row ) {
321 return true;
322 }
323 }