Project

General

Profile

Download (4.48 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.INameService;
18
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
19
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
20
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
21
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
22
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
23
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.NameCreator;
24
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

    
27
/**
28
 * <p>NameEditorInput class.</p>
29
 *
30
 * @author p.ciardelli
31
 * @created 20.08.2009
32
 * @version 1.0
33
 */
34
public class NameEditorInput extends AbstractBulkEditorInput<TaxonNameBase> {
35

    
36
	/**
37
	 * 
38
	 */
39
	private static final long serialVersionUID = -3085029575759626823L;
40
	private static NameEditorInput instance;
41

    
42
	/** Constant <code>ID="bulkeditor.input.name"</code> */
43
	public static final String ID = "bulkeditor.input.name";
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 getInstance() {
51
		if (instance == null) {
52
			instance = new NameEditorInput();
53
		}
54
		return instance;
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.ui.IEditorInput#getName()
59
	 */
60
	/**
61
	 * <p>getName</p>
62
	 *
63
	 * @return a {@link java.lang.String} object.
64
	 */
65
	public String getName() {
66
		return BulkEditorInputType.NAME.label;
67
	}
68

    
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
71
	 */
72
	/**
73
	 * <p>getToolTipText</p>
74
	 *
75
	 * @return a {@link java.lang.String} object.
76
	 */
77
	public String getToolTipText() {
78
		return getName();
79
	}
80

    
81
	/**
82
	 * <p>getID</p>
83
	 *
84
	 * @return a {@link java.lang.Object} object.
85
	 */
86
	public static Object getID() {
87
		return ID;
88
	}
89

    
90
	/* (non-Javadoc)
91
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
92
	 */
93
	/** {@inheritDoc} */
94
	@Override
95
	public boolean isMergingEnabled() {
96
		return false;
97
	}
98

    
99
	/** {@inheritDoc} */
100
	@Override
101
	public List listEntities(IIdentifiableEntityServiceConfigurator configurator) {
102
		return CdmStore.getSearchManager().findNames(configurator);
103
	}
104

    
105
	/** {@inheritDoc} */
106
	@Override
107
	public TaxonNameBase loadEntity(UUID uuid) {
108
		List<String> propertyPaths = Arrays.asList(new String[]{}); 
109
		return CdmStore.getService(INameService.class).load(uuid, propertyPaths);
110
	}
111

    
112
	/** {@inheritDoc} 
113
	 * @throws ReferencedObjectUndeletableException */
114
	public boolean delete(TaxonNameBase entity) throws ReferencedObjectUndeletableException {
115
		return CdmStore.getService(INameService.class).delete(entity) != null;
116
	}
117

    
118
	/** {@inheritDoc} */
119
	public boolean save(TaxonNameBase entity) {
120
		return CdmStore.getService(INameService.class).saveOrUpdate(entity) != null;
121
	}
122

    
123
	/* (non-Javadoc)
124
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
125
	 */
126
	@Override
127
	protected IEntityCreator<TaxonNameBase> createEntityCreator() {
128
		return new NameCreator();
129
	}
130

    
131
	/* (non-Javadoc)
132
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
133
	 */
134
	@Override
135
	public List<IBulkEditorSortProvider<TaxonNameBase>> getSortProviders() {
136
		List<IBulkEditorSortProvider<TaxonNameBase>> sortProviders = super.getSortProviders();
137
		
138
		sortProviders.add(0, new IdentifiableEntitySortProvider<TaxonNameBase>());
139
		
140
		return sortProviders;
141
	}
142
	
143
	/* (non-Javadoc)
144
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
145
	 */
146
	@Override
147
	public String getTypeText(Object entity) {
148
		if((entity instanceof TaxonNameBase) && (((TaxonNameBase) entity).getNomenclaturalCode() != null)){
149
			return ((TaxonNameBase) entity).getNomenclaturalCode().getTitleCache();
150
		}
151
		return super.getTypeText(entity);
152
	}
153
	
154
	/* (non-Javadoc)
155
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
156
	 */
157
	@Override
158
	public String getText(TaxonNameBase entity) {
159
		return (entity).getFullTitleCache();
160
	}
161

    
162

    
163
}
(5-5/9)