2 * Copyright (C) 2017 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.
9 package eu
.etaxonomy
.cdm
.io
.wfo
.out
;
11 import java
.util
.ArrayList
;
12 import java
.util
.HashMap
;
13 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import eu
.etaxonomy
.cdm
.io
.common
.ExportResult
;
18 import eu
.etaxonomy
.cdm
.io
.common
.ExportResult
.ExportResultState
;
19 import eu
.etaxonomy
.cdm
.io
.out
.TaxonTreeExportStateBase
;
20 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
21 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
22 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
25 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
28 * State for WFO Backbone export.
30 * @see https://dev.e-taxonomy.eu/redmine/issues/10446
35 public class WfoBackboneExportState
36 extends TaxonTreeExportStateBase
<WfoBackboneExportConfigurator
,WfoBackboneExportState
>{
38 private ExportResult result
;
40 private WfoBackboneExportResultProcessor processor
= new WfoBackboneExportResultProcessor(this);
42 private TaxonBase
<?
> currentTaxonBase
;
44 private ArrayList
<UUID
> homotypicalGroupStore
= new ArrayList
<>();
46 //private Map<Integer, SpecimenOrObservationBase> specimenStore = new HashMap<>();
47 private List
<UUID
> referenceStore
= new ArrayList
<>();
48 private Map
<Integer
, UUID
> nameStore
= new HashMap
<>();
49 private Map
<UUID
,List
<TaxonNodeDto
>> nodeChildrenMap
= new HashMap
<>();
50 private UUID classificationUUID
= null;
51 private String familyStr
= null;
52 private Map
<UUID
,String
> taxonNodeToWfoMap
= new HashMap
<>();
53 private Map
<UUID
,String
> taxonToWfoMap
= new HashMap
<>();
54 private Map
<UUID
,String
> nameToWfoMap
= new HashMap
<>();
56 private UUID rootUuid
;
59 protected WfoBackboneExportState(WfoBackboneExportConfigurator config
) {
61 result
= ExportResult
.NewInstance(config
.getResultType());
62 familyStr
= config
.getFamilyStr();
67 public ExportResult
getResult() {
71 public void setResult(ExportResult result
) {
76 protected void setEmptyData() {
77 this.result
.setState(ExportResultState
.SUCCESS_BUT_NO_DATA
);
81 protected WfoBackboneExportResultProcessor
getProcessor() {
86 protected void setCurrentTaxonBase(TaxonBase
<?
> currentTaxonBase
){
87 this.currentTaxonBase
= currentTaxonBase
;
89 protected TaxonBase
<?
> getCurrentTaxonBase() {
90 return currentTaxonBase
;
93 //homotypical group store
94 protected ArrayList
<UUID
> getHomotypicalGroupStore() {
95 return homotypicalGroupStore
;
97 protected void addHomotypicalGroupToStore(HomotypicalGroup homotypicalGroup
) {
98 this.homotypicalGroupStore
.add(homotypicalGroup
.getUuid());
100 protected boolean containsHomotypicalGroupFromStore(UUID id
){
101 return homotypicalGroupStore
.contains(id
);
103 protected void setHomotypicalGroupStore(ArrayList
<UUID
> homotypicalGroupStore
) {
104 this.homotypicalGroupStore
= homotypicalGroupStore
;
108 protected void addReferenceToStore(Reference ref
) {
109 this.referenceStore
.add(ref
.getUuid());
111 protected void setReferenceStore(List
<UUID
> referenceStore
) {
112 this.referenceStore
= referenceStore
;
114 protected List
<UUID
> getReferenceStore() {
115 return referenceStore
;
119 protected Map
<UUID
, List
<TaxonNodeDto
>> getNodeChildrenMap() {
120 return nodeChildrenMap
;
122 protected void setNodeChildrenMap(Map
<UUID
,List
<TaxonNodeDto
>> nodeChildrenMap
) {
123 this.nodeChildrenMap
= nodeChildrenMap
;
127 protected UUID
getClassificationUUID(TaxonNode root
) {
128 if (classificationUUID
== null){
129 classificationUUID
= root
.getClassification().getUuid();
131 return classificationUUID
;
133 protected void setClassificationUUID(UUID classificationUUID
) {
134 this.classificationUUID
= classificationUUID
;
138 protected UUID
getRootId() {
141 protected void setRootId(UUID rootId
) {
142 this.rootUuid
= rootId
;
146 protected Map
<Integer
, UUID
> getNameStore() {
149 protected void setNameStore(Map
<Integer
, UUID
> nameStore
) {
150 this.nameStore
= nameStore
;
154 public String
getFamilyStr() {
157 public void setFamilyStr(String familyStr
) {
158 this.familyStr
= familyStr
;
162 public void putTaxonNodeWfoId(TaxonNode node
, String wfoId
) {
163 taxonNodeToWfoMap
.put(node
.getUuid(), wfoId
);
165 public String
getTaxonNodeWfoId(TaxonNode node
) {
166 return taxonNodeToWfoMap
.get(node
.getUuid());
169 public void putTaxonWfoId(TaxonBase
<?
> taxon
, String wfoId
) {
170 taxonToWfoMap
.put(taxon
.getUuid(), wfoId
);
172 public String
getTaxonWfoId(TaxonBase
<?
> taxon
) {
173 return taxonToWfoMap
.get(taxon
.getUuid());
176 public void putNameWfoId(TaxonName name
, String wfoId
) {
177 nameToWfoMap
.put(name
.getUuid(), wfoId
);
179 public String
getNameWfoId(TaxonName name
) {
180 return nameToWfoMap
.get(name
.getUuid());