Revision 37780 branches/v2_0_0_prep/libraries/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.file/src/main/java/org/gvsig/exportto/swing/prov/file/AbstractExporttoFileService.java

View differences:

AbstractExporttoFileService.java
41 41
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
42 42
import org.gvsig.tools.task.TaskStatus;
43 43

  
44

  
45 44
/**
46 45
 * @author gvSIG Team
47 46
 * @version $Id$
48
 *
47
 * 
49 48
 */
50 49
public abstract class AbstractExporttoFileService implements ExporttoService {
51
    protected static final  ExporttoManager EXPORTTO_MANAGER = ExporttoLocator.getManager();
52
    protected File file; 
50

  
51
    protected static final ExporttoManager EXPORTTO_MANAGER = ExporttoLocator
52
        .getManager();
53
    protected File file;
53 54
    protected FeatureStore featureStore;
54 55
    protected ExporttoService exporttoService;
55 56

  
56
    private NewFeatureStoreParameters newFeatureStoreParameters;     
57
    private NewFeatureStoreParameters newFeatureStoreParameters;
57 58
    private ExporttoServiceFinishAction exporttoServiceFinishAction;
58
    
59
    public AbstractExporttoFileService(File file, FeatureStore featureStore)  {
60
        super();         
59

  
60
    public AbstractExporttoFileService(File file, FeatureStore featureStore) {
61
        super();
61 62
        this.featureStore = featureStore;
62
        this.file = file;          
63
    }  
64
    
65
    public void open() throws ExporttoServiceException{
63
        this.file = file;
64
    }
65

  
66
    public void open() throws ExporttoServiceException {
66 67
        String path = file.getAbsolutePath();
67 68

  
68 69
        String extension = "." + getFileExtension();
69
        
70
        if (!(path.toLowerCase().endsWith(extension))){
70

  
71
        if (!(path.toLowerCase().endsWith(extension))) {
71 72
            path = path + extension;
72 73
        }
73 74

  
......
76 77

  
77 78
        FilesystemServerExplorerParameters explorerParams;
78 79
        try {
79
            explorerParams = (FilesystemServerExplorerParameters) dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME);
80
            explorerParams =
81
                (FilesystemServerExplorerParameters) dataManager
82
                    .createServerExplorerParameters(FilesystemServerExplorer.NAME);
80 83
        } catch (InitializeException e) {
81 84
            throw new ExporttoServiceException(e);
82 85
        } catch (ProviderNotRegisteredException e) {
......
86 89

  
87 90
        FilesystemServerExplorer explorer;
88 91
        try {
89
            explorer = (FilesystemServerExplorer) dataManager.openServerExplorer("FilesystemExplorer", explorerParams);
92
            explorer =
93
                (FilesystemServerExplorer) dataManager.openServerExplorer(
94
                    "FilesystemExplorer", explorerParams);
90 95
        } catch (ValidateDataParametersException e) {
91 96
            throw new ExporttoServiceException(e);
92 97
        } catch (InitializeException e) {
......
95 100
            throw new ExporttoServiceException(e);
96 101
        }
97 102

  
98
        try {          
99
            newFeatureStoreParameters = (NewFeatureStoreParameters) explorer.getAddParameters(newFile);
103
        try {
104
            newFeatureStoreParameters =
105
                (NewFeatureStoreParameters) explorer.getAddParameters(newFile);
100 106
            addParameters(newFeatureStoreParameters);
101 107

  
102
            exporttoService = EXPORTTO_MANAGER.getExporttoService(explorer, newFeatureStoreParameters);
108
            exporttoService =
109
                EXPORTTO_MANAGER.getExporttoService(explorer,
110
                    newFeatureStoreParameters);
103 111
        } catch (DataException e) {
104 112
            throw new ExporttoServiceException(e);
105
        } 
113
        }
106 114
    }
107
    
108
    public abstract void addParameters(NewFeatureStoreParameters newFeatureStoreParameters) throws DataException;
109
    
115

  
116
    public abstract void addParameters(
117
        NewFeatureStoreParameters newFeatureStoreParameters)
118
        throws DataException;
119

  
110 120
    public abstract String getFileExtension();
111 121

  
112 122
    public void export(FeatureSet featureSet) throws ExporttoServiceException {
113
        exporttoService.export(featureSet); 
114
        if (exporttoServiceFinishAction != null){           
115
            exporttoServiceFinishAction.finished(file.getName(), newFeatureStoreParameters);
123
        exporttoService.export(featureSet);
124
        if (exporttoServiceFinishAction != null) {
125
            exporttoServiceFinishAction.finished(file.getName(),
126
                newFeatureStoreParameters);
116 127
        }
117
    }  
128
    }
118 129

  
119 130
    public void setFinishAction(
120 131
        ExporttoServiceFinishAction exporttoServiceFinishAction) {
121 132
        this.exporttoServiceFinishAction = exporttoServiceFinishAction;
122 133
    }
123
    
124
    public TaskStatus getTaskStatus() {       
134

  
135
    public TaskStatus getTaskStatus() {
125 136
        return exporttoService.getTaskStatus();
126 137
    }
127 138

  

Also available in: Unified diff