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 }