1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.bulkeditor.input;
|
12
|
|
13
|
import java.util.List;
|
14
|
|
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.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
21
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
22
|
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
|
23
|
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.OccurrenceCreator;
|
24
|
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
|
27
|
/**
|
28
|
* <p>OccurrenceEditorInput class.</p>
|
29
|
*
|
30
|
* @author n.hoffmann
|
31
|
* @created Jun 16, 2010
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class OccurrenceEditorInput extends AbstractBulkEditorInput<SpecimenOrObservationBase> {
|
35
|
|
36
|
/**
|
37
|
*
|
38
|
*/
|
39
|
private static final long serialVersionUID = 1014860873939989973L;
|
40
|
|
41
|
/** Constant <code>ID="bulkeditor.input.occurrence"</code> */
|
42
|
public static final String ID = "bulkeditor.input.occurrence";
|
43
|
|
44
|
private static OccurrenceEditorInput instance;
|
45
|
|
46
|
/**
|
47
|
* <p>Getter for the field <code>instance</code>.</p>
|
48
|
*
|
49
|
* @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
|
50
|
*/
|
51
|
public static AbstractBulkEditorInput<SpecimenOrObservationBase> getInstance() {
|
52
|
if (instance == null) {
|
53
|
instance = new OccurrenceEditorInput();
|
54
|
}
|
55
|
return instance;
|
56
|
}
|
57
|
|
58
|
/* (non-Javadoc)
|
59
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
|
60
|
*/
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
protected List<SpecimenOrObservationBase> listEntities(
|
64
|
IIdentifiableEntityServiceConfigurator configurator) {
|
65
|
return CdmStore.getSearchManager().findOccurrences(configurator);
|
66
|
}
|
67
|
|
68
|
/* (non-Javadoc)
|
69
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
|
70
|
*/
|
71
|
/** {@inheritDoc}
|
72
|
@Override
|
73
|
protected SpecimenOrObservationBase loadEntity(UUID entityUuid) {
|
74
|
List<String> propertyPaths = Arrays.asList(new String[]{});
|
75
|
return CdmStore.getService(IOccurrenceService.class).load(entityUuid, propertyPaths);
|
76
|
}*/
|
77
|
|
78
|
/* (non-Javadoc)
|
79
|
* @see org.eclipse.ui.IEditorInput#getName()
|
80
|
*/
|
81
|
/**
|
82
|
* <p>getName</p>
|
83
|
*
|
84
|
* @return a {@link java.lang.String} object.
|
85
|
*/
|
86
|
@Override
|
87
|
public String getName() {
|
88
|
return BulkEditorInputType.OCCURRENCE.label;
|
89
|
}
|
90
|
|
91
|
/* (non-Javadoc)
|
92
|
* @see org.eclipse.ui.IEditorInput#getToolTipText()
|
93
|
*/
|
94
|
/**
|
95
|
* <p>getToolTipText</p>
|
96
|
*
|
97
|
* @return a {@link java.lang.String} object.
|
98
|
*/
|
99
|
@Override
|
100
|
public String getToolTipText() {
|
101
|
return getName();
|
102
|
}
|
103
|
|
104
|
/* (non-Javadoc)
|
105
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
|
106
|
*/
|
107
|
@Override
|
108
|
public String getTypeText(Object entity) {
|
109
|
if(HibernateProxyHelper.isInstanceOf(entity, SpecimenOrObservationBase.class)){
|
110
|
return ((SpecimenOrObservationBase) entity).getRecordBasis().getMessage();
|
111
|
}
|
112
|
return super.getTypeText(entity);
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* <p>getId</p>
|
117
|
*
|
118
|
* @return a {@link java.lang.Object} object.
|
119
|
*/
|
120
|
public static Object getId(){
|
121
|
return ID;
|
122
|
}
|
123
|
|
124
|
/* (non-Javadoc)
|
125
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
|
126
|
*/
|
127
|
/** {@inheritDoc}
|
128
|
* @throws ReferencedObjectUndeletableException */
|
129
|
@Override
|
130
|
public boolean delete(SpecimenOrObservationBase entity) throws ReferencedObjectUndeletableException {
|
131
|
return CdmStore.getService(IOccurrenceService.class).delete(entity) != null;
|
132
|
}
|
133
|
|
134
|
/* (non-Javadoc)
|
135
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
|
136
|
*/
|
137
|
/** {@inheritDoc} */
|
138
|
@Override
|
139
|
public SpecimenOrObservationBase<IIdentifiableEntityCacheStrategy> save(SpecimenOrObservationBase entity) {
|
140
|
if(CdmStore.getCurrentSessionManager().isRemoting()) {
|
141
|
return CdmStore.getService(IOccurrenceService.class).merge(entity) ;
|
142
|
} else {
|
143
|
CdmStore.getService(IOccurrenceService.class).save(entity);
|
144
|
return entity;
|
145
|
}
|
146
|
}
|
147
|
|
148
|
|
149
|
/* (non-Javadoc)
|
150
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
|
151
|
*/
|
152
|
@Override
|
153
|
protected IEntityCreator<SpecimenOrObservationBase> createEntityCreator() {
|
154
|
return new OccurrenceCreator();
|
155
|
}
|
156
|
|
157
|
/* (non-Javadoc)
|
158
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
|
159
|
*/
|
160
|
@Override
|
161
|
public List<IBulkEditorSortProvider<SpecimenOrObservationBase>> getSortProviders() {
|
162
|
List<IBulkEditorSortProvider<SpecimenOrObservationBase>> sortProviders = super.getSortProviders();
|
163
|
|
164
|
sortProviders.add(0, new IdentifiableEntitySortProvider<SpecimenOrObservationBase>());
|
165
|
|
166
|
return sortProviders;
|
167
|
}
|
168
|
|
169
|
/* (non-Javadoc)
|
170
|
* @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
|
171
|
*/
|
172
|
@Override
|
173
|
public void merge() {
|
174
|
|
175
|
}
|
176
|
}
|