3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.dna
;
13 import java
.util
.Collection
;
14 import java
.util
.LinkedList
;
16 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
17 import eu
.etaxonomy
.cdm
.model
.common
.Identifier
;
18 import eu
.etaxonomy
.cdm
.model
.molecular
.DnaSample
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
21 import eu
.etaxonomy
.taxeditor
.view
.derivateSearch
.DerivateLabelProvider
;
25 * @created May 11, 2011
28 public class SampleDesignationHistoryDetailSection
extends AbstractSampleDesignationDetailSection
{
33 * @param parentElement
36 public SampleDesignationHistoryDetailSection(CdmFormFactory formFactory
,
37 ConversationHolder conversation
, ICdmFormElement parentElement
,
39 super(formFactory
, conversation
, parentElement
, "Sample Designation History", style
);
43 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
46 public Collection
<Identifier
<DnaSample
>> getCollection(DnaSample entity
) {
47 LinkedList
<Identifier
<DnaSample
>> sampleDesignations
= new LinkedList
<Identifier
<DnaSample
>>();
48 for (Identifier
<DnaSample
> identifier
: entity
.getIdentifiers()) {
49 if(identifier
.getType()!=null && identifier
.getType().equals(DerivateLabelProvider
.getSampleDesignationTerm())){
50 sampleDesignations
.add(identifier
);
53 if(sampleDesignations
.size()>0){
54 sampleDesignations
.removeFirst();//first is the current sample designation
56 return sampleDesignations
;
60 public void refresh() {
61 internalUpdateSection(false);
66 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
70 protected String
getTooltipString() {
71 return "Add a sample designation to the history";
75 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
79 public void addElement(Identifier
<DnaSample
> sampleDesignation
) {
80 //The current sample designation is always the first one found.
81 //The following are recent sample designations with the most recent being
82 //the second one found and so on
83 Identifier
<DnaSample
> currentSampleDesignation
= DerivateLabelProvider
.getCurrentSampleDesignation(getEntity());
84 int indexOfCurrentSampleDesignation
= getEntity().getIdentifiers().indexOf(currentSampleDesignation
);
85 getEntity().addIdentifier(indexOfCurrentSampleDesignation
+1, sampleDesignation
);