1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2016 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.List;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.service.IMediaService;
|
15
|
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
|
16
|
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
|
17
|
import eu.etaxonomy.cdm.model.media.Media;
|
18
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
19
|
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
|
20
|
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.MediaCreator;
|
21
|
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
/**
|
25
|
* @author k.luther
|
26
|
* @date 10.03.2016
|
27
|
*
|
28
|
*/
|
29
|
public class MediaEditorInput extends AbstractBulkEditorInput<Media> {
|
30
|
public static final String ID = "bulkeditor.input.media";
|
31
|
|
32
|
private static MediaEditorInput instance;
|
33
|
|
34
|
public static String getID() {
|
35
|
return ID;
|
36
|
}
|
37
|
|
38
|
public static AbstractBulkEditorInput getInstance() {
|
39
|
if (instance == null) {
|
40
|
instance = new MediaEditorInput();
|
41
|
}
|
42
|
return instance;
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
public String getName() {
|
47
|
return BulkEditorInputType.MEDIA.label;
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
public String getToolTipText() {
|
52
|
return getName();
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public Media save(Media entity) {
|
57
|
if(CdmStore.getCurrentSessionManager().isRemoting()) {
|
58
|
return CdmStore.getService(IMediaService.class).merge(entity, true).getMergedEntity();
|
59
|
} else {
|
60
|
CdmStore.getService(IMediaService.class).saveOrUpdate(entity) ;
|
61
|
return entity;
|
62
|
}
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
public boolean delete(Media entity) throws ReferencedObjectUndeletableException {
|
67
|
return CdmStore.getService(IMediaService.class).delete(entity) != null;
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
protected List<Media> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
|
72
|
return CdmStore.getSearchManager().findMedia(configurator);
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
protected IEntityCreator<Media> createEntityCreator() {
|
77
|
return new MediaCreator();
|
78
|
}
|
79
|
|
80
|
@Override
|
81
|
public void merge() {
|
82
|
// TODO Auto-generated method stub
|
83
|
|
84
|
}
|
85
|
|
86
|
@Override
|
87
|
public List<IBulkEditorSortProvider<Media>> getSortProviders() {
|
88
|
List<IBulkEditorSortProvider<Media>> sortProviders = super.getSortProviders();
|
89
|
|
90
|
sortProviders.add(0, new IdentifiableEntitySortProvider<Media>());
|
91
|
|
92
|
return sortProviders;
|
93
|
}
|
94
|
}
|