Project

General

Profile

Download (3.29 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

    
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 boolean save(Group entity) {
65
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
66
	        return CdmStore.getService(IGroupService.class).merge(entity) != null;
67
	    } else {
68
	        return CdmStore.getService(IGroupService.class).saveOrUpdate(entity) != null;
69
	    }
70
	}
71

    
72
	/* (non-Javadoc)
73
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
74
	 */
75
	@Override
76
	public boolean delete(Group entity) throws ReferencedObjectUndeletableException {
77
		return CdmStore.getService(IGroupService.class).delete(entity) != null;
78
	}
79

    
80
	/* (non-Javadoc)
81
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
82
	 */
83
	@Override
84
	protected List<Group> listEntities(
85
			IIdentifiableEntityServiceConfigurator configurator) {
86
		return CdmStore.getSearchManager().findGroups(configurator);
87
	}
88

    
89
	/* (non-Javadoc)
90
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
91

    
92
	@Override
93
	protected Group loadEntity(UUID entityUuid) {
94
		List<String> propertyPaths = Arrays.asList(new String[]{});
95
		return CdmStore.getService(IGroupService.class).load(entityUuid, propertyPaths);
96
	}
97
*/
98
	/* (non-Javadoc)
99
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
100
	 */
101
	@Override
102
	protected IEntityCreator<Group> createEntityCreator() {
103
		return new GroupCreator();
104
	}
105

    
106
	/* (non-Javadoc)
107
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
108
	 */
109
	@Override
110
	public String getText(Group entity) {
111
		return entity.getName();
112
	}
113

    
114

    
115

    
116
}
(4-4/11)