Project

General

Profile

Download (4.93 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11

    
12
import java.util.Arrays;
13
import java.util.List;
14
import java.util.UUID;
15

    
16
import eu.etaxonomy.cdm.api.service.INameService;
17
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
18
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
19
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
20
import eu.etaxonomy.cdm.model.name.TaxonName;
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
 */
33
public class NameEditorInput extends AbstractBulkEditorInput<TaxonName> {
34

    
35
	private static final long serialVersionUID = -3085029575759626823L;
36
	private static NameEditorInput instance;
37

    
38
	/** Constant <code>ID="bulkeditor.input.name"</code> */
39
	public static final String ID = "bulkeditor.input.name";
40

    
41
	/**
42
	 * <p>Getter for the field <code>instance</code>.</p>
43
	 *
44
	 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
45
	 */
46
	public static AbstractBulkEditorInput getInstance() {
47
		if (instance == null) {
48
			instance = new NameEditorInput();
49
		}
50
		return instance;
51
	}
52

    
53
	/**
54
	 * <p>getName</p>
55
	 *
56
	 * @return a {@link java.lang.String} object.
57
	 */
58
	@Override
59
    public String getName() {
60
		return BulkEditorInputType.NAME.label;
61
	}
62

    
63
	/**
64
	 * <p>getToolTipText</p>
65
	 *
66
	 * @return a {@link java.lang.String} object.
67
	 */
68
	@Override
69
    public String getToolTipText() {
70
		return getName();
71
	}
72

    
73
	/**
74
	 * <p>getID</p>
75
	 *
76
	 * @return a {@link java.lang.Object} object.
77
	 */
78
	public static Object getID() {
79
		return ID;
80
	}
81

    
82
	/* (non-Javadoc)
83
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
84
	 */
85
	/** {@inheritDoc} */
86
	@Override
87
	public boolean isMergingEnabled() {
88
		return false;
89
	}
90

    
91
	/** {@inheritDoc} */
92
	@Override
93
	public List listEntities(IIdentifiableEntityServiceConfigurator configurator) {
94
		
95
		configurator.setPropertyPaths(getPropertyPaths());
96
		return CdmStore.getSearchManager().findNames(configurator, this.getConversation());
97
	}
98

    
99
	/** {@inheritDoc}
100
	@Override
101
	public TaxonNameBase loadEntity(UUID uuid) {
102
		List<String> propertyPaths = Arrays.asList(new String[]{});
103
		return CdmStore.getService(INameService.class).load(uuid, propertyPaths);
104
	}
105
*/
106
	@Override
107
    public boolean delete(TaxonName entity, DeleteConfiguratorBase config)  {
108
		NameDeletionConfigurator nameConfig = null;
109
		if (config instanceof NameDeletionConfigurator){
110
			nameConfig = (NameDeletionConfigurator) config;
111
		} else{
112
			
113
		}
114
		return CdmStore.getService(INameService.class).delete(entity.getUuid(), nameConfig) != null;
115
	}
116
	
117
	/** {@inheritDoc} */
118
	@Override
119
    public TaxonName save(TaxonName entity) {
120
		TaxonName mergedName = null;
121
		mergedName =  CdmStore.getService(INameService.class).merge(entity, true).getMergedEntity();
122
	   	return mergedName;
123
		
124
	}
125

    
126
	@Override
127
	protected IEntityCreator<TaxonName> createEntityCreator() {
128
		return new NameCreator();
129
	}
130

    
131
	@Override
132
	public List<IBulkEditorSortProvider<TaxonName>> getSortProviders() {
133
		List<IBulkEditorSortProvider<TaxonName>> sortProviders = super.getSortProviders();
134

    
135
		sortProviders.add(0, new IdentifiableEntitySortProvider<>());
136

    
137
		return sortProviders;
138
	}
139

    
140
	@Override
141
	public String getTypeText(Object entity) {
142
		if((entity instanceof TaxonName) && (((TaxonName) entity).getNomenclaturalCode() != null)){
143
			return ((TaxonName) entity).getNomenclaturalCode().getTitleCache();
144
		}
145
		return super.getTypeText(entity);
146
	}
147

    
148
	@Override
149
	public String getText(TaxonName entity) {
150
		return (entity).getFullTitleCache();
151
	}
152

    
153
    @Override
154
    public void merge() {
155

    
156
    }
157

    
158
	@Override
159
	protected TaxonName loadEntity(UUID entityUuid) {
160
		List<String> propertyPaths = Arrays.asList(new String[]{});
161
		return CdmStore.getService(INameService.class).load(entityUuid, getPropertyPaths());
162
	}
163

    
164

    
165
    private List<String> getPropertyPaths(){
166
    	 List<String> nameBasePropertyPaths = Arrays.asList(new String[] {
167
    	 "name.descriptions",
168
         "name.typeDesignations",
169
         "name.status",
170
         "name.nomenclaturalReference.inReference",
171
         "name.taxonBases.taxonNodes",
172
         "name.relationsFromThisName",
173
         "name.relationsToThisName",
174
         "name.homotypicalGroup.typifiedNames.taxonBases.synonymRelations.synonym.name.status",
175
         "name.homotypicalGroup.typifiedNames.relationsToThisName.fromName"});
176
    	 
177
    	 return nameBasePropertyPaths;
178
    }
179

    
180
}
(6-6/11)