export all specimenOrObservationBase not only derivedUnits
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / cdmLight / CdmLightExportState.java
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.cdmLight;
10
11 import java.io.File;
12 import java.util.HashMap;
13 import java.util.Map;
14
15 import eu.etaxonomy.cdm.io.common.ExportResult;
16 import eu.etaxonomy.cdm.io.common.ExportResult.ExportResultState;
17 import eu.etaxonomy.cdm.io.common.ExportStateBase;
18 import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
19 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
20 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
21 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
22 import eu.etaxonomy.cdm.model.reference.Reference;
23 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24
25 /**
26 * @author k.luther
27 * @date 15.03.2017
28 *
29 */
30 public class CdmLightExportState
31 extends ExportStateBase<CdmLightExportConfigurator, IExportTransformer, File>{
32
33 private ExportResult result;
34
35 private CdmLightExportResultProcessor processor = new CdmLightExportResultProcessor(this);
36
37 private TaxonBase<?> actualTaxonBase;
38
39 private Map<Integer, HomotypicalGroup> homotypicalGroupStore = new HashMap<>();
40 private Map<Integer, TeamOrPersonBase<?>> authorStore = new HashMap<>();
41 private Map<Integer, SpecimenOrObservationBase> specimenStore = new HashMap<>();
42 private Map<Integer, Reference> referenceStore = new HashMap<>();
43
44 /**
45 * @param config
46 */
47 protected CdmLightExportState(CdmLightExportConfigurator config) {
48 super(config);
49 result = ExportResult.NewInstance(config.getResultType());
50 }
51
52 /**
53 * @return the result
54 */
55 @Override
56 public ExportResult getResult() {
57 return result;
58 }
59
60 /**
61 * @param result the result to set
62 */
63 @Override
64 public void setResult(ExportResult result) {
65 this.result = result;
66 }
67
68 /**
69 *
70 */
71 public void setEmptyData() {
72 this.result.setState(ExportResultState.SUCCESS_BUT_NO_DATA);
73 }
74
75 /**
76 * @return the processor
77 */
78 public CdmLightExportResultProcessor getProcessor() {
79 return processor;
80 }
81
82 public void setActualTaxonBase(TaxonBase<?> actualTaxonBase){
83 this.actualTaxonBase = actualTaxonBase;
84 }
85
86 public TaxonBase<?> getActualTaxonBase() {
87 return actualTaxonBase;
88 }
89
90 /**
91 * @return the homotypicalGroupStore
92 */
93 public Map<Integer, HomotypicalGroup> getHomotypicalGroupStore() {
94 return homotypicalGroupStore;
95 }
96
97 /**
98 * @param homotypicalGroupStore the homotypicalGroupStore to set
99 */
100 public void addHomotypicalGroupToStore(HomotypicalGroup homotypicalGroup) {
101 this.homotypicalGroupStore.put(homotypicalGroup.getId(), homotypicalGroup);
102 }
103
104 public HomotypicalGroup getHomotypicalGroupFromStore(Integer id){
105 return homotypicalGroupStore.get(id);
106 }
107
108 /**
109 * @return the homotypicalGroupStore
110 */
111 public Map<Integer, TeamOrPersonBase<?>> getAuthorStore() {
112 return authorStore;
113 }
114
115 /**
116 * @param homotypicalGroupStore the homotypicalGroupStore to set
117 */
118 public void addAuthorToStore(TeamOrPersonBase<?> author) {
119 this.authorStore.put(author.getId(), author);
120 }
121
122 public TeamOrPersonBase<?> getAuthorFromStore(Integer id){
123 return authorStore.get(id);
124 }
125
126
127 public void addSpecimenToStore(SpecimenOrObservationBase specimen) {
128 this.specimenStore.put(specimen.getId(), specimen);
129
130 }
131
132
133 public SpecimenOrObservationBase getSpecimenFromStore(Integer id){
134 return specimenStore.get(id);
135 }
136
137 public Reference getReferenceFromStore(Integer id){
138 return referenceStore.get(id);
139 }
140 public void addReferenceToStore(Reference ref) {
141 this.referenceStore.put(ref.getId(), ref);
142
143 }
144
145
146 }