Project

General

Profile

Download (3.64 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
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.IAgentService;
17
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
18
import eu.etaxonomy.cdm.model.agent.AgentBase;
19
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
20
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
21
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.AgentCreator;
22
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25

    
26
/**
27
 * <p>AgentEditorInput class.</p>
28
 *
29
 * @author p.ciardelli
30
 * @created 25.06.2009
31
 * @version 1.0
32
 */
33
public class AgentEditorInput extends AbstractBulkEditorInput<AgentBase> {
34

    
35
	/**
36
	 * 
37
	 */
38
	private static final long serialVersionUID = 3387950621617078479L;
39

    
40
	/** Constant <code>ID="bulkeditor.input.author"</code> */
41
	public static final String ID = "bulkeditor.input.author";
42
	
43
	private static AgentEditorInput instance;
44

    
45
	/**
46
	 * <p>getID</p>
47
	 *
48
	 * @return the iD
49
	 */
50
	public static String getID() {
51
		return ID;
52
	}
53
	
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.ui.IEditorInput#getName()
56
	 */
57
	/**
58
	 * <p>getName</p>
59
	 *
60
	 * @return a {@link java.lang.String} object.
61
	 */
62
	public String getName() {
63
		return BulkEditorInputType.AGENT.label;
64
	}
65

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

    
78
	/**
79
	 * <p>Getter for the field <code>instance</code>.</p>
80
	 *
81
	 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
82
	 */
83
	public static AbstractBulkEditorInput getInstance() {
84
		if (instance == null) {
85
			instance = new AgentEditorInput();
86
		}
87
		return instance;
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<AgentBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
102
		return CdmStore.getSearchManager().findTeamOrPersons(configurator);
103
	}
104
	
105
	/** {@inheritDoc} */
106
	@Override
107
	public AgentBase loadEntity(UUID uuid) {
108
		List<String> propertyPaths = Arrays.asList(new String[]{}); 
109
		return CdmStore.getService(IAgentService.class).load(uuid, propertyPaths);
110
	}
111

    
112
	/** {@inheritDoc} */
113
	public boolean delete(AgentBase entity) {
114
		return CdmStore.getService(IAgentService.class).delete(entity) != null;			
115
	}
116

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

    
122
	/* (non-Javadoc)
123
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
124
	 */
125
	@Override
126
	public List<IBulkEditorSortProvider<AgentBase>> getSortProviders() {
127
		List<IBulkEditorSortProvider<AgentBase>> sortProviders = super.getSortProviders();
128
		
129
		sortProviders.add(0, new IdentifiableEntitySortProvider<AgentBase>());
130
		
131
		return sortProviders;
132
	}
133
	
134
	/* (non-Javadoc)
135
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
136
	 */
137
	@Override
138
	protected IEntityCreator<AgentBase> createEntityCreator() {
139
		return new AgentCreator();
140
	}
141

    
142
}
(2-2/9)