1
|
/**
|
2
|
* Copyright (C) 2007 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.remote.dto.assembler;
|
10
|
|
11
|
import java.util.Enumeration;
|
12
|
import java.util.Locale;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
import org.springframework.stereotype.Component;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.media.Media;
|
19
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
20
|
import eu.etaxonomy.cdm.remote.dto.IReferenceSTO;
|
21
|
import eu.etaxonomy.cdm.remote.dto.ReferenceSTO;
|
22
|
import eu.etaxonomy.cdm.remote.dto.ReferenceTO;
|
23
|
|
24
|
@Component
|
25
|
public class ReferenceAssembler extends AssemblerBase<ReferenceSTO, ReferenceTO, ReferenceBase> {
|
26
|
static Logger logger = Logger.getLogger(ReferenceAssembler.class);
|
27
|
|
28
|
@Autowired
|
29
|
private MediaAssembler mediaAssembler;
|
30
|
|
31
|
public ReferenceSTO getSTO(ReferenceBase rb, Enumeration<Locale> locales){
|
32
|
ReferenceSTO r = null;
|
33
|
if (rb !=null){
|
34
|
r = new ReferenceSTO();
|
35
|
fillReferenceSTO(r,rb, locales);
|
36
|
//TODO: add STO specific mappings here
|
37
|
}
|
38
|
return r;
|
39
|
}
|
40
|
|
41
|
public ReferenceTO getTO(ReferenceBase rb, Enumeration<Locale> locales){
|
42
|
ReferenceTO r = null;
|
43
|
if (rb !=null){
|
44
|
r = new ReferenceTO();
|
45
|
fillReferenceSTO(r,rb, locales);
|
46
|
r.setCitation(rb.getCitation());
|
47
|
//TODO: add TO specific mappings here
|
48
|
}
|
49
|
return r;
|
50
|
}
|
51
|
|
52
|
private IReferenceSTO fillReferenceSTO(IReferenceSTO r, ReferenceBase rb, Enumeration<Locale> locales){
|
53
|
setVersionableEntity(rb, r);
|
54
|
if (rb.getAuthorTeam() != null){
|
55
|
r.setAuthorship(rb.getAuthorTeam().getTitleCache());
|
56
|
}
|
57
|
for (Media m : rb.getMedia()){
|
58
|
r.addMedia(mediaAssembler.getSTO(m, locales));
|
59
|
}
|
60
|
String fullCitation = rb.getTitleCache();
|
61
|
//TODO compile fullCitation using a formatter
|
62
|
r.setFullCitation(fullCitation);
|
63
|
return r;
|
64
|
}
|
65
|
}
|