1
|
/**
|
2
|
* Copyright (C) 2016 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.bulkeditor.input;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.Arrays;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.IMediaService;
|
17
|
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
|
18
|
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
|
19
|
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
|
20
|
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
|
21
|
import eu.etaxonomy.cdm.model.media.Media;
|
22
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
23
|
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
|
24
|
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.MediaCreator;
|
25
|
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
|
26
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
27
|
|
28
|
/**
|
29
|
* @author k.luther
|
30
|
* @date 10.03.2016
|
31
|
*
|
32
|
*/
|
33
|
public class MediaEditorInput extends AbstractBulkEditorInput<Media> {
|
34
|
public static final String ID = "bulkeditor.input.media";
|
35
|
|
36
|
private static MediaEditorInput instance;
|
37
|
|
38
|
public static String getID() {
|
39
|
return ID;
|
40
|
}
|
41
|
|
42
|
public static AbstractBulkEditorInput getInstance() {
|
43
|
if (instance == null) {
|
44
|
instance = new MediaEditorInput();
|
45
|
}
|
46
|
return instance;
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
protected List<String> getPropertyKeys_internal() {
|
51
|
List<String> propertyKeysInternal = new ArrayList<>();
|
52
|
return propertyKeysInternal;
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public String getName() {
|
57
|
return BulkEditorInputType.MEDIA.label;
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public Media save(Media entity) {
|
62
|
return CdmStore.getService(IMediaService.class).merge(entity, true).getMergedEntity();
|
63
|
|
64
|
}
|
65
|
|
66
|
@Override
|
67
|
public boolean delete(Media entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
|
68
|
MediaDeletionConfigurator mediaConfig = null;
|
69
|
if (config instanceof MediaDeletionConfigurator){
|
70
|
mediaConfig = (MediaDeletionConfigurator) config;
|
71
|
} else{
|
72
|
|
73
|
}
|
74
|
return CdmStore.getService(IMediaService.class).delete(entity.getUuid(), mediaConfig) != null;
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) {
|
79
|
return CdmStore.getService(IMediaService.class).countByTitle(configurator);
|
80
|
}
|
81
|
|
82
|
@Override
|
83
|
protected List<Media> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
|
84
|
return CdmStore.getSearchManager().findMedia(configurator);
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
protected IEntityCreator<Media> createEntityCreator() {
|
89
|
return new MediaCreator();
|
90
|
}
|
91
|
|
92
|
@Override
|
93
|
public void merge() {
|
94
|
// TODO Auto-generated method stub
|
95
|
|
96
|
}
|
97
|
|
98
|
@Override
|
99
|
public List<IBulkEditorSortProvider<Media>> getSortProviders() {
|
100
|
List<IBulkEditorSortProvider<Media>> sortProviders = super.getSortProviders();
|
101
|
|
102
|
sortProviders.add(0, new IdentifiableEntitySortProvider<Media>());
|
103
|
|
104
|
return sortProviders;
|
105
|
}
|
106
|
|
107
|
@Override
|
108
|
protected Media loadEntity(UUID entityUuid) {
|
109
|
List<String> propertyPaths = Arrays.asList(new String[]{});
|
110
|
return CdmStore.getService(IMediaService.class).load(entityUuid, propertyPaths);
|
111
|
}
|
112
|
|
113
|
}
|