Fixes #2366
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / AgentEditorInput.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 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.BulkEditorInputTypeValues.BulkEditorInputType;
22 import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.AgentCreator;
23 import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
24 import eu.etaxonomy.taxeditor.store.CdmStore;
25
26
27 /**
28 * <p>AgentEditorInput class.</p>
29 *
30 * @author p.ciardelli
31 * @created 25.06.2009
32 * @version 1.0
33 */
34 public class AgentEditorInput extends AbstractBulkEditorInput<AgentBase> {
35
36 /**
37 *
38 */
39 private static final long serialVersionUID = 3387950621617078479L;
40
41 /** Constant <code>ID="bulkeditor.input.author"</code> */
42 public static final String ID = "bulkeditor.input.author";
43
44 private static AgentEditorInput instance;
45
46 /**
47 * <p>getID</p>
48 *
49 * @return the iD
50 */
51 public static String getID() {
52 return ID;
53 }
54
55 /* (non-Javadoc)
56 * @see org.eclipse.ui.IEditorInput#getName()
57 */
58 /**
59 * <p>getName</p>
60 *
61 * @return a {@link java.lang.String} object.
62 */
63 public String getName() {
64 return BulkEditorInputType.AGENT.label;
65 }
66
67 /* (non-Javadoc)
68 * @see org.eclipse.ui.IEditorInput#getToolTipText()
69 */
70 /**
71 * <p>getToolTipText</p>
72 *
73 * @return a {@link java.lang.String} object.
74 */
75 public String getToolTipText() {
76 return getName();
77 }
78
79 /**
80 * <p>Getter for the field <code>instance</code>.</p>
81 *
82 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
83 */
84 public static AbstractBulkEditorInput getInstance() {
85 if (instance == null) {
86 instance = new AgentEditorInput();
87 }
88 return instance;
89 }
90
91 /* (non-Javadoc)
92 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
93 */
94 /** {@inheritDoc} */
95 @Override
96 public boolean isMergingEnabled() {
97 return false;
98 }
99
100 /** {@inheritDoc} */
101 @Override
102 public List<AgentBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
103 return CdmStore.getSearchManager().findTeamOrPersons(configurator);
104 }
105
106 /** {@inheritDoc} */
107 @Override
108 public AgentBase loadEntity(UUID uuid) {
109 List<String> propertyPaths = Arrays.asList(new String[]{});
110 return CdmStore.getService(IAgentService.class).load(uuid, propertyPaths);
111 }
112
113 /** {@inheritDoc} */
114 public boolean delete(AgentBase entity) {
115 return CdmStore.getService(IAgentService.class).delete(entity) != null;
116 }
117
118 /** {@inheritDoc} */
119 public boolean save(AgentBase entity) {
120 return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null;
121 }
122
123 /* (non-Javadoc)
124 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
125 */
126 @Override
127 public List<IBulkEditorSortProvider<AgentBase>> getSortProviders() {
128 List<IBulkEditorSortProvider<AgentBase>> sortProviders = super.getSortProviders();
129
130 sortProviders.add(0, new IdentifiableEntitySortProvider<AgentBase>());
131
132 return sortProviders;
133 }
134
135 /* (non-Javadoc)
136 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
137 */
138 @Override
139 protected IEntityCreator<AgentBase> createEntityCreator() {
140 return new AgentCreator();
141 }
142 }