Revision 258
trunk/org.gvsig.dwg/pom.xml | ||
---|---|---|
11 | 11 |
<parent> |
12 | 12 |
<groupId>org.gvsig</groupId> |
13 | 13 |
<artifactId>org.gvsig.desktop</artifactId> |
14 |
<version>2.0.169</version>
|
|
14 |
<version>2.0.173</version>
|
|
15 | 15 |
</parent> |
16 | 16 |
|
17 | 17 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-dwg</url> |
trunk/org.gvsig.dwg/org.gvsig.dwg.provider/src/test/java/org/gvsig/dwg/fmap/dal/store/dwg/TestDWG.java | ||
---|---|---|
51 | 51 |
*/ |
52 | 52 |
public DataStoreParameters getDefaultDataStoreParameters() |
53 | 53 |
throws DataException { |
54 |
DWGStoreParameters dwgParameters = null; |
|
54 |
DWGOpenStoreParameters dwgParameters = null;
|
|
55 | 55 |
|
56 |
dwgParameters = (DWGStoreParameters) dataManager |
|
56 |
dwgParameters = (DWGOpenStoreParameters) dataManager
|
|
57 | 57 |
.createStoreParameters(DWGStoreProvider.NAME); |
58 | 58 |
|
59 | 59 |
dwgParameters.setFile(file_prueba); |
trunk/org.gvsig.dwg/org.gvsig.dwg.provider/src/main/java/org/gvsig/dwg/fmap/dal/store/dwg/DWGStoreParameters.java | ||
---|---|---|
1 |
package org.gvsig.dwg.fmap.dal.store.dwg; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.cresques.cts.IProjection; |
|
6 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
7 |
import org.gvsig.fmap.dal.FileHelper; |
|
8 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
10 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
11 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
12 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
13 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
14 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
15 |
|
|
16 |
public class DWGStoreParameters extends AbstractDataParameters implements |
|
17 |
DataStoreParameters, FilesystemStoreParameters, |
|
18 |
NewFeatureStoreParameters { |
|
19 |
|
|
20 |
public static final String PARAMETERS_DEFINITION_NAME = "DWGStoreParameters"; |
|
21 |
|
|
22 |
private static final String FIELD_FILE = "file"; |
|
23 |
private static final String FIELD_CRS = "CRS"; |
|
24 |
|
|
25 |
private DelegatedDynObject parameters; |
|
26 |
|
|
27 |
public DWGStoreParameters() { |
|
28 |
this(PARAMETERS_DEFINITION_NAME); |
|
29 |
} |
|
30 |
|
|
31 |
protected DWGStoreParameters(String parametersDefinitionName) { |
|
32 |
this(parametersDefinitionName, DWGStoreProvider.NAME); |
|
33 |
} |
|
34 |
|
|
35 |
public DWGStoreParameters(String parametersDefinitionName, String name) { |
|
36 |
super(); |
|
37 |
this.parameters = (DelegatedDynObject) FileHelper |
|
38 |
.newParameters(parametersDefinitionName); |
|
39 |
this |
|
40 |
.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, |
|
41 |
name); |
|
42 |
} |
|
43 |
|
|
44 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
45 |
return parameters; |
|
46 |
} |
|
47 |
|
|
48 |
public String getDataStoreName() { |
|
49 |
return (String) this |
|
50 |
.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME); |
|
51 |
} |
|
52 |
|
|
53 |
public String getDescription() { |
|
54 |
return this.getDynClass().getDescription(); |
|
55 |
} |
|
56 |
|
|
57 |
public void setCRS(IProjection crs) { |
|
58 |
setDynValue(FIELD_CRS, crs); |
|
59 |
} |
|
60 |
|
|
61 |
public void setCRS(String crs) { |
|
62 |
setDynValue(FIELD_CRS, crs); |
|
63 |
} |
|
64 |
|
|
65 |
public IProjection getCRS() { |
|
66 |
return (IProjection) getDynValue(FIELD_CRS); |
|
67 |
} |
|
68 |
|
|
69 |
public String getFileName() { |
|
70 |
return this.getFile().getPath(); |
|
71 |
} |
|
72 |
|
|
73 |
public void setFileName(String file) { |
|
74 |
setDynValue(FIELD_FILE, file); |
|
75 |
} |
|
76 |
|
|
77 |
public boolean isValid() { |
|
78 |
if (getCRS() == null) { |
|
79 |
return false; |
|
80 |
} |
|
81 |
if (getFile() == null) { |
|
82 |
return false; |
|
83 |
} |
|
84 |
return true; |
|
85 |
} |
|
86 |
|
|
87 |
public File getFile() { |
|
88 |
return (File) this.getDynValue(FIELD_FILE); |
|
89 |
} |
|
90 |
|
|
91 |
public void setFile(File file) { |
|
92 |
this.setDynValue(FIELD_FILE, file); |
|
93 |
} |
|
94 |
|
|
95 |
public EditableFeatureType getDefaultFeatureType() { |
|
96 |
return null; //TODO ???? |
|
97 |
} |
|
98 |
|
|
99 |
public void setDefaultFeatureType(FeatureType defaultFeatureType) { |
|
100 |
throw new UnsupportedOperationException(); |
|
101 |
} |
|
102 |
|
|
103 |
} |
trunk/org.gvsig.dwg/org.gvsig.dwg.provider/src/main/java/org/gvsig/dwg/fmap/dal/store/dwg/DWGStoreProviderFactory.java | ||
---|---|---|
1 |
package org.gvsig.dwg.fmap.dal.store.dwg; |
|
2 |
|
|
3 |
|
|
4 |
import org.gvsig.fmap.dal.DataParameters; |
|
5 |
import org.gvsig.fmap.dal.DataStoreProvider; |
|
6 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
|
8 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProviderFactory; |
|
9 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
10 |
import org.gvsig.tools.dynobject.DynObject; |
|
11 |
|
|
12 |
public class DWGStoreProviderFactory extends AbstractFeatureStoreProviderFactory implements FeatureStoreProviderFactory{ |
|
13 |
|
|
14 |
protected DWGStoreProviderFactory(String name, String description) { |
|
15 |
super(name, description); |
|
16 |
} |
|
17 |
|
|
18 |
public DataStoreProvider createProvider(DataParameters parameters, |
|
19 |
DataStoreProviderServices providerServices) |
|
20 |
throws InitializeException { |
|
21 |
return new DWGStoreProvider((DWGOpenStoreParameters) parameters, providerServices); |
|
22 |
} |
|
23 |
|
|
24 |
public DynObject createParameters() { |
|
25 |
return new DWGOpenStoreParameters(); |
|
26 |
} |
|
27 |
|
|
28 |
public int allowCreate() { |
|
29 |
return NO; |
|
30 |
} |
|
31 |
|
|
32 |
public int allowWrite() { |
|
33 |
return NO; |
|
34 |
} |
|
35 |
|
|
36 |
public int allowRead() { |
|
37 |
return YES; |
|
38 |
} |
|
39 |
|
|
40 |
public int hasRasterSupport() { |
|
41 |
return NO; |
|
42 |
} |
|
43 |
|
|
44 |
public int hasTabularSupport() { |
|
45 |
return YES; |
|
46 |
} |
|
47 |
|
|
48 |
public int hasVectorialSupport() { |
|
49 |
return YES; |
|
50 |
} |
|
51 |
|
|
52 |
public int allowMultipleGeometryTypes() { |
|
53 |
return YES; |
|
54 |
} |
|
55 |
|
|
56 |
} |
trunk/org.gvsig.dwg/org.gvsig.dwg.provider/src/main/java/org/gvsig/dwg/fmap/dal/store/dwg/DWGOpenStoreParameters.java | ||
---|---|---|
1 |
package org.gvsig.dwg.fmap.dal.store.dwg; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.cresques.cts.IProjection; |
|
6 |
import org.gvsig.fmap.dal.FileHelper; |
|
7 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
9 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
|
10 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
11 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
12 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
13 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
14 |
|
|
15 |
public class DWGOpenStoreParameters extends AbstractDataParameters implements |
|
16 |
FilesystemStoreParameters, |
|
17 |
OpenFeatureStoreParameters { |
|
18 |
|
|
19 |
public static final String PARAMETERS_DEFINITION_NAME = "DWGStoreParameters"; |
|
20 |
|
|
21 |
private static final String FIELD_FILE = "file"; |
|
22 |
private static final String FIELD_CRS = "CRS"; |
|
23 |
|
|
24 |
private DelegatedDynObject parameters; |
|
25 |
|
|
26 |
public DWGOpenStoreParameters() { |
|
27 |
this(PARAMETERS_DEFINITION_NAME); |
|
28 |
} |
|
29 |
|
|
30 |
protected DWGOpenStoreParameters(String parametersDefinitionName) { |
|
31 |
this(parametersDefinitionName, DWGStoreProvider.NAME); |
|
32 |
} |
|
33 |
|
|
34 |
public DWGOpenStoreParameters(String parametersDefinitionName, String name) { |
|
35 |
super(); |
|
36 |
this.parameters = (DelegatedDynObject) FileHelper |
|
37 |
.newParameters(parametersDefinitionName); |
|
38 |
this |
|
39 |
.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, |
|
40 |
name); |
|
41 |
} |
|
42 |
|
|
43 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
44 |
return parameters; |
|
45 |
} |
|
46 |
|
|
47 |
public String getDataStoreName() { |
|
48 |
return (String) this |
|
49 |
.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME); |
|
50 |
} |
|
51 |
|
|
52 |
public String getDescription() { |
|
53 |
return this.getDynClass().getDescription(); |
|
54 |
} |
|
55 |
|
|
56 |
public void setCRS(IProjection crs) { |
|
57 |
setDynValue(FIELD_CRS, crs); |
|
58 |
} |
|
59 |
|
|
60 |
public void setCRS(String crs) { |
|
61 |
setDynValue(FIELD_CRS, crs); |
|
62 |
} |
|
63 |
|
|
64 |
public IProjection getCRS() { |
|
65 |
return (IProjection) getDynValue(FIELD_CRS); |
|
66 |
} |
|
67 |
|
|
68 |
public String getFileName() { |
|
69 |
return this.getFile().getPath(); |
|
70 |
} |
|
71 |
|
|
72 |
public void setFileName(String file) { |
|
73 |
setDynValue(FIELD_FILE, file); |
|
74 |
} |
|
75 |
|
|
76 |
public boolean isValid() { |
|
77 |
if (getCRS() == null) { |
|
78 |
return false; |
|
79 |
} |
|
80 |
if (getFile() == null) { |
|
81 |
return false; |
|
82 |
} |
|
83 |
return true; |
|
84 |
} |
|
85 |
|
|
86 |
public File getFile() { |
|
87 |
return (File) this.getDynValue(FIELD_FILE); |
|
88 |
} |
|
89 |
|
|
90 |
public void setFile(File file) { |
|
91 |
this.setDynValue(FIELD_FILE, file); |
|
92 |
} |
|
93 |
|
|
94 |
public EditableFeatureType getDefaultFeatureType() { |
|
95 |
return null; //TODO ???? |
|
96 |
} |
|
97 |
|
|
98 |
public void setDefaultFeatureType(FeatureType defaultFeatureType) { |
|
99 |
throw new UnsupportedOperationException(); |
|
100 |
} |
|
101 |
|
|
102 |
} |
trunk/org.gvsig.dwg/org.gvsig.dwg.provider/src/main/java/org/gvsig/dwg/fmap/dal/store/dwg/DWGLibrary.java | ||
---|---|---|
59 | 59 |
@Override |
60 | 60 |
protected void doPostInitialize() throws LibraryException { |
61 | 61 |
FileHelper.registerParametersDefinition( |
62 |
DWGStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
63 |
DWGStoreParameters.class, |
|
62 |
DWGOpenStoreParameters.PARAMETERS_DEFINITION_NAME,
|
|
63 |
DWGOpenStoreParameters.class,
|
|
64 | 64 |
"DWGParameters.xml" |
65 | 65 |
); |
66 | 66 |
try { |
... | ... | |
77 | 77 |
.getDataManager(); |
78 | 78 |
|
79 | 79 |
if (!dataman.getStoreProviders().contains(DWGStoreProvider.NAME)) { |
80 |
dataman.registerStoreProvider(DWGStoreProvider.NAME, |
|
81 |
DWGStoreProvider.class, DWGStoreParameters.class); |
|
80 |
dataman.registerStoreProviderFactory(new DWGStoreProviderFactory( |
|
81 |
DWGStoreProvider.NAME, |
|
82 |
DWGStoreProvider.DESCRIPTION |
|
83 |
)); |
|
82 | 84 |
} |
83 | 85 |
|
84 | 86 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
trunk/org.gvsig.dwg/org.gvsig.dwg.provider/src/main/java/org/gvsig/dwg/fmap/dal/store/dwg/DWGFilesystemServerProvider.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
public DataStoreParameters getParameters(File file) throws DataException { |
43 | 43 |
DataManager manager = DALLocator.getDataManager(); |
44 |
DWGStoreParameters params = (DWGStoreParameters) manager
|
|
44 |
DWGOpenStoreParameters params = (DWGOpenStoreParameters) manager
|
|
45 | 45 |
.createStoreParameters(this |
46 | 46 |
.getDataStoreProviderName()); |
47 | 47 |
params.setFileName(file.getPath()); |
... | ... | |
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
public boolean canCreate(NewDataStoreParameters parameters) { |
56 |
if (!(parameters instanceof DWGStoreParameters)) { |
|
56 |
if (!(parameters instanceof DWGOpenStoreParameters)) {
|
|
57 | 57 |
throw new IllegalArgumentException(); // FIXME ??? |
58 | 58 |
} |
59 |
DWGStoreParameters dwgParams = (DWGStoreParameters) parameters;
|
|
59 |
DWGOpenStoreParameters dwgParams = (DWGOpenStoreParameters) parameters;
|
|
60 | 60 |
// TODO comporbar si el ftype es correcto (para este formato es fijo) |
61 | 61 |
File file = new File(dwgParams.getFileName()); |
62 | 62 |
|
... | ... | |
88 | 88 |
} |
89 | 89 |
|
90 | 90 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
91 |
File file = new File(((DWGStoreParameters) parameters).getFileName()); |
|
91 |
File file = new File(((DWGOpenStoreParameters) parameters).getFileName());
|
|
92 | 92 |
if (!file.exists()) { |
93 | 93 |
throw new RemoveException(this.getDataStoreProviderName(), |
94 | 94 |
new FileNotFoundException(file)); |
trunk/org.gvsig.dwg/org.gvsig.dwg.provider/src/main/java/org/gvsig/dwg/fmap/dal/store/dwg/DWGStoreProvider.java | ||
---|---|---|
95 | 95 |
private long counterNewsOIDs = 0; |
96 | 96 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
97 | 97 |
|
98 |
public DWGStoreProvider(DWGStoreParameters parameters, |
|
98 |
public DWGStoreProvider(DWGOpenStoreParameters parameters,
|
|
99 | 99 |
DataStoreProviderServices storeServices) throws InitializeException { |
100 | 100 |
super(parameters, storeServices, FileHelper |
101 | 101 |
.newMetadataContainer(METADATA_DEFINITION_NAME)); |
... | ... | |
125 | 125 |
this.initializeFeatureTypes(); |
126 | 126 |
} |
127 | 127 |
|
128 |
private DWGStoreParameters getDWGParameters() { |
|
129 |
return (DWGStoreParameters) this.getParameters(); |
|
128 |
private DWGOpenStoreParameters getDWGParameters() {
|
|
129 |
return (DWGOpenStoreParameters) this.getParameters();
|
|
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
public String getProviderName() { |
Also available in: Unified diff