| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
package fr.paris.lutece.plugins.dbpage.business.section; |
| 35 | |
|
| 36 | |
import fr.paris.lutece.plugins.dbpage.business.DbPageHome; |
| 37 | |
import fr.paris.lutece.portal.service.template.AppTemplateService; |
| 38 | |
import fr.paris.lutece.portal.service.util.AppLogService; |
| 39 | |
import fr.paris.lutece.portal.service.util.AppPropertiesService; |
| 40 | |
import fr.paris.lutece.util.html.HtmlTemplate; |
| 41 | |
|
| 42 | |
import java.sql.SQLException; |
| 43 | |
|
| 44 | |
import java.util.ArrayList; |
| 45 | |
import java.util.HashMap; |
| 46 | |
import java.util.List; |
| 47 | |
import java.util.Map; |
| 48 | |
|
| 49 | |
import javax.servlet.http.HttpServletRequest; |
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public class DbPageSectionTable extends DbPageSection |
| 56 | |
{ |
| 57 | |
private static final long serialVersionUID = 3589380186475889829L; |
| 58 | |
private static final String MARK_RESULT_DATASET = "result_dataset"; |
| 59 | |
private static final String MARK_SECTION_TITLE = "section_title"; |
| 60 | |
private static final String MARK_COLUMN_NAMES = "column_names"; |
| 61 | |
private static final String PROPERTY_FILES_PATH = "dbpage.files.path"; |
| 62 | |
private static final String TEMPLATE_DEFAULT_TABLE = "skin/plugins/dbpage/default_table.html"; |
| 63 | |
private static final String TEMPLATE_CREATION_TABLE = "admin/plugins/dbpage/create_section_table.html"; |
| 64 | |
private static final String TEMPLATE_MODIFICATION_TABLE = "admin/plugins/dbpage/modify_section_table.html"; |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
public DbPageSectionTable( String strDescType ) |
| 71 | 0 | { |
| 72 | 0 | this.setIdTypeSignature( serialVersionUID ); |
| 73 | 0 | this.setDescType( strDescType ); |
| 74 | 0 | } |
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
public String getHtmlSection( List listValues, HttpServletRequest request ) |
| 83 | |
{ |
| 84 | 0 | HashMap rootModel = new HashMap( ); |
| 85 | |
|
| 86 | 0 | rootModel.put( MARK_SECTION_TITLE, getTitle( ) ); |
| 87 | 0 | rootModel.put( MARK_COLUMN_NAMES, getTableHeader( ) ); |
| 88 | 0 | rootModel.put( MARK_RESULT_DATASET, getTableDataset( getValuatedQuery( listValues ) ) ); |
| 89 | |
|
| 90 | 0 | if ( getTemplatePath( ).equals( "" ) ) |
| 91 | |
{ |
| 92 | 0 | HtmlTemplate tTable = AppTemplateService.getTemplate( TEMPLATE_DEFAULT_TABLE, request.getLocale( ), |
| 93 | |
rootModel ); |
| 94 | |
|
| 95 | 0 | return tTable.getHtml( ); |
| 96 | |
} |
| 97 | |
else |
| 98 | |
{ |
| 99 | 0 | String strFilePath = AppPropertiesService.getProperty( PROPERTY_FILES_PATH ); |
| 100 | 0 | HtmlTemplate tSelect = AppTemplateService.getTemplate( getTemplatePath( ), strFilePath, |
| 101 | 0 | ( request == null ) ? null : request.getLocale( ), rootModel ); |
| 102 | |
|
| 103 | 0 | return tSelect.getHtml( ); |
| 104 | |
} |
| 105 | |
} |
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
private List<String> getTableHeader( ) |
| 112 | |
{ |
| 113 | 0 | List<String> listColumnNames = new ArrayList<String>( ); |
| 114 | |
|
| 115 | 0 | for ( String strColumnName : getColumnNames( ) ) |
| 116 | |
{ |
| 117 | 0 | listColumnNames.add( strColumnName ); |
| 118 | 0 | } |
| 119 | |
|
| 120 | 0 | return listColumnNames; |
| 121 | |
} |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
private List<List<String>> getTableDataset( String strRequest ) |
| 129 | |
{ |
| 130 | 0 | List<List<String>> listDataset = null; |
| 131 | |
|
| 132 | |
try |
| 133 | |
{ |
| 134 | 0 | listDataset = DbPageHome.selectRows( strRequest, getConnectionService( getDbPool( ) ) ); |
| 135 | |
} |
| 136 | 0 | catch ( SQLException e ) |
| 137 | |
{ |
| 138 | 0 | AppLogService.error( e ); |
| 139 | 0 | } |
| 140 | |
|
| 141 | 0 | return listDataset; |
| 142 | |
} |
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
public long getIdType( ) |
| 149 | |
{ |
| 150 | 0 | return getIdTypeSignature( ); |
| 151 | |
} |
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
public String getTypeDescription( ) |
| 158 | |
{ |
| 159 | 0 | return getDescType( ); |
| 160 | |
} |
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
public String getCreationTemplate( ) |
| 167 | |
{ |
| 168 | 0 | return TEMPLATE_CREATION_TABLE; |
| 169 | |
} |
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
public String getModificationTemplate( ) |
| 176 | |
{ |
| 177 | 0 | return TEMPLATE_MODIFICATION_TABLE; |
| 178 | |
} |
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
public Map<String, Object> getMarkMap( ) |
| 184 | |
{ |
| 185 | 0 | Map map = new HashMap( ); |
| 186 | |
|
| 187 | 0 | return map; |
| 188 | |
} |
| 189 | |
} |