Revision 32880 branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/dgn/DGNStoreParameters.java
DGNStoreParameters.java | ||
---|---|---|
3 | 3 |
import java.io.File; |
4 | 4 |
|
5 | 5 |
import org.cresques.cts.IProjection; |
6 |
import org.gvsig.fmap.crs.CRSFactory; |
|
7 | 6 |
import org.gvsig.fmap.dal.DataStoreParameters; |
8 |
import org.gvsig.fmap.dal.DataTypes;
|
|
7 |
import org.gvsig.fmap.dal.FileHelper;
|
|
9 | 8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
10 | 9 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
11 | 10 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
12 | 11 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
12 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
13 | 13 |
import org.gvsig.tools.ToolsLocator; |
14 | 14 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
15 |
import org.gvsig.tools.dynobject.DynClass; |
|
16 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
15 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
17 | 16 |
|
18 | 17 |
public class DGNStoreParameters extends AbstractDataParameters implements |
19 | 18 |
DataStoreParameters, FilesystemStoreParameters, |
20 | 19 |
NewFeatureStoreParameters { |
21 | 20 |
|
22 |
public static final String DYNCLASS_NAME = "DGNStoreParameters";
|
|
21 |
public static final String PARAMETERS_DEFINITION_NAME = "DGNStoreParameters";
|
|
23 | 22 |
|
24 |
private static final String FIELD_FILEPATH = "filepath";
|
|
25 |
private static final String FIELD_SRS = "srsid";
|
|
23 |
private static final String FIELD_FILE = "file";
|
|
24 |
private static final String FIELD_CRS = "CRS";
|
|
26 | 25 |
|
27 |
private static DynClass DYNCLASS = null;
|
|
26 |
private DelegatedDynObject parameters;
|
|
28 | 27 |
|
29 |
private DelegatedDynObject delegatedDynObject; |
|
28 |
|
|
29 |
public DGNStoreParameters() { |
|
30 |
this(PARAMETERS_DEFINITION_NAME); |
|
31 |
} |
|
30 | 32 |
|
31 |
public DGNStoreParameters() { |
|
32 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
33 |
.getDynObjectManager() |
|
34 |
.createDynObject(DYNCLASS); |
|
33 |
protected DGNStoreParameters(String parametersDefinitionName) { |
|
34 |
this(parametersDefinitionName, DGNStoreProvider.NAME); |
|
35 | 35 |
} |
36 | 36 |
|
37 |
public DGNStoreParameters(String parametersDefinitionName, String name) { |
|
38 |
super(); |
|
39 |
this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName); |
|
40 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name); |
|
41 |
} |
|
42 |
|
|
37 | 43 |
public String getDataStoreName() { |
38 |
return DGNStoreProvider.NAME;
|
|
44 |
return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
|
|
39 | 45 |
} |
40 | 46 |
|
41 | 47 |
public String getDescription() { |
42 |
return DGNStoreProvider.DESCRIPTION;
|
|
48 |
return this.getDynClass().getDescription();
|
|
43 | 49 |
} |
44 | 50 |
|
45 |
public String getSRSID() { |
|
46 |
IProjection srs = (IProjection) getDynValue(FIELD_SRS); |
|
47 |
if (srs == null) { |
|
48 |
return null; |
|
49 |
} |
|
50 |
return srs.getAbrev(); |
|
51 |
} |
|
52 | 51 |
|
53 |
public void setSRSID(String srsid) { |
|
54 |
if (srsid == null) { |
|
55 |
setDynValue(FIELD_SRS, null); |
|
56 |
} else { |
|
57 |
setDynValue(FIELD_SRS, CRSFactory.getCRS(srsid)); |
|
58 |
} |
|
52 |
public void setCRS(IProjection srs) { |
|
53 |
setDynValue(FIELD_CRS, srs); |
|
59 | 54 |
} |
60 | 55 |
|
61 |
public void setSRS(IProjection srs) {
|
|
62 |
setDynValue(FIELD_SRS, srs);
|
|
56 |
public void setCRS(String srs) {
|
|
57 |
setDynValue(FIELD_CRS, srs);
|
|
63 | 58 |
} |
64 | 59 |
|
65 |
public IProjection getSRS() { |
|
66 |
if (this.getSRSID() == null) { |
|
67 |
return null; |
|
68 |
} |
|
69 |
return (IProjection) getDynValue(FIELD_SRS); |
|
60 |
public IProjection getCRS() { |
|
61 |
return (IProjection) getDynValue(FIELD_CRS); |
|
70 | 62 |
} |
71 | 63 |
|
72 | 64 |
public String getFileName() { |
73 |
return (String) getDynValue(FIELD_FILEPATH);
|
|
65 |
return this.getFile().getPath();
|
|
74 | 66 |
} |
75 | 67 |
|
76 |
public void setFileName(String file) { |
|
77 |
setDynValue(FIELD_FILEPATH, file); |
|
78 |
} |
|
79 |
|
|
80 | 68 |
public boolean isValid() { |
81 |
if (getSRSID() == null || getSRSID().equals("")) {
|
|
69 |
if (getCRS() == null ) {
|
|
82 | 70 |
return false; |
83 | 71 |
} |
84 |
if (getFileName() == null) {
|
|
72 |
if (getFile() == null) { |
|
85 | 73 |
return false; |
86 | 74 |
} |
87 | 75 |
return true; |
88 | 76 |
} |
89 | 77 |
|
90 | 78 |
public File getFile() { |
91 |
return new File(this.getFileName());
|
|
79 |
return (File) this.getDynValue(FIELD_FILE);
|
|
92 | 80 |
} |
93 | 81 |
|
94 | 82 |
public void setFile(File file) { |
95 |
this.setFileName(file.getPath());
|
|
83 |
this.setDynValue(FIELD_FILE, file);
|
|
96 | 84 |
} |
97 | 85 |
|
86 |
public void setFile(String file) { |
|
87 |
this.setDynValue(FIELD_FILE, file); |
|
88 |
} |
|
89 |
|
|
98 | 90 |
public FeatureType getDefaultFeatureType() { |
99 | 91 |
return null; //TODO ???? |
100 | 92 |
} |
... | ... | |
103 | 95 |
throw new UnsupportedOperationException(); |
104 | 96 |
} |
105 | 97 |
|
106 |
protected static void registerDynClass() { |
|
107 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
108 |
DynClass dynClass; |
|
109 |
if (DYNCLASS == null) { |
|
110 |
dynClass = dynman.add(DYNCLASS_NAME); |
|
111 |
|
|
112 |
dynClass.addDynField(FIELD_SRS) |
|
113 |
.setType(DataTypes.SRS) |
|
114 |
.setDescription("The SRS identifier") |
|
115 |
.setMandatory(true); |
|
116 |
|
|
117 |
dynClass.addDynFieldString(FIELD_FILEPATH) |
|
118 |
.setDescription("The DGN file path") |
|
119 |
.setMandatory(true); |
|
120 |
|
|
121 |
DYNCLASS = dynClass; |
|
122 |
|
|
123 |
// Register the DynClass in the PersistenceManager |
|
124 |
ToolsLocator.getPersistenceManager().registerClass( |
|
125 |
DGNStoreParameters.class, dynClass); |
|
98 |
protected static void registerParametersDefinition() { |
|
99 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
100 |
if( manager.getDefinition(PARAMETERS_DEFINITION_NAME) == null ) { |
|
101 |
manager.addDefinition( |
|
102 |
DGNStoreParameters.class, |
|
103 |
PARAMETERS_DEFINITION_NAME, |
|
104 |
DGNStoreParameters.class.getResourceAsStream("DGNStoreParameters.xml"), |
|
105 |
DGNStoreParameters.class.getClassLoader(), |
|
106 |
null, |
|
107 |
null |
|
108 |
); |
|
126 | 109 |
} |
127 | 110 |
} |
128 | 111 |
|
129 | 112 |
protected DelegatedDynObject getDelegatedDynObject() { |
130 |
return delegatedDynObject;
|
|
113 |
return parameters;
|
|
131 | 114 |
} |
132 | 115 |
} |
Also available in: Unified diff