package eu.etaxonomy.taxeditor.ui.section.name;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
/** {@inheritDoc} */
@Override
- public Collection<DescriptionElementBase> getCollection(
- TaxonNameBase entity) {
- return getTaxonNameDescription(entity).getElements();
+ public Collection<DescriptionElementBase> getCollection(TaxonNameBase entity) {
+ Collection<DescriptionElementBase> result = new ArrayList<DescriptionElementBase>();
+ List<TaxonNameDescription> descriptions = getTaxonNameDescriptions(entity);
+ for (TaxonNameDescription desc : descriptions){
+ result.addAll(desc.getElements());
+ }
+ return result;
+//OLD: return getTaxonNameDescription(entity).getElements();
}
/** {@inheritDoc} */
@Override
public void addElement(DescriptionElementBase element) {
+ //for simplification we always use the first description to add elements here
getTaxonNameDescription(getEntity()).addElement(element);
}
/** {@inheritDoc} */
@Override
public void removeElement(DescriptionElementBase element) {
- getTaxonNameDescription(getEntity()).removeElement(element);
+ List<TaxonNameDescription> descriptions = getTaxonNameDescriptions(getEntity());
+ for (TaxonNameDescription desc : descriptions){
+ desc.removeElement(element);
+ }
}
/** {@inheritDoc} */
setEntity(name);
}
+ /**
+ * NOTE: returns first description
+ * @param name
+ * @return
+ */
private TaxonNameDescription getTaxonNameDescription(TaxonNameBase name){
- // FIXME does not handle multiple name descriptions at the moment
if(name.getDescriptions().size() == 0){
name.addDescription(TaxonNameDescription.NewInstance(name));
}
return (TaxonNameDescription) name.getDescriptions().iterator().next();
}
+
+ /**
+ * Try to fix FIXME in {@link #getTaxonNameDescription(TaxonNameBase)}
+ * @param name
+ * @return
+ */
+ private List<TaxonNameDescription> getTaxonNameDescriptions(TaxonNameBase<?,?> name){
+ List<TaxonNameDescription> result = new ArrayList<TaxonNameDescription>();
+ if(name.getDescriptions().size() == 0){
+ name.addDescription(TaxonNameDescription.NewInstance(name));
+ }
+ for (TaxonNameDescription desc : name.getDescriptions()){
+ result.add(desc);
+ }
+ return result;
+ }
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)