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
.List
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
16 import eu
.etaxonomy
.cdm
.api
.service
.config
.IIdentifiableEntityServiceConfigurator
;
17 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
18 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
19 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
20 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
21 import eu
.etaxonomy
.taxeditor
.bulkeditor
.IBulkEditorSortProvider
;
22 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
.OccurrenceCreator
;
23 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.sortprovider
.IdentifiableEntitySortProvider
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 * <p>OccurrenceEditorInput class.</p>
30 * @created Jun 16, 2010
33 public class OccurrenceEditorInput
extends AbstractBulkEditorInput
<SpecimenOrObservationBase
> {
38 private static final long serialVersionUID
= 1014860873939989973L;
40 /** Constant <code>ID="bulkeditor.input.occurrence"</code> */
41 public static final String ID
= "bulkeditor.input.occurrence";
43 private static OccurrenceEditorInput instance
;
46 * <p>Getter for the field <code>instance</code>.</p>
48 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
50 public static AbstractBulkEditorInput
<SpecimenOrObservationBase
> getInstance() {
51 if (instance
== null) {
52 instance
= new OccurrenceEditorInput();
58 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
62 protected List
<SpecimenOrObservationBase
> listEntities(
63 IIdentifiableEntityServiceConfigurator configurator
) {
64 return CdmStore
.getSearchManager().findOccurrences(configurator
);
68 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
72 protected SpecimenOrObservationBase loadEntity(UUID entityUuid) {
73 List<String> propertyPaths = Arrays.asList(new String[]{});
74 return CdmStore.getService(IOccurrenceService.class).load(entityUuid, propertyPaths);
78 * @see org.eclipse.ui.IEditorInput#getName()
83 * @return a {@link java.lang.String} object.
86 public String
getName() {
87 return BulkEditorInputType
.OCCURRENCE
.label
;
91 * @see org.eclipse.ui.IEditorInput#getToolTipText()
94 * <p>getToolTipText</p>
96 * @return a {@link java.lang.String} object.
99 public String
getToolTipText() {
104 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
107 public String
getTypeText(Object entity
) {
108 if(HibernateProxyHelper
.isInstanceOf(entity
, SpecimenOrObservationBase
.class)){
109 return ((SpecimenOrObservationBase
) entity
).getRecordBasis().getMessage();
111 return super.getTypeText(entity
);
117 * @return a {@link java.lang.Object} object.
119 public static Object
getId(){
124 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
127 * @throws ReferencedObjectUndeletableException */
129 public boolean delete(SpecimenOrObservationBase entity
) throws ReferencedObjectUndeletableException
{
130 return CdmStore
.getService(IOccurrenceService
.class).delete(entity
) != null;
134 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
138 public boolean save(SpecimenOrObservationBase entity
) {
139 if(CdmStore
.getCurrentSessionManager().isRemoting()) {
140 return CdmStore
.getService(IOccurrenceService
.class).merge(entity
) != null;
142 return CdmStore
.getService(IOccurrenceService
.class).save(entity
) != null;
148 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
151 protected IEntityCreator
<SpecimenOrObservationBase
> createEntityCreator() {
152 return new OccurrenceCreator();
156 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
159 public List
<IBulkEditorSortProvider
<SpecimenOrObservationBase
>> getSortProviders() {
160 List
<IBulkEditorSortProvider
<SpecimenOrObservationBase
>> sortProviders
= super.getSortProviders();
162 sortProviders
.add(0, new IdentifiableEntitySortProvider
<SpecimenOrObservationBase
>());
164 return sortProviders
;
168 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
171 public void merge() {