22 |
22 |
import org.springframework.stereotype.Component;
|
23 |
23 |
import org.springframework.transaction.TransactionStatus;
|
24 |
24 |
|
25 |
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
26 |
25 |
import eu.etaxonomy.cdm.io.common.Source;
|
27 |
26 |
import eu.etaxonomy.cdm.model.common.CdmBase;
|
28 |
|
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
|
29 |
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
30 |
27 |
import eu.etaxonomy.cdm.model.description.Distribution;
|
31 |
28 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
32 |
29 |
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
... | ... | |
74 |
71 |
logger.warn("Start distribution doInvoke");
|
75 |
72 |
ProfilerController.memorySnapshot();
|
76 |
73 |
*/
|
77 |
|
|
|
74 |
|
78 |
75 |
if (!state.getConfig().isDoOccurrence()){
|
79 |
76 |
return;
|
80 |
77 |
}
|
81 |
|
|
|
78 |
|
82 |
79 |
int limit = state.getConfig().getLimitSave();
|
83 |
80 |
UUID noDataUuid;
|
84 |
81 |
/* Taxon store for retrieving taxa from and saving taxa to CDM */
|
... | ... | |
92 |
89 |
TransactionStatus txStatus = null;
|
93 |
90 |
|
94 |
91 |
//txStatus = startTransaction();
|
95 |
|
PresenceAbsenceTerm noDataStatusTerm = PresenceAbsenceTerm.NewPresenceInstance("no data", "no data", "nod");
|
|
92 |
/*PresenceAbsenceTerm noDataStatusTerm = PresenceAbsenceTerm.NewPresenceInstance("no data", "no data", "nod");
|
96 |
93 |
noDataUuid = noDataStatusTerm.getUuid();
|
97 |
94 |
TermVocabulary<PresenceAbsenceTerm> voc = getVocabularyService().find(30);
|
98 |
95 |
HibernateProxyHelper.deproxy(voc, OrderedTermVocabulary.class);
|
99 |
96 |
//voc.addTerm(noDataStatusTerm);
|
100 |
97 |
// getVocabularyService().saveOrUpdate(voc);
|
101 |
|
getTermService().save(noDataStatusTerm);
|
|
98 |
getTermService().save(noDataStatusTerm);*/
|
102 |
99 |
//commitTransaction(txStatus);
|
103 |
100 |
|
104 |
|
FaunaEuropaeaTransformer.setUUIDs(noDataUuid);
|
|
101 |
// FaunaEuropaeaTransformer.setUUIDs(noDataUuid);
|
105 |
102 |
|
106 |
103 |
FaunaEuropaeaImportConfigurator fauEuConfig = state.getConfig();
|
107 |
104 |
Source source = fauEuConfig.getSource();
|
... | ... | |
197 |
194 |
if (((i % limit) == 0 && i != 1 ) || i == count ) {
|
198 |
195 |
|
199 |
196 |
try {
|
200 |
|
commitTaxaAndDistribution(state, noDataUuid, taxonUuids, fauEuTaxonMap, txStatus);
|
|
197 |
commitTaxaAndDistribution(state, taxonUuids, fauEuTaxonMap, txStatus);
|
201 |
198 |
taxonUuids = null;
|
202 |
199 |
taxonList = null;
|
203 |
200 |
fauEuTaxonMap = null;
|
... | ... | |
214 |
211 |
}
|
215 |
212 |
if (taxonUuids != null){
|
216 |
213 |
try {
|
217 |
|
commitTaxaAndDistribution(state, noDataUuid, taxonUuids, fauEuTaxonMap, txStatus);
|
|
214 |
commitTaxaAndDistribution(state, taxonUuids, fauEuTaxonMap, txStatus);
|
218 |
215 |
taxonUuids = null;
|
219 |
216 |
taxonList = null;
|
220 |
217 |
fauEuTaxonMap = null;
|
... | ... | |
232 |
229 |
|
233 |
230 |
if(logger.isInfoEnabled()) { logger.info("End making distributions..."); }
|
234 |
231 |
|
235 |
|
|
|
232 |
|
236 |
233 |
return;
|
237 |
234 |
}
|
238 |
235 |
|
239 |
236 |
private void commitTaxaAndDistribution(
|
240 |
|
FaunaEuropaeaImportState state, UUID noDataUuid,
|
|
237 |
FaunaEuropaeaImportState state,
|
241 |
238 |
Set<UUID> taxonUuids,
|
242 |
239 |
Map<UUID, FaunaEuropaeaDistributionTaxon> fauEuTaxonMap,
|
243 |
240 |
TransactionStatus txStatus) throws Exception {
|
244 |
|
List<TaxonBase> taxonList = prepareTaxaAndDistribution(getTaxonService().find(taxonUuids), fauEuTaxonMap, noDataUuid, state);
|
|
241 |
List<TaxonBase> taxonList = prepareTaxaAndDistribution(getTaxonService().find(taxonUuids), fauEuTaxonMap, state);
|
245 |
242 |
|
246 |
243 |
getTaxonService().save(taxonList);
|
247 |
244 |
taxonList = null;
|
... | ... | |
251 |
248 |
|
252 |
249 |
}
|
253 |
250 |
|
254 |
|
private List<TaxonBase> prepareTaxaAndDistribution(List<TaxonBase> taxonList, Map<UUID, FaunaEuropaeaDistributionTaxon> fauEuTaxonMap, UUID noData, FaunaEuropaeaImportState state) throws Exception{
|
|
251 |
private List<TaxonBase> prepareTaxaAndDistribution(List<TaxonBase> taxonList, Map<UUID, FaunaEuropaeaDistributionTaxon> fauEuTaxonMap, FaunaEuropaeaImportState state) throws Exception{
|
255 |
252 |
|
256 |
253 |
Distribution newDistribution = null;
|
257 |
254 |
NamedArea namedArea;
|
... | ... | |
289 |
286 |
newDistribution = null;
|
290 |
287 |
presenceAbsenceStatus = null;
|
291 |
288 |
|
292 |
|
if (fauEuHelperDistribution.getOccurrenceStatusId() != 0 && fauEuHelperDistribution.getOccurrenceStatusId() != 2 && fauEuHelperDistribution.getOccurrenceStatusId() != 1){
|
293 |
|
presenceAbsenceStatus = (PresenceAbsenceTerm)getTermService().find(noData);
|
294 |
|
}else{
|
295 |
|
presenceAbsenceStatus = FaunaEuropaeaTransformer.occStatus2PresenceAbsence(fauEuHelperDistribution.getOccurrenceStatusId());
|
296 |
|
}
|
|
289 |
presenceAbsenceStatus = FaunaEuropaeaTransformer.occStatus2PresenceAbsence(fauEuHelperDistribution.getOccurrenceStatusId());
|
|
290 |
|
297 |
291 |
|
298 |
292 |
namedArea = FaunaEuropaeaTransformer.areaId2TdwgArea(fauEuHelperDistribution);
|
299 |
293 |
|
delete no data term creation and referencing code