Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dataDB / src / org / gvsig / fmap / data / feature / db / jdbc / JDBCStoreParameters.java @ 24250

History | View | Annotate | Download (1.55 KB)

1
package org.gvsig.fmap.data.feature.db.jdbc;
2

    
3
import java.util.Map;
4

    
5
import org.gvsig.fmap.data.exceptions.InitializeException;
6
import org.gvsig.fmap.data.feature.db.DBStoreParameters;
7

    
8
import com.iver.utiles.NotExistInXMLEntity;
9
import com.iver.utiles.XMLEntity;
10

    
11
public abstract class JDBCStoreParameters extends
12
                DBStoreParameters {
13

    
14
        public static final int IS_VIEW = 1;
15
        public static final int NOT_IS_VIEW = 0;
16
        public static final int UNKNOW_IS_VIEW = -1;
17

    
18
        protected Map createDefaultValuesMap() {
19
                Map defaultParams = super.createDefaultValuesMap();
20
                defaultParams.put("isView", new Integer(UNKNOW_IS_VIEW));
21
                return defaultParams;
22
        }
23

    
24
        public abstract String getUrl();
25

    
26
        public void setIsView(int isView) {
27
                this.put("isView", new Integer(UNKNOW_IS_VIEW));
28
        }
29

    
30
        public int getIsView() {
31
                return ((Integer) this.getAttribute("isView")).intValue();
32
        }
33

    
34
        public XMLEntity getXMLEntity() {
35
                XMLEntity xmlEntity = super.getXMLEntity();
36

    
37
                xmlEntity.putProperty("isView", this.getIsView());
38
                return xmlEntity;
39
        }
40

    
41
        public void loadFromXMLEntity(XMLEntity xmlEntity)
42
                        throws InitializeException {
43

    
44
                super.loadFromXMLEntity(xmlEntity);
45

    
46
                try {
47
                        int isView = xmlEntity.getIntProperty("isView");
48

    
49
                        if (!(isView == IS_VIEW || isView == NOT_IS_VIEW)) {
50
                                this.remove("isView");
51
                        } else {
52
                                this.setIsView(isView);
53
                        }
54
                } catch (NotExistInXMLEntity e) {
55
                        this.remove("isView");
56
                }
57
        }
58

    
59
        public String tableID() {
60
                if (this.getSchema() == null || this.getSchema() == "") {
61
                        return this.getTableName();
62
                }
63
                return this.getSchema()+"."+this.getTableName();
64
        }
65

    
66
}