0283f4de89cff8dd2fa627ed4fc2daa6d461daa1
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / handler / TaxonParameterConverter.java
1 package eu.etaxonomy.taxeditor.editor.handler;
2
3 import java.util.UUID;
4
5 import org.eclipse.core.commands.AbstractParameterValueConverter;
6 import org.eclipse.core.commands.ParameterValueConversionException;
7
8 import eu.etaxonomy.cdm.api.service.ITaxonService;
9 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
10 import eu.etaxonomy.taxeditor.store.CdmStore;
11
12 public class TaxonParameterConverter extends AbstractParameterValueConverter {
13
14 public TaxonParameterConverter() {
15 }
16
17 @Override
18 public Object convertToObject(String parameterValue) throws ParameterValueConversionException {
19 return CdmStore.getService(ITaxonService.class).load(UUID.fromString(parameterValue));
20 }
21
22 @Override
23 public String convertToString(Object parameterValue) throws ParameterValueConversionException {
24 if(parameterValue instanceof TaxonBase<?>){
25 return ((TaxonBase<?>) parameterValue).getUuid().toString();
26 }
27 return null;
28 }
29
30 }