Project

General

Profile

Download (1.64 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / sitools-idoc / hesiod / javaExt / src / fr / ias / sitools / vo / representation / DatabaseRequestIasModel.java @ 779bac69

1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6

    
7
package fr.ias.sitools.vo.representation;
8

    
9
import fr.cnes.sitools.astro.representation.DatabaseRequestModel;
10
import fr.cnes.sitools.common.exception.SitoolsException;
11
import fr.cnes.sitools.dataset.converter.business.ConverterChained;
12
import fr.cnes.sitools.dataset.database.DatabaseRequest;
13
import java.util.logging.Level;
14
import java.util.logging.Logger;
15

    
16
/**
17
 *
18
 * @author marc
19
 */
20
public class DatabaseRequestIasModel extends  DatabaseRequestModel {
21
    
22
    /**
23
   * Logger.
24
   */
25
    private static final Logger LOG = Logger.getLogger(DatabaseRequestIasModel.class.getName());
26
   /**
27
     * DB Result set.
28
     */
29
    private DatabaseRequest request;
30
    /**
31
     * SITools2 converters.
32
     */
33
    private ConverterChained converterChained;
34
    /**
35
     * Number of rows.
36
     */
37
    private transient int sizeValue;
38

    
39
    /**
40
     * Empty constructor.
41
     */
42
    protected DatabaseRequestIasModel() {
43
        setSize(0);
44
    }
45

    
46
    public DatabaseRequestIasModel(DatabaseRequest rsVal, ConverterChained converterChainedVal) {
47
        super(rsVal, converterChainedVal);
48
        int countRowRequest = rsVal.getCount();
49
        setSize(countRowRequest);
50

    
51
        // we need to close the connection here
52
        // otherwise the connection will not be free.
53
        if (this.size() == 0) {
54
            try {
55
                this.request.close();
56
            } catch (SitoolsException ex) {
57
                LOG.log(Level.SEVERE, null, ex);
58
            }
59
        }
60
    }
61
    
62
    
63
    
64
}