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