1
|
/**
|
2
|
* Copyright (C) 2013 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.cdm.persistence.dao.initializer;
|
10
|
|
11
|
import java.util.Optional;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.media.Media;
|
14
|
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
|
15
|
|
16
|
|
17
|
/**
|
18
|
* @author a.kohlbecker
|
19
|
* @since Jan 15, 2013
|
20
|
*
|
21
|
*/
|
22
|
public class MediaAutoInitializer extends AutoPropertyInitializer<Media> {
|
23
|
|
24
|
@Override
|
25
|
public void initialize(Media bean) {
|
26
|
beanInitializer.initializeInstance(bean.getAllTitles());
|
27
|
beanInitializer.initializeInstance(bean.getAllDescriptions());
|
28
|
for (MediaRepresentation r : bean.getRepresentations()){
|
29
|
beanInitializer.initializeInstance(r.getParts());
|
30
|
}
|
31
|
}
|
32
|
|
33
|
|
34
|
@Override
|
35
|
public Optional<String> hibernateFetchJoin(Class<?> clazz, String beanAlias){
|
36
|
return Optional.of(String.format(" LEFT JOIN FETCH %1$s.representations r LEFT JOIN FETCH %1$s.title LEFT JOIN FETCH r.mediaRepresentationParts ", beanAlias));
|
37
|
}
|
38
|
}
|