Project

General

Profile

Download (7.41 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.io.tropicos.in;
10

    
11
import java.io.IOException;
12
import java.io.InputStreamReader;
13
import eu.etaxonomy.cdm.common.URI;
14
import java.util.UUID;
15

    
16
import eu.etaxonomy.cdm.database.ICdmDataSource;
17
import eu.etaxonomy.cdm.io.csv.in.CsvImportConfiguratorBase;
18
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20

    
21
/**
22
 * @author a.mueller
23
 * @since 15.11.2017
24
 */
25
public class TropicosNameImportConfigurator extends CsvImportConfiguratorBase {
26

    
27
    private static final long serialVersionUID = -648787716062337242L;
28

    
29
    private boolean createTaxa = false;
30
    private UUID parentNodeUuid;
31
    private String classificationName;
32
    private boolean unplaced = true;  //if new nodes should be created, should they be marked as unplaced?
33

    
34
    private boolean allowTropicosDuplicates = false;
35
    private boolean allowIpniDuplicates = false;
36
    private boolean allowWfoDuplicates = false;
37
    private boolean reportDuplicateIdentifier = true;
38

    
39
    private boolean addAuthorsToReference = true;
40

    
41
    /**
42
     * @param inputStream
43
     * @param object
44
     * @return
45
     */
46
    public static TropicosNameImportConfigurator NewInstance(InputStreamReader inputStream, ICdmDataSource cdmDestination) {
47
        return new TropicosNameImportConfigurator(inputStream, cdmDestination);
48
    }
49

    
50
    public static TropicosNameImportConfigurator NewInstance(URI uri, ICdmDataSource cdmDestination)
51
            throws IOException {
52
        return new TropicosNameImportConfigurator(uri, cdmDestination);
53
    }
54

    
55
    /**
56
     * @param inputStream
57
     * @param cdmDestination
58
     */
59
    private TropicosNameImportConfigurator(InputStreamReader inputStream, ICdmDataSource cdmDestination) {
60
        super(inputStream, cdmDestination);
61
    }
62

    
63
    /**
64
     * @param uri
65
     * @param cdmDestination
66
     * @param transformer
67
     * @throws IOException
68
     */
69
    private TropicosNameImportConfigurator(URI uri, ICdmDataSource cdmDestination)
70
            throws IOException {
71
        super(uri, cdmDestination, null);
72
        this.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
73
    }
74

    
75
    /**
76
     * {@inheritDoc}
77
     */
78
    @Override
79
    protected void makeIoClassList() {
80
        ioClassList = new Class[]{
81
                TropicosNameImport.class
82
            };
83
    }
84

    
85
    @Override
86
    public TropicosNameImportState getNewState() {
87
        return new TropicosNameImportState(this);
88
    }
89

    
90
    /**
91
     * If <code>true</code> additional to the name a
92
     * taxon is created. Depending on further parameters
93
     * {@link #getParentNodeUuid()} and/or {@link #getClassificationName()}
94
     * it is decided where to put the taxon in a classification.
95
     * @return <code>true</code> if a taxon is to be created.
96
     */
97
    public boolean isCreateTaxa() {
98
        return createTaxa;
99
    }
100
    /**
101
     * {@link #setEditor(eu.etaxonomy.cdm.io.common.IImportConfigurator.EDITOR)}
102
     */
103
    public void setCreateTaxa(boolean createTaxa) {
104
        this.createTaxa = createTaxa;
105
    }
106

    
107
    /**
108
     * If {@link #isCreateTaxa()} is <code>true</code> the taxon
109
     * to be created will be imported below the {@link TaxonNode taxon node}
110
     * with the given taxon node uuid.
111
     */
112
    public UUID getParentNodeUuid() {
113
        return parentNodeUuid;
114
    }
115
    public void setParentNodeUuid(UUID parentNodeUuid) {
116
        this.parentNodeUuid = parentNodeUuid;
117
    }
118

    
119
    /**
120
     * If {@link #isCreateTaxa()} is <code>true</code> and if no
121
     * {@link #getParentNodeUuid() parent node uuid} is given
122
     * the taxon to be created will be imported into a newly created
123
     * classification with the given classification name.
124
     */
125
    @Override
126
    public String getClassificationName() {
127
        return classificationName;
128
    }
129
    @Override
130
    public void setClassificationName(String classificationName) {
131
        this.classificationName = classificationName;
132
    }
133

    
134
    /**
135
     * If taxa are created ({@link #isCreateTaxa()} should the according
136
     * taxon nodes be marked as unplaced?
137
     * @see #isCreateTaxa()
138
     * @see #getClassificationName()
139
     * @see #getParentNodeUuid()
140
     * @return the unplaced
141
     */
142
    public boolean isUnplaced() {
143
        return unplaced;
144
    }
145
    public void setUnplaced(boolean unplaced) {
146
        this.unplaced = unplaced;
147
    }
148

    
149
    /**
150
     * If <code>false</code> and if the name has a Tropicos ID
151
     * and if this Tropicos ID already exists in the database or in previously
152
     * imported data the import of the given record will be stopped.
153
     * @return <code>true</code> if Tropicos duplicates are allowed for this import
154
     */
155
    public boolean isAllowTropicosDuplicates() {
156
        return allowTropicosDuplicates;
157
    }
158

    
159
    /**
160
     * @see #isAllowTropicosDuplicates()
161
     */
162
    public void setAllowTropicosDuplicates(boolean allowTropicosDuplicates) {
163
        this.allowTropicosDuplicates = allowTropicosDuplicates;
164
    }
165

    
166
    /**
167
     * If <code>false</code> and if the name has an IPNI ID
168
     * and if this IPNI ID already exists in the database or in previously
169
     * imported data the import of the given record will be stopped.
170
     * @return <code>true</code> if IPNI duplicates are allowed for this import
171
     */
172
    public boolean isAllowIpniDuplicates() {
173
        return allowIpniDuplicates;
174
    }
175

    
176
    /**
177
     * @see #isAllowIpniDuplicates()
178
     */
179
    public void setAllowIpniDuplicates(boolean allowIpniDuplicates) {
180
        this.allowIpniDuplicates = allowIpniDuplicates;
181
    }
182

    
183
    /**
184
     * If <code>false</code> and if the name has a World Flora Online (WFO) ID
185
     * and if this WFO ID already exists in the database or in previously
186
     * imported data the import of the given record will be stopped.
187
     * @return <code>true</code> if WFO duplicates are allowed for this import
188
     */
189
    public boolean isAllowWfoDuplicates() {
190
        return allowWfoDuplicates;
191
    }
192
    /**
193
     * @see #isAllowWfoDuplicates()
194
     * @param allowWfoDuplicates
195
     */
196
    public void setAllowWfoDuplicates(boolean allowWfoDuplicates) {
197
        this.allowWfoDuplicates = allowWfoDuplicates;
198
    }
199

    
200
    /**
201
     * If <code>true</code> the name authors will be added
202
     * to the nomenclatural reference (Book or Article) though
203
     * it might not be the exact same author.<BR>
204
     * Default is <code>true</code>
205
     */
206
    public boolean isAddAuthorsToReference() {
207
        return addAuthorsToReference;
208
    }
209
    /**
210
     * @see #isAddAuthorsToReference()
211
     */
212
    public void setAddAuthorsToReference(boolean addAuthorsToReference) {
213
        this.addAuthorsToReference = addAuthorsToReference;
214
    }
215

    
216
    /**
217
     * if <code>true</code> duplicate identifiers like
218
     * {@link #isAllowTropicosDuplicates() Tropicos IDs}
219
     * {@link #isAllowIpniDuplicates() IPNI IDs} or
220
     * {@link #isAllowWfoDuplicates() WFO IDs} will be reported.
221
     * This is only relevant if duplicates are allowed,
222
     * otherwise the duplicates will be reported anyway.
223
     */
224
    public boolean isReportDuplicateIdentifier() {
225
        return reportDuplicateIdentifier;
226
    }
227
    /**
228
     * @see #isReportDuplicateIdentifier()
229
     */
230
    public void setReportDuplicateIdentifier(boolean reportDuplicateIdentifier) {
231
        this.reportDuplicateIdentifier = reportDuplicateIdentifier;
232
    }
233

    
234
}
(2-2/3)