Project

General

Profile

Revision 69c95165

ID69c95165854d79461daeca3e2bcf20d7aa055ad6
Parent d6b1a014
Child ecb38d0c

Added by Andreas Müller over 2 years ago

ref #6965 add reference author handling and and reporting for ID duplicates

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tropicos/in/TropicosNameImport.java
20 20
import eu.etaxonomy.cdm.api.service.pager.Pager;
21 21
import eu.etaxonomy.cdm.common.CdmUtils;
22 22
import eu.etaxonomy.cdm.io.csv.in.CsvImportBase;
23
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
23 24
import eu.etaxonomy.cdm.model.common.DefinedTerm;
24 25
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
25 26
import eu.etaxonomy.cdm.model.common.Language;
......
213 214
            return;
214 215
        }
215 216

  
217
        //Create and set title + in-Reference
216 218
        Reference reference;
217 219
        if (type == null){
218 220
            //TODO check against DB
......
235 237
        }
236 238
        reference.setVolume(volume);
237 239

  
238
        name.setNomenclaturalReference(reference);
239
        name.setNomenclaturalMicroReference(detail);
240

  
241

  
240
        //date
242 241
        if (titlePageYear != null){
243 242
            if (yearPublished == null){
244 243
                TimePeriod tp = TimePeriodParser.parseString(titlePageYear);
......
251 250
            TimePeriod tp = TimePeriodParser.parseString(yearPublished);
252 251
            reference.setDatePublished(tp);
253 252
        }
253

  
254
        //add to name
255
        name.setNomenclaturalReference(reference);
256
        name.setNomenclaturalMicroReference(detail);
257
        //author
258
        if (state.getConfig().isAddAuthorsToReference()){
259
            TeamOrPersonBase<?> author = name.getCombinationAuthorship();
260
            if (author != null){
261
                reference.setAuthorship(author);
262
            }
263
        }
264

  
265
        //source
254 266
        addSourceReference(state, reference);
255 267
    }
256 268

  
......
270 282
            return false;
271 283
        }
272 284

  
273
        //TODO check for existing WFO ID
274
        Pager<IdentifiedEntityDTO<TaxonName>> existing = getNameService().findByIdentifier(TaxonName.class, identifier, identifierType, MatchMode.EXACT, false, null, null, null);
275
        if (! allowDuplicate && existing.getCount() > 0){
276
            String message = "The name with the given identifier (%s: %s) exists already in the database. Record is not imported.";
277
            //TODO make language configurable
278
            message = String.format(message, identifierType.getPreferredRepresentation(Language.DEFAULT()).getText(), identifier);
279
            state.getResult().addWarning(message, state.getRow());
280
            return true;
285
        if (! allowDuplicate || state.getConfig().isReportDuplicateIdentifier()){
286
            //TODO precompute existing per session or, at least, implement count
287
            Pager<IdentifiedEntityDTO<TaxonName>> existing = getNameService().findByIdentifier(TaxonName.class, identifier, identifierType, MatchMode.EXACT, false, null, null, null);
288
            if (existing.getCount() > 0){
289
                //TODO make language configurable
290
                Language language = Language.DEFAULT();
291
                if (! allowDuplicate){
292
                    String message = "The name with the given identifier (%s: %s) exists already in the database. Record is not imported.";
293
                    message = String.format(message, identifierType.getPreferredRepresentation(Language.DEFAULT()).getText(), identifier);
294
                    state.getResult().addWarning(message, state.getRow());
295
                    return true;
296
                }else{
297
                    String message = "The name with the given identifier (%s: %s) exists already in the database. Record is imported but maybe needs to be reviewed.";
298
                    message = String.format(message, identifierType.getPreferredRepresentation(language).getText(), identifier);
299
                    state.getResult().addWarning(message, state.getRow());
300
                }
301
            }
281 302
        }
282 303

  
283 304
        name.addIdentifier(identifier, identifierType);
......
320 341
        }else{
321 342
            name = parser.parseSimpleName(nameStr, state.getConfig().getNomenclaturalCode(), null);
322 343
        }
344

  
323 345
        if (name.isProtectedTitleCache() || name.isProtectedNameCache() || name.isProtectedAuthorshipCache()){
324 346
            String message = "Name (%s) could not be fully parsed, but is processed";
325 347
            message = String.format(message, name.getTitleCache());
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tropicos/in/TropicosNameImportConfigurator.java
31 31
    private String classificationName;
32 32
    private boolean unplaced = true;  //if new nodes should be created, should they be marked as unplaced?
33 33

  
34
    private boolean allowTropicosDuplicates;
35
    private boolean allowIpniDuplicates;
36
    private boolean allowWfoDuplicates;
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;
37 40

  
38 41
    /**
39 42
     * @param inputStream
......
194 197
        this.allowWfoDuplicates = allowWfoDuplicates;
195 198
    }
196 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

  
197 234
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)