merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / OccurrenceEditorInput.java
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.Arrays;
14 import java.util.List;
15 import java.util.UUID;
16
17 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
18 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
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 /**
104 * <p>getId</p>
105 *
106 * @return a {@link java.lang.Object} object.
107 */
108 public static Object getId(){
109 return ID;
110 }
111
112 /* (non-Javadoc)
113 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
114 */
115 /** {@inheritDoc} */
116 @Override
117 public boolean delete(SpecimenOrObservationBase entity) {
118 return CdmStore.getService(IOccurrenceService.class).delete(entity) != null;
119 }
120
121 /* (non-Javadoc)
122 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
123 */
124 /** {@inheritDoc} */
125 @Override
126 public boolean save(SpecimenOrObservationBase entity) {
127 return CdmStore.getService(IOccurrenceService.class).save(entity) != null;
128 }
129
130
131 /* (non-Javadoc)
132 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
133 */
134 @Override
135 protected IEntityCreator<SpecimenOrObservationBase> createEntityCreator() {
136 return new OccurrenceCreator();
137 }
138
139 /* (non-Javadoc)
140 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
141 */
142 @Override
143 public List<IBulkEditorSortProvider<SpecimenOrObservationBase>> getSortProviders() {
144 List<IBulkEditorSortProvider<SpecimenOrObservationBase>> sortProviders = super.getSortProviders();
145
146 sortProviders.add(0, new IdentifiableEntitySortProvider<SpecimenOrObservationBase>());
147
148 return sortProviders;
149 }
150 }