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.develop;
017
018 import java.util.List;
019 import java.util.ArrayList;
020 import java.util.Map;
021
022 import org.opengion.hayabusa.develop.AbstractJspCreate;
023 import org.opengion.hayabusa.develop.JspConvertEntity;
024 import org.opengion.fukurou.xml.OGElement;
025 import org.opengion.fukurou.xml.OGAttributes;
026
027 /**
028 * result.jspの<og:view>タグを作æ?しますã?
029 *
030 * ●使用ä¾?
031 * JspConvertEntity e = new JspConvertEntity();
032 * e.setTableName("GF92");
033 * e.setColumnName("CLM");
034 * List< JspConvertEntity> a = new ArrayList< JspConvertEntity>();
035 * a.add( e );
036 * Map< String , List< JspConvertEntity> > m = new Map< String , List< JspConvertEntity > >();
037 * m.put( "RESULT", a );
038 * JspCreate j = JspCreateFactory.newInstance( "QUERY",m );
039 * j.execute("<og:view />");
040 *
041 * @og.rev 5.6.1.2 (2013/02/22) æ–?—å?連結からã?XML処ç�?�™るよã�?�«変更しますã?
042 * @author Takeshi.Takada
043 *
044 */
045 public class JspCreate_VIEW extends AbstractJspCreate {
046 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
047 private static final String VERSION = "5.6.1.2 (2013/02/22)" ;
048
049 private List<JspConvertEntity> RESULT_ROWS ;
050 private boolean IS_NULL ;
051
052 /**
053 * 初期化メソãƒ?ƒ‰
054 *
055 * å†?ƒ¨で使用する JspConvertEntityのリストã?マップを受け取り、å?期化を行いますã?
056 *
057 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、名前空間指定無しに変更しますã?
058 * @og.rev 5.6.1.2 (2013/02/22) 対象ファイルをã?result ã�?�‘から、update も含めるように変更ã€?
059 *
060 * @param master JspConvertEntityのリストã?マッãƒ?
061 */
062 @Override
063 protected void init( final Map<String,List<JspConvertEntity>> master ) {
064 RESULT_ROWS = master.get( "RESULT" );
065 IS_NULL = !isNotEmpty( RESULT_ROWS );
066 KEY = ":view"; // 5.2.1.0 (2010/10/01) 名前空間指定無ã�?
067 NAME = "result,update";
068 }
069
070 /**
071 * JSPに出力するタグのå†?®¹を作æ?しますã?
072 * 引数より作æ?前ã?タグの属æ?å†?®¹を確認するする事が出来ますã?
073 *
074 * @og.rev 5.2.1.0 (2010/10/01) メソãƒ?ƒ‰の引数をã?OGAttributes から OGElement に変更しますã?
075 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、引数を使用するように変更しますã?
076 *
077 * @param ele OGElementエレメントオブジェクãƒ?
078 * @param nameSpace こã?ドキュメントã?nameSpace( og とã�?mis とã�?)
079 *
080 * @return 変換された文字å?
081 * @throws Throwable 変換時ã?エラー
082 */
083 @Override
084 protected String execute( final OGElement ele , final String nameSpace ) throws Throwable {
085 if( IS_NULL ) { return ""; }
086
087 // String ns = (nameSpace.length() == 0) ? "" : nameSpace + ":" ; // 5.2.1.0 (2010/10/01) 名前空é–?
088
089 // こã? OGElement の階層の深さを探りますã?
090 // ele.getText( para ) とすることでXML全体を階層表示できるã€?
091 // int para = ele.getParentCount();
092
093 // TODO Auto-generated method stub
094 //書きå?す文字å?を作æ?開始ã?
095 // StringBuilder sbTub = new StringBuilder();
096
097 List<String> no_displays = new ArrayList<String>();
098 for(JspConvertEntity display : RESULT_ROWS){
099 // 非表示は、GF92の属æ?(Remarks)に、何もセãƒ?ƒˆされてã�?�ªã�?‚«ラãƒ??äº?
100 String remks = display.getRemarks();
101 if ( remks == null || ( remks.trim().length() == 0 ) ) {
102 no_displays.add( display.getColumnName() );
103 }
104 }
105
106 OGAttributes attri = ele.getOGAttributes(); // OGElementのå†?ƒ¨オブジェクトなので、副作用あり
107 attri.setUseCR( true );
108 if ( ! no_displays.isEmpty() ) {
109 attri.setVal( "noDisplay" , chainChar( no_displays ,",") ); // あれば更新、なければ追åŠ?
110 }
111 // ogAtt.setUseCR( true );
112 return ele.getText( 0 );
113
114 // sbTub.append( "<" ).append( ns ).append( "view" ).append( CR );
115 // sbTub.append( "\tviewFormType = \"HTMLTable\"" ).append( CR );
116 // sbTub.append( "\tcommand = \"{@command}\"" ).append( CR );
117 // if ( ! no_displays.isEmpty() ) {
118 // sbTub.append( "\tnoDisplay = \"").append(chainChar( no_displays ,",") ).append("\"" ).append( CR );
119 // }
120 // sbTub.append( "/>" ).append( CR );
121
122 // return sbTub.toString();
123 }
124 }