import java.util.Collection;
import java.util.Collections;
-import java.util.LinkedList;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.widgets.Control;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.common.Identifier;
import eu.etaxonomy.cdm.model.molecular.DnaSample;
-import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
super(formFactory, conversation, parentElement, "Current Sample Designation", style);
}
- @Override
- protected Control createToolbar() {
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
-
- Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- Identifier<DnaSample> element = createNewElement();
-
- getEntity().addIdentifier(element);
-
- if(element != null){
- if(! getSection().isExpanded()) {
- getSection().setExpanded(true);
- }
- internalUpdateSection(true);
- }
- }
- };
- addAction.setImageDescriptor(new ImageDescriptor() {
-
- @Override
- public ImageData getImageData() {
- return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
- }
- });
- addAction.setToolTipText(getTooltipString());
-
- toolBarManager.add(addAction);
-
- return toolBarManager.createControl(this);
- }
-
@Override
public void refresh() {
internalUpdateSection(false);
*/
@Override
public Collection<Identifier<DnaSample>> getCollection(DnaSample entity) {
- LinkedList<Identifier<DnaSample>> sampleDesignations = new LinkedList<Identifier<DnaSample>>();
- for (Identifier<DnaSample> identifier : entity.getIdentifiers()) {
- if(identifier.getType()!=null && identifier.getType().equals(DerivateLabelProvider.getSampleDesignationTerm())){
- sampleDesignations.add(identifier);
- }
- }
- Collections.reverse(sampleDesignations);
- if(sampleDesignations.size()>0){
- //last sample designation is the current
- return Collections.singleton(sampleDesignations.getFirst());
- }
- else{
- return Collections.emptyList();
- }
+ Identifier<DnaSample> currentSampleDesignation = DerivateLabelProvider.getCurrentSampleDesignation(entity);
+ if(currentSampleDesignation!=null){
+ return Collections.singleton(currentSampleDesignation);
+ }
+ else{
+ return Collections.emptyList();
+ }
}
/* (non-Javadoc)
return "Create new current sample designation";
}
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void addElement(Identifier<DnaSample> sampleDesignation) {
+ //The current sample designation is always the first one found.
+ //The following are recent sample designations with the most recent being
+ //the second one found and so on
+ getEntity().addIdentifier(0, sampleDesignation);
+ }
+
}
package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
import eu.etaxonomy.cdm.model.common.DefinedTerm;
+import eu.etaxonomy.cdm.model.molecular.DnaQuality;
import eu.etaxonomy.cdm.model.molecular.DnaSample;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
*/
public class DnaQualityDetailElement extends AbstractCdmDetailElement<DnaSample> {
+// private final TermType qualityTermVocabulary = CdmStore.getService(IVocabularyService.class).find(VocabularyEnum.DnaQualityTerm.getUuid());
+
private NumberWithLabelElement numberRatioOfAbsorbance260_280;
- private NumberWithLabelElement numberRatioOfAbsorbance260_230;
+ private NumberWithLabelElement numberRatioOfAbsorbance230_260;
private NumberWithLabelElement numberConcentration;
private TermComboElement<DefinedTerm> comboQualityTerm;
private DateElement dateQualityCheck;
*/
@Override
protected void createControls(ICdmFormElement formElement, DnaSample entity, int style) {
+ DnaQuality dnaQuality = entity.getDnaQuality();
+ if(dnaQuality==null){
+ dnaQuality = DnaQuality.NewInstance();
+ }
+ Double ratioOfAbsorbance230_260 = dnaQuality.getRatioOfAbsorbance230_260();
+ Double ratioOfAbsorbance260_280 = dnaQuality.getRatioOfAbsorbance260_280();
+ Double concentration = dnaQuality.getConcentration();
+ DefinedTerm qualityTerm = dnaQuality.getQualityTerm();
+
+ numberRatioOfAbsorbance230_260 = formFactory.createNumberTextWithLabelElement(formElement, "Ratio of absorbance 230-260", ratioOfAbsorbance230_260, style);
+ numberRatioOfAbsorbance260_280 = formFactory.createNumberTextWithLabelElement(formElement, "Ratio of absorbance 260-280", ratioOfAbsorbance260_280, style);
+ numberConcentration = formFactory.createNumberTextWithLabelElement(formElement, "Concentration", concentration, style);
+// comboQualityTerm = formFactory.createDefinedTermComboElement(qualityTermVocabulary, formElement, "Quality Term", qualityTerm, style);
+
//TODO DNA purification details
- //TODO Ratio of absorbance 260-280
- //TODO Ratio of absorbance 260-230
//TODO concentration unit
- //TODO concentration
//TODO DNA quality
//TODO Quality check date
- //TODO Descritpion
+ //TODO Description
}
/*
*/
@Override
public void handleEvent(Object eventSource) {
+ if(eventSource==numberRatioOfAbsorbance230_260){
+ getEntity().getDnaQuality().setRatioOfAbsorbance230_260(numberRatioOfAbsorbance230_260.getDouble());
+ }
+ else if(eventSource==numberRatioOfAbsorbance260_280){
+ getEntity().getDnaQuality().setRatioOfAbsorbance260_280(numberRatioOfAbsorbance260_280.getDouble());
+ }
+ else if(eventSource==numberConcentration){
+ getEntity().getDnaQuality().setConcentration(numberConcentration.getDouble());
+ }
}
}
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.DefinedTerm;
+import eu.etaxonomy.cdm.model.common.Identifier;
import eu.etaxonomy.cdm.model.molecular.DnaSample;
import eu.etaxonomy.cdm.model.molecular.Sequence;
import eu.etaxonomy.cdm.model.molecular.SingleRead;
*/
public class DerivateLabelProvider extends ColumnLabelProvider {
+ private static final String NO_SAMPLE_DESIGNATION = "[no sample designation]";
+
private Set<SingleRead> multiLinkSingleReads;
private ConversationHolder conversation;
/**
*
- * @param element
+ * @param derivate
* @return
*/
public String getDerivateText(Object element){
+ //TODO: use list of strings to assemble labels to avoid adding the separator every time and to allow null values
TreeNode parentNode = null;
+ TreeNode node = null;
+ Object derivate = element;
if(element instanceof TreeNode){
- parentNode = ((TreeNode) element).getParent();
+ node = (TreeNode) element;
+ parentNode = node.getParent();
//unwrap specimen from TreeNode
- element = ((TreeNode) element).getValue();
+ derivate = node.getValue();
}
conversation.bind();
- String label = "";
- if(element instanceof FieldUnit){
- FieldUnit fieldUnit = (FieldUnit)element;
+ final String emptyString = "";
+ final String separator = ", ";
+
+ String label = emptyString;
+
+ //Field Unit
+ if(derivate instanceof FieldUnit){
+ FieldUnit fieldUnit = (FieldUnit)derivate;
if(fieldUnit.getGatheringEvent()!=null){
GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
if(!conversation.getSession().contains(gatheringEvent)){
fieldUnit = (FieldUnit) CdmStore.getService(IOccurrenceService.class).load(fieldUnit.getUuid());
gatheringEvent = fieldUnit.getGatheringEvent();
}
- label += gatheringEvent.getCountry()!=null?gatheringEvent.getCountry().getLabel()+", ":"";
- label += gatheringEvent.getLocality()!=null?gatheringEvent.getLocality().getText()+", ":"";
- label += gatheringEvent.getGatheringDate()!=null?gatheringEvent.getGatheringDate()+", ":"";
- label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+", ":"";
+ label += gatheringEvent.getCountry()!=null?gatheringEvent.getCountry().getLabel()+separator:emptyString;
+ label += gatheringEvent.getLocality()!=null?gatheringEvent.getLocality().getText()+separator:emptyString;
+ label += gatheringEvent.getGatheringDate()!=null?gatheringEvent.getGatheringDate()+separator:emptyString;
+ label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+separator:emptyString;
}
- label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber():"";
+ label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber():emptyString;
}
- else if(element instanceof MediaSpecimen){
- MediaSpecimen mediaSpecimen = (MediaSpecimen)element;
+ //MediaSpecimen
+ else if(derivate instanceof MediaSpecimen){
+ MediaSpecimen mediaSpecimen = (MediaSpecimen)derivate;
if(mediaSpecimen.getMediaSpecimen()!=null){
- label += mediaSpecimen.getMediaSpecimen().getTitle()!=null?mediaSpecimen.getMediaSpecimen().getTitle().getText()+", ":"[no motif]";
- label += mediaSpecimen.getMediaSpecimen().getArtist()!=null?mediaSpecimen.getMediaSpecimen().getArtist()+", ":"";
+ label += mediaSpecimen.getMediaSpecimen().getTitle()!=null?mediaSpecimen.getMediaSpecimen().getTitle().getText()+separator:"[no motif]";
+ label += mediaSpecimen.getMediaSpecimen().getArtist()!=null?mediaSpecimen.getMediaSpecimen().getArtist()+separator:emptyString;
}
eu.etaxonomy.cdm.model.occurrence.Collection collection = mediaSpecimen.getCollection();
if(collection!=null){
- label += collection.getName()!=null?collection.getName()+" ":"";
- label += collection.getCode()!=null?"("+collection.getCode()+"), ":"";
+ label += collection.getName()!=null?collection.getName()+" ":emptyString;
+ label += collection.getCode()!=null?"("+collection.getCode()+")"+separator:emptyString;
}
- label += mediaSpecimen.getAccessionNumber()!=null?mediaSpecimen.getAccessionNumber()+", ":"";
+ label += mediaSpecimen.getAccessionNumber()!=null?mediaSpecimen.getAccessionNumber()+separator:emptyString;
}
- else if(element instanceof DnaSample
- || (element instanceof DerivedUnit
- && ((SpecimenOrObservationBase<?>) element).getRecordBasis()==SpecimenOrObservationType.DnaSample)){
- DerivedUnit derivedUnit = (DerivedUnit)element;
- Set<String> identifiers = derivedUnit.getIdentifiers(getSampleDesignationTerm());
- if(identifiers.isEmpty()){
- label += "[no sample designation]";
+ //TissueSample + DnaSample
+ else if(derivate instanceof DnaSample){
+ DnaSample dnaSample = (DnaSample)derivate;
+ if(((DnaSample) derivate).getRecordBasis()==SpecimenOrObservationType.DnaSample){
+ Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(dnaSample);
+ if(currentSampleDesignation!=null){
+ label += currentSampleDesignation.getIdentifier()+separator;
+ }
+ else{
+ label += NO_SAMPLE_DESIGNATION+separator;
+ }
}
- else{
- String identifier = identifiers.iterator().next();
- label += identifier==null?"":identifier;
+ else if(((DnaSample) derivate).getRecordBasis()==SpecimenOrObservationType.TissueSample){
+ label += dnaSample.getKindOfUnit()+separator;
+ Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(dnaSample);
+ if(currentSampleDesignation!=null){
+ label += currentSampleDesignation.getIdentifier()+separator;
+ }
+ else{
+ label += NO_SAMPLE_DESIGNATION+separator;
+ }
}
}
- else if(element instanceof DerivedUnit){
- DerivedUnit derivedUnit = (DerivedUnit)element;
+ //DerivedUnit + TissueSample
+ else if(derivate instanceof DerivedUnit){
+ DerivedUnit derivedUnit = (DerivedUnit)derivate;
if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
java.util.Collection<FieldUnit> fieldUnits = CdmStore.getService(IOccurrenceService.class).getFieldUnits(derivedUnit.getUuid());
if(fieldUnits!=null && !fieldUnits.isEmpty()){
FieldUnit fieldUnit = fieldUnits.iterator().next();
GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
-// gatheringEvent = HibernateProxyHelper.deproxy(gatheringEvent, GatheringEvent.class);
+// gatheringEvent = HibernateProxyHelper.deproxy(gatheringEvent, GatheringEvent.class);
if(gatheringEvent!=null){
- label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+", ":"";
+ label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+separator:emptyString;
}
- label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber()+", ":"";
+ label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber()+separator:emptyString;
}
eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();
if(collection!=null){
- label += collection.getName()!=null?collection.getName()+" ":"";
- label += collection.getCode()!=null?"("+collection.getCode()+"), ":"";
+ label += collection.getName()!=null?collection.getName()+" ":emptyString;
+ label += collection.getCode()!=null?"("+collection.getCode()+"), ":emptyString;
}
- label += derivedUnit.getAccessionNumber()!=null?derivedUnit.getAccessionNumber()+", ":"";
- label += derivedUnit.getBarcode()!=null?derivedUnit.getBarcode():"";
+ label += derivedUnit.getAccessionNumber()!=null?derivedUnit.getAccessionNumber()+separator:emptyString;
+ label += derivedUnit.getBarcode()!=null?derivedUnit.getBarcode():emptyString;
}
else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.TissueSample){
- //TODO: implement
- label += "kindofTissue? + [no sample designation]";
+ label += derivedUnit.getKindOfUnit() + NO_SAMPLE_DESIGNATION;
}
}
- else if(element instanceof Sequence){
- Sequence sequence = (Sequence)element;
- label += "[no sample designation]"+", ";
- label += sequence.getDnaMarker()!=null?sequence.getDnaMarker():"";
+ //Sequence
+ else if(derivate instanceof Sequence){
+ Sequence sequence = (Sequence)derivate;
+ Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(sequence);
+ if(currentSampleDesignation!=null){
+ label += currentSampleDesignation.getIdentifier()+separator;
+ }
+ else{
+ label += NO_SAMPLE_DESIGNATION+separator;
+ }
+ label += sequence.getDnaMarker()!=null?sequence.getDnaMarker():emptyString;
}
- else if(element instanceof SingleRead){
- SingleRead singleRead = (SingleRead)element;
- label += "[no sample designation]"+", ";
- label += singleRead.getPrimer()!=null?singleRead.getPrimer().getLabel()+", ":"";
+ //SingleRead
+ else if(derivate instanceof SingleRead){
+ SingleRead singleRead = (SingleRead)derivate;
if(parentNode!=null && parentNode.getValue() instanceof Sequence){
Sequence sequence = (Sequence) parentNode.getValue();
- label += sequence.getDnaMarker()!=null?sequence.getDnaMarker():"";
+ Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(sequence);
+ if(currentSampleDesignation!=null){
+ label = currentSampleDesignation.getIdentifier()+separator;
+ }
+ else{
+ label += NO_SAMPLE_DESIGNATION+separator;
+ }
+ label += singleRead.getPrimer()!=null?singleRead.getPrimer().getLabel()+separator:emptyString;
+ if(sequence!=null){
+ label += sequence.getDnaMarker()!=null?sequence.getDnaMarker():emptyString;
+ }
}
}
- else if(element instanceof SpecimenOrObservationBase){
- SpecimenOrObservationBase<?> derivate = (SpecimenOrObservationBase<?>) element;
- SpecimenOrObservationType type = derivate.getRecordBasis();
- return derivate.getTitleCache() + (type!=null?" ["+type.toString()+"]":"");
+ //SOOB
+ else if(derivate instanceof SpecimenOrObservationBase){
+ SpecimenOrObservationBase<?> specimen = (SpecimenOrObservationBase<?>) derivate;
+ SpecimenOrObservationType type = specimen.getRecordBasis();
+ return specimen.getTitleCache() + (type!=null?" ["+type.toString()+"]":emptyString);
}
if(label.isEmpty()){
- label = element.toString();
+ label = derivate.toString();
}
//remove last comma
- else if(label.endsWith(", ")){
- label = label.substring(0, label.length()-2);
+ else if(label.endsWith(separator)){
+ label = label.substring(0, label.length()-separator.length());
}
return label;
}
return super.getImage(element);
}
+ public static Identifier<DnaSample> getCurrentSampleDesignation(CdmBase entity) {
+ if(entity instanceof DnaSample){
+ DnaSample dnaSample = (DnaSample)entity;
+ for (Identifier<DnaSample> identifier : dnaSample.getIdentifiers()) {
+ if(identifier.getType()!=null && identifier.getType().equals(DerivateLabelProvider.getSampleDesignationTerm())){
+ //first sample designation is the current
+ return identifier;
+ }
+ }
+ }
+ else if(entity instanceof Sequence){
+ Sequence sequence = (Sequence)entity;
+ //check if sequence has its own sample designation
+// if(sequence.getSampleDesignation()){
+//
+// }
+// else
+ //if not take a look at the DnaSample
+ if(sequence.getDnaSample()!=null){
+ return getCurrentSampleDesignation(sequence.getDnaSample());
+ }
+ }
+ return null;
+ }
+
/**
* @param multiLinkSingleReads2
*/