Revision 7659b935
Added by Andreas Kohlbecker almost 8 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/TransmissionEngineDistribution.java | ||
---|---|---|
58 | 58 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
59 | 59 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
60 | 60 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
61 |
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao; |
|
62 | 61 |
import eu.etaxonomy.cdm.persistence.dto.ClassificationLookupDTO; |
63 | 62 |
|
64 | 63 |
/** |
65 |
* The TransmissionEngineDistribution is meant to be used from within a service class. |
|
66 | 64 |
* |
67 | 65 |
* <h2>GENERAL NOTES </h2> |
68 | 66 |
* <em>TODO: These notes are directly taken from original Transmission Engine Occurrence |
... | ... | |
92 | 90 |
* @date Feb 22, 2013 |
93 | 91 |
*/ |
94 | 92 |
@Service |
95 |
|
|
96 | 93 |
public class TransmissionEngineDistribution { //TODO extends IoBase? |
97 | 94 |
|
98 | 95 |
public static final String EXTENSION_VALUE_PREFIX = "transmissionEngineDistribution.priority:"; |
... | ... | |
102 | 99 |
/** |
103 | 100 |
* only used for performance testing |
104 | 101 |
*/ |
105 |
final boolean ONLY_FISRT_BATCH = false;
|
|
102 |
final boolean ONLY_FISRT_BATCH = true;
|
|
106 | 103 |
|
107 | 104 |
|
108 | 105 |
protected static final List<String> TAXONDESCRIPTION_INIT_STRATEGY = Arrays.asList(new String [] { |
109 | 106 |
"description.markers.markerType", |
110 | 107 |
"description.elements.markers.markerType", |
111 | 108 |
"description.elements.area", |
109 |
"description.elements.status", |
|
112 | 110 |
"description.elements.sources.citation.authorship", |
113 |
"description.elements.sources.nameUsedInSource", |
|
114 |
"description.elements.multilanguageText", |
|
115 |
"name.status.type", |
|
111 |
// "description.elements.sources.nameUsedInSource",
|
|
112 |
// "description.elements.multilanguageText",
|
|
113 |
// "name.status.type",
|
|
116 | 114 |
}); |
117 | 115 |
|
118 | 116 |
|
... | ... | |
134 | 132 |
@Autowired |
135 | 133 |
private IClassificationService classificationService; |
136 | 134 |
|
137 |
@Autowired |
|
138 |
private IClassificationDao classificationDao; |
|
139 |
|
|
140 | 135 |
@Autowired |
141 | 136 |
private INameService mameService; |
142 | 137 |
|
... | ... | |
358 | 353 |
|
359 | 354 |
for(Classification _classification : classifications) { |
360 | 355 |
|
361 |
ClassificationLookupDTO classificationLookupDao = classificationDao.classificationLookup(_classification); |
|
356 |
ClassificationLookupDTO classificationLookupDao = classificationService.classificationLookup(_classification); |
|
357 |
|
|
358 |
double end1 = System.currentTimeMillis(); |
|
359 |
logger.info("Time elapsed for classificationLookup() : " + (end1 - start) / (1000) + "s"); |
|
360 |
double start2 = System.currentTimeMillis(); |
|
362 | 361 |
|
363 | 362 |
monitor.subTask("Accumulating distributions to super areas for " + _classification.getTitleCache()); |
364 | 363 |
if (mode.equals(AggregationMode.byAreas) || mode.equals(AggregationMode.byAreasAndRanks)) { |
365 |
accumulateByArea(superAreas, classificationLookupDao, new SubProgressMonitor(monitor, 200), |
|
366 |
mode.equals(AggregationMode.byAreas) || mode.equals(AggregationMode.byAreasAndRanks)); |
|
364 |
accumulateByArea(superAreas, classificationLookupDao, new SubProgressMonitor(monitor, 200), true); |
|
367 | 365 |
} |
368 | 366 |
monitor.subTask("Accumulating distributions to higher ranks for " + _classification.getTitleCache()); |
369 | 367 |
|
370 |
double end1 = System.currentTimeMillis(); |
|
371 |
|
|
372 |
logger.info("Time elapsed for accumulateByArea() : " + (end1 - start) / (1000) + "s"); |
|
368 |
double end2 = System.currentTimeMillis(); |
|
369 |
logger.info("Time elapsed for accumulateByArea() : " + (end2 - start2) / (1000) + "s"); |
|
373 | 370 |
|
374 |
double start2 = System.currentTimeMillis();
|
|
371 |
double start3 = System.currentTimeMillis();
|
|
375 | 372 |
if (mode.equals(AggregationMode.byRanks) || mode.equals(AggregationMode.byAreasAndRanks)) { |
376 |
accumulateByRank(lowerRank, upperRank, classification, new SubProgressMonitor(monitor, 200), |
|
377 |
mode.equals(AggregationMode.byRanks)); |
|
373 |
accumulateByRank(lowerRank, upperRank, classification, new SubProgressMonitor(monitor, 200), mode.equals(AggregationMode.byRanks)); |
|
378 | 374 |
} |
379 | 375 |
|
380 |
double end2 = System.currentTimeMillis();
|
|
381 |
logger.info("Time elapsed for accumulateByRank() : " + (end2 - start2) / (1000) + "s");
|
|
382 |
logger.info("Time elapsed for accumulate(): " + (end2 - start) / (1000) + "s");
|
|
376 |
double end3 = System.currentTimeMillis();
|
|
377 |
logger.info("Time elapsed for accumulateByRank() : " + (end3 - start3) / (1000) + "s");
|
|
378 |
logger.info("Time elapsed for accumulate(): " + (end3 - start) / (1000) + "s");
|
|
383 | 379 |
|
384 | 380 |
if(ONLY_FISRT_BATCH) { |
381 |
monitor.done(); |
|
385 | 382 |
break; |
386 | 383 |
} |
387 | 384 |
} |
... | ... | |
427 | 424 |
subMonitor.beginTask("Accumulating by area ", classificationLookupDao.getTaxonIds().size()); |
428 | 425 |
Iterator<Integer> taxonIdIterator = classificationLookupDao.getTaxonIds().iterator(); |
429 | 426 |
|
430 |
int pageIndex = 0; |
|
431 | 427 |
while (taxonIdIterator.hasNext()) { |
432 |
while (!isLastPage) { |
|
433 | 428 |
|
434 | 429 |
if(txStatus == null) { |
435 | 430 |
// transaction has been comitted at the end of this batch, start a new one |
... | ... | |
601 | 596 |
if(taxonSubMonitor == null) { |
602 | 597 |
taxonSubMonitor = new SubProgressMonitor(subMonitor, ticksPerRank); |
603 | 598 |
taxonSubMonitor.beginTask("Accumulating by rank " + rank.getLabel(), taxonPager.getCount().intValue()); |
604 |
|
|
605 | 599 |
} |
606 | 600 |
|
607 | 601 |
if(taxonPager != null){ |
... | ... | |
680 | 674 |
} |
681 | 675 |
} // next batch |
682 | 676 |
|
683 |
taxonSubMonitor.done(); |
|
677 |
if(taxonSubMonitor != null) { // TODO taxonSubpager, this check should not be needed |
|
678 |
taxonSubMonitor.done(); |
|
679 |
} |
|
684 | 680 |
subMonitor.worked(1); |
685 | 681 |
|
686 | 682 |
if(ONLY_FISRT_BATCH) { |
Also available in: Unified diff
performance logging