Project

General

Profile

Revision 1600af50

ID1600af50c10e857df19d35baddc75c87539bdb74
Parent 090cb34e
Child 8f3575e1

Added by Katja Luther about 3 years ago

minor

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/service/IOServiceImpl.java
1
// $Id$
2
/**
3
 * Copyright (C) 2015 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.cdm.io.service;
11

  
12
import java.io.ByteArrayInputStream;
13
import java.io.FileOutputStream;
14
import java.io.IOException;
15
import java.io.Serializable;
16
import java.nio.file.Files;
17
import java.nio.file.Path;
18
import java.util.List;
19
import java.util.UUID;
20

  
21
import org.springframework.beans.factory.annotation.Autowired;
22
import org.springframework.beans.factory.annotation.Qualifier;
23
import org.springframework.stereotype.Service;
24
import org.springframework.transaction.annotation.Transactional;
25

  
26
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
27
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
28
import eu.etaxonomy.cdm.common.monitor.RemotingProgressMonitorThread;
29
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
30
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultExport;
31
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
32
import eu.etaxonomy.cdm.io.common.ExportResult;
33
import eu.etaxonomy.cdm.io.common.IExportConfigurator;
34
import eu.etaxonomy.cdm.io.common.IExportConfigurator.TARGET;
35
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
36
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
37
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
38
import eu.etaxonomy.cdm.io.common.ImportResult;
39
import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
40
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
41

  
42
/**
43
 * @author cmathew
44
 * @date 31 Jul 2015
45
 *
46
 */
47
@Service
48
@Transactional(readOnly = false)
49
public class IOServiceImpl implements IIOService {
50

  
51
    @Autowired
52
    CdmApplicationAwareDefaultExport cdmExport;
53

  
54
    @Autowired
55
    @Qualifier("defaultImport")
56
    CdmApplicationAwareDefaultImport cdmImport;
57

  
58
    @Autowired
59
    IProgressMonitorService progressMonitorService;
60

  
61

  
62

  
63
    /* (non-Javadoc)
64
     * @see eu.etaxonomy.cdm.io.service.IExportService#export(eu.etaxonomy.cdm.io.common.IExportConfigurator)
65
     */
66
    @Override
67
    public ExportResult export(IExportConfigurator config) {
68
        config.setTarget(TARGET.EXPORT_DATA);
69
        return cdmExport.execute(config);
70
    }
71

  
72

  
73
    @Override
74
    public UUID monitImportData(final IImportConfigurator configurator, final byte[] importData, final SOURCE_TYPE type) {
75
        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
76
            @Override
77
            public Serializable doRun(IRemotingProgressMonitor monitor) {
78
                configurator.setProgressMonitor(monitor);
79
                ImportResult result = importData(configurator, importData, type);
80
                for(byte[] report : result.getReports()) {
81
                    monitor.addReport(new String(report));
82
                }
83
                return result;
84
            }
85
        };
86
        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);
87
        monitorThread.setPriority(3);
88
        monitorThread.start();
89
        return uuid;
90
    }
91

  
92
    @Override
93
    public ImportResult importData(IImportConfigurator configurator, byte[] importData, SOURCE_TYPE type) {
94
        ImportResult result;
95
        switch(type) {
96
        case URI:
97
            return importDataFromUri(configurator, importData);
98
        case INPUTSTREAM:
99
            return importDataFromInputStream(configurator,importData);
100
        default :
101
            throw new RuntimeException("Source type is not recongnised");
102
        }
103
    }
104

  
105
    @Override
106
    public ImportResult importDataFromUri(IImportConfigurator configurator, byte[] importData) {
107
        ImportResult result;
108

  
109
        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;
110
        String suffix = ".import";
111
        String prefix = "cdm-";
112
        FileOutputStream stream = null;
113

  
114
        try {
115
            Path tempFilePath = Files.createTempFile(prefix, suffix);
116
            stream = new FileOutputStream(tempFilePath.toFile());
117
            stream.write(importData);
118
            config.setSource(tempFilePath.toUri());
119
            result = cdmImport.execute(config);
120
     //       Files.delete(tempFilePath);
121
        } catch (Exception e) {
122
            throw new RuntimeException(e);
123
        } finally {
124
            if(stream != null) {
125
                try {
126
                    stream.close();
127
                } catch (IOException e) {
128
                    throw new RuntimeException(e);
129
                }
130
            }
131
        }
132
        return result;
133
    }
134

  
135
    @Override
136
    public ImportResult importDataFromInputStream(IImportConfigurator configurator, byte[] importData) {
137
        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;
138
        ImportResult result;
139
        try {
140
            config.setSource(new ByteArrayInputStream(importData));
141
            result = cdmImport.execute(config);
142
        } catch (Exception e) {
143
            throw new RuntimeException(e);
144
        }
145
        return result;
146
    }
147

  
148

  
149
    @Override
150
    public ImportResult importDataFromStream(SpecimenImportConfiguratorBase configurator) {
151
        ImportResult result = new ImportResult();
152

  
153
            OccurenceQuery query;
154
            result = cdmImport.execute(configurator);
155
            return result;
156
    }
157

  
158
    @Override
159
    public ImportResult importDataFromStream(List<Abcd206ImportConfigurator> configurators) {
160
        ImportResult result = new ImportResult();
161

  
162
            OccurenceQuery query;
163
            for (SpecimenImportConfiguratorBase configurator:configurators){
164
                result = cdmImport.execute(configurator);
165
            }
166
            return result;
167
    }
168

  
169

  
170

  
171

  
172

  
173
}
1
// $Id$
2
/**
3
 * Copyright (C) 2015 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.cdm.io.service;
11

  
12
import java.io.ByteArrayInputStream;
13
import java.io.FileOutputStream;
14
import java.io.IOException;
15
import java.io.Serializable;
16
import java.nio.file.Files;
17
import java.nio.file.Path;
18
import java.util.List;
19
import java.util.UUID;
20

  
21
import org.springframework.beans.factory.annotation.Autowired;
22
import org.springframework.beans.factory.annotation.Qualifier;
23
import org.springframework.stereotype.Service;
24
import org.springframework.transaction.annotation.Transactional;
25

  
26
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
27
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
28
import eu.etaxonomy.cdm.common.monitor.RemotingProgressMonitorThread;
29
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
30
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultExport;
31
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
32
import eu.etaxonomy.cdm.io.common.ExportResult;
33
import eu.etaxonomy.cdm.io.common.IExportConfigurator;
34
import eu.etaxonomy.cdm.io.common.IExportConfigurator.TARGET;
35
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
36
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
37
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
38
import eu.etaxonomy.cdm.io.common.ImportResult;
39
import eu.etaxonomy.cdm.io.specimen.SpecimenImportConfiguratorBase;
40
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
41

  
42
/**
43
 * @author cmathew
44
 * @date 31 Jul 2015
45
 *
46
 */
47
@Service
48
@Transactional(readOnly = false)
49
public class IOServiceImpl implements IIOService {
50

  
51
    @Autowired
52
    CdmApplicationAwareDefaultExport cdmExport;
53

  
54
    @Autowired
55
    @Qualifier("defaultImport")
56
    CdmApplicationAwareDefaultImport cdmImport;
57

  
58
    @Autowired
59
    IProgressMonitorService progressMonitorService;
60

  
61

  
62

  
63
    /* (non-Javadoc)
64
     * @see eu.etaxonomy.cdm.io.service.IExportService#export(eu.etaxonomy.cdm.io.common.IExportConfigurator)
65
     */
66
    @Override
67
    public ExportResult export(IExportConfigurator config) {
68
        config.setTarget(TARGET.EXPORT_DATA);
69
        return cdmExport.execute(config);
70
    }
71

  
72

  
73
    @Override
74
    public UUID monitImportData(final IImportConfigurator configurator, final byte[] importData, final SOURCE_TYPE type) {
75
        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
76
            @Override
77
            public Serializable doRun(IRemotingProgressMonitor monitor) {
78
                configurator.setProgressMonitor(monitor);
79
                ImportResult result = importData(configurator, importData, type);
80
                for(byte[] report : result.getReports()) {
81
                    monitor.addReport(new String(report));
82
                }
83
                return result;
84
            }
85
        };
86
        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);
87
        monitorThread.setPriority(3);
88
        monitorThread.start();
89
        return uuid;
90
    }
91

  
92
    @Override
93
    public ImportResult importData(IImportConfigurator configurator, byte[] importData, SOURCE_TYPE type) {
94
        ImportResult result;
95
        switch(type) {
96
        case URI:
97
            return importDataFromUri(configurator, importData);
98
        case INPUTSTREAM:
99
            return importDataFromInputStream(configurator,importData);
100
        default :
101
            throw new RuntimeException("Source type is not recongnised");
102
        }
103
    }
104

  
105
    @Override
106
    public ImportResult importDataFromUri(IImportConfigurator configurator, byte[] importData) {
107
        ImportResult result;
108

  
109
        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;
110
        String suffix = ".import";
111
        String prefix = "cdm-";
112
        FileOutputStream stream = null;
113

  
114
        try {
115
            Path tempFilePath = Files.createTempFile(prefix, suffix);
116
            stream = new FileOutputStream(tempFilePath.toFile());
117
            stream.write(importData);
118
            config.setSource(tempFilePath.toUri());
119
            result = cdmImport.execute(config);
120
     //       Files.delete(tempFilePath);
121
        } catch (Exception e) {
122
            throw new RuntimeException(e);
123
        } finally {
124
            if(stream != null) {
125
                try {
126
                    stream.close();
127
                } catch (IOException e) {
128
                    throw new RuntimeException(e);
129
                }
130
            }
131
        }
132
        return result;
133
    }
134

  
135
    @Override
136
    public ImportResult importDataFromInputStream(IImportConfigurator configurator, byte[] importData) {
137
        ImportConfiguratorBase config = (ImportConfiguratorBase)configurator;
138
        ImportResult result;
139
        try {
140
            config.setSource(new ByteArrayInputStream(importData));
141
            result = cdmImport.execute(config);
142
        } catch (Exception e) {
143
            throw new RuntimeException(e);
144
        }
145
        return result;
146
    }
147

  
148

  
149
    @Override
150
    public ImportResult importDataFromStream(SpecimenImportConfiguratorBase configurator) {
151
        ImportResult result = new ImportResult();
152

  
153
            OccurenceQuery query;
154
            result = cdmImport.execute(configurator);
155
            return result;
156
    }
157

  
158
    @Override
159
    public ImportResult importDataFromStream(List<Abcd206ImportConfigurator> configurators) {
160
        ImportResult result = new ImportResult();
161

  
162
            OccurenceQuery query;
163
            for (SpecimenImportConfiguratorBase configurator:configurators){
164
                result = cdmImport.execute(configurator);
165
            }
166
            return result;
167
    }
168

  
169

  
170

  
171

  
172

  
173
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenDataHolder.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.specimen;
11

  
12
import java.util.ArrayList;
13
import java.util.HashMap;
14
import java.util.List;
15
import java.util.Map;
16

  
17
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Identification;
18
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
19

  
20
/**
21
 * @author k.luther
22
 * @date 18.07.2016
23
 *
24
 */
25
public class SpecimenDataHolder {
26

  
27
    protected String nomenclatureCode;
28
    protected List<HashMap<String, String>> atomisedIdentificationList;
29
    private String recordBasis;
30
    protected String gatheringElevationText;
31
    private String gatheringElevationMin;
32
    private String gatheringElevationMax;
33
    private String gatheringNotes;
34
    private String gatheringDateText;
35

  
36
    protected String gatheringElevation;
37

  
38
    private String gatheringElevationUnit;
39
    protected Double depth;
40
    /**
41
     * @return the depth
42
     */
43
    public Double getDepth() {
44
        return depth;
45
    }
46

  
47

  
48

  
49
    /**
50
     * @param depth the depth to set
51
     */
52
    public void setDepth(Double depth) {
53
        this.depth = depth;
54
    }
55

  
56

  
57

  
58
    private String gatheringSpatialDatum;
59
    private String gatheringCoordinateErrorMethod;
60
    private String kindOfUnit;
61

  
62
    private Map<String, String> namedAreaList;
63
    private String fieldNumber;
64
    private String unitNotes; //  occurenceRemarks(DwCA)
65

  
66
    private HashMap<String, Map<String,String>> multimediaObjects;
67
    private HashMap<String, Map<String,String>> gatheringMultimediaObjects;
68
    private List<Identification> identificationList;
69

  
70
    private List<SpecimenTypeDesignationStatus> statusList;
71

  
72
    private List<String[]> referenceList;
73
    private List<String> docSources;
74
    private String unitID;
75

  
76

  
77

  
78

  
79

  
80
    /**
81
     * @return the nomenclatureCode
82
     */
83
    public String getNomenclatureCode() {
84
        return nomenclatureCode;
85
    }
86

  
87

  
88

  
89
    /**
90
     * @param nomenclatureCode the nomenclatureCode to set
91
     */
92
    public void setNomenclatureCode(String nomenclatureCode) {
93
        this.nomenclatureCode = nomenclatureCode;
94
    }
95

  
96

  
97

  
98
    /**
99
     * @return the atomisedIdentificationList
100
     */
101
    public List<HashMap<String, String>> getAtomisedIdentificationList() {
102
        return atomisedIdentificationList;
103
    }
104

  
105

  
106

  
107
    /**
108
     * @param atomisedIdentificationList the atomisedIdentificationList to set
109
     */
110
    public void setAtomisedIdentificationList(List<HashMap<String, String>> atomisedIdentificationList) {
111
        this.atomisedIdentificationList = atomisedIdentificationList;
112
    }
113

  
114

  
115

  
116
    /**
117
     * @return the gatheringElevationText
118
     */
119
    public String getGatheringElevationText() {
120
        return gatheringElevationText;
121
    }
122

  
123

  
124

  
125
    /**
126
     * @param gatheringElevationText the gatheringElevationText to set
127
     */
128
    public void setGatheringElevationText(String gatheringElevationText) {
129
        this.gatheringElevationText = gatheringElevationText;
130
    }
131

  
132

  
133

  
134
    /**
135
     * @return the gatheringElevationMax
136
     */
137
    public String getGatheringElevationMax() {
138
        return gatheringElevationMax;
139
    }
140

  
141

  
142

  
143
    /**
144
     * @param gatheringElevationMax the gatheringElevationMax to set
145
     */
146
    public void setGatheringElevationMax(String gatheringElevationMax) {
147
        this.gatheringElevationMax = gatheringElevationMax;
148
    }
149

  
150

  
151

  
152
    /**
153
     * @return the gatheringElevationMin
154
     */
155
    public String getGatheringElevationMin() {
156
        return gatheringElevationMin;
157
    }
158

  
159

  
160

  
161
    /**
162
     * @param gatheringElevationMin the gatheringElevationMin to set
163
     */
164
    public void setGatheringElevationMin(String gatheringElevationMin) {
165
        this.gatheringElevationMin = gatheringElevationMin;
166
    }
167

  
168

  
169

  
170
    /**
171
     * @return the kindOfUnit
172
     */
173
    public String getKindOfUnit() {
174
        return kindOfUnit;
175
    }
176

  
177

  
178

  
179
    /**
180
     * @param kindOfUnit the kindOfUnit to set
181
     */
182
    public void setKindOfUnit(String kindOfUnit) {
183
        this.kindOfUnit = kindOfUnit;
184
    }
185

  
186

  
187

  
188
    /**
189
     * @return the gatheringElevationUnit
190
     */
191
    public String getGatheringElevationUnit() {
192
        return gatheringElevationUnit;
193
    }
194

  
195

  
196

  
197
    /**
198
     * @param gatheringElevationUnit the gatheringElevationUnit to set
199
     */
200
    public void setGatheringElevationUnit(String gatheringElevationUnit) {
201
        this.gatheringElevationUnit = gatheringElevationUnit;
202
    }
203

  
204

  
205

  
206
    /**
207
     * @return the gatheringDateText
208
     */
209
    public String getGatheringDateText() {
210
        return gatheringDateText;
211
    }
212

  
213

  
214

  
215
    /**
216
     * @param gatheringDateText the gatheringDateText to set
217
     */
218
    public void setGatheringDateText(String gatheringDateText) {
219
        this.gatheringDateText = gatheringDateText;
220
    }
221

  
222

  
223

  
224
    /**
225
     * @return the gatheringNotes
226
     */
227
    public String getGatheringNotes() {
228
        return gatheringNotes;
229
    }
230

  
231

  
232

  
233
    /**
234
     * @param gatheringNotes the gatheringNotes to set
235
     */
236
    public void setGatheringNotes(String gatheringNotes) {
237
        this.gatheringNotes = gatheringNotes;
238
    }
239

  
240

  
241

  
242
    /**
243
     * @return the gatheringSpatialDatum
244
     */
245
    public String getGatheringSpatialDatum() {
246
        return gatheringSpatialDatum;
247
    }
248

  
249

  
250

  
251
    /**
252
     * @param gatheringSpatialDatum the gatheringSpatialDatum to set
253
     */
254
    public void setGatheringSpatialDatum(String gatheringSpatialDatum) {
255
        this.gatheringSpatialDatum = gatheringSpatialDatum;
256
    }
257

  
258

  
259

  
260
    /**
261
     * @return the namedAreaList
262
     */
263
    public Map<String, String> getNamedAreaList() {
264
        return namedAreaList;
265
    }
266

  
267

  
268

  
269
    /**
270
     * @param namedAreaList the namedAreaList to set
271
     */
272
    public void setNamedAreaList(Map<String, String> namedAreaList) {
273
        this.namedAreaList = namedAreaList;
274
    }
275

  
276

  
277

  
278
    /**
279
     * @return the gatheringCoordinateErrorMethod
280
     */
281
    public String getGatheringCoordinateErrorMethod() {
282
        return gatheringCoordinateErrorMethod;
283
    }
284

  
285

  
286

  
287
    /**
288
     * @param gatheringCoordinateErrorMethod the gatheringCoordinateErrorMethod to set
289
     */
290
    public void setGatheringCoordinateErrorMethod(String gatheringCoordinateErrorMethod) {
291
        this.gatheringCoordinateErrorMethod = gatheringCoordinateErrorMethod;
292
    }
293

  
294

  
295

  
296
    /**
297
     *
298
     */
299
    public void reset() {
300
        nomenclatureCode = null;
301
        atomisedIdentificationList = new ArrayList<HashMap<String,String>>();
302
        gatheringDateText = null;
303
        gatheringNotes = null;
304
        kindOfUnit = null;
305

  
306
        setRecordBasis(null);
307
        gatheringElevationText = null;
308
        gatheringElevationMin = null;
309
        gatheringElevationMax = null;
310
        gatheringNotes = null;
311
        gatheringDateText = null;
312

  
313
        gatheringElevation = null;
314

  
315
        gatheringElevationUnit = null;
316
        gatheringSpatialDatum = null;
317
        gatheringCoordinateErrorMethod = null;
318
        depth = null;
319

  
320

  
321
    }
322

  
323

  
324

  
325
    /**
326
     * @return the fieldNumber
327
     */
328
    public String getFieldNumber() {
329
        return fieldNumber;
330
    }
331

  
332

  
333

  
334
    /**
335
     * @param fieldNumber the fieldNumber to set
336
     */
337
    public void setFieldNumber(String fieldNumber) {
338
        this.fieldNumber = fieldNumber;
339
    }
340

  
341

  
342

  
343
    /**
344
     * @return the unitNotes
345
     */
346
    public String getUnitNotes() {
347
        return unitNotes;
348
    }
349

  
350

  
351

  
352
    /**
353
     * @param unitNotes the unitNotes to set
354
     */
355
    public void setUnitNotes(String unitNotes) {
356
        this.unitNotes = unitNotes;
357
    }
358

  
359

  
360

  
361
    /**
362
     * @return the multimediaObjects
363
     */
364
    public HashMap<String,Map<String, String>> getMultimediaObjects() {
365
        return multimediaObjects;
366
    }
367

  
368

  
369

  
370
    /**
371
     * @param multimediaObjects the multimediaObjects to set
372
     */
373
    public void setMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {
374
        this.multimediaObjects = multimediaObjects;
375
    }
376

  
377
    public void putMultiMediaObject(String uri, Map<String, String> attributes){
378
        this.multimediaObjects.put(uri, attributes);
379
    }
380

  
381
    /**
382
     * @return the multimediaObjects
383
     */
384
    public HashMap<String,Map<String, String>> getGatheringMultimediaObjects() {
385
        return gatheringMultimediaObjects;
386
    }
387

  
388

  
389

  
390
    /**
391
     * @param multimediaObjects the multimediaObjects to set
392
     */
393
    public void setGatheringMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {
394
        this.gatheringMultimediaObjects = multimediaObjects;
395
    }
396

  
397
    public void putGatheringMultiMediaObject(String uri, Map<String, String> attributes){
398
        this.gatheringMultimediaObjects.put(uri, attributes);
399
    }
400

  
401

  
402

  
403
    /**
404
     * @return the identificationList
405
     */
406
    public List<Identification> getIdentificationList() {
407
        return identificationList;
408
    }
409

  
410

  
411

  
412
    /**
413
     * @param identificationList the identificationList to set
414
     */
415
    public void setIdentificationList(List<Identification> identificationList) {
416
        this.identificationList = identificationList;
417
    }
418

  
419

  
420

  
421
    /**
422
     * @return the statusList
423
     */
424
    public List<SpecimenTypeDesignationStatus> getStatusList() {
425
        return statusList;
426
    }
427

  
428

  
429

  
430
    /**
431
     * @param statusList the statusList to set
432
     */
433
    public void setStatusList(List<SpecimenTypeDesignationStatus> statusList) {
434
        this.statusList = statusList;
435
    }
436

  
437

  
438

  
439
    /**
440
     * @return the referenceList
441
     */
442
    public List<String[]> getReferenceList() {
443
        return referenceList;
444
    }
445

  
446

  
447

  
448
    /**
449
     * @param referenceList the referenceList to set
450
     */
451
    public void setReferenceList(List<String[]> referenceList) {
452
        this.referenceList = referenceList;
453
    }
454

  
455

  
456

  
457
    /**
458
     * @return the docSources
459
     */
460
    public List<String> getDocSources() {
461
        return docSources;
462
    }
463

  
464

  
465

  
466
    /**
467
     * @param docSources the docSources to set
468
     */
469
    public void setDocSources(List<String> docSources) {
470
        this.docSources = docSources;
471
    }
472

  
473

  
474

  
475
    /**
476
     * @return the unitID
477
     */
478
    public String getUnitID() {
479
        return unitID;
480
    }
481

  
482

  
483

  
484
    /**
485
     * @param unitID the unitID to set
486
     */
487
    public void setUnitID(String unitID) {
488
        this.unitID = unitID;
489
    }
490

  
491

  
492

  
493
    /**
494
     * @return the recordBasis
495
     */
496
    public String getRecordBasis() {
497
        return recordBasis;
498
    }
499

  
500

  
501

  
502
    /**
503
     * @param recordBasis the recordBasis to set
504
     */
505
    public void setRecordBasis(String recordBasis) {
506
        this.recordBasis = recordBasis;
507
    }
508
}
1
// $Id$
2
/**
3
* Copyright (C) 2016 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.specimen;
11

  
12
import java.util.ArrayList;
13
import java.util.HashMap;
14
import java.util.List;
15
import java.util.Map;
16

  
17
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Identification;
18
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
19

  
20
/**
21
 * @author k.luther
22
 * @date 18.07.2016
23
 *
24
 */
25
public class SpecimenDataHolder {
26

  
27
    protected String nomenclatureCode;
28
    protected List<HashMap<String, String>> atomisedIdentificationList;
29
    private String recordBasis;
30
    protected String gatheringElevationText;
31
    private String gatheringElevationMin;
32
    private String gatheringElevationMax;
33
    private String gatheringNotes;
34
    private String gatheringDateText;
35

  
36
    protected String gatheringElevation;
37

  
38
    private String gatheringElevationUnit;
39
    protected Double depth;
40
    /**
41
     * @return the depth
42
     */
43
    public Double getDepth() {
44
        return depth;
45
    }
46

  
47

  
48

  
49
    /**
50
     * @param depth the depth to set
51
     */
52
    public void setDepth(Double depth) {
53
        this.depth = depth;
54
    }
55

  
56

  
57

  
58
    private String gatheringSpatialDatum;
59
    private String gatheringCoordinateErrorMethod;
60
    private String kindOfUnit;
61

  
62
    private Map<String, String> namedAreaList;
63
    private String fieldNumber;
64
    private String unitNotes; //  occurenceRemarks(DwCA)
65

  
66
    private HashMap<String, Map<String,String>> multimediaObjects;
67
    private HashMap<String, Map<String,String>> gatheringMultimediaObjects;
68
    private List<Identification> identificationList;
69

  
70
    private List<SpecimenTypeDesignationStatus> statusList;
71

  
72
    private List<String[]> referenceList;
73
    private List<String> docSources;
74
    private String unitID;
75

  
76

  
77

  
78

  
79

  
80
    /**
81
     * @return the nomenclatureCode
82
     */
83
    public String getNomenclatureCode() {
84
        return nomenclatureCode;
85
    }
86

  
87

  
88

  
89
    /**
90
     * @param nomenclatureCode the nomenclatureCode to set
91
     */
92
    public void setNomenclatureCode(String nomenclatureCode) {
93
        this.nomenclatureCode = nomenclatureCode;
94
    }
95

  
96

  
97

  
98
    /**
99
     * @return the atomisedIdentificationList
100
     */
101
    public List<HashMap<String, String>> getAtomisedIdentificationList() {
102
        return atomisedIdentificationList;
103
    }
104

  
105

  
106

  
107
    /**
108
     * @param atomisedIdentificationList the atomisedIdentificationList to set
109
     */
110
    public void setAtomisedIdentificationList(List<HashMap<String, String>> atomisedIdentificationList) {
111
        this.atomisedIdentificationList = atomisedIdentificationList;
112
    }
113

  
114

  
115

  
116
    /**
117
     * @return the gatheringElevationText
118
     */
119
    public String getGatheringElevationText() {
120
        return gatheringElevationText;
121
    }
122

  
123

  
124

  
125
    /**
126
     * @param gatheringElevationText the gatheringElevationText to set
127
     */
128
    public void setGatheringElevationText(String gatheringElevationText) {
129
        this.gatheringElevationText = gatheringElevationText;
130
    }
131

  
132

  
133

  
134
    /**
135
     * @return the gatheringElevationMax
136
     */
137
    public String getGatheringElevationMax() {
138
        return gatheringElevationMax;
139
    }
140

  
141

  
142

  
143
    /**
144
     * @param gatheringElevationMax the gatheringElevationMax to set
145
     */
146
    public void setGatheringElevationMax(String gatheringElevationMax) {
147
        this.gatheringElevationMax = gatheringElevationMax;
148
    }
149

  
150

  
151

  
152
    /**
153
     * @return the gatheringElevationMin
154
     */
155
    public String getGatheringElevationMin() {
156
        return gatheringElevationMin;
157
    }
158

  
159

  
160

  
161
    /**
162
     * @param gatheringElevationMin the gatheringElevationMin to set
163
     */
164
    public void setGatheringElevationMin(String gatheringElevationMin) {
165
        this.gatheringElevationMin = gatheringElevationMin;
166
    }
167

  
168

  
169

  
170
    /**
171
     * @return the kindOfUnit
172
     */
173
    public String getKindOfUnit() {
174
        return kindOfUnit;
175
    }
176

  
177

  
178

  
179
    /**
180
     * @param kindOfUnit the kindOfUnit to set
181
     */
182
    public void setKindOfUnit(String kindOfUnit) {
183
        this.kindOfUnit = kindOfUnit;
184
    }
185

  
186

  
187

  
188
    /**
189
     * @return the gatheringElevationUnit
190
     */
191
    public String getGatheringElevationUnit() {
192
        return gatheringElevationUnit;
193
    }
194

  
195

  
196

  
197
    /**
198
     * @param gatheringElevationUnit the gatheringElevationUnit to set
199
     */
200
    public void setGatheringElevationUnit(String gatheringElevationUnit) {
201
        this.gatheringElevationUnit = gatheringElevationUnit;
202
    }
203

  
204

  
205

  
206
    /**
207
     * @return the gatheringDateText
208
     */
209
    public String getGatheringDateText() {
210
        return gatheringDateText;
211
    }
212

  
213

  
214

  
215
    /**
216
     * @param gatheringDateText the gatheringDateText to set
217
     */
218
    public void setGatheringDateText(String gatheringDateText) {
219
        this.gatheringDateText = gatheringDateText;
220
    }
221

  
222

  
223

  
224
    /**
225
     * @return the gatheringNotes
226
     */
227
    public String getGatheringNotes() {
228
        return gatheringNotes;
229
    }
230

  
231

  
232

  
233
    /**
234
     * @param gatheringNotes the gatheringNotes to set
235
     */
236
    public void setGatheringNotes(String gatheringNotes) {
237
        this.gatheringNotes = gatheringNotes;
238
    }
239

  
240

  
241

  
242
    /**
243
     * @return the gatheringSpatialDatum
244
     */
245
    public String getGatheringSpatialDatum() {
246
        return gatheringSpatialDatum;
247
    }
248

  
249

  
250

  
251
    /**
252
     * @param gatheringSpatialDatum the gatheringSpatialDatum to set
253
     */
254
    public void setGatheringSpatialDatum(String gatheringSpatialDatum) {
255
        this.gatheringSpatialDatum = gatheringSpatialDatum;
256
    }
257

  
258

  
259

  
260
    /**
261
     * @return the namedAreaList
262
     */
263
    public Map<String, String> getNamedAreaList() {
264
        return namedAreaList;
265
    }
266

  
267

  
268

  
269
    /**
270
     * @param namedAreaList the namedAreaList to set
271
     */
272
    public void setNamedAreaList(Map<String, String> namedAreaList) {
273
        this.namedAreaList = namedAreaList;
274
    }
275

  
276

  
277

  
278
    /**
279
     * @return the gatheringCoordinateErrorMethod
280
     */
281
    public String getGatheringCoordinateErrorMethod() {
282
        return gatheringCoordinateErrorMethod;
283
    }
284

  
285

  
286

  
287
    /**
288
     * @param gatheringCoordinateErrorMethod the gatheringCoordinateErrorMethod to set
289
     */
290
    public void setGatheringCoordinateErrorMethod(String gatheringCoordinateErrorMethod) {
291
        this.gatheringCoordinateErrorMethod = gatheringCoordinateErrorMethod;
292
    }
293

  
294

  
295

  
296
    /**
297
     *
298
     */
299
    public void reset() {
300
        nomenclatureCode = null;
301
        atomisedIdentificationList = new ArrayList<HashMap<String,String>>();
302
        gatheringDateText = null;
303
        gatheringNotes = null;
304
        kindOfUnit = null;
305

  
306
        setRecordBasis(null);
307
        gatheringElevationText = null;
308
        gatheringElevationMin = null;
309
        gatheringElevationMax = null;
310
        gatheringNotes = null;
311
        gatheringDateText = null;
312

  
313
        gatheringElevation = null;
314

  
315
        gatheringElevationUnit = null;
316
        gatheringSpatialDatum = null;
317
        gatheringCoordinateErrorMethod = null;
318
        depth = null;
319

  
320

  
321
    }
322

  
323

  
324

  
325
    /**
326
     * @return the fieldNumber
327
     */
328
    public String getFieldNumber() {
329
        return fieldNumber;
330
    }
331

  
332

  
333

  
334
    /**
335
     * @param fieldNumber the fieldNumber to set
336
     */
337
    public void setFieldNumber(String fieldNumber) {
338
        this.fieldNumber = fieldNumber;
339
    }
340

  
341

  
342

  
343
    /**
344
     * @return the unitNotes
345
     */
346
    public String getUnitNotes() {
347
        return unitNotes;
348
    }
349

  
350

  
351

  
352
    /**
353
     * @param unitNotes the unitNotes to set
354
     */
355
    public void setUnitNotes(String unitNotes) {
356
        this.unitNotes = unitNotes;
357
    }
358

  
359

  
360

  
361
    /**
362
     * @return the multimediaObjects
363
     */
364
    public HashMap<String,Map<String, String>> getMultimediaObjects() {
365
        return multimediaObjects;
366
    }
367

  
368

  
369

  
370
    /**
371
     * @param multimediaObjects the multimediaObjects to set
372
     */
373
    public void setMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {
374
        this.multimediaObjects = multimediaObjects;
375
    }
376

  
377
    public void putMultiMediaObject(String uri, Map<String, String> attributes){
378
        this.multimediaObjects.put(uri, attributes);
379
    }
380

  
381
    /**
382
     * @return the multimediaObjects
383
     */
384
    public HashMap<String,Map<String, String>> getGatheringMultimediaObjects() {
385
        return gatheringMultimediaObjects;
386
    }
387

  
388

  
389

  
390
    /**
391
     * @param multimediaObjects the multimediaObjects to set
392
     */
393
    public void setGatheringMultimediaObjects(HashMap<String,Map<String, String>> multimediaObjects) {
394
        this.gatheringMultimediaObjects = multimediaObjects;
395
    }
396

  
397
    public void putGatheringMultiMediaObject(String uri, Map<String, String> attributes){
398
        this.gatheringMultimediaObjects.put(uri, attributes);
399
    }
400

  
401

  
402

  
403
    /**
404
     * @return the identificationList
405
     */
406
    public List<Identification> getIdentificationList() {
407
        return identificationList;
408
    }
409

  
410

  
411

  
412
    /**
413
     * @param identificationList the identificationList to set
414
     */
415
    public void setIdentificationList(List<Identification> identificationList) {
416
        this.identificationList = identificationList;
417
    }
418

  
419

  
420

  
421
    /**
422
     * @return the statusList
423
     */
424
    public List<SpecimenTypeDesignationStatus> getStatusList() {
425
        return statusList;
426
    }
427

  
428

  
429

  
430
    /**
431
     * @param statusList the statusList to set
432
     */
433
    public void setStatusList(List<SpecimenTypeDesignationStatus> statusList) {
434
        this.statusList = statusList;
435
    }
436

  
437

  
438

  
439
    /**
440
     * @return the referenceList
441
     */
442
    public List<String[]> getReferenceList() {
443
        return referenceList;
444
    }
445

  
446

  
447

  
448
    /**
449
     * @param referenceList the referenceList to set
450
     */
451
    public void setReferenceList(List<String[]> referenceList) {
452
        this.referenceList = referenceList;
453
    }
454

  
455

  
456

  
457
    /**
458
     * @return the docSources
459
     */
460
    public List<String> getDocSources() {
461
        return docSources;
462
    }
463

  
464

  
465

  
466
    /**
467
     * @param docSources the docSources to set
468
     */
469
    public void setDocSources(List<String> docSources) {
470
        this.docSources = docSources;
471
    }
472

  
473

  
474

  
475
    /**
476
     * @return the unitID
477
     */
478
    public String getUnitID() {
479
        return unitID;
480
    }
481

  
482

  
483

  
484
    /**
485
     * @param unitID the unitID to set
486
     */
487
    public void setUnitID(String unitID) {
488
        this.unitID = unitID;
489
    }
490

  
491

  
492

  
493
    /**
494
     * @return the recordBasis
495
     */
496
    public String getRecordBasis() {
497
        return recordBasis;
498
    }
499

  
500

  
501

  
502
    /**
503
     * @param recordBasis the recordBasis to set
504
     */
505
    public void setRecordBasis(String recordBasis) {
506
        this.recordBasis = recordBasis;
507
    }
508
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenImportConfiguratorBase.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.specimen;
11

  
12
import java.net.URI;
13
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.UUID;
16

  
17
import eu.etaxonomy.cdm.ext.occurrence.OccurenceQuery;
18
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
19
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
20
import eu.etaxonomy.cdm.model.agent.Person;
21
import eu.etaxonomy.cdm.model.agent.Team;
22
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
23

  
24
/**
25
 * @author k.luther
26
 * @date 15.07.2016
27
 *
28
 */
29
public abstract class SpecimenImportConfiguratorBase<STATE extends SpecimenImportStateBase, InputStream>  extends ImportConfiguratorBase<STATE, InputStream> {
30

  
31
    /**
32
     * @param transformer
33
     */
34
    public SpecimenImportConfiguratorBase(IInputTransformer transformer) {
35
        super(transformer);
36

  
37
    }
38

  
39
    private boolean ignoreImportOfExistingSpecimen = true;
40
    private boolean reuseExistingTaxaWhenPossible = true;
41
    private final Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();
42

  
43
    private Map<String, Team> titleCacheTeam;
44
    private Map<String, Person> titleCachePerson;
45
    private boolean ignoreAuthorship = false;
46
    private boolean removeCountryFromLocalityText = false;
47
    protected OccurenceQuery query ;
48

  
49
    private boolean addMediaAsMediaSpecimen = false;
50
    private boolean reuseExistingMetaData = true;
51

  
52
    private static String sourceReferenceTitle = null;
53

  
54
    private String taxonReference = null;
55
    private boolean addIndividualsAssociationsSuchAsSpecimenAndObservations = true;
56
    private boolean reuseExistingDescriptiveGroups = false;
57

  
58

  
59
    private String defaultAuthor="";
60
    private boolean allowReuseOtherClassifications =true;
61

  
62
    private boolean deduplicateReferences = false;
63
    private boolean deduplicateClassifications = false;
64

  
65
    private boolean moveNewTaxaToDefaultClassification = true;
66

  
67
    private boolean mapUnitIdToCatalogNumber = true;
68
    private boolean mapUnitIdToAccessionNumber = false;
69
    private boolean mapUnitIdToBarcode = false;
70

  
71
    private boolean overwriteExistingSpecimens = false;
72

  
73
    private SpecimenOrObservationType type;
74

  
75

  
76
    /**
77
     * @return the type
78
     */
79
    public SpecimenOrObservationType getType() {
80
        return type;
81
    }
82

  
83
    /**
84
     * @param type the type to set
85
     */
86
    public void setType(SpecimenOrObservationType type) {
87
        this.type = type;
88
    }
89

  
90
    private final SpecimenUserInteraction specimenUserInteraction = new SpecimenUserInteraction();
91

  
92
    protected Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();
93

  
94
    private URI reportUri;
95

  
96

  
97
    public boolean isIgnoreImportOfExistingSpecimen() {
98
        return ignoreImportOfExistingSpecimen;
99
    }
100

  
101
    public void setIgnoreImportOfExistingSpecimen(boolean ignoreImportOfExistingSpecimen) {
102
        this.ignoreImportOfExistingSpecimen = ignoreImportOfExistingSpecimen;
103
    }
104

  
105
    public Map<String, Team> getTitleCacheTeam() {
106
        return titleCacheTeam;
107
    }
108

  
109
    public void setTitleCacheTeam(Map<String, Team> titleCacheTeam) {
110
        this.titleCacheTeam = titleCacheTeam;
111
    }
112

  
113
    public Map<String, Person> getTitleCachePerson() {
114
        return titleCachePerson;
115
    }
116

  
117
    public void setTitleCachePerson(Map<String, Person> titleCachePerson) {
118
        this.titleCachePerson = titleCachePerson;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)