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.plugin.column; 017 018 import org.opengion.hayabusa.common.HybsSystem; 019 import org.opengion.hayabusa.common.HybsSystemException; 020 021 import org.opengion.hayabusa.db.AbstractRenderer; 022 import org.opengion.hayabusa.db.CellRenderer; 023 import org.opengion.hayabusa.db.DBColumn; 024 import org.opengion.hayabusa.db.Selection; 025 import org.opengion.hayabusa.db.SelectionFactory; 026 import org.opengion.fukurou.util.StringFormat; 027 028 /** 029 * DBMENU レンãƒ?ƒ©ãƒ¼ã¯ã€è¡¨ç¤ºãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ã§æŒ?®šã•れ㟠SQLæ–?‚’実行ã—ã€? 030 * プルãƒ?‚¦ãƒ³ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã§è¡¨ç¤ºã™ã‚‹å ´åˆã«ä½¿ç”¨ã™ã‚‹ã‚¯ãƒ©ã‚¹ã§ã™ã? 031 * 032 * カラãƒ??表示ã«å¿?¦ãªå±žæ?ã¯, DBColumn オブジェクãƒ?よりå–り出ã—ã¾ã™ã? 033 * ã“ã?クラスã¯ã€DBColumn オブジェクト毎ã«?‘ã¤ä½œæ?ã•れã¾ã™ã? 034 * 035 * @og.rev 3.2.3.0 (2003/06/06) æ–°è¦ä½œæ? 036 * @og.rev 3.4.0.1 (2003/09/03) ?¤?¢æ¤œç´¢ã‚’リアルタイãƒ?«å¤‰æ›´ã€? 037 * @og.rev 3.5.4.2 (2003/12/15) 継承å…?‚¯ãƒ©ã‚¹ã‚’ã?Editor_DBMENU ã‹ã‚‰ AbstractRenderer ã«å¤‰æ›´ã€? 038 * @og.group ãƒ??タ表示 039 * 040 * @version 4.0 041 * @author Kazuhiko Hasegawa 042 * @since JDK5.0, 043 */ 044 public class Renderer_DBMENU extends AbstractRenderer { 045 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */ 046 private static final String VERSION = "5.6.2.3 (2013/03/22)" ; 047 048 private final String query ; 049 private final String dbid ; 050 private final String lang ; // 4.0.0 (2006/11/15) 051 private final String name ; 052 private final String useSLabel ; // 5.5.1.0 (2012/04/03) 053 private final String noDisplayVal ; // 5.6.2.3 (2013/03/22) 054 055 /** 056 * ãƒ?ƒ•ォルトコンストラクターã€? 057 * ã“ã?コンストラクターã§ã€åŸºæœ¬ã‚ªãƒ–ジェクトを作æ?ã—ã¾ã™ã? 058 * 059 * @og.rev 3.4.0.2 (2003/09/05) クラスå†?ƒ¨è¦‹ç›´ã—ã?query ã® final åŒ? 060 * @og.rev 3.5.4.2 (2003/12/15) name , query 変数をã?åˆæœŸè¨å®šã—ã¦ãŠãã¾ã™ã? 061 * @og.rev 5.6.2.3 (2013/03/22) noDisplayVal å¤‰æ•°åˆæœŸåŒ? 062 * 063 */ 064 public Renderer_DBMENU() { 065 query = null; // 3.5.4.2 (2003/12/15) 066 dbid = null; 067 lang = null; // 4.0.0 (2006/11/15) 068 name = null; // 3.5.4.2 (2003/12/15) 069 useSLabel = "auto"; // 5.5.1.0 (2012/04/03) 070 noDisplayVal = null; // 5.5.1.0 (2012/04/03) 071 } 072 073 /** 074 * ãƒ?ƒ•ォルトコンストラクターã€? 075 * 076 * @og.rev 3.3.1.1 (2003/07/03) CodeSelection ã®è¨å®šã«ãŠã„ã¦ã€ãƒã‚°ä¿®æ£ã€? 077 * @og.rev 3.4.0.1 (2003/09/03) 継承ã®è¦ªå…??変更ã«ä¼´ã?®Ÿè£??移動ã? 078 * @og.rev 3.5.4.2 (2003/12/15) 継承å…?‚¯ãƒ©ã‚¹ã‚’ã?Editor_DBMENU ã‹ã‚‰ AbstractRenderer ã«å¤‰æ›´ã€? 079 * @og.rev 3.5.5.9 (2004/06/07) editorParam 属æ?ã?null ã®å ´åˆã?ã€ã‚¨ãƒ©ãƒ¼ã¨ã—ã¾ã™ã? 080 * @og.rev 5.6.2.3 (2013/03/22) noDisplayVal 変数追åŠ? 081 * 082 * @param clm DBColumnオブジェクãƒ? 083 */ 084 private Renderer_DBMENU( final DBColumn clm ) { 085 name = clm.getName(); 086 query = clm.getRendererParam(); 087 dbid = clm.getDbid(); 088 lang = clm.getLang(); // 4.0.0 (2006/11/15) 089 useSLabel = clm.getUseSLabel() ; // 5.5.1.0 (2012/04/03) 090 noDisplayVal = clm.getNoDisplayVal(); // 5.6.2.3 (2013/03/22) 091 092 // 3.5.5.9 (2004/06/07) 093 if( query == null || query.length() == 0 ) { 094 String errMsg = "DBMENU Renderer ã§ã¯ã€è¡¨ç¤ºãƒ‘ラメータã¯å¿??ã§ã™ã?" 095 + " name=[" + name + "]" + HybsSystem.CR ; 096 throw new HybsSystemException( errMsg ); 097 } 098 } 099 100 /** 101 * å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã—ã¾ã™ã? 102 * 自åˆ??身をã‚ャãƒ?‚·ãƒ¥ã™ã‚‹ã®ã‹ã?æ–°ãŸã«ä½œæ?ã™ã‚‹ã®ã‹ã?ã€å„サブクラスã®å®Ÿè£?« 103 * ã¾ã‹ã•れã¾ã™ã? 104 * 105 * @param clm DBColumnオブジェクãƒ? 106 * 107 * @return CellRendererオブジェクãƒ? 108 */ 109 public CellRenderer newInstance( final DBColumn clm ) { 110 return new Renderer_DBMENU( clm ); 111 } 112 113 /** 114 * ãƒ??ã‚¿ã®è¡¨ç¤ºç”¨æ–?—å?ã‚’è¿”ã—ã¾ã™ã? 115 * 116 * ã“ã“ã§ã¯ã€AAA:BBB:CCC:DDD ã¨ã?†å€¤ã‚’ã?$1,$2,$3,$4 ã«å‰²ã‚Šå½“ã¦ãªãŠã—ã¦ã€? 117 * QUERYを実行ã—ã¾ã™ã?ã¾ãŸã?$1 ã¯ã€æœ¬æ¥ã®å€¤ã¨ã—ã¦ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®åˆæœŸå€¤è¨å®šç‰ã« 118 * 使用ã—ã¾ã™ã?上記ã?例ã§ã¯ã€AAA ãŒå?ã§ã€ãれ以é™ã?ã€å¼•æ•°ã«ãªã‚Šã¾ã™ã? 119 * ã•らã«ã€å?ã®æ–?—å?"AAA:BBB:CCC:DDD"ã¯ã€?0 ã«å‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¾ã™ã?割り当ã¦ãŒãªã? 120 * 変数ã¯ã€?"(ã‚¼ãƒæ–?—å?)ã¨ã—ã¦ã€æ‰±ã‚れã¾ã™ã? 121 * 122 * @og.rev 3.4.0.1 (2003/09/03) ?¤?¢æ¤œç´¢ã‚’リアルタイãƒ?«å¤‰æ›´ã€? 123 * @og.rev 3.4.0.2 (2003/09/05) AAA:BBB:CCC:DDD ã¨ã?†å€¤ã‚’ã?$1,$2,$3,$4 ã«å‰²ã‚Šå½“ã¦ã¾ã™ã? 124 * @og.rev 3.5.4.2 (2003/12/15) makeCodeSelection メソãƒ?ƒ‰ã‚?CodeSelectionクラスã«å¤‰æ›´ã€? 125 * @og.rev 3.5.5.7 (2004/05/10) SelectionFactory を使用ã—ã¦ã€ã‚ªãƒ–ジェクト作æ? 126 * @og.rev 4.0.0.0 (2006/11/15) SelectionFactory ã« lang 属æ?を追åŠ?—ã¾ã™ã? 127 * @og.rev 4.3.4.0 (2008/12/01) $Cã®ã‚«ãƒ©ãƒ?ç½®æ›ãˆã‚’追åŠ? 128 * @og.rev 5.5.1.0 (2012/04/03) Slabel対応ã?"auto"ã¯ã€false ã«ãªã‚Šã¾ã™ã? 129 * @og.rev 5.6.2.3 (2013/03/22) noDisplayVal 変数追åŠ? 130 * 131 * @param value 入力å? 132 * 133 * @return ãƒ??ã‚¿ã®è¡¨ç¤ºç”¨æ–?—å? 134 */ 135 @Override 136 public String getValue( final String value ) { 137 // 5.6.2.3 (2013/03/22) noDisplayVal 変数追åŠ? 138 if( noDisplayVal != null && noDisplayVal.equalsIgnoreCase( value ) ) { return "" ; } 139 140 // StringFormat format = new StringFormat( query,value); 141 StringFormat format = new StringFormat( query, value, name ); // 4.3.4.0 (2008/12/01) 142 String newQuery = format.format(); 143 String newValue = format.getValue(); 144 145 Selection selection = SelectionFactory.newDBSelection( newQuery,dbid,lang ); 146 // final boolean uslbl = !"true".equals(useSLabel) ? false : true; // 5.5.1.0 (2012/04/03) 147 final boolean uslbl = "true".equalsIgnoreCase( useSLabel ); // 5.5.1.0 (2012/04/03) 148 // return selection.getValueLabel( newValue ); 149 return selection.getValueLabel( newValue,uslbl ); 150 } 151 152 /** 153 * name属æ?を変ãˆãŸã?ãƒ??タ表示/ç·¨é›?”¨ã®HTMLæ–?—å?を作æ?ã—ã¾ã™ã? 154 * ãƒ??ブル上ã? name 㫠行番å·ã‚’ä»˜åŠ ã—ã¦ã€åå‰_è¡Œç•ªå· ã§ç™»éŒ²ã™ã‚‹ã‚ーを作æ?ã? 155 * ãƒªã‚¯ã‚¨ã‚¹ãƒˆæƒ…å ±ã‚’ï¼‘ã¤æ¯Žã?フィールドã§å‡¦ç?§ãã¾ã™ã? 156 * 157 * @og.rev 4.0.0.0 (2005/11/30) ä¸?¦§è¡¨ç¤ºã§ã¯ã€çŸç¸®ãƒ©ãƒ™ãƒ«ã‚’使用ã—ã¾ã™ã? 158 * @og.rev 4.0.0.0 (2006/11/15) SelectionFactory ã« lang 属æ?を追åŠ?—ã¾ã™ã? 159 * @og.rev 4.3.4.0 (2008/12/01) $Cã®ã‚«ãƒ©ãƒ?ç½®æ›ãˆã‚’追åŠ? 160 * @og.rev 5.5.1.0 (2012/04/03) Slabel対応ã?"auto"ã¯ã€true ã«ãªã‚Šã¾ã™ã? 161 * @og.rev 5.6.2.3 (2013/03/22) noDisplayVal 変数追åŠ? 162 * 163 * @param row è¡Œç•ªå· 164 * @param value 入力å? 165 * 166 * @return ãƒ??タ表示/ç·¨é›?”¨ã®æ–?—å? 167 */ 168 @Override 169 public String getValue( final int row,final String value ) { 170 // 5.6.2.3 (2013/03/22) noDisplayVal 変数追åŠ? 171 if( noDisplayVal != null && noDisplayVal.equalsIgnoreCase( value ) ) { return "" ; } 172 173 // StringFormat format = new StringFormat( query,value); 174 StringFormat format = new StringFormat( query, value, name ); // 4.3.4.0 (2008/12/01) 175 String newQuery = format.format(); 176 String newValue = format.getValue(); 177 178 Selection selection = SelectionFactory.newDBSelection( newQuery,dbid,lang ); 179 // final boolean uslbl = ("auto".equals(useSLabel) || "true".equals(useSLabel) ) ? true : false; // 5.5.1.0 (2012/04/03) 180 final boolean uslbl = "auto".equalsIgnoreCase( useSLabel ) || "true".equalsIgnoreCase( useSLabel ); // 5.5.1.0 (2012/04/03) 181 // return selection.getValueLabel( newValue,true ); 182 return selection.getValueLabel( newValue,uslbl ); 183 } 184 }