Project

General

Profile

Download (4.28 KB) Statistics
| Branch: | Tag: | Revision:
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
	public String getName() {
86
		return BulkEditorInputType.OCCURRENCE.label;
87
	}
88

    
89
	/* (non-Javadoc)
90
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
91
	 */
92
	/**
93
	 * <p>getToolTipText</p>
94
	 *
95
	 * @return a {@link java.lang.String} object.
96
	 */
97
	public String getToolTipText() {
98
		return getName();
99
	}
100
	
101
	/**
102
	 * <p>getId</p>
103
	 *
104
	 * @return a {@link java.lang.Object} object.
105
	 */
106
	public static Object getId(){
107
		return ID;
108
	}
109

    
110
	/* (non-Javadoc)
111
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
112
	 */
113
	/** {@inheritDoc} */
114
	public boolean delete(SpecimenOrObservationBase entity) {
115
		return CdmStore.getService(IOccurrenceService.class).delete(entity) != null;
116
	}
117

    
118
	/* (non-Javadoc)
119
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
120
	 */
121
	/** {@inheritDoc} */
122
	public boolean save(SpecimenOrObservationBase entity) {
123
		return CdmStore.getService(IOccurrenceService.class).save(entity) != null;
124
	}
125
	
126

    
127
	/* (non-Javadoc)
128
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
129
	 */
130
	@Override
131
	protected IEntityCreator<SpecimenOrObservationBase> createEntityCreator() {
132
		return new OccurrenceCreator();
133
	}
134

    
135
	/* (non-Javadoc)
136
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
137
	 */
138
	@Override
139
	public List<IBulkEditorSortProvider<SpecimenOrObservationBase>> getSortProviders() {
140
		List<IBulkEditorSortProvider<SpecimenOrObservationBase>> sortProviders = super.getSortProviders();
141
		
142
		sortProviders.add(0, new IdentifiableEntitySortProvider<SpecimenOrObservationBase>());
143
		
144
		return sortProviders;
145
	}
146
}
(7-7/9)