Project

General

Profile

Download (3.79 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.Arrays;
14
import java.util.List;
15
import java.util.UUID;
16

    
17
import eu.etaxonomy.cdm.api.service.IAgentService;
18
import eu.etaxonomy.cdm.api.service.IGroupService;
19
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
20
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
21
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
22
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
23
import eu.etaxonomy.cdm.model.common.Group;
24
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
25
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27

    
28
/**
29
 * @author n.hoffmann
30
 * @created Mar 9, 2011
31
 * @version 1.0
32
 */
33
public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
34

    
35
	public static final String ID = "bulkeditor.input.group";
36

    
37
	private static GroupEditorInput instance;
38

    
39
	/**
40
	 * @return the instance
41
	 */
42
	public static GroupEditorInput getInstance() {
43
		if(instance == null){
44
			instance = new GroupEditorInput();
45
		}
46
		return instance;
47
	}
48

    
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.ui.IEditorInput#getName()
51
	 */
52
	@Override
53
	public String getName() {
54
		return BulkEditorInputType.GROUP.label;
55
	}
56

    
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
59
	 */
60
	@Override
61
	public String getToolTipText() {
62
		return getName();
63
	}
64

    
65
	/* (non-Javadoc)
66
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
67
	 */
68
	@Override
69
	public Group save(Group entity) {
70
	    return CdmStore.getService(IGroupService.class).merge(entity, true).getMergedEntity();
71
	    
72
	}
73

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

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

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

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

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

    
116
    /* (non-Javadoc)
117
     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
118
     */
119
    @Override
120
    public void merge() {
121

    
122
    }
123

    
124
	@Override
125
	protected Group loadEntity(UUID entityUuid) {
126
		List<String> propertyPaths = Arrays.asList(new String[]{});
127
		return HibernateProxyHelper.deproxy(CdmStore.getService(IAgentService.class).load(entityUuid, propertyPaths), Group.class);
128
	}
129

    
130

    
131

    
132
}
(4-4/12)