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
.bulkeditor
.input
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.IIdentifiableEntityServiceConfigurator
;
19 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
20 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
21 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
22 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
23 import eu
.etaxonomy
.taxeditor
.bulkeditor
.IBulkEditorSortProvider
;
24 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
.OccurrenceCreator
;
25 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.sortprovider
.IdentifiableEntitySortProvider
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * <p>OccurrenceEditorInput class.</p>
32 * @created Jun 16, 2010
35 public class OccurrenceEditorInput
extends AbstractBulkEditorInput
<SpecimenOrObservationBase
> {
40 private static final long serialVersionUID
= 1014860873939989973L;
42 /** Constant <code>ID="bulkeditor.input.occurrence"</code> */
43 public static final String ID
= "bulkeditor.input.occurrence";
45 private static OccurrenceEditorInput instance
;
48 * <p>Getter for the field <code>instance</code>.</p>
50 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
52 public static AbstractBulkEditorInput
<SpecimenOrObservationBase
> getInstance() {
53 if (instance
== null) {
54 instance
= new OccurrenceEditorInput();
60 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
64 protected List
<SpecimenOrObservationBase
> listEntities(
65 IIdentifiableEntityServiceConfigurator configurator
) {
66 return CdmStore
.getSearchManager().findOccurrences(configurator
);
70 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
74 protected SpecimenOrObservationBase loadEntity(UUID entityUuid) {
75 List<String> propertyPaths = Arrays.asList(new String[]{});
76 return CdmStore.getService(IOccurrenceService.class).load(entityUuid, propertyPaths);
80 * @see org.eclipse.ui.IEditorInput#getName()
85 * @return a {@link java.lang.String} object.
88 public String
getName() {
89 return BulkEditorInputType
.OCCURRENCE
.label
;
93 * @see org.eclipse.ui.IEditorInput#getToolTipText()
96 * <p>getToolTipText</p>
98 * @return a {@link java.lang.String} object.
101 public String
getToolTipText() {
106 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
109 public String
getTypeText(Object entity
) {
110 if(HibernateProxyHelper
.isInstanceOf(entity
, SpecimenOrObservationBase
.class)){
111 return ((SpecimenOrObservationBase
) entity
).getRecordBasis().getMessage();
113 return super.getTypeText(entity
);
119 * @return a {@link java.lang.Object} object.
121 public static Object
getId(){
126 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
129 * @throws ReferencedObjectUndeletableException */
131 public boolean delete(SpecimenOrObservationBase entity
) throws ReferencedObjectUndeletableException
{
132 return CdmStore
.getService(IOccurrenceService
.class).delete(entity
) != null;
136 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
140 public boolean save(SpecimenOrObservationBase entity
) {
141 return CdmStore
.getService(IOccurrenceService
.class).save(entity
) != null;
146 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
149 protected IEntityCreator
<SpecimenOrObservationBase
> createEntityCreator() {
150 return new OccurrenceCreator();
154 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
157 public List
<IBulkEditorSortProvider
<SpecimenOrObservationBase
>> getSortProviders() {
158 List
<IBulkEditorSortProvider
<SpecimenOrObservationBase
>> sortProviders
= super.getSortProviders();
160 sortProviders
.add(0, new IdentifiableEntitySortProvider
<SpecimenOrObservationBase
>());
162 return sortProviders
;