svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / main / java / org / gvsig / fmap / dal / store / h2 / H2SpatialStoreParameters.java @ 47779
History | View | Annotate | Download (3.77 KB)
1 | 45472 | jjdelcerro | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | package org.gvsig.fmap.dal.store.h2; |
||
23 | |||
24 | import java.io.File; |
||
25 | 47779 | fdiaz | import java.io.IOException; |
26 | 45472 | jjdelcerro | import java.util.Properties; |
27 | 47779 | fdiaz | import org.apache.commons.io.FilenameUtils; |
28 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
29 | 45472 | jjdelcerro | import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
30 | import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
||
31 | 46542 | fdiaz | import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParametersBase; |
32 | 45472 | jjdelcerro | |
33 | 46542 | fdiaz | public class H2SpatialStoreParameters extends JDBCStoreParametersBase implements H2SpatialConnectionParameters { |
34 | 45472 | jjdelcerro | |
35 | private final H2SpatialConnectionParametersHelper helper; |
||
36 | |||
37 | public H2SpatialStoreParameters() {
|
||
38 | super(
|
||
39 | H2SpatialLibrary.NAME + "StoreParameters",
|
||
40 | H2SpatialLibrary.NAME |
||
41 | ); |
||
42 | this.helper = new H2SpatialConnectionParametersHelper(this); |
||
43 | } |
||
44 | |||
45 | @Override
|
||
46 | public String getUrl() { |
||
47 | return this.helper.getUrl(); |
||
48 | } |
||
49 | |||
50 | @Override
|
||
51 | public void validate() throws ValidateDataParametersException { |
||
52 | this.helper.validate();
|
||
53 | super.validate();
|
||
54 | } |
||
55 | |||
56 | @Override
|
||
57 | public Properties getProperties() { |
||
58 | return this.helper.getProperties(); |
||
59 | } |
||
60 | |||
61 | @Override
|
||
62 | public File getFile() { |
||
63 | return this.helper.getFile(); |
||
64 | } |
||
65 | |||
66 | @Override
|
||
67 | public void setFile(File database) { |
||
68 | try {
|
||
69 | this.helper.setFile(database);
|
||
70 | 45901 | jjdelcerro | String url = H2SpatialUtils.getConnectionURL((H2SpatialConnectionParameters) this); |
71 | 45472 | jjdelcerro | this.setDynValue(JDBCConnectionParameters.URL_PARAMTER_NAME, url);
|
72 | } catch (Exception ex) { |
||
73 | } |
||
74 | } |
||
75 | |||
76 | @Override
|
||
77 | public int getMaxSecondsIdle() { |
||
78 | return this.helper.getMaxSecondsIdle(); |
||
79 | } |
||
80 | |||
81 | @Override
|
||
82 | public boolean getServerAllowOthers() { |
||
83 | return this.helper.getServerAllowOthers(); |
||
84 | } |
||
85 | |||
86 | @Override
|
||
87 | public int getServerPort() { |
||
88 | return this.helper.getServerPort(); |
||
89 | } |
||
90 | |||
91 | 45901 | jjdelcerro | @Override
|
92 | public String getServerPortAsString() { |
||
93 | return this.helper.getServerPortAsString(); |
||
94 | } |
||
95 | 46259 | jjdelcerro | |
96 | public int getSplitSize() { |
||
97 | return this.helper.getSplitSize(); |
||
98 | } |
||
99 | 47716 | jjdelcerro | |
100 | @Override
|
||
101 | 47779 | fdiaz | public boolean isTheSameStore(DataStoreParameters params) { |
102 | if(!(params instanceof H2SpatialStoreParameters)){ |
||
103 | return false; |
||
104 | } |
||
105 | File f1 = H2SpatialUtils.normalizeH2File(this.getFile()); |
||
106 | File f2 = H2SpatialUtils.normalizeH2File(((H2SpatialStoreParameters)params).getFile());
|
||
107 | try {
|
||
108 | if(!FilenameUtils.equalsOnSystem(f1.getCanonicalPath(), f2.getCanonicalPath())){
|
||
109 | return false; |
||
110 | } |
||
111 | } catch (IOException ex) { |
||
112 | if(!FilenameUtils.equalsOnSystem(f1.getAbsolutePath(), f2.getAbsolutePath())){
|
||
113 | return false; |
||
114 | } |
||
115 | } |
||
116 | return super.isTheSameStore(params); |
||
117 | |||
118 | } |
||
119 | |||
120 | |||
121 | @Override
|
||
122 | 47716 | jjdelcerro | public boolean getMaintainGlobalConnection() { |
123 | return this.helper.getMaintainGlobalConnection(); |
||
124 | } |
||
125 | 45472 | jjdelcerro | } |