Update root entity merge calls to use new merge method.
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / GroupEditorInput.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
11 package eu.etaxonomy.taxeditor.bulkeditor.input;
12
13 import java.util.List;
14
15 import eu.etaxonomy.cdm.api.service.IGroupService;
16 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
17 import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
18 import eu.etaxonomy.cdm.model.common.Group;
19 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
20 import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator;
21 import eu.etaxonomy.taxeditor.store.CdmStore;
22
23 /**
24 * @author n.hoffmann
25 * @created Mar 9, 2011
26 * @version 1.0
27 */
28 public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
29
30 public static final String ID = "bulkeditor.input.group";
31
32 private static GroupEditorInput instance;
33
34 /**
35 * @return the instance
36 */
37 public static GroupEditorInput getInstance() {
38 if(instance == null){
39 instance = new GroupEditorInput();
40 }
41 return instance;
42 }
43
44 /* (non-Javadoc)
45 * @see org.eclipse.ui.IEditorInput#getName()
46 */
47 @Override
48 public String getName() {
49 return BulkEditorInputType.GROUP.label;
50 }
51
52 /* (non-Javadoc)
53 * @see org.eclipse.ui.IEditorInput#getToolTipText()
54 */
55 @Override
56 public String getToolTipText() {
57 return getName();
58 }
59
60 /* (non-Javadoc)
61 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
62 */
63 @Override
64 public Group save(Group entity) {
65 if(CdmStore.getCurrentSessionManager().isRemoting()) {
66 return CdmStore.getService(IGroupService.class).merge(entity, true).getMergedEntity();
67 } else {
68 CdmStore.getService(IGroupService.class).saveOrUpdate(entity);
69 return entity;
70 }
71 }
72
73 /* (non-Javadoc)
74 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
75 */
76 @Override
77 public boolean delete(Group entity) throws ReferencedObjectUndeletableException {
78 return CdmStore.getService(IGroupService.class).delete(entity) != null;
79 }
80
81 /* (non-Javadoc)
82 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
83 */
84 @Override
85 protected List<Group> listEntities(
86 IIdentifiableEntityServiceConfigurator configurator) {
87 return CdmStore.getSearchManager().findGroups(configurator);
88 }
89
90 /* (non-Javadoc)
91 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
92
93 @Override
94 protected Group loadEntity(UUID entityUuid) {
95 List<String> propertyPaths = Arrays.asList(new String[]{});
96 return CdmStore.getService(IGroupService.class).load(entityUuid, propertyPaths);
97 }
98 */
99 /* (non-Javadoc)
100 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
101 */
102 @Override
103 protected IEntityCreator<Group> createEntityCreator() {
104 return new GroupCreator();
105 }
106
107 /* (non-Javadoc)
108 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
109 */
110 @Override
111 public String getText(Group entity) {
112 return entity.getName();
113 }
114
115 /* (non-Javadoc)
116 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
117 */
118 @Override
119 public void merge() {
120
121 }
122
123
124
125 }