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
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
23 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
24 import eu
.etaxonomy
.taxeditor
.bulkeditor
.IBulkEditorSortProvider
;
25 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
.OccurrenceCreator
;
26 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.sortprovider
.IdentifiableEntitySortProvider
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 * <p>OccurrenceEditorInput class.</p>
33 * @created Jun 16, 2010
36 public class OccurrenceEditorInput
extends AbstractBulkEditorInput
<SpecimenOrObservationBase
> {
41 private static final long serialVersionUID
= 1014860873939989973L;
43 /** Constant <code>ID="bulkeditor.input.occurrence"</code> */
44 public static final String ID
= "bulkeditor.input.occurrence";
46 private static OccurrenceEditorInput instance
;
49 * <p>Getter for the field <code>instance</code>.</p>
51 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
53 public static AbstractBulkEditorInput
<SpecimenOrObservationBase
> getInstance() {
54 if (instance
== null) {
55 instance
= new OccurrenceEditorInput();
61 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
65 protected List
<SpecimenOrObservationBase
> listEntities(
66 IIdentifiableEntityServiceConfigurator configurator
) {
67 return CdmStore
.getSearchManager().findOccurrences(configurator
);
71 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
75 protected SpecimenOrObservationBase loadEntity(UUID entityUuid) {
76 List<String> propertyPaths = Arrays.asList(new String[]{});
77 return CdmStore.getService(IOccurrenceService.class).load(entityUuid, propertyPaths);
81 * @see org.eclipse.ui.IEditorInput#getName()
86 * @return a {@link java.lang.String} object.
89 public String
getName() {
90 return BulkEditorInputType
.OCCURRENCE
.label
;
94 * @see org.eclipse.ui.IEditorInput#getToolTipText()
97 * <p>getToolTipText</p>
99 * @return a {@link java.lang.String} object.
102 public String
getToolTipText() {
107 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
110 public String
getTypeText(Object entity
) {
111 if(HibernateProxyHelper
.isInstanceOf(entity
, SpecimenOrObservationBase
.class)){
112 return ((SpecimenOrObservationBase
) entity
).getRecordBasis().getMessage();
114 return super.getTypeText(entity
);
120 * @return a {@link java.lang.Object} object.
122 public static Object
getId(){
127 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
130 * @throws ReferencedObjectUndeletableException */
132 public boolean delete(SpecimenOrObservationBase entity
) throws ReferencedObjectUndeletableException
{
133 return CdmStore
.getService(IOccurrenceService
.class).delete(entity
) != null;
137 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
141 public SpecimenOrObservationBase
<IIdentifiableEntityCacheStrategy
> save(SpecimenOrObservationBase entity
) {
142 return CdmStore
.getService(IOccurrenceService
.class).merge(entity
, true).getMergedEntity();
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() {
176 protected SpecimenOrObservationBase
loadEntity(UUID entityUuid
) {
177 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{});
178 return CdmStore
.getService(IOccurrenceService
.class).load(entityUuid
, propertyPaths
);