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