1 package fr.paris.lutece.plugin.documentimport.business;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import fr.paris.lutece.util.sql.DAOUtil;
7
8 public final class DocumentAttributDAO implements IDocumentAttributDAO {
9
10 private static final String SQL_QUERY_SELECT_ATTRIBUTES_OF_DOCUMENT_TYPE = " SELECT a.id_document_attr" +
11 " FROM document_type_attr a" + " WHERE a.document_type_attr_name = ?" + " AND a.code_document_type= ?";
12
13 private static final String SQL_QUERY_SELEC_VALUE_ATTRIBUTE = " SELECT d.text_value" +
14 " FROM document_content d" + " WHERE d.id_document_attr = ?";
15
16 @Override
17 public int findIdDocumentAttributs(String documentTypeAttrName,
18 String codeDocumentType) {
19
20 int id= -1;
21 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ATTRIBUTES_OF_DOCUMENT_TYPE );
22 daoUtil.setString( 1, documentTypeAttrName );
23 daoUtil.setString( 2, codeDocumentType );
24 daoUtil.executeQuery( );
25 if ( daoUtil.next( ) )
26 {
27 id = daoUtil.getInt( 1 );
28 }
29
30 daoUtil.free( );
31
32 return id;
33 }
34
35 @Override
36 public List<String> findValueAttributs(int idDocumentAttribut) {
37
38 List<String> listAttributs = new ArrayList<String>();
39 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELEC_VALUE_ATTRIBUTE );
40 daoUtil.setInt( 1, idDocumentAttribut );
41
42 daoUtil.executeQuery( );
43 while ( daoUtil.next( ) )
44 {
45 listAttributs.add(daoUtil.getString( 1 ));
46 }
47
48 daoUtil.free( );
49
50 return listAttributs;
51 }
52
53
54 }