Revision 44270 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.dbf/src/main/java/org/gvsig/export/dbf/service/ExportDBFService.java
ExportDBFService.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.util.ArrayList; |
27 | 27 |
import java.util.List; |
28 |
import org.gvsig.export.ExportAttributes; |
|
28 | 29 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
29 | 30 |
import org.gvsig.export.ExportException; |
30 | 31 |
import org.gvsig.export.ExportLocator; |
... | ... | |
42 | 43 |
import org.gvsig.fmap.dal.DataManager; |
43 | 44 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
44 | 45 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
46 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
45 | 47 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
46 | 48 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
47 | 49 |
import org.gvsig.tools.util.HasAFile; |
... | ... | |
49 | 51 |
/** |
50 | 52 |
* @author gvSIG Team |
51 | 53 |
* @version $Id$ |
52 |
*
|
|
54 |
* |
|
53 | 55 |
*/ |
54 |
public class ExportDBFService |
|
55 |
extends AbstractExportService |
|
56 |
implements ExportService |
|
57 |
{ |
|
56 |
public class ExportDBFService |
|
57 |
extends AbstractExportService |
|
58 |
implements ExportService { |
|
58 | 59 |
|
59 | 60 |
public static final int MAX_FIELD_NAME_LENGTH = 10; |
60 |
|
|
61 |
|
|
61 | 62 |
protected ExportDBFService(ExportServiceFactory factory, ExportDBFParameters parameters) { |
62 | 63 |
super(factory, parameters); |
63 | 64 |
} |
64 | 65 |
|
65 | 66 |
@Override |
66 | 67 |
public ExportDBFParameters getParameters() { |
67 |
return (ExportDBFParameters) super.getParameters();
|
|
68 |
return (ExportDBFParameters) super.getParameters(); |
|
68 | 69 |
} |
69 | 70 |
|
70 | 71 |
@Override |
71 |
protected FilesystemServerExplorer createServerExplorer() throws ExportException{ |
|
72 |
|
|
72 |
protected FilesystemServerExplorer createServerExplorer() throws ExportException {
|
|
73 |
|
|
73 | 74 |
DataManager dataManager = DALLocator.getDataManager(); |
74 | 75 |
|
75 | 76 |
FilesystemServerExplorerParameters explorerParams; |
76 | 77 |
try { |
77 |
explorerParams =
|
|
78 |
(FilesystemServerExplorerParameters) dataManager |
|
79 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
78 |
explorerParams |
|
79 |
= (FilesystemServerExplorerParameters) dataManager
|
|
80 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
|
80 | 81 |
} catch (Exception e) { |
81 | 82 |
throw new ExportException(e); |
82 | 83 |
} |
... | ... | |
102 | 103 |
); |
103 | 104 |
newStoreParameters.setDynValue("Encoding", this.getParameters().getEncoding()); |
104 | 105 |
|
105 |
FeatureType ft = this.getParameters().getSourceFeatureType(); |
|
106 |
FeatureType ft = this.getParameters().getExportAttributes().getTargetFeatureType(); |
|
107 |
if (ft==null) { |
|
108 |
ft = this.getParameters().getSourceFeatureType(); |
|
109 |
} |
|
110 |
|
|
106 | 111 |
AttributeNamesTranslator nameTranslator = ExportLocator.getServiceManager().createAttributeNamesTranslator( |
107 |
ft, |
|
108 | 112 |
MAX_FIELD_NAME_LENGTH |
109 | 113 |
); |
110 |
if( nameTranslator.hasTranslations() ) { |
|
111 |
// Obtenemos una copia del ft desbinculada del store. |
|
112 |
ft = ft.getCopy(); |
|
113 |
EditableFeatureType eft = ft.getEditable(); |
|
114 |
for( int i=0; i<eft.size(); i++) { |
|
115 |
EditableFeatureAttributeDescriptor attr = eft.getEditableAttributeDescriptor(i); |
|
116 |
String name = attr.getName(); |
|
117 |
if( nameTranslator.hasTranslation(name) ) { |
|
118 |
attr.setName(nameTranslator.getTargetName(name)); |
|
119 |
} |
|
120 |
} |
|
121 |
// Volvemos a obtener una copia "limpia" con los cambios consolidados |
|
122 |
ft = eft.getNotEditableCopy(); |
|
123 |
} |
|
124 |
|
|
114 |
|
|
125 | 115 |
// FIXME: check types of fields in ft (remove Geometry?) |
126 |
|
|
127 | 116 |
newStoreParameters.setDefaultFeatureType(ft.getEditable()); |
128 | 117 |
return newStoreParameters; |
129 | 118 |
} catch (DataException ex) { |
... | ... | |
136 | 125 |
try { |
137 | 126 |
DataManager dataManager = DALLocator.getDataManager(); |
138 | 127 |
OpenFeatureStoreParameters openStoreParameters = (OpenFeatureStoreParameters) dataManager.createStoreParameters("DBF"); |
139 |
((HasAFile)openStoreParameters).setFile(getParameters().getFile()); |
|
128 |
((HasAFile) openStoreParameters).setFile(getParameters().getFile());
|
|
140 | 129 |
openStoreParameters.setDynValue("Encoding", getParameters().getEncoding()); |
141 | 130 |
return openStoreParameters; |
142 | 131 |
} catch (DataException ex) { |
... | ... | |
150 | 139 |
r.add(this.createTargetOpenStoreParameters()); |
151 | 140 |
return r; |
152 | 141 |
} |
153 |
|
|
142 |
|
|
154 | 143 |
} |
Also available in: Unified diff