Project

General

Profile

« Previous | Next » 

Revision f0109d06

Added by Andreas Müller over 4 years ago

ref #8479 split taxon and description import, remove auditing and some other improvements

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/FauEu2CdmActivator.java
41 41

  
42 42
    static final int partitionSize = 5000;
43 43

  
44
    static final boolean doTaxa = false;
45
    static final boolean doDescriptions = true;
46

  
44 47
    static final boolean doConcurrent = false;
48
    //auditing
49
    static final boolean registerAuditing = false;
45 50

  
46 51
// ***************** ALL ************************************************//
47 52

  
48 53
//    >50 records
49
    UUID uuidTaxonNodeFilter = UUID.fromString("0e8bc793-f434-47c4-ba82-650c3bbd83bf");
54
//    UUID uuidTaxonNodeFilter = UUID.fromString("0e8bc793-f434-47c4-ba82-650c3bbd83bf");
50 55
    //>17000 records
51 56
//    UUID uuidTaxonNodeFilter = UUID.fromString("7ee4983b-78a3-44c5-9af2-beb0494b5fc8");
57
    //complete
58
    UUID uuidTaxonNodeFilter = UUID.fromString("feaa3025-a4a9-499a-b62f-15b3b96e5c55");
52 59

  
53 60

  
54 61
    private void doImport(ICdmDataSource source, ICdmDataSource destination, DbSchemaValidation hbm2dll){
......
58 65

  
59 66
        FauEu2CdmImportConfigurator config = FauEu2CdmImportConfigurator.NewInstance(source,  destination);
60 67
        config.setConcurrent(doConcurrent);
68
        config.setDoTaxa(doTaxa);
69
        config.setDoDescriptions(doDescriptions);
61 70

  
62 71
        IProgressMonitor monitor = config.getProgressMonitor();
63 72

  
......
75 84
        config.setCheck(check);
76 85
//        config.setRecordsPerTransaction(partitionSize);
77 86

  
87
        config.setRegisterAuditing(registerAuditing);
88

  
78 89
        // invoke import
79 90
        CdmDefaultImport<FauEu2CdmImportConfigurator> myImport = new CdmDefaultImport<>();
80 91
        myImport.invoke(config);
......
82 93
        System.out.println("End" + importFrom);
83 94
    }
84 95

  
85
    /**
86
     * @param args
87
     */
88 96
    public static void main(String[] args) {
89 97
        ICdmDataSource cdmDB = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
90 98
        FauEu2CdmActivator myImport = new FauEu2CdmActivator();
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmDescriptionImport.java
1
/**
2
* Copyright (C) 2019 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.pesi.fauEu2Cdm;
10

  
11
import java.util.HashSet;
12
import java.util.Set;
13

  
14
import org.apache.log4j.Logger;
15
import org.springframework.stereotype.Component;
16
import org.springframework.transaction.TransactionStatus;
17

  
18
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
19
import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
20
import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitioner;
21
import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitionerConcurrent;
22
import eu.etaxonomy.cdm.model.description.TaxonDescription;
23
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
24

  
25
/**
26
 * @author a.mueller
27
 * @since 17.08.2019
28
 */
29
@Component
30
public class FauEu2CdmDescriptionImport
31
        extends FauEu2CdmImportBase {
32

  
33
    private static final long serialVersionUID = -2111102574346601573L;
34
    private static final Logger logger = Logger.getLogger(FauEu2CdmDescriptionImport.class);
35

  
36

  
37
    @Override
38
    protected void doInvoke(FauEu2CdmImportState state) {
39
        setState(state);
40
        IProgressMonitor monitor = state.getConfig().getProgressMonitor();
41

  
42
        FauEu2CdmImportConfigurator config = state.getConfig();
43

  
44
        ITaxonNodeOutStreamPartitioner partitioner = getPartitioner(state, monitor, config);
45
        monitor.subTask("Start partitioning");
46
        doData(state, partitioner);
47
    }
48

  
49
    private void doData(FauEu2CdmImportState state, ITaxonNodeOutStreamPartitioner partitioner){
50
        TaxonNode node = partitioner.next();
51
        int partitionSize = 100;
52
        int count = 0;
53
        TransactionStatus tx = startTransaction();
54
        while (node != null) {
55
            doSingleNode(state, node);
56
            count++;
57
            if (count>=partitionSize){
58
                clearCache();
59
                try {
60
                    commitTransaction(tx);
61
                } catch (Exception e) {
62
                    logger.warn("Exception during commit node " + node.treeIndex());
63
                    e.printStackTrace();
64
                }
65
                tx = startTransaction();
66
                count=0;
67
            }
68
            node = partitioner.next();
69
        }
70
        commitTransaction(tx);
71
        partitioner.close();
72
    }
73

  
74
    private void doSingleNode(FauEu2CdmImportState state, TaxonNode node) {
75
        Set<TaxonDescription> result = new HashSet<>();
76
        logger.info(node.treeIndex());
77
        try {
78
            for (TaxonDescription desc : node.getTaxon().getDescriptions()){
79
                result.add(detache(desc));
80
            }
81
        } catch (Exception e) {
82
            logger.warn("Exception during detache node " + node.treeIndex());
83
            e.printStackTrace();
84
        }
85
        try {
86
            if (!result.isEmpty()){
87
                getDescriptionService().saveOrUpdate((Set)result);
88
                getCommonService().saveOrUpdate(toSave);
89
                toSave.clear();
90
            }
91
        } catch (Exception e) {
92
            logger.warn("Exception during save node " + node.treeIndex());
93
             e.printStackTrace();
94
        }
95
    }
96

  
97
    private ITaxonNodeOutStreamPartitioner getPartitioner(FauEu2CdmImportState state, IProgressMonitor monitor,
98
            FauEu2CdmImportConfigurator config) {
99
        ITaxonNodeOutStreamPartitioner partitioner = config.getPartitioner();
100
        if (partitioner == null){
101
            if(!config.isConcurrent()){
102
                partitioner = TaxonNodeOutStreamPartitioner.NewInstance(sourceRepo(state), state,
103
                        state.getConfig().getTaxonNodeFilter(), 100,
104
                        monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
105
                ((TaxonNodeOutStreamPartitioner)partitioner).setLastCommitManually(true);
106
            }else{
107
                partitioner = TaxonNodeOutStreamPartitionerConcurrent
108
                        .NewInstance(state.getConfig().getSource(), state.getConfig().getTaxonNodeFilter(),
109
                                1000, monitor, 1, TaxonNodeOutStreamPartitioner.fullPropertyPaths);
110
            }
111
        }
112
        return partitioner;
113
    }
114

  
115

  
116
    @Override
117
    protected boolean doDescriptions(FauEu2CdmImportState state) {
118
        return true;
119
    }
120

  
121
    @Override
122
    protected boolean doCheck(FauEu2CdmImportState state) {
123
        return false;
124
    }
125

  
126
    @Override
127
    protected boolean isIgnore(FauEu2CdmImportState state) {
128
        return !state.getConfig().isDoDescriptions();
129
    }
130

  
131
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportBase.java
49 49
import eu.etaxonomy.cdm.model.common.LanguageString;
50 50
import eu.etaxonomy.cdm.model.common.LanguageStringBase;
51 51
import eu.etaxonomy.cdm.model.common.Marker;
52
import eu.etaxonomy.cdm.model.common.MarkerType;
52 53
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
53 54
import eu.etaxonomy.cdm.model.common.RelationshipBase;
54 55
import eu.etaxonomy.cdm.model.common.SourcedEntityBase;
......
75 76
import eu.etaxonomy.cdm.model.name.HybridRelationship;
76 77
import eu.etaxonomy.cdm.model.name.NameRelationship;
77 78
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
79
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
78 80
import eu.etaxonomy.cdm.model.name.Registration;
79 81
import eu.etaxonomy.cdm.model.name.TaxonName;
80 82
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
......
112 114
    private static final long serialVersionUID = 8917991155285743172L;
113 115
    private static final Logger logger = Logger.getLogger(FauEu2CdmImportBase.class);
114 116

  
117
    //quick and dirty
118
    private FauEu2CdmImportState state;
115 119

  
116 120
    //TODO move to state
117 121
    private Map<UUID, CdmBase> sessionCache = new HashMap<>();
118
    private Map<UUID, CdmBase> permanentCache = new HashMap<>();
119
    private Set<UUID> movedObjects = new HashSet<>();
122

  
120 123

  
121 124
    protected Set<CdmBase> toSave = new HashSet<>();
122 125

  
......
153 156
        return detache(cdmBase, false);
154 157
    }
155 158

  
156

  
159
    private Map<Class,Set<UUID>> existingObjects = new HashMap<>();
157 160
    protected <T extends CdmBase> T detache(T cdmBase, boolean notFromSource) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
158 161
        cdmBase = CdmBase.deproxy(cdmBase);
159 162
        if (cdmBase == null ){
......
161 164
        }else if(isInCache(cdmBase)){
162 165
            return getCached(cdmBase);
163 166
        }else {
164
            //TODO better load all existing UUIDs just in case any of the objects is already in the DB
165
            if (cdmBase instanceof TermBase || movedObjects.contains(cdmBase.getUuid())){
167
            if (existingObjects.get(cdmBase.getClass()) == null){
168
                loadExistingUuids(cdmBase.getClass());
169
            }
170
            boolean exists = existingObjects.get(cdmBase.getClass()).contains(cdmBase.getUuid());
171
            if (exists){
166 172
                Class<T> clazz = (Class<T>)cdmBase.getClass();
167
                T exists = getCommonService().find(clazz, cdmBase.getUuid());
168
                if (exists != null){
169
                    return exists;
170
                }else if (movedObjects.contains(cdmBase.getUuid())){
171
                    logger.warn("Object should be moved already but does not exist in target. This should not happen: " + cdmBase.getUuid());
173
                T existingObj = getCommonService().find(clazz, cdmBase.getUuid());
174
                if (existingObj != null){
175
                    cache(existingObj);
176
                    return existingObj;
177
                }else{
178
                    logger.warn("Object should exist already but does not exist in target. This should not happen: " + cdmBase.getClass().getSimpleName() + "/" + cdmBase.getUuid());
172 179
                }
173 180
            }
174 181
        }
......
180 187
        }
181 188
    }
182 189

  
190
    /**
191
     * @param class1
192
     * @return
193
     */
194
    private Set<UUID> loadExistingUuids(Class<? extends CdmBase> clazz) {
195
        List<UUID> list = getCommonService().listUuid(clazz);
196
        Set<UUID> result = new HashSet<>(list);
197
        existingObjects.put(clazz, result);
198
        return result;
199
    }
200

  
183 201
    protected <A extends CdmBase> CdmBase handlePersisted(A cdmBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
184 202
        if(cdmBase instanceof TaxonNode){
185 203
            return handlePersistedTaxonNode((TaxonNode)cdmBase);
......
253 271
            return handlePersistedIntextReference((IntextReference)cdmBase);
254 272
        }else if(cdmBase instanceof ExtensionType){
255 273
            return handlePersistedExtensionType((ExtensionType)cdmBase);
274
        }else if(cdmBase instanceof NomenclaturalStatusType){
275
            return handlePersistedNomenclaturalStatusType((NomenclaturalStatusType)cdmBase);
276
        }else if(cdmBase instanceof MarkerType){
277
            return handlePersistedMarkerType((MarkerType)cdmBase);
256 278
        }else if(cdmBase instanceof DefinedTerm){
257 279
            return handlePersistedDefinedTerm((DefinedTerm)cdmBase);
258 280
        }else if(cdmBase instanceof DefinedTermBase){
......
269 291
        if (result ==null){
270 292
            return result;
271 293
        }
294
        //complete
272 295
        handleCollection(result, TaxonNode.class, "agentRelations", TaxonNodeAgentRelation.class);
273 296
        result.setTaxon(detache(result.getTaxon()));
274 297
        result.setReference(detache(node.getReference()));
298
        result.setSynonymToBeUsed(detache(result.getSynonymToBeUsed()));
275 299
        handleMap(result, TaxonNode.class, "excludedNote", Language.class, LanguageString.class);
276 300
        //classification, parent, children
277 301
        this.setInvisible(node, "classification", detache(node.getClassification()));
......
296 320

  
297 321
    protected Taxon handlePersistedTaxon(Taxon taxon) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
298 322
        Taxon result = handlePersisted((TaxonBase)taxon);
323
        //complete
299 324
        handleCollection(result, Taxon.class, "synonyms", Synonym.class);
300 325
//        handleCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
301 326
        setNewCollection(result, Taxon.class, "taxonNodes", TaxonNode.class);
302 327
        handleCollection(result, Taxon.class, "relationsFromThisTaxon", TaxonRelationship.class);
303 328
        handleCollection(result, Taxon.class, "relationsToThisTaxon", TaxonRelationship.class);
304
        handleCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
329
        if (this.doDescriptions(state)){
330
            handleCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
331
        }else{
332
            setNewCollection(result, Taxon.class, "descriptions", TaxonDescription.class);
333
        }
305 334
        return result;
306 335
    }
307 336

  
337
    protected boolean doDescriptions(FauEu2CdmImportState state) {
338
        return false;
339
    }
340

  
308 341
    protected Synonym handlePersistedSynonym(Synonym synonym) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
309 342
        Synonym result = handlePersisted((TaxonBase)synonym);
343
        //complete
310 344
        setInvisible(result, "acceptedTaxon", detache(result.getAcceptedTaxon()));
311 345
        result.setType(detache(result.getType()));
312 346
        return result;
......
314 348

  
315 349
    protected TaxonRelationship handlePersistedTaxonRelationship(TaxonRelationship taxRel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
316 350
        TaxonRelationship result = handlePersisted((RelationshipBase)taxRel);
351
        //complete
317 352
        result.setFromTaxon(detache(result.getFromTaxon()));
318 353
        result.setToTaxon(detache(result.getToTaxon()));
319 354
        result.setType(detache(result.getType()));
......
322 357

  
323 358
    protected NameRelationship handlePersistedNameRelationship(NameRelationship rel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
324 359
        NameRelationship result = handlePersisted((RelationshipBase)rel);
360
        //complete
325 361
        setInvisible(result, "relatedFrom", detache(result.getFromName()));
326 362
        setInvisible(result, "relatedTo", detache(result.getToName()));
327 363
//        result.setFromName(detache(result.getFromName()));
......
332 368

  
333 369
    protected HybridRelationship handlePersistedHybridRelationship(HybridRelationship rel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
334 370
        HybridRelationship result = handlePersisted((RelationshipBase)rel);
371
        //complete
335 372
        setInvisible(result, "relatedFrom", detache(result.getParentName()));
336 373
        setInvisible(result, "relatedTo", detache(result.getHybridName()));
337 374
//        result.setFromName(detache(result.getFromName()));
......
342 379

  
343 380
    protected NomenclaturalStatus handlePersistedNomenclaturalStatus(NomenclaturalStatus status) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
344 381
        NomenclaturalStatus result = handlePersisted((ReferencedEntityBase)status);
382
        //complete
345 383
        result.setType(detache(result.getType()));
346 384
        return result;
347 385
    }
348 386

  
349 387
    protected TypeDesignationBase handlePersistedTypeDesignationBase(TypeDesignationBase<?> designation) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
350 388
        TypeDesignationBase result = handlePersisted((SourcedEntityBase)designation);
389
        //complete
351 390
        result.setCitation(detache(result.getCitation()));
352 391
        handleCollection(result, TypeDesignationBase.class, "registrations", Registration.class);
353 392
        handleCollection(result, TypeDesignationBase.class, "typifiedNames", TaxonName.class);
......
357 396

  
358 397
    protected InstitutionalMembership handlePersistedInstitutionalMembership(InstitutionalMembership institutionalMembership) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
359 398
        InstitutionalMembership result = handlePersisted((VersionableEntity)institutionalMembership);
399
        //complete
360 400
//        result.setPerson(detache(result.getPerson()));
361 401
        setInvisible(result, "person", detache(result.getPerson()));
362 402
        result.setInstitute(detache(result.getInstitute()));
......
365 405

  
366 406
    protected Institution handlePersistedInstitution(Institution institution) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
367 407
        Institution result = handlePersisted((AgentBase)institution);
408
        //complete
368 409
        result.setIsPartOf(detache(result.getIsPartOf()));
369 410
        handleCollection(result, Institution.class, "types", DefinedTerm.class);
370 411
        return result;
......
372 413

  
373 414
    protected TaxonNodeAgentRelation handlePersistedTaxonNodeAgentRelation(TaxonNodeAgentRelation nodeAgentRel) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
374 415
        TaxonNodeAgentRelation result = handlePersisted((AnnotatableEntity)nodeAgentRel);
375
        if (result ==null){
376
            return result;
377
        }
416
        //complete
378 417
        result.setAgent(detache(result.getAgent()));
379 418
        result.setType(detache(result.getType()));
380 419
        setInvisible(result, "taxonNode", detache(result.getTaxonNode()));
......
385 424
    protected TaxonName handlePersistedTaxonName(TaxonName taxonName) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
386 425
        @SuppressWarnings("rawtypes")
387 426
        TaxonName result = handlePersisted((IdentifiableEntity)taxonName);
388
        if (result ==null){
389
            return result;
390
        }
427
        //complete
428
        result.setRank(detache(result.getRank()));
391 429
        result.setCombinationAuthorship(detache(result.getCombinationAuthorship()));
392 430
        result.setExCombinationAuthorship(detache(result.getExCombinationAuthorship()));
393 431
        result.setBasionymAuthorship(detache(result.getBasionymAuthorship()));
......
396 434
        result.setInCombinationAuthorship(detache(result.getInCombinationAuthorship()));
397 435

  
398 436
        result.setNomenclaturalReference(detache(result.getNomenclaturalReference()));
437
        result.setNomenclaturalSource(detache(result.getNomenclaturalSource()));
399 438
        result.setHomotypicalGroup(detache(result.getHomotypicalGroup()));
400 439
        handleCollection(result, TaxonName.class, "descriptions", TaxonNameDescription.class);
401 440
        handleCollection(result, TaxonName.class, "hybridChildRelations", HybridRelationship.class);
......
414 453

  
415 454
    protected HomotypicalGroup handlePersistedHomotypicalGroup(HomotypicalGroup group) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
416 455
        HomotypicalGroup result = handlePersisted((AnnotatableEntity)group);
417
        if (result ==null){
418
            return result;
419
        }
456
        //complete
420 457
        handleCollection(result, HomotypicalGroup.class, "typifiedNames", TaxonName.class);
421 458
        return result;
422 459
    }
423 460

  
424 461
    protected Annotation handlePersistedAnnotation(Annotation annotation) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
425 462
        Annotation result = handlePersisted((AnnotatableEntity)annotation);
426
        if (result ==null){
427
            return result;
428
        }
463
        //complete
429 464
        result.setAnnotationType(detache(annotation.getAnnotationType()));
465
        result.setCommentator(detache(result.getCommentator()));
430 466
        handleCollection(result, Annotation.class, "intextReferences", IntextReference.class);
431 467
        return result;
432 468
    }
433 469

  
434 470
    protected Extension handlePersistedExtension(Extension extension) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
435 471
        Extension result = handlePersisted((VersionableEntity)extension);
436
        if (result ==null){
437
            return result;
438
        }
472
        //complete
439 473
        result.setType(detache(extension.getType()));
440 474
        return result;
441 475
    }
442 476

  
443 477
    protected Marker handlePersistedMarker(Marker marker) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
444 478
        Marker result = handlePersisted((VersionableEntity)marker);
445
        if (result ==null){
446
            return result;
447
        }
479
        //complete
448 480
        result.setMarkerType(detache(marker.getMarkerType()));
449 481
        return result;
450 482
    }
451 483

  
452 484
    protected Team handlePersistedTeam(Team team) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
453 485
        Team result = handlePersisted((TeamOrPersonBase)team);
454
        if (result ==null){
455
            return result;
456
        }
486
        //complete
457 487
        handleCollection(result, Team.class, "teamMembers", Person.class);
458 488
        return result;
459 489
    }
......
479 509

  
480 510
    protected Person handlePersistedPerson(Person person) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
481 511
        Person result = handlePersisted((TeamOrPersonBase)person);
512
        //complete
482 513
        handleCollection(result, Person.class, "institutionalMemberships", InstitutionalMembership.class);
483 514
        return result;
484 515
    }
485 516

  
486 517
    protected NamedArea handlePersistedNamedArea(NamedArea area) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
487 518
        NamedArea result = handlePersisted((OrderedTermBase)area);
519
        //complete
488 520
        handleCollection(result, NamedArea.class, "countries", Country.class);
489 521
        result.setLevel(detache(result.getLevel()));
490 522
        result.setType(detache(result.getType()));
......
494 526

  
495 527
    protected Classification handlePersistedClassification(Classification classification) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
496 528
        Classification result = handlePersisted((IdentifiableEntity)classification);
497
        if (result ==null){
498
            return result;
499
        }
529
        //complete
500 530
        result.setName(detache(classification.getName()));
501 531
        result.setReference(detache(classification.getReference()));
502 532
        result.setRootNode(detache(classification.getRootNode()));
503 533
        handleCollection(result, Classification.class, "geoScopes", NamedArea.class);
504 534
        handleMap(result, Classification.class, "description", Language.class, LanguageString.class);
505

  
506 535
        return result;
507 536
    }
508 537

  
......
516 545
    }
517 546

  
518 547
    protected SpecimenOrObservationBase<?> handlePersistedSpecimenOrObservationBase(SpecimenOrObservationBase specimen) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
548
        //TODO implement for classes
519 549
        SpecimenOrObservationBase<?> result = handlePersisted((IdentifiableEntity)specimen);
550
        //complete
520 551
        result.setSex(detache(result.getSex()));
521 552
        result.setLifeStage(detache(result.getLifeStage()));
522 553
        result.setKindOfUnit(detache(result.getKindOfUnit()));
523
        //TODO implement for classes
524 554
        handleCollection(result, SpecimenOrObservationBase.class, "determinations", DeterminationEvent.class);
525 555
        handleCollection(result, SpecimenOrObservationBase.class, "descriptions", SpecimenDescription.class);
526 556
        handleCollection(result, SpecimenOrObservationBase.class, "derivationEvents", DerivationEvent.class);
......
530 560

  
531 561
    protected IdentifiableSource handlePersistedIdentifiableSource(IdentifiableSource source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
532 562
        IdentifiableSource result = handlePersisted((OriginalSourceBase)source);
533
        if (result ==null){
534
            return null;
535
        }
563
        //complete
536 564
        return result;
537 565
    }
538 566

  
539 567
    protected DescriptionElementSource handlePersistedDescriptionElementSource(DescriptionElementSource source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
540 568
        DescriptionElementSource result = handlePersisted((OriginalSourceBase)source);
569
        //complete
541 570
        result.setNameUsedInSource(detache(result.getNameUsedInSource()));
542 571
        return result;
543 572
    }
544 573

  
545 574
    protected <T extends CommonTaxonName> T  handlePersistedCommonTaxonName(CommonTaxonName element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
546 575
        T result = handlePersisted((DescriptionElementBase)element);
576
        //complete
547 577
        result.setLanguage(detache(result.getLanguage()));
548 578
        result.setArea(detache(result.getArea()));
549 579
        return result;
......
551 581

  
552 582
    protected <T extends TextData> T  handlePersistedTextData(TextData element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
553 583
        T result = handlePersisted((DescriptionElementBase)element);
584
        //complete
554 585
        result.setFormat(detache(result.getFormat()));
555 586
        handleMap(result, TextData.class, "multilanguageText", Language.class, LanguageString.class);
556 587
        return result;
......
558 589

  
559 590
    protected <T extends Distribution> T  handlePersistedDistribution(Distribution element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
560 591
        T result = handlePersisted((DescriptionElementBase)element);
592
        //complete
561 593
        result.setArea(detache(result.getArea()));
562 594
        result.setStatus(detache(result.getStatus()));
563 595
        return result;
......
565 597

  
566 598
    protected ExtensionType handlePersistedExtensionType(ExtensionType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
567 599
        ExtensionType result = handlePersisted((DefinedTermBase)term);
600
        //complete
601
        return result;
602
    }
603

  
604
    protected MarkerType handlePersistedMarkerType(MarkerType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
605
        MarkerType result = handlePersisted((DefinedTermBase)term);
606
        //complete
568 607
        return result;
569 608
    }
570 609

  
610
    protected NomenclaturalStatusType handlePersistedNomenclaturalStatusType(NomenclaturalStatusType term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
611
        NomenclaturalStatusType result = handlePersisted((OrderedTermBase)term);
612
        //complete
613
        return result;
614
    }
571 615

  
572 616
    protected DefinedTerm handlePersistedDefinedTerm(DefinedTerm term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
573 617
        DefinedTerm result = handlePersisted((DefinedTermBase)term);
618
        //complete
574 619
        return result;
575 620
    }
576 621

  
577 622
    //placeholder for not implemented methods for subclasses
578 623
    protected DefinedTermBase<?> handlePersistedTerm(DefinedTermBase term) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
579 624
        DefinedTermBase<?> result = handlePersisted(term);
625
        logger.warn("Class not yet handled: " + term.getClass().getSimpleName());
580 626
        return result;
581 627
    }
582 628

  
......
588 634

  
589 635
    protected TermNode<?> handlePersistedTermNode(TermNode node) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
590 636
        TermNode<?> result = (TermNode<?>)handlePersisted((TermRelationBase)node);
637
        //complete
591 638
        setInvisible(result, "parent", detache(result.getParent()));
592 639
        handleCollection(result, TermNode.class, "inapplicableIf", FeatureState.class);
593 640
        handleCollection(result, TermNode.class, "onlyApplicableIf", FeatureState.class);
......
605 652

  
606 653
    protected <T extends TermBase> T  handlePersisted(TermBase termBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
607 654
        T result = handlePersisted((IdentifiableEntity)termBase);
608
        if (result ==null){
609
            return null;
610
        }
655
        //complete
611 656
        handleCollection(result, TermBase.class, "representations", Representation.class);
612 657
        return result;
613 658
    }
614 659

  
615 660
    protected <T extends TermCollection> T  handlePersisted(TermCollection termCollection) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
616 661
        T result = handlePersisted((TermBase)termCollection);
617
        if (result ==null){
618
            return null;
619
        }
662
        //complete
620 663
        handleCollection(result, TermCollection.class, "termRelations", TermRelationBase.class);
621 664
        return result;
622 665
    }
......
632 675
        User result = (User)handlePersistedCdmBase(user);
633 676
        if (result.getUsername().equals("admin")){
634 677
            result = getUserService().listByUsername("admin", MatchMode.EXACT, null, null, null, null, null).iterator().next();
635
            permanentCache.put(user.getUuid(), result);
678
            getState().putPermanent(user.getUuid(), result);
636 679
            cache(result); //necessary?
637 680
            toSave.add(result);
638 681
            toSave.remove(user);
......
648 691

  
649 692
    protected LanguageString handlePersistedLanguageString(LanguageString languageString) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
650 693
        LanguageString result = handlePersisted((LanguageStringBase)languageString);
694
        //complete
651 695
        handleCollection(result, LanguageString.class, "intextReferences", IntextReference.class);
652 696
        return result;
653 697
    }
......
663 707

  
664 708
    protected <T extends TaxonDescription> T  handlePersistedTaxonDescription(TaxonDescription taxDescription) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
665 709
        T result = handlePersisted((DescriptionBase)taxDescription);
710
        //complete
666 711
        setInvisible(taxDescription, "taxon", detache(taxDescription.getTaxon()));
667 712
        handleCollection(taxDescription, TaxonDescription.class, "geoScopes", NamedArea.class);
668 713
        handleCollection(taxDescription, TaxonDescription.class, "scopes", DefinedTerm.class);
......
671 716

  
672 717
    protected <T extends TaxonDescription> T  handlePersistedTaxonNameDescription(TaxonNameDescription nameDescription) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
673 718
        T result = handlePersisted((DescriptionBase)nameDescription);
719
        //complete
674 720
        setInvisible(nameDescription, "taxonName", detache(nameDescription.getTaxonName()));
675 721
        return result;
676 722
    }
......
680 726

  
681 727
    protected <T extends CdmBase> T handlePersistedCdmBase(CdmBase cdmBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
682 728
        T result = (T)getTarget(cdmBase);
683
        if (result == null){
684
            return null;
685
        }
729
        //complete
686 730
        cdmBase.setCreatedBy(detache(cdmBase.getCreatedBy()));
687 731
        return result;
688 732
    }
689 733

  
690 734
    protected <T extends VersionableEntity> T handlePersisted(VersionableEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
691 735
        T result = (T)handlePersistedCdmBase((CdmBase)entity);
692
        if (result ==null){
693
            return null;
694
        }
736
        //complete
695 737
        entity.setUpdatedBy(detache(entity.getUpdatedBy()));
696 738
        return result;
697 739
    }
698 740

  
699 741
    protected <T extends AnnotatableEntity> T handlePersisted(AnnotatableEntity entity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
700 742
        T result = handlePersisted((VersionableEntity)entity);
701
        if (result ==null){
702
            return null;
703
        }
743
        //complete
704 744
        handleCollection(result, AnnotatableEntity.class, "annotations", Annotation.class);
705 745
        handleCollection(result, AnnotatableEntity.class, "markers", Marker.class);
706 746
        return result;
......
708 748

  
709 749
    protected <T extends SourcedEntityBase> T  handlePersisted(SourcedEntityBase sourcedEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
710 750
        T result = handlePersisted((AnnotatableEntity)sourcedEntity);
711
        if (result ==null){
712
            return null;
713
        }
751
        //complete
714 752
        handleCollection(result, SourcedEntityBase.class, "sources", OriginalSourceBase.class);
715 753
        return result;
716 754
    }
717 755

  
718 756
    protected <T extends IdentifiableEntity> T  handlePersisted(IdentifiableEntity identifiableEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
719 757
        T result = handlePersisted((SourcedEntityBase)identifiableEntity);
720
        if (result ==null){
721
            return null;
722
        }
758
        //complete
723 759
        handleCollection(result, IdentifiableEntity.class, "credits", Credit.class);
724 760
        handleCollection(result, IdentifiableEntity.class, "extensions", Extension.class);
725 761
        handleCollection(result, IdentifiableEntity.class, "identifiers", Identifier.class);
......
729 765

  
730 766
    protected <T extends DefinedTermBase> T  handlePersisted(DefinedTermBase definedTermBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
731 767
        T result = handlePersisted((TermBase)definedTermBase);
732

  
768
        //complete
733 769
        handleCollection(result, DefinedTermBase.class, "media", Media.class);
734 770
        handleCollection(result, DefinedTermBase.class, "generalizationOf", DefinedTermBase.class);
735 771
        handleCollection(result, DefinedTermBase.class, "includes", DefinedTermBase.class);
772
        result.setKindOf(detache(result.getKindOf()));
773
        result.setPartOf(detache(result.getPartOf()));
736 774
        setInvisible(result, DefinedTermBase.class, "vocabulary", detache(result.getVocabulary()));
737 775

  
738 776
        return result;
......
740 778

  
741 779
    protected <T extends OriginalSourceBase> T  handlePersisted(OriginalSourceBase source) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
742 780
        T result = handlePersisted((ReferencedEntityBase)source);
781
        //complete
743 782
        handleCollection(result, OriginalSourceBase.class, "links", ExternalLink.class);
744

  
745 783
        return result;
746 784
    }
747 785

  
748 786
    protected <T extends LanguageStringBase> T  handlePersisted(LanguageStringBase lsBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
749 787
        T result = handlePersisted((AnnotatableEntity)lsBase);
788
        //complete
750 789
        result.setLanguage(detache(lsBase.getLanguage()));
751 790
        return result;
752 791
    }
753 792

  
754 793
    protected <T extends TeamOrPersonBase> T  handlePersisted(TeamOrPersonBase teamOrPerson) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
755 794
        T result = handlePersisted((AgentBase)teamOrPerson);
795
        //complete
756 796
        return result;
757 797
    }
758 798

  
759 799
    protected <T extends AgentBase> T  handlePersisted(AgentBase agent) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
760 800
        T result = handlePersisted((IdentifiableMediaEntity)agent);
761 801
        result.setContact(detache(result.getContact()));
802
        //complete
762 803
        return result;
763 804
    }
764 805

  
765 806
    protected <T extends TaxonBase> T  handlePersisted(TaxonBase taxonBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
766 807
        T result = handlePersisted((IdentifiableEntity)taxonBase);
808
        //complete
767 809
        result.setName(detache(taxonBase.getName()));
768 810
        result.setSec(detache(taxonBase.getSec()));
769 811
        return result;
......
771 813

  
772 814
    protected <T extends IdentifiableMediaEntity> T  handlePersisted(IdentifiableMediaEntity mediaEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
773 815
        T result = handlePersisted((IdentifiableEntity)mediaEntity);
816
        //complete
774 817
        handleCollection(result, IdentifiableMediaEntity.class, "media", Media.class);
775 818
        return result;
776 819
    }
777 820

  
778 821
    protected <T extends ReferencedEntityBase> T  handlePersisted(ReferencedEntityBase referencedEntity) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
779 822
        T result = handlePersisted((AnnotatableEntity)referencedEntity);
823
        //complete
780 824
        result.setCitation(detache(result.getCitation()));
781 825
        return result;
782 826
    }
783 827

  
784 828
    protected <T extends DescriptionBase> T  handlePersisted(DescriptionBase descriptionBase) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
785 829
        T result = handlePersisted((IdentifiableEntity)descriptionBase);
830
        //complete
786 831
        handleCollection(result, DescriptionBase.class, "descriptionElements", DescriptionElementBase.class);
787 832
        handleCollection(result, DescriptionBase.class, "descriptiveDataSets", DescriptiveDataSet.class);
788 833
        handleCollection(result, DescriptionBase.class, "descriptionSources", Reference.class);
......
792 837

  
793 838
    protected <T extends DescriptionElementBase> T  handlePersisted(DescriptionElementBase element) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException, SecurityException, IllegalArgumentException, NoSuchMethodException {
794 839
        T result = handlePersisted((AnnotatableEntity)element);
840
        //complete
795 841
        result.setFeature(detache(result.getFeature()));
796 842
        setInvisible(result, DescriptionElementBase.class, "inDescription", detache(result.getInDescription()));
797 843
        handleCollection(result, DescriptionElementBase.class, "sources", DescriptionElementSource.class);
......
929 975

  
930 976
    protected void cache(CdmBase cdmBase) {
931 977
       if (cdmBase instanceof User || cdmBase instanceof DefinedTermBase){
932
           permanentCache.put(cdmBase.getUuid(), cdmBase);
978
           getState().putPermanent(cdmBase.getUuid(), cdmBase);
933 979
       }else{
934 980
           sessionCache.put(cdmBase.getUuid(), cdmBase);
935 981
       }
936
       movedObjects.add(cdmBase.getUuid());
982
       addExistingObject(cdmBase);
983

  
984
    }
937 985

  
986
    private void addExistingObject(CdmBase cdmBase) {
987
        cdmBase = CdmBase.deproxy(cdmBase);
988
        Set<UUID> set = existingObjects.get(cdmBase.getClass());
989
        if (set == null){
990
            set = loadExistingUuids(cdmBase.getClass());
991
//            set = new HashSet<>();
992
//            existingObjects.put(cdmBase.getClass(), set);
993
        }
994
        set.add(cdmBase.getUuid());
938 995
    }
939 996

  
940 997
    protected boolean isInCache(CdmBase cdmBase) {
......
944 1001
    protected <T extends CdmBase> T getCached(T cdmBase) {
945 1002
        T result = (T)sessionCache.get(cdmBase.getUuid());
946 1003
        if (result == null){
947
            result = (T)permanentCache.get(cdmBase.getUuid());
1004
            result = (T)getState().getPermanent(cdmBase.getUuid());
948 1005
        }
949 1006
        return result;
950 1007
    }
......
953 1010
        sessionCache.clear();
954 1011
    }
955 1012

  
1013
    public FauEu2CdmImportState getState() {
1014
        return state;
1015
    }
1016

  
1017
    public void setState(FauEu2CdmImportState state) {
1018
        this.state = state;
1019
    }
1020

  
956 1021
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportConfigurator.java
30 30
    private ITaxonNodeOutStreamPartitioner partitioner;
31 31
    private boolean concurrent = false;
32 32

  
33
    private boolean doTaxa = true;
34
    private boolean doDescriptions = true;
35

  
33 36
    public static FauEu2CdmImportConfigurator NewInstance(ICdmDataSource source, ICdmDataSource destination) {
34 37
        return new FauEu2CdmImportConfigurator(source, destination);
35 38
    }
......
50 53
    protected void makeIoClassList() {
51 54
        ioClassList = new Class[]{
52 55
                FauEu2CdmTaxonNodeImport.class ,
56
                FauEu2CdmDescriptionImport.class ,
53 57
        };
54 58
    }
55 59

  
......
81 85
        this.concurrent = concurrent;
82 86
    }
83 87

  
88
    public boolean isDoDescriptions() {
89
        return doDescriptions;
90
    }
91
    public void setDoDescriptions(boolean doDescriptions) {
92
        this.doDescriptions = doDescriptions;
93
    }
94

  
95
    public boolean isDoTaxa() {
96
        return doTaxa;
97
    }
98
    public void setDoTaxa(boolean doTaxa) {
99
        this.doTaxa = doTaxa;
100
    }
101

  
84 102

  
85 103
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmImportState.java
25 25
        extends ImportStateBase<FauEu2CdmImportConfigurator,CdmImportBase>{
26 26

  
27 27
    private ICdmRepository sourceRepository;
28
    private UUID rootUuid;
28

  
29
    private Map<UUID, CdmBase> permanentCache = new HashMap<>();
30

  
29 31

  
30 32
    protected FauEu2CdmImportState(FauEu2CdmImportConfigurator config) {
31 33
        super(config);
......
39 41
        this.sourceRepository = sourceRepository;
40 42
    }
41 43

  
42
    public UUID getRootId() {
43
        return rootUuid;
44
    }
45
    public void setRootId(UUID rootId) {
46
        this.rootUuid = rootId;
47
    }
48 44

  
45
    public void putPermanent(UUID uuid, CdmBase cdmBase) {
46
        permanentCache.put(uuid, cdmBase);
47
    }
49 48

  
50
    private Map<UUID, Integer> targetMap = new HashMap<>();
51
    /**
52
     * @param uuid
53
     * @param class1
54
     */
55
    public <T extends CdmBase> Integer getTarget(UUID uuid, Class<T> clazz) {
56
        return targetMap.get(uuid);
57

  
49
    public CdmBase getPermanent(UUID uuid) {
50
        return permanentCache.get(uuid);
58 51
    }
59 52

  
53

  
60 54
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTaxonNodeImport.java
16 16
import eu.etaxonomy.cdm.io.common.ITaxonNodeOutStreamPartitioner;
17 17
import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitioner;
18 18
import eu.etaxonomy.cdm.io.common.TaxonNodeOutStreamPartitionerConcurrent;
19
import eu.etaxonomy.cdm.model.taxon.Classification;
20 19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21 20

  
22 21
/**
......
33 32

  
34 33
    @Override
35 34
    protected void doInvoke(FauEu2CdmImportState state) {
35
        setState(state);
36 36
        IProgressMonitor monitor = state.getConfig().getProgressMonitor();
37 37

  
38 38
        FauEu2CdmImportConfigurator config = state.getConfig();
39
        setRootId(state, config); //necessary?
40 39

  
41 40
        ITaxonNodeOutStreamPartitioner partitioner = getPartitioner(state, monitor, config);
42 41
        monitor.subTask("Start partitioning");
......
109 108
        return partitioner;
110 109
    }
111 110

  
112
    private void setRootId(FauEu2CdmImportState state, FauEu2CdmImportConfigurator config) {
113
        if (config.getTaxonNodeFilter().hasClassificationFilter()) {
114
            Classification classification = getClassificationService()
115
                    .load(config.getTaxonNodeFilter().getClassificationFilter().get(0).getUuid());
116
            state.setRootId(classification.getRootNode().getUuid());
117
        } else if (config.getTaxonNodeFilter().hasSubtreeFilter()) {
118
            state.setRootId(config.getTaxonNodeFilter().getSubtreeFilter().get(0).getUuid());
119
        }
120
    }
121 111

  
122 112
    @Override
123 113
    protected boolean doCheck(FauEu2CdmImportState state) {
......
126 116

  
127 117
    @Override
128 118
    protected boolean isIgnore(FauEu2CdmImportState state) {
129
        return false;
119
        return !state.getConfig().isDoTaxa();
130 120
    }
131 121

  
132 122
}
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/fauEu2Cdm/FauEu2CdmTermImport.java
1
/**
2
* Copyright (C) 2019 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.pesi.fauEu2Cdm;
10

  
11
import java.util.HashMap;
12
import java.util.HashSet;
13
import java.util.List;
14
import java.util.Map;
15
import java.util.Set;
16
import java.util.UUID;
17

  
18
import org.apache.log4j.Logger;
19
import org.springframework.stereotype.Component;
20
import org.springframework.transaction.TransactionStatus;
21

  
22
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
23
import eu.etaxonomy.cdm.model.common.CdmBase;
24
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
25

  
26
/**
27
 * @author a.mueller
28
 * @since 17.08.2019
29
 * NOT YET USED
30
 */
31
@Component
32
public class FauEu2CdmTermImport
33
        extends FauEu2CdmImportBase {
34

  
35
    private static final long serialVersionUID = 3995116783196060465L;
36

  
37
    private static final Logger logger = Logger.getLogger(FauEu2CdmTermImport.class);
38

  
39
    //TODO move to state
40
    private Map<UUID, CdmBase> sessionCache = new HashMap<>();
41
    private Map<UUID, CdmBase> permanentCache = new HashMap<>();
42
    private Set<UUID> movedObjects = new HashSet<>();
43

  
44
    private Set<CdmBase> toSave = new HashSet<>();
45

  
46

  
47
    @Override
48
    protected void doInvoke(FauEu2CdmImportState state) {
49
        setState(state);
50
        IProgressMonitor monitor = state.getConfig().getProgressMonitor();
51

  
52
        FauEu2CdmImportConfigurator config = state.getConfig();
53

  
54
        doData(state);
55
    }
56

  
57

  
58
    private void doData(FauEu2CdmImportState state){
59
      //term uuids laden
60
        //gegen existierende Terme abgleichen
61
        //fehlende Terme importieren
62

  
63
        TransactionStatus tx = startTransaction();
64
        List<String> propertyPaths = null;
65
        List<DefinedTermBase> terms = sourceRepo(state).getTermService().list(null, null, null, null, propertyPaths);
66
        int count = 0;
67
        for(DefinedTermBase term: terms){
68
            doSingleTerm(state, term);
69
            count++;
70
        }
71
        commitTransaction(tx);
72
    }
73

  
74
    private DefinedTermBase doSingleTerm(FauEu2CdmImportState state, DefinedTermBase term) {
75
        DefinedTermBase result = null;
76
        if (logger.isInfoEnabled()){logger.info(term.getTitleCache());}
77
        try {
78
            result = detache(term);
79
        } catch (Exception e) {
80
            logger.warn("Exception during detache node " + term.getUuid());
81
            e.printStackTrace();
82
        }
83
        try {
84
            if (result != null){
85
                getTermService().saveOrUpdate(term);
86
                getCommonService().saveOrUpdate(toSave);
87
                toSave.clear();
88
            }
89
        } catch (Exception e) {
90
            logger.warn("Exception during save node " + term.getUuid());
91
             e.printStackTrace();
92
        }
93

  
94
        return result;
95
    }
96

  
97

  
98

  
99

  
100

  
101
    @Override
102
    protected boolean doCheck(FauEu2CdmImportState state) {
103
        return false;
104
    }
105

  
106
    @Override
107
    protected boolean isIgnore(FauEu2CdmImportState state) {
108
        return false;
109
    }
110

  
111
}

Also available in: Unified diff