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.taglib;
017    
018    import static org.opengion.fukurou.util.StringUtil.nval;
019    
020    import java.util.ArrayList;
021    import java.util.Collections;
022    import java.util.Enumeration;
023    import java.util.HashMap;
024    import java.util.List;
025    import java.util.Map;
026    
027    import org.opengion.fukurou.util.StringUtil;
028    import org.opengion.fukurou.util.TagBuffer;
029    import org.opengion.hayabusa.common.HybsSystem;
030    import org.opengion.hayabusa.common.HybsSystemException;
031    import org.opengion.hayabusa.db.DBColumn;
032    import org.opengion.hayabusa.db.DBEditConfig;
033    import org.opengion.hayabusa.db.DBLastSql;
034    import org.opengion.hayabusa.db.DBTableModel;
035    
036    /**
037     * ç”»é�¢è¡¨ç¤ºã€?›†è¨ˆã�«é–¢ã�™ã‚‹è¨­å®šæƒ…å ±ã�®è¡¨ç¤ºã€�登録を行ã�†ã�Ÿã‚�ã�®ã‚¿ã‚°ã�§ã�™ã?
038     * (ã�“ã?ã‚¿ã‚°ã�¯æ¨™æº–ã?設定編é›?”»é�¢ã�«çµ?�¿è¾¼ã‚“ã�§ä½¿ç”¨ã�•れã€�å�„ç”»é�¢JSPã�‹ã‚‰å‘¼ã�³å‡ºã�™ã�“ã�¨ã�¯ã�‚りã�¾ã�›ã‚“)
039     *
040     * ã�“ã?ã‚¿ã‚°ã�¯ã€�ユーザーå�˜ä½�ã�«ç®¡ç�?�•れるエãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã�«å¯¾ã�™ã‚‹I/Fã�®æ©Ÿè?ã‚?
041     * æ��ä¾›ã�—ã�¦ã�?�¾ã�™ã?ã�“ã?エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトã�«ã�¤ã�?�¦ã�¯ã€�ç”»é�¢æ¯Žã�«è¨­å®šã‚’行ã�†ã�Ÿã‚�ã€?
042     * ã‚¿ã‚°ã�®å‘¼ã�³å‡ºã�—ã�«ã�¯ã€�ç”»é�¢IDã�Œå¿??ã�¨ã�ªã�£ã�¦ã�?�¾ã�™ã?
043     *
044     * 具体的ã�ªæ©Ÿè?ã�¨ã�—ã�¦ã�¯ã€?ã�¤ã�®æ©Ÿè?ã‚’æ��ä¾›ã�—ã�¾ã�™ã?
045     * (1)設定画�表示(command="GET")
046     *    ユーザーå�˜ä½�ã�«ç®¡ç�?�•れるエãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクトをHTMLã�«å¤‰æ�›ã�—ã�¦è¡¨ç¤º
047     *    ã�¾ã�Ÿã?表示カラãƒ??ä¸?¦§(カンマ区åˆ?‚Š)ã�«ã�¤ã�?�¦ã�¯ã€�ç”»é�¢å�´ã�®JavaScriptã�§å†�設定を行ã�†ã�Ÿã‚�ã€?
048     *    ã��ã?値ã‚?viewClms"ã�¨ã�?�†å��å‰�ã�®hiddenã‚¿ã‚°ã�§å‡ºåŠ›ã�—ã�¾ã�™ã?
049     * (2)エãƒ?‚£ãƒ?ƒˆå��ä¸?¦§(command="LIST")
050     *    æŒ?®šã?ç”»é�¢IDã�«å¯¾ã�—ã�¦ã€�設定ã�•れã�¦ã�?‚‹ã‚¨ãƒ?‚£ãƒ?ƒˆå��ã?ä¸?¦§ã‚’ã?ルãƒ?‚¦ãƒ³(selectã‚¿ã‚°)ã�«
051     *    変æ�›ã�—ã�¦è¡¨ç¤ºã�—ã�¾ã�™ã?(name="editName")
052     * (3)設定情報登録/削除(command="SET"/"DELETE")
053     *    (1)ã�§è¨­å®šã�•れã�Ÿå†?®¹ã�«å¯¾ã�—ã�¦ã€�エãƒ?‚£ãƒ?ƒˆå��ã‚’æŒ?®šã�—ã�¦ã��ã?å†?®¹ã‚’ä¿�å­?削除ã�—ã�¾ã�™ã?
054     *    æƒ??ã�®ä¿�å­˜ã?ã€�command="GET"ã�§è¡¨ç¤ºã�•れるé?ç›®å��ã�¨é€£å‹•ã�—ã�¦ã�?�¾ã�™ã?ã�§ã€�å�˜ç‹¬ã�§ã�®ä½¿ç”¨ã�¯
055     *    ����ん�
056     *
057     * @og.formSample
058     * â—�å½¢å¼�:ä¸?ˆ¬ãƒ¦ãƒ¼ã‚¶ãƒ¼ã�Œç›´æŽ¥çµ?�¿è¾¼ã‚?�“ã�¨ã�¯ã�‚りã�¾ã�›ã‚“ã€?
059     * â—�body?šã�ªã�?
060     *
061     * �Tag定義??
062     *   <og:editConfig
063     *       command          â—‹ã?TAG】command を指定ã�—ã�¾ã�?å¿??)ã€?
064     *       gamenId          â—‹ã?TAG】画é�¢ID を指定ã�—ã�¾ã�?å¿??)ã€?
065     *       editName           ã€�TAG】エãƒ?‚£ãƒ?ƒˆå�?を指定ã�—ã�¾ã�?
066     *       debug              ã€�TAG】デãƒ�ッグæƒ??ã‚’å?力ã�™ã‚‹ã�‹ã�©ã�?�‹[true/false]を指定ã�—ã�¾ã�?åˆ�期値:false)
067     *   />
068     *
069     * �使用�
070     *     <og:editConfig command="{@command}" gamenId="{@gamenId}" editName="{@editName}" />
071     *
072     *     <og:editConfig
073     *         command        = command設�(GET/LIST/SET/REMOVE)
074     *         gamenId        = "GE0000"    画�ID
075     *       [ editName ]     = "EDITNAME"  エãƒ?‚£ãƒ?ƒˆå�?
076     *     />
077     *
078     * @og.group エãƒ?‚£ãƒ?ƒˆè¨­å®?
079     *
080     * @og.rev 5.3.6.0 (2011/06/01)
081     *
082     * @version  5.0
083     * @author       Hiroki Nakamura
084     * @since    JDK6.0,
085     */
086    public class EditConfigTag extends CommonTagSupport {
087            //* ã�“ã?プログラãƒ??VERSIONæ–?­—å?を設定ã�—ã�¾ã�™ã?       {@value} */
088            private static final String VERSION = "5.7.5.2 (2014/04/11)" ;
089    
090            private static final long serialVersionUID = 575220140411L ;
091    
092            private static final String VIEW_PREFIX                 = "EDIT_VIEW_";
093            private static final String SUM_PREFIX                  = "EDIT_SUM_";
094            private static final String GROUP_PREFIX                = "EDIT_GROUP_";
095            private static final String SUBTOTAL_PREFIX             = "EDIT_SUBTOTAL_";
096            private static final String TOTAL_PREFIX                = "EDIT_TOTAL_";
097            private static final String ORDERBY_PREFIX              = "EDIT_ORDERBY_";
098            private static final String DESC_PREFIX                 = "EDIT_DESC_";
099            private static final String GRANDTOTAL_PREFIX   = "EDIT_GRANDTOTAL_";
100            private static final String COMMON_PREFIX               = "EDIT_COMMON_";
101    
102            private String  command                 = null;         // EW" �ア�?ロー�"COPY|INSERT"
103            private String  gamenId                 = null;
104            private String  editName                = null;
105    
106            private transient DBTableModel table            = null;         // 5.5.2.4 (2012/05/16) transient 定義追�
107            private transient DBEditConfig config           = null;         // 5.5.2.4 (2012/05/16) transient 定義追�
108            
109            private boolean orderOnly               = false; // 5.5.5.2 (2012/08/10)
110    
111            /**
112             * Taglibã�®é–‹å§‹ã‚¿ã‚°ã�Œè¦‹ã�¤ã�‹ã�£ã�Ÿã�¨ã��ã�«å‡¦ç�?�™ã‚?doStartTag() ã‚?オーãƒ�ã?ライドã�—ã�¾ã�™ã?
113             *
114             * @return      後続å?ç�??æŒ?¤º(SKIP_BODY)
115             */
116            @Override
117            public int doStartTag() {
118                    return(SKIP_BODY);                              // Body を評価���
119            }
120    
121            /**
122             * Taglibã�®çµ‚äº?‚¿ã‚°ã�Œè¦‹ã�¤ã�‹ã�£ã�Ÿã�¨ã��ã�«å‡¦ç�?�™ã‚?doEndTag() ã‚?オーãƒ�ã?ライドã�—ã�¾ã�™ã?
123             *
124             * @og.rev 5.7.1.2 (2013/12/20) msg �errMsg 変更
125             *
126             * @return      後続å?ç�??æŒ?¤º
127             */
128            @Override
129            public int doEndTag() {
130                    debugPrint();
131    
132                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
133    
134                    // エãƒ?‚£ãƒ?ƒˆæƒ??ã‚’HTMLã�«å¤‰æ�›ã�—ã�¦è¡¨ç¤ºã�—ã�¾ã�™ã?
135                    // 表示ã�«å½“ã�Ÿã�£ã�¦ã€�最後ã�«ç™ºè¡Œã�•れã�ŸQUERYã�®tableIdã€�scopeã‚’ãƒ�ã‚§ãƒ?‚¯ã�—ã�Ÿä¸Šã�§
136                    // 表示ã�™ã‚‹ã�‹ã‚’判断ã�—ã�¾ã�™ã?
137                    if( "GET".equals( command ) ) {
138                            DBLastSql lastSql = (DBLastSql)getSessionAttribute( HybsSystem.DB_LAST_SQL_KEY );
139                            if( lastSql != null ) {
140                                    if( !lastSql.isViewEditable() ) {
141                                            // ã�“ã?ç”»é�¢ã�¯ã€??ç›®ã�®ä¸¦ã�³æ›¿ã�ˆã?ã�§ã��ã�¾ã�›ã‚“ã€?
142                                            String rtn = "<b style=\"font-color:red;\">" + getResource().getLabel( "GEE0003" ) + "</b>";
143                                            jspPrint( rtn );
144                                    }
145                                    else if( lastSql.isGuiMatch( gamenId ) ) {
146                                            setScope( lastSql.getScope() );
147                                            table = (DBTableModel)getObject( lastSql.getTableId() );
148                                            if( table != null ) {
149                                                    config = getUser().getEditConfig( gamenId, editName );
150                                                    String viewClms = null;
151                                                    if( config == null ) {
152                                                            viewClms = lastSql.getViewClmNames();
153                                                            config = new DBEditConfig();
154                                                    }
155                                                    else {
156    //                                                      viewClms = config.getViewClms();
157                                                            viewClms = config.getViewClms( lastSql.getOrgClmNames() );
158                                                    }
159                                                    buf.append( makeEditTable( viewClms ) );
160                                            }
161                                    }
162                            }
163                    }
164                    // エãƒ?‚£ãƒ?ƒˆæƒ??ã‚’ä¿�å­˜ã�—ã�¾ã�™ã?
165                    else if( "SET".equals( command ) ) {
166                            if( editName == null || editName.length() == 0 ) {
167    //                              String msg = "エãƒ?‚£ãƒ?ƒˆå��ã�ŒæŒ?®šã�•れã�¦ã�?�¾ã�›ã‚“ã€?;
168    //                              throw new HybsSystemException( msg );
169                                    String errMsg = "エãƒ?‚£ãƒ?ƒˆå��ã�ŒæŒ?®šã�•れã�¦ã�?�¾ã�›ã‚“ã€?;
170                                    throw new HybsSystemException( errMsg );        // 5.7.1.2 (2013/12/20) msg �errMsg 変更
171                            }
172                            saveEditConfig();
173                    }
174                    // エãƒ?‚£ãƒ?ƒˆæƒ??を削除ã�—ã�¾ã�™ã?
175                    else if( "DELETE".equals( command ) ) {
176                            if( editName == null || editName.length() == 0 ) {
177    //                              String msg = "エãƒ?‚£ãƒ?ƒˆå��ã�ŒæŒ?®šã�•れã�¦ã�?�¾ã�›ã‚“ã€?;
178    //                              throw new HybsSystemException( msg );
179                                    String errMsg = "エãƒ?‚£ãƒ?ƒˆå��ã�ŒæŒ?®šã�•れã�¦ã�?�¾ã�›ã‚“ã€?;
180                                    throw new HybsSystemException( errMsg );        // 5.7.1.2 (2013/12/20) msg �errMsg 変更
181                            }
182                            deleteEditConfig();
183                    }
184                    // æŒ?®šã�•れã�Ÿç”»é�¢IDã�«å¯¾ã�™ã‚‹ã‚¨ãƒ?‚£ãƒ?ƒˆæƒ??ã�®ä¸?¦§(プルãƒ?‚¦ãƒ³)を表示ã�—ã�¾ã�™ã?
185                    else if( "LIST".equals( command ) ) {
186                            DBEditConfig[] configs = getUser().getEditConfigs( gamenId );
187                            if( configs != null && configs.length > 0 ) {
188                                    buf.append( getEditSelect( configs ) ).append( HybsSystem.CR );
189                            }
190                    }
191    
192                    jspPrint( buf.toString() );
193    
194                    return(EVAL_PAGE);
195            }
196    
197            /**
198             * タグリブオブジェクトをリリースã�—ã�¾ã�™ã?
199             * キャãƒ?‚·ãƒ¥ã�•れã�¦å†�利用ã�•れるã?ã�§ã€�フィールドã?åˆ�期設定を行ã�„ã�¾ã�™ã?
200             *
201             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
202             */
203            @Override
204            protected void release2() {
205                    super.release2();
206                    command = "GET";
207                    gamenId = null;
208                    editName = null;
209                    table = null;
210                    config = null;
211                    orderOnly               = false; //5.5.5.2 (2012/08/10)
212            }
213    
214            /**
215             * エãƒ?‚£ãƒ?ƒˆæƒ??ã‚’HTMLã�«å¤‰æ�›ã�—ã�¦è¡¨ç¤ºã�—ã�¾ã�™ã?
216             *
217             * @og.rev 5.4.2.0 (2011/12/01) 入替ã�ˆå¯¾è±¡ã�®ã‚«ãƒ©ãƒ??ã�§ã�®ã�¿ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã�Œè¡¨ç¤ºã�•れるよã�?�«å¯¾å¿œã�—ã�¾ã�™ã?
218             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
219             *
220             * @param viewClms 表示カラãƒ?カンマ区åˆ?‚Š)
221             *
222             * @return エãƒ?‚£ãƒ?ƒˆæƒ??ã�®HTML
223             */
224            private String makeEditTable( final String viewClms ) {
225                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
226    
227                    boolean useSum = getUseSum( viewClms );
228                    String[] viewGroups = StringUtil.csv2Array( viewClms, '|' );
229                    buf.append( "<input type=\"hidden\" name=\"viewClms\" id=\"viewClms\" value=\"" + viewClms + "\"/>" );
230                    buf.append( "<div />" );
231                    buf.append( "<div style=\"float:left;\">" );
232                    buf.append( makeLabelRow( useSum ) );
233                    buf.append( "</div>" );
234                    buf.append( "<div id=\"clmLayer\" style=\" float:left; width: 670px;overflow-x:scroll;\">" );
235                    for( int i=0; i<viewGroups.length; i++ ) {
236                            if( i > 0 ) {
237                                    buf.append( makeSeparateRow( useSum ) );
238                            }
239                            buf.append( "<table class=\"clmGroup\" style=\"float:left;\"><tr>" );
240                            String[] clms = StringUtil.csv2Array( viewGroups[i] );
241                            for( int j=0; j<clms.length; j++ ) {
242                                    String clm = ( !clms[j].startsWith( "!" ) ? clms[j] : clms[j].substring( 1 ) );
243                                    if( "rowCount".equals( clm ) ) { continue; }
244                                    boolean isView = ( !clms[j].startsWith( "!" ) ? true : false );
245                                    buf.append( makeColumnRow( clm, isView, useSum, config ) );
246                            }
247                            buf.append( "</tr></table>" );
248                    }
249                    buf.append( "</div>" );
250    
251                    String grandTotalLabel = "<b>" + getDBColumn( GRANDTOTAL_PREFIX + "LABEL" ).getLongLabel() + ":</b>";
252                    buf.append( "<div style=\"clear:both;\">" );
253                    buf.append( "<table>" );
254    //              buf.append( makeCheckbox( GRANDTOTAL_PREFIX, config.useGrandTotal(), "h", grandTotalLabel ) );
255                    buf.append( makeCheckbox( GRANDTOTAL_PREFIX, config.useGrandTotal(), "h", grandTotalLabel, orderOnly ) ); // 5.5.5.2 (2012/08/10)
256                    buf.append( "</table>" );
257                    buf.append( "</div>" );
258    
259                    return buf.toString();
260            }
261    
262            /**
263             * エãƒ?‚£ãƒ?ƒˆæƒ??ã�®ãƒ˜ãƒƒãƒ??(ラベルè¡?ã�®HTMLを生æˆ�ã�—ã�¾ã�™ã?
264             *
265             * @og.rev 5.4.2.0 (2011/12/01) 表示é ?›®ã�®å…¨ãƒ�ã‚§ãƒ?‚¯æ©Ÿè?を追åŠ?
266             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
267             *
268             * @param useSum é›?¨ˆå¯¾è±¡ã�®ã‚«ãƒ©ãƒ?=NUMBERåž?ã�Œå­˜åœ¨ã�—ã�¦ã�?‚‹ã�?
269             *
270             * @return エãƒ?‚£ãƒ?ƒˆæƒ??ã�®ãƒ˜ãƒƒãƒ??(ラベルè¡?ã�®HTML
271             */
272            private String makeLabelRow( final boolean useSum ) {
273                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
274                    String commonLabel = "<b>" + getDBColumn( COMMON_PREFIX + "LABEL" ).getLongLabel() + ":</b>";
275                    String canEditCommon = HybsSystem.sys( "EDIT_COMMON_ROLES" );
276    
277                    String groupLabel = "<b>" + getDBColumn( GROUP_PREFIX + "LABEL" ).getLongLabel() + "</b>";
278                    groupLabel += "<img id=\"groupBtn\" src=\"" + HybsSystem.sys( "JSP" ) + "/image/ball-green.gif\" />";
279    
280                    buf.append( "<table><tr>" );
281                    buf.append( "<td style=\"margin:0px; padding:0px;\"><table>" );
282                    if( getUser().isAccess( canEditCommon ) ) {
283    //                      buf.append( makeCheckbox( COMMON_PREFIX, config.isCommon(), "h", commonLabel ) );
284                            buf.append( makeCheckbox( COMMON_PREFIX, config.isCommon(), "h", commonLabel, orderOnly ) ); // 5.5.5.2 (2012/08/10)
285                    }
286                    else {
287                            buf.append( makeLabel   ( commonLabel ) );
288                    }
289    //              buf.append( makeLabel   ( VIEW_PREFIX           + "LABEL" ) );
290                    String viewLabel = "<b>" + getDBColumn( VIEW_PREFIX + "LABEL" ).getLongLabel() + ":</b>";
291    //              buf.append( makeCheckbox( "VIEW_ALL_CHECK", true, "h", viewLabel ) );
292                    buf.append( makeCheckbox( "VIEW_ALL_CHECK", true, "h", viewLabel, orderOnly ) ); // 5.5.5.2 (2012/08/10)
293                    if( useSum ) {
294                            buf.append( makeLabel   ( SUM_PREFIX            + "LABEL" ) );
295                    }
296                    buf.append( makeCell    ( groupLabel, "h" ) );
297                    buf.append( makeLabel   ( SUBTOTAL_PREFIX       + "LABEL" ) );
298                    buf.append( makeLabel   ( TOTAL_PREFIX          + "LABEL" ) );
299                    buf.append( makeLabel   ( ORDERBY_PREFIX        + "LABEL" ) );
300                    buf.append( makeLabel   ( DESC_PREFIX           + "LABEL" ) );
301                    buf.append( "</table></td>" );
302                    buf.append( "</tr></table>" );
303                    return buf.toString();
304            }
305    
306            /**
307             * エãƒ?‚£ãƒ?ƒˆæƒ??ã�®ã‚«ãƒ©ãƒ??ã�®HTMLを生æˆ�ã�—ã�¾ã�™ã?
308             * 
309             * @og.rev 5.5.5.2 (2012/08/10) orderOnly対�
310             * @og.rev 5.7.5.2 (2014/04/11) é™�é?ã�¯orderOnlyã�«é–¢ã‚�らã�šç·¨é›?�¯èƒ½ã�«ã�™ã‚‹
311             *
312             * @param clm カラ�
313             * @param isView 表示対象ã�‹ã�©ã�?�‹
314             * @param useSum é›?¨ˆå¯¾è±¡ã�®ã‚«ãƒ©ãƒ?=NUMBERåž?ã�Œå­˜åœ¨ã�—ã�¦ã�?‚‹ã�?
315             * @param config エãƒ?‚£ãƒ?ƒˆè¨­å®šã‚ªãƒ–ジェクãƒ?
316             *
317             * @return エãƒ?‚£ãƒ?ƒˆæƒ??ã�®ã‚«ãƒ©ãƒ??ã�®HTMLを生æˆ�ã�—ã�¾ã�™ã?
318             */
319            private String makeColumnRow( final String clm, final boolean isView, final boolean useSum, final DBEditConfig config ) {
320                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
321    
322                    int clmNo = table.getColumnNo( clm, false  );
323                    DBColumn column = ( clmNo < 0 ? getDBColumn( clm ) : table.getDBColumn( clmNo ) );
324                    buf.append( "<td name=\"" ).append( clm ).append( "\" class=\"sortItem\" style=\"margin:0px; padding:0px;\">" );
325                    buf.append( "<table>" );
326                    buf.append( makeLabel   ( column.getLongLabel() ) );
327    //              buf.append( makeCheckbox( VIEW_PREFIX                   + clm, isView                                           , "0", null ) );
328                    buf.append( makeCheckbox( VIEW_PREFIX                   + clm, isView                                           , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
329                    if( useSum ) {
330                            boolean isSumClm = isNumberClm( clm );
331    //                      buf.append( makeCheckbox( SUM_PREFIX            + clm, config.isSumClm( clm )           , "1", isSumClm , null ) );
332                            buf.append( makeCheckbox( SUM_PREFIX            + clm, config.isSumClm( clm )           , "1", isSumClm , null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
333                    }
334    //              buf.append( makeCheckbox( GROUP_PREFIX          + clm, config.isGroupClm( clm )         , "0", null ) );
335    //              buf.append( makeCheckbox( SUBTOTAL_PREFIX       + clm, config.isSubTotalClm( clm )      , "1", null ) );
336    //              buf.append( makeCheckbox( TOTAL_PREFIX          + clm, config.isTotalClm( clm )         , "0", null ) );
337    //              buf.append( makeInput   ( ORDERBY_PREFIX                + clm, config.getOrder( clm )           , "1", null ) );
338    //              buf.append( makeCheckbox( DESC_PREFIX                   + clm, config.isOrderByDesc( clm )      , "0", null ) );
339                    buf.append( makeCheckbox( GROUP_PREFIX          + clm, config.isGroupClm( clm )         , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
340                    buf.append( makeCheckbox( SUBTOTAL_PREFIX       + clm, config.isSubTotalClm( clm )      , "1", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
341                    buf.append( makeCheckbox( TOTAL_PREFIX          + clm, config.isTotalClm( clm )         , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
342                    buf.append( makeInput   ( ORDERBY_PREFIX                + clm, config.getOrder( clm )           , "1", null ) );
343    //              buf.append( makeCheckbox( DESC_PREFIX                   + clm, config.isOrderByDesc( clm )      , "0", null, orderOnly ) ); // 5.5.5.2 (2012/08/10)
344                    buf.append( makeCheckbox( DESC_PREFIX                   + clm, config.isOrderByDesc( clm )      , "0", null, false ) ); // 5.7.5.1 (2014/04/11)
345                    buf.append( "</table>" );
346                    buf.append( "</td>" );
347    
348                    return buf.toString();
349            }
350    
351            /**
352             * ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®HTMLæ–?­—å?を生æˆ�ã�—ã�¾ã�™ã?
353             * 生æ?ã�—ã�ŸHTMLã�¯ä»¥ä¸‹ã?よã�†ã�«ã�ªã‚Šã�¾ã�™ã?
354             * ä¾?&lt;tr&gt;&lt;td class="row_[bgCnt]" ...&gt;[prefix]&lt;input type="checkbox" name="[clm]" ... /&gt;&lt;/td&gt;&lt;/tr&gt;
355             *
356             * @param clm カラ�
357             * @param checked åˆ�期ãƒ�ã‚§ãƒ?‚¯ã�™ã‚‹ã�‹ã�©ã�?�‹
358             * @param bgCnt 背景色ゼブラカラーã�®æŒ?®?"0"or"1"or"h")
359             * @param prefix ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®ã‚¿ã‚°ã�®å‰�ã�«æŒ¿å…¥ã�™ã‚‹HTMLæ–?­—å?
360             * @param readonly リードオンリー
361             * 
362             * @og.rev 5.5.5.2 (2012/08/10) readOnly追�
363             *
364             * @return ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®HMTLæ–?­—å?
365             */
366    //      private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final String prefix ) {
367            private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final String prefix, final boolean readonly ) {
368                    return makeCheckbox( clm, checked, bgCnt, true, prefix, readonly );
369            }
370    
371            /**
372             * ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®HTMLæ–?­—å?を生æˆ�ã�—ã�¾ã�™ã?
373             * 生æ?ã�—ã�ŸHTMLã�¯ä»¥ä¸‹ã?よã�†ã�«ã�ªã‚Šã�¾ã�™ã?
374             * ä¾?&lt;tr&gt;&lt;td class="row_[bgCnt]" ...&gt;[prefix]&lt;input type="checkbox" name="[clm]" ... /&gt;&lt;/td&gt;&lt;/tr&gt;
375             *
376             * @param clm カラ�
377             * @param checked åˆ�期ãƒ�ã‚§ãƒ?‚¯ã�™ã‚‹ã�‹ã�©ã�?�‹
378             * @param bgCnt 背景色ゼブラカラーã�®æŒ?®?"0"or"1"or"h")
379             * @param isChbox ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã‚’生æˆ�ã�™ã‚‹ã�‹ã�©ã�?�‹(falseã�®å ´å�ˆã?ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®inputã‚¿ã‚°ã�¯ç”Ÿæ?ã�•れã�¾ã�›ã‚“)
380             * @param prefix ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®ã‚¿ã‚°ã�®å‰�ã�«æŒ¿å…¥ã�™ã‚‹HTMLæ–?­—å?
381             * @param readonly リードオンリー
382             * 
383             * @og.rev 5.5.5.2 (2012/08/10) readOnly追�
384             *
385             * @return ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®HMTLæ–?­—å?
386             */
387    //      private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final boolean isChbox, final String prefix ) {
388            private String makeCheckbox( final String clm, final boolean checked, final String bgCnt, final boolean isChbox, final String prefix, final boolean readonly ) {
389                    if( isChbox ) {
390                            String suffix = "";
391                            TagBuffer tag = new TagBuffer( "input" );
392                            tag.add( "type", "checkbox" );
393                            tag.add( "name", clm );
394                            tag.add( "value", "1" );
395                            if( checked ) {
396                                    tag.add( "checked", "checked" );
397                            }
398                            if( readonly ){ // 5.5.5.2 (2012/08/10)
399                                    tag.add( "disabled", "disabled" );
400                                    if( checked ){
401                                            TagBuffer tag2 = new TagBuffer( "input" );
402                                            tag2.add( "type", "hidden" );
403                                            tag2.add( "name", clm );
404                                            tag2.add( "value", "1" );
405                                            suffix += tag2.makeTag();
406                                    }
407                                    
408                            }
409    //                      return makeCell( ( prefix == null ? "" : prefix ) + tag.makeTag(), bgCnt );
410                            return makeCell( ( prefix == null ? "" : prefix ) + tag.makeTag() + suffix, bgCnt ); // 5.5.5.2 (2012/08/10)
411                    }
412                    else {
413                            return makeCell( ( prefix == null ? "" : prefix ) + "&nbsp;", bgCnt );
414                    }
415            }
416    
417            /**
418             * ãƒ?‚­ã‚¹ãƒˆå?力HTMLæ–?­—å?を生æˆ�ã�—ã�¾ã�™ã?
419             * 生æ?ã�—ã�ŸHTMLã�¯ä»¥ä¸‹ã?よã�†ã�«ã�ªã‚Šã�¾ã�™ã?
420             * ä¾?&lt;tr&gt;&lt;td class="row_[bgCnt]" ...&gt;[prefix]&lt;input type="text" name="[clm]" ... /&gt;&lt;/td&gt;&lt;/tr&gt;
421             *
422             * @param clm カラ�
423             * @param value åˆ�期ãƒ�ã‚§ãƒ?‚¯ã�™ã‚‹ã�‹ã�©ã�?�‹
424             * @param bgCnt 背景色ゼブラカラーã�®æŒ?®?"0"or"1"or"h")
425             * @param prefix ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®ã‚¿ã‚°ã�®å‰�ã�«æŒ¿å…¥ã�™ã‚‹HTMLæ–?­—å?
426             *
427             * @return ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®HMTLæ–?­—å?
428             */
429            private String makeInput( final String clm, final String value, final String bgCnt, final String prefix ) {
430                    TagBuffer tag = new TagBuffer( "input" );
431                    tag.add( "type", "text" );
432                    tag.add( "name", clm );
433                    tag.add( "value", value );
434                    tag.add( "style", "width: 10px; font-size:10px;" );
435                    tag.add( "maxlength", "2" );
436                    tag.add( "class", "S9" );
437    
438                    return makeCell( ( prefix == null ? "" : prefix ) + tag.makeTag(), bgCnt );
439            }
440    
441            /**
442             * å·¦å�³åˆ?‰²ã�•れã�¦ã�?‚‹éš›ã?åˆ?‰²åˆ—ã?HTMLæ–?­—å?を生æˆ�ã�—ã�¾ã�™ã?
443             *
444             * @param useSum é›?¨ˆå¯¾è±¡ã�®ã‚«ãƒ©ãƒ?=NUMBERåž?ã�Œå­˜åœ¨ã�—ã�¦ã�?‚‹ã�?
445             *
446             * @return ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®HMTLæ–?­—å?
447             */
448            private String makeSeparateRow( final boolean useSum ) {
449                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
450    
451                    buf.append( "<table style=\"float:left;\"><tr>" );
452                    buf.append( "<td style=\"margin:0px; padding:0px;\"><table>" );
453                    buf.append( makeCell( "&nbsp", "h" ) );             // ラベル
454                    buf.append( makeCell( "&nbsp", "h" ) );             // 表示
455                    if( useSum ) {
456                            buf.append( makeCell( "&nbsp", "h" ) );             // é›?¨ˆé?ç›®
457                    }
458                    buf.append( makeCell( "&nbsp", "h" ) ); // é›?¨ˆã‚­ãƒ¼
459                    buf.append( makeCell( "&nbsp", "h" ) );     // �計キー
460                    buf.append( makeCell( "&nbsp", "h" ) ); // �計キー
461                    buf.append( makeCell( "&nbsp", "h" ) ); // 表示�
462                    buf.append( makeCell( "&nbsp", "h" ) ); // æ˜??・é™�é?
463                    buf.append( "</table></td>");
464                    buf.append( "</tr></table>" );
465    
466                    return buf.toString();
467            }
468    
469            /**
470             * ラベルã�®HTMLæ–?­—å?を生æˆ�ã�—ã�¾ã�™ã?
471             *
472             * @param clm カラ�
473             *
474             * @return ラベルã�®HTMLæ–?­—å?
475             */
476            private String makeLabel( final String clm ) {
477                    return makeCell( getDBColumn( clm ).getLongLabel(), "h" );
478            }
479    
480            /**
481             * セルã�®HTMLæ–?­—å?を生æˆ�ã�—ã�¾ã�™ã?
482             *
483             * @param body tdã‚¿ã‚°å†??HTMLæ–?­—å?
484             * @param bgCnt 背景色ゼブラカラーã�®æŒ?®?"0"or"1"or"h")
485             *
486             * @return セルã�®HTMLæ–?­—å?
487             */
488            private String makeCell( final String body, final String bgCnt ) {
489                    return "<tr><td align=\"center\" style=\"height:22px;\" class=\"row_" + bgCnt + "\">" + body + "</td></tr>";
490            }
491    
492            /**
493             * ã�“ã?エãƒ?‚£ãƒ?ƒˆè¨­å®šã�§é›?¨ˆå¯¾è±¡ã�®ã‚«ãƒ©ãƒ?=NUMBERåž?ã�Œå­˜åœ¨ã�—ã�¦ã�?‚‹ã�‹ã‚’è¿”ã�—ã�¾ã�™ã?
494             *
495             * @param viewClms カラ�
496             *
497             * @return é›?¨ˆå¯¾è±¡ã�®ã‚«ãƒ©ãƒ?=NUMBERåž?ã�Œå­˜åœ¨ã�—ã�¦ã�?‚‹ã�?
498             */
499            private boolean getUseSum( final String viewClms ) {
500                    if( viewClms == null ) { return false; }
501    
502                    boolean rtn = false;
503                    String[] clms = StringUtil.csv2Array( viewClms.replace( '|', ',' ) );
504                    for( int j=0; j<clms.length; j++ ) {
505                            String clm = ( !clms[j].startsWith( "!" ) ? clms[j] : clms[j].substring( 1 ) );
506                            rtn = isNumberClm( clm );
507                            if( rtn ) { break; }
508                    }
509                    return rtn;
510            }
511    
512            /**
513             * 引数ã�®ã‚«ãƒ©ãƒ?�ŒNUMBERåž‹ã�‹ã�©ã�?�‹ã‚’ãƒ�ã‚§ãƒ?‚¯ã�—ã�¾ã�™ã?
514             *
515             * @param clm カラ�
516             *
517             * @return NUMBERåž‹ã�‹ã�©ã�?�‹
518             */
519            private boolean isNumberClm( final String clm ) {
520                    if( clm == null ) { return false; }
521    
522                    int no = table.getColumnNo( clm, false );
523                    if( no >= 0 ) {
524                            DBColumn dbClm = table.getDBColumn( table.getColumnNo( clm ) );
525                            if( dbClm != null ) {
526                                    if( "NUMBER".equals( dbClm.getClassName()) ) {
527                                            return true;
528                                    }
529                            }
530                    }
531                    return false;
532            }
533    
534            /**
535             * エãƒ?‚£ãƒ?ƒˆè¨­å®šæƒ…報をä¿�å­˜ã�—ã�¾ã�™ã?
536             */
537            private void saveEditConfig() {
538                    String viewClms         = getRequest().getParameter( "viewClms" );
539                    String sumClms          = getColumns( SUM_PREFIX );
540                    String groupClms        = getColumns( GROUP_PREFIX );
541                    String subTotalClms = getColumns( SUBTOTAL_PREFIX );
542                    String totalClms        = getColumns( TOTAL_PREFIX );
543                    String useGrandTotal= getRequest().getParameter( GRANDTOTAL_PREFIX );
544                    String orderByClms      = getOrderByColumns();
545                    String isCommon         = getRequest().getParameter( COMMON_PREFIX );
546    
547                    DBEditConfig config
548                            = new DBEditConfig( editName, viewClms, sumClms, groupClms
549                                                                    , subTotalClms, totalClms, useGrandTotal, orderByClms, isCommon );
550    
551                    getUser().addEditConfig( gamenId, editName, config );
552            }
553    
554            /**
555             * エãƒ?‚£ãƒ?ƒˆè¨­å®šæƒ…報を削除ã�—ã�¾ã�™ã?
556             */
557            private void deleteEditConfig() {
558                    getUser().deleteEditConfig( gamenId, editName );
559            }
560    
561            /**
562             * パラメーターã�‹ã‚‰å¼•æ•°ã�®ãƒ—レフィãƒ?‚¯ã‚¹ã‚’キーã�«ã€�ãƒ�ã‚§ãƒ?‚¯ã�•れã�Ÿã‚«ãƒ©ãƒ?¸?¦§(カンマ区åˆ?‚Š)ã‚’è¿”ã�—ã�¾ã�™ã?
563             *
564             * @param prefixKey å�?‚­ãƒ¼ã�®å�–å¾—ã�™ã‚‹ã�Ÿã‚�ã?プレフィãƒ?‚¯ã‚¹
565             *
566             * @return カラãƒ?¸?¦§(カンマ区åˆ?‚Š)
567             */
568            private String getColumns( final String prefixKey ) {
569                    StringBuilder buf = new StringBuilder();
570    
571                    Enumeration<?> enume = getParameterNames();
572                    while( enume.hasMoreElements() ) {
573                            String key = (String)(enume.nextElement());
574                            if( key.startsWith( prefixKey ) ) {
575                                    String val = getRequest().getParameter( key );
576                                    if( "1".equals( val ) ) {
577                                            String clm = key.substring( prefixKey.length() );
578                                            if( buf.length() > 0 ) { buf.append( "," ); }
579                                            buf.append( clm );
580                                    }
581                            }
582                    }
583    
584                    return buf.toString();
585            }
586    
587            /**
588             * 表示é ??カラãƒ?¸?¦§(カンマ区åˆ?‚Š)ã‚’è¿”ã�—ã�¾ã�™ã?
589             *
590             * @return 表示é ??カラãƒ?¸?¦§(カンマ区åˆ?‚Š)
591             */
592            private String getOrderByColumns() {
593                    Enumeration<?> enume = getParameterNames();
594                    List<Integer> orderNo = new ArrayList<Integer>();
595                    Map<Integer,String> orderClm = new HashMap<Integer,String>();
596                    while( enume.hasMoreElements() ) {
597                            String key = (String)(enume.nextElement());
598                            if( key.startsWith( ORDERBY_PREFIX ) ) {
599                                    String val = getRequest().getParameter( key );
600                                    if( val != null && val.length() > 0 ) {
601                                            String clm = key.substring( ORDERBY_PREFIX.length() );
602                                            String desc = getRequest().getParameter( DESC_PREFIX + clm );
603                                            if( "1".equals( desc ) ) {
604                                                    clm = "!"  + clm;
605                                            }
606                                            // æ•°å­—é?目以外ã�Œå…¥åŠ›ã�•れã�Ÿå ´å�ˆã?ç„¡è¦?
607                                            Integer odno = null;
608                                            try {
609                                                    odno = Integer.valueOf( val );
610                                            }
611                                            catch ( NumberFormatException ex ) {
612                                                    continue;
613                                            }
614                                            String str = orderClm.get( odno );
615                                            // å�Œã�˜ç•ªå�·ã�®å ´å�ˆã�§ã‚‚é‡�ã�ªã‚‰ã�ªã�?‚ˆã�?�«æŒ¯ã‚Šç›´ã�—ã�™ã‚‹ã?
616                                            while( str != null ) {
617                                                    odno = Integer.valueOf( odno.intValue() + 1 );
618                                                    str = orderClm.get( odno );
619                                            }
620                                            orderClm.put( odno, clm );
621                                            orderNo.add( odno );
622                                    }
623                            }
624                    }
625    
626                    Collections.sort( orderNo );
627    
628                    StringBuilder buf = new StringBuilder();
629                    for( Integer i : orderNo ) {
630                            if( buf.length() > 0 ) { buf.append( "," ); }
631                            String clm = orderClm.get( i );
632                            buf.append( clm );
633                    }
634    
635                    return buf.toString();
636            }
637    
638            /**
639             * エãƒ?‚£ãƒ?ƒˆè¨­å®šä¸?¦§ã�®ãƒ—ルãƒ?‚¦ãƒ³ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’作æ?ã�—ã�¾ã�™ã?
640             *
641             * @param       configs DBEditConfigé…�å?
642             *
643             * @return      エãƒ?‚£ãƒ?ƒˆä¸?¦§ã�®ãƒ—ルãƒ?‚¦ãƒ³
644             */
645            private String getEditSelect( final DBEditConfig[] configs ) {
646                    DBColumn column = getDBColumn( "editName" );
647    
648                    StringBuilder buf = new StringBuilder();
649                    buf.append( "<span class=\"label editName\">" )
650                            .append( column.getLongLabel() )
651                            .append( ":</span><span class=\"editName\">" )
652                            .append( "<select name=\"editName\">" )
653                            .append( "<option />" );
654                    for( DBEditConfig config : configs ) {
655                            String name = config.getEditName();
656                            buf.append( "<option value=\"" ).append( name ).append( "\"" );
657                            if( config.isCommon() ) {
658                                    buf.append( " class=\"commonEdit\"" );
659                            }
660                            buf.append( "\">" );
661                            buf.append( name ).append( "</option>" );
662                    }
663                    buf.append( "</select></span>" );
664                    return buf.toString();
665            }
666    
667            /**
668             * ã€�TAG】command を指定ã�—ã�¾ã�™ã?
669             *
670             * @og.tag
671             * command を指定ã�—ã�¾ã�™ã?
672             * [GET/LIST/SET/DELETE]ã�®ã�¿ã�Œè¨­å®šå�¯èƒ½ã�§ã�™ã?ã��れ以外ã?å ´å�ˆã?何も処ç�?�•れã�¾ã�›ã‚“ã€?
673             *
674             * @param       cmd コマンド[GET/LIST/SET/DELETE]
675             */
676            public void setCommand( final String cmd ) {
677                    command = nval( getRequestParameter( cmd ),command );
678            }
679    
680            /**
681             * ã€�TAG】画é�¢ID を指定ã�—ã�¾ã�™ã?
682             *
683             * @og.tag
684             * ç”»é�¢ID を指定ã�—ã�¾ã�™ã?
685             *
686             * @param       key 画�ID
687             */
688            public void setGamenId( final String key ) {
689                    gamenId = nval( getRequestParameter( key ),gamenId );
690            }
691    
692            /**
693             * ã€�TAG】エãƒ?‚£ãƒ?ƒˆå�?を指定ã�—ã�¾ã�™ã?
694             *
695             * @og.tag
696             * エãƒ?‚£ãƒ?ƒˆå�?を指定ã�—ã�¾ã�™ã?
697             * commandã�ŒSETã�¾ã�Ÿã?DELETEã�®å ´å�ˆã?å¿??ã�§ã�™ã?
698             * commandã�ŒGETã�¾ã�Ÿã?LISTã�®å ´å�ˆã?無効ã�§ã�™ã?
699             *
700             * @param       name エãƒ?‚£ãƒ?ƒˆå�?
701             */
702            public void setEditName( final String name ) {
703                    editName = nval( getRequestParameter( name ),editName );
704            }
705            
706            /**
707             * ã€�TAG】ãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®ãƒªãƒ¼ãƒ‰ã‚ªãƒ³ãƒªãƒ¼åŒ–を行ã�„ã�¾ã�?
708             *
709             * @og.tag
710             * é ?•ªã�®å…¥ã‚Œæ›¿ã�ˆã�¨ã€�表示é ??設定ã?ã�¿ã‚’行ã�†å ´å�ˆã�«trueã�«ã�—ã�¾ã�™ã?
711             * 表示/é�žè¡¨ç¤ºåˆ?›¿ã‚??é›?¨ˆæ©Ÿè?ã�¯åˆ©ç”¨ã�§ã��ã�ªã��ã�ªã‚Šã�¾ã�™ã?
712             * ?ˆãƒ�ã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã�®ãƒªãƒ¼ãƒ‰ã‚ªãƒ³ãƒªãƒ¼ã�¯ã�§ã��ã�ªã�?�Ÿã‚�ã?実際ã�«ã�¯disable+hiddenã�§å‡ºåŠ›ã�—ã�¦ã�?�¾ã�™ï¼?
713             *
714             * @og.rev 5.5.5.2 (2012/08/10) 新�追�
715             *
716             * @param   flag  [true:リードオンリー/ã��れ以å¤?ç·¨é›?�¯]
717             */
718            public void setOrderOnly( final String flag ) {
719                    orderOnly = nval( getRequestParameter( flag ),orderOnly );
720            }
721    
722            /**
723             * ã�“ã?オブジェクトã?æ–?­—å?表ç�¾ã‚’è¿”ã�—ã�¾ã�™ã?
724             * 基本çš?�«ãƒ?ƒ�ãƒ?‚°ç›®çš?�«ä½¿ç”¨ã�—ã�¾ã�™ã?
725             *
726             * @return ã�“ã?クラスã�®æ–?­—å?表ç�¾
727             */
728            @Override
729            public String toString() {
730                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
731                                    .println( "VERSION"             ,VERSION                )
732                                    .println( "command"             ,command                )
733                                    .println( "gamenId"             ,gamenId                )
734                                    .println( "editName"    ,editName               )
735                                    .println( "Other..."    ,getAttributes().getAttribute() )
736                                    .fixForm().toString() ;
737            }
738    }