1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.view.specimenView;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
16
|
import org.eclipse.jface.viewers.Viewer;
|
17
|
|
18
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
19
|
import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
|
20
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
21
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
22
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
23
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
24
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
25
|
|
26
|
/**
|
27
|
* @author pplitzner
|
28
|
* @date Sep 7, 2015
|
29
|
*
|
30
|
*/
|
31
|
public class SpecimenViewContentProvider implements IStructuredContentProvider{
|
32
|
|
33
|
private final Object[] EMPTY_ARRAY = {};
|
34
|
|
35
|
@Override
|
36
|
public void dispose() {
|
37
|
// TODO Auto-generated method stub
|
38
|
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
43
|
// TODO Auto-generated method stub
|
44
|
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
public Object[] getElements(Object inputElement) {
|
49
|
List<FieldUnitDTO> fieldUnitDTOs = new ArrayList<FieldUnitDTO>();
|
50
|
if(inputElement instanceof Taxon){
|
51
|
Taxon taxon = HibernateProxyHelper.deproxy(inputElement, Taxon.class);
|
52
|
List<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).pageFieldUnitsByAssociatedTaxon(null, taxon, null, null, null, null, null).getRecords();
|
53
|
for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) {
|
54
|
if(specimenOrObservationBase.isInstanceOf(FieldUnit.class)){
|
55
|
fieldUnitDTOs.add(CdmStore.getService(IOccurrenceService.class).assembleFieldUnitDTO(HibernateProxyHelper.deproxy(specimenOrObservationBase, FieldUnit.class), taxon.getUuid()));
|
56
|
}
|
57
|
}
|
58
|
return fieldUnitDTOs.toArray();
|
59
|
}
|
60
|
return EMPTY_ARRAY;
|
61
|
}
|
62
|
|
63
|
}
|