1
|
/**
|
2
|
* Copyright (C) 2009 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.controller.oaipmh;
|
10
|
|
11
|
import static eu.etaxonomy.cdm.remote.dto.oaipmh.MetadataPrefix.DWC;
|
12
|
import io.swagger.annotations.Api;
|
13
|
|
14
|
import java.util.Arrays;
|
15
|
import java.util.HashSet;
|
16
|
import java.util.List;
|
17
|
import java.util.Set;
|
18
|
|
19
|
import org.springframework.beans.factory.annotation.Autowired;
|
20
|
import org.springframework.stereotype.Controller;
|
21
|
import org.springframework.web.bind.annotation.RequestMapping;
|
22
|
import org.springframework.web.servlet.ModelAndView;
|
23
|
|
24
|
import eu.etaxonomy.cdm.api.service.IReferenceService;
|
25
|
import eu.etaxonomy.cdm.model.common.LSID;
|
26
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
27
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
28
|
import eu.etaxonomy.cdm.model.view.AuditEventRecord;
|
29
|
import eu.etaxonomy.cdm.remote.controller.IdDoesNotExistException;
|
30
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.MetadataPrefix;
|
31
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.SetSpec;
|
32
|
|
33
|
@Controller
|
34
|
@Api("OAI-PMH References")
|
35
|
@RequestMapping(value = "/reference/oai", params = "verb")
|
36
|
public class ReferenceOaiPmhController extends AbstractOaiPmhController<Reference, IReferenceService> {
|
37
|
|
38
|
@Override
|
39
|
protected List<String> getPropertyPaths() {
|
40
|
return Arrays.asList(new String []{
|
41
|
"$",
|
42
|
"inBook.authorship",
|
43
|
"inJournal",
|
44
|
"inProceedings",
|
45
|
});
|
46
|
}
|
47
|
|
48
|
private static final List<String> TAXON_INIT_STRATEGY = Arrays.asList(new String []{
|
49
|
"titleCache",
|
50
|
"name.titleCache",
|
51
|
"name.nomenclaturalSource.citation.titleCache",
|
52
|
"$"
|
53
|
});
|
54
|
|
55
|
@Override
|
56
|
protected void addSets(ModelAndView modelAndView) {
|
57
|
Set<SetSpec> sets = new HashSet<SetSpec>();
|
58
|
sets.add(SetSpec.REFERENCE);
|
59
|
modelAndView.addObject("sets",sets);
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
@Autowired
|
64
|
public void setService(IReferenceService service) {
|
65
|
this.service = service;
|
66
|
}
|
67
|
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see eu.etaxonomy.cdm.remote.controller.AbstractOaiPmhController#finishModelAndView(eu.etaxonomy.cdm.model.common.LSID, eu.etaxonomy.cdm.remote.dto.oaipmh.MetadataPrefix, org.springframework.web.servlet.ModelAndView)
|
71
|
*/
|
72
|
@Override
|
73
|
protected void finishModelAndView(LSID identifier,
|
74
|
MetadataPrefix metadataPrefix, ModelAndView modelAndView)
|
75
|
throws IdDoesNotExistException {
|
76
|
|
77
|
if(metadataPrefix.equals(DWC)){
|
78
|
modelAndView.addObject("entitylist", obtainCoveredTaxaList(identifier, metadataPrefix));
|
79
|
modelAndView.setViewName("oai/getRecord.dwc");
|
80
|
} else {
|
81
|
super.finishModelAndView(identifier, metadataPrefix, modelAndView);
|
82
|
}
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* @param identifier
|
87
|
* @param metadataPrefix
|
88
|
* @return
|
89
|
* @throws IdDoesNotExistException
|
90
|
*/
|
91
|
private List<TaxonBase> obtainCoveredTaxaList(
|
92
|
LSID identifier, MetadataPrefix metadataPrefix)
|
93
|
throws IdDoesNotExistException {
|
94
|
|
95
|
AuditEventRecord<Reference> auditEventRecord = obtainCdmEntity(identifier);
|
96
|
Reference reference = auditEventRecord.getAuditableObject();
|
97
|
List<TaxonBase> list = service.listCoveredTaxa(reference, true, TAXON_INIT_STRATEGY);
|
98
|
return list;
|
99
|
}
|
100
|
|
101
|
|
102
|
|
103
|
}
|