automated build configuration is on its way
[taxeditor.git] / 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.command.BulkEditorInputTypeValues.BulkEditorInputType;
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 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 public String getToolTipText() {
99 return getName();
100 }
101
102 /**
103 * <p>getId</p>
104 *
105 * @return a {@link java.lang.Object} object.
106 */
107 public static Object getId(){
108 return ID;
109 }
110
111 /* (non-Javadoc)
112 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
113 */
114 /** {@inheritDoc} */
115 public boolean delete(SpecimenOrObservationBase entity) {
116 return CdmStore.getService(IOccurrenceService.class).delete(entity) != null;
117 }
118
119 /* (non-Javadoc)
120 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
121 */
122 /** {@inheritDoc} */
123 public boolean save(SpecimenOrObservationBase entity) {
124 return CdmStore.getService(IOccurrenceService.class).save(entity) != null;
125 }
126
127
128 /* (non-Javadoc)
129 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
130 */
131 @Override
132 protected IEntityCreator<SpecimenOrObservationBase> createEntityCreator() {
133 return new OccurrenceCreator();
134 }
135
136 /* (non-Javadoc)
137 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
138 */
139 @Override
140 public List<IBulkEditorSortProvider<SpecimenOrObservationBase>> getSortProviders() {
141 List<IBulkEditorSortProvider<SpecimenOrObservationBase>> sortProviders = super.getSortProviders();
142
143 sortProviders.add(0, new IdentifiableEntitySortProvider<SpecimenOrObservationBase>());
144
145 return sortProviders;
146 }
147 }