2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.common
;
12 import org
.apache
.log4j
.Logger
;
14 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonomicTree
;
23 public abstract class CdmImportBase
<CONFIG
extends IImportConfigurator
, STATE
extends ImportStateBase
> extends CdmIoBase
<STATE
> implements ICdmImport
<CONFIG
, STATE
>{
24 @SuppressWarnings("unused")
25 private static Logger logger
= Logger
.getLogger(CdmImportBase
.class);
27 protected TaxonomicTree
makeTree(STATE state
, ReferenceBase ref
){
28 String treeName
= "TaxonTree (Import)";
29 if (ref
!= null && CdmUtils
.isNotEmpty(ref
.getTitleCache())){
30 treeName
= ref
.getTitleCache();
32 TaxonomicTree tree
= TaxonomicTree
.NewInstance(treeName
);
33 tree
.setReference(ref
);
36 // use defined uuid for first tree
37 CONFIG config
= (CONFIG
)state
.getConfig();
38 if (state
.countTrees() < 1 ){
39 tree
.setUuid(config
.getTreeUuid());
41 getTaxonService().saveTaxonomicTree(tree
);
42 state
.putTree(ref
, tree
);
48 * Alternative memory saving method variant of
49 * {@link #makeTree(STATE state, ReferenceBase ref)} which stores only the
50 * UUID instead of the full tree in the <code>ImportStateBase</code> by
51 * using <code>state.putTreeUuid(ref, tree);</code>
57 protected TaxonomicTree
makeTreeMemSave(STATE state
, ReferenceBase ref
){
58 String treeName
= "TaxonTree (Import)";
59 if (ref
!= null && CdmUtils
.isNotEmpty(ref
.getTitleCache())){
60 treeName
= ref
.getTitleCache();
62 TaxonomicTree tree
= TaxonomicTree
.NewInstance(treeName
);
63 tree
.setReference(ref
);
66 // use defined uuid for first tree
67 CONFIG config
= (CONFIG
)state
.getConfig();
68 if (state
.countTrees() < 1 ){
69 tree
.setUuid(config
.getTreeUuid());
71 getTaxonService().saveTaxonomicTree(tree
);
72 state
.putTreeUuid(ref
, tree
);