Revision 56e66046
Added by Andreas Kohlbecker over 13 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrenceController.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
package eu.etaxonomy.cdm.remote.controller; |
12 | 12 |
|
13 |
import java.io.IOException; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import javax.servlet.http.HttpServletRequest; |
|
17 |
import javax.servlet.http.HttpServletResponse; |
|
18 |
|
|
13 | 19 |
import org.springframework.beans.factory.annotation.Autowired; |
14 | 20 |
import org.springframework.stereotype.Controller; |
21 |
import org.springframework.web.bind.annotation.PathVariable; |
|
15 | 22 |
import org.springframework.web.bind.annotation.RequestMapping; |
23 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
24 |
import org.springframework.web.bind.annotation.RequestParam; |
|
25 |
import org.springframework.web.servlet.ModelAndView; |
|
16 | 26 |
|
17 | 27 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
18 | 28 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java | ||
---|---|---|
11 | 11 |
package eu.etaxonomy.cdm.remote.controller; |
12 | 12 |
|
13 | 13 |
import java.io.IOException; |
14 |
import java.util.ArrayList; |
|
14 | 15 |
import java.util.Arrays; |
15 | 16 |
import java.util.HashSet; |
16 | 17 |
import java.util.List; |
... | ... | |
26 | 27 |
import org.springframework.web.bind.annotation.PathVariable; |
27 | 28 |
import org.springframework.web.bind.annotation.RequestMapping; |
28 | 29 |
import org.springframework.web.bind.annotation.RequestMethod; |
30 |
import org.springframework.web.servlet.ModelAndView; |
|
29 | 31 |
|
32 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
30 | 33 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
34 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
31 | 35 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
32 | 36 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
33 | 37 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
34 | 38 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
39 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
|
40 |
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder; |
|
35 | 41 |
|
36 | 42 |
/** |
37 | 43 |
* TODO write controller documentation |
... | ... | |
46 | 52 |
{ |
47 | 53 |
public static final Logger logger = Logger.getLogger(TaxonController.class); |
48 | 54 |
|
55 |
@Autowired |
|
56 |
private IOccurrenceService occurrenceService; |
|
57 |
|
|
49 | 58 |
protected static final List<String> TAXONNODE_INIT_STRATEGY = Arrays.asList(new String []{ |
50 | 59 |
"taxonNodes" |
51 | 60 |
}); |
... | ... | |
111 | 120 |
return null; |
112 | 121 |
} |
113 | 122 |
} |
123 |
|
|
124 |
@RequestMapping(value = "specimensOrObersvations", method = RequestMethod.GET) |
|
125 |
public ModelAndView doListSpecimensOrObersvations( |
|
126 |
@PathVariable("uuid") UUID uuid, |
|
127 |
HttpServletRequest request, |
|
128 |
HttpServletResponse response) throws IOException { |
|
129 |
logger.info("doGetDescriptionElementsByType() - " + request.getServletPath()); |
|
130 |
|
|
131 |
ModelAndView mv = new ModelAndView(); |
|
132 |
|
|
133 |
TaxonBase tb = service.load(uuid); |
|
134 |
|
|
135 |
List<OrderHint> orderHints = new ArrayList<OrderHint>(); |
|
136 |
orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING)); |
|
137 |
|
|
138 |
if(tb instanceof Taxon){ |
|
139 |
List<SpecimenOrObservationBase> specimensOrObersvations = occurrenceService.listByAnyAssociation( |
|
140 |
null, (Taxon)tb, null, 0, orderHints, null); |
|
141 |
mv.addObject(specimensOrObersvations); |
|
142 |
} else { |
|
143 |
HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response); |
|
144 |
return null; |
|
145 |
} |
|
146 |
|
|
147 |
return mv; |
|
148 |
} |
|
114 | 149 |
|
115 | 150 |
} |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ext/ExternalGeoController.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.awt.Color; |
13 | 13 |
import java.io.IOException; |
14 |
import java.util.ArrayList; |
|
14 | 15 |
import java.util.List; |
15 | 16 |
import java.util.Map; |
16 | 17 |
import java.util.UUID; |
... | ... | |
27 | 28 |
import org.springframework.web.servlet.ModelAndView; |
28 | 29 |
|
29 | 30 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
31 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
30 | 32 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
31 | 33 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
32 | 34 |
import eu.etaxonomy.cdm.database.UpdatableRoutingDataSource; |
... | ... | |
37 | 39 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
38 | 40 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
39 | 41 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
42 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
|
43 |
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder; |
|
40 | 44 |
import eu.etaxonomy.cdm.remote.controller.BaseController; |
45 |
import eu.etaxonomy.cdm.remote.controller.HttpStatusMessage; |
|
41 | 46 |
import eu.etaxonomy.cdm.remote.l10n.LocaleContext; |
42 | 47 |
|
43 | 48 |
/** |
... | ... | |
61 | 66 |
|
62 | 67 |
@Autowired |
63 | 68 |
private IEditGeoService geoservice; |
69 |
|
|
64 | 70 |
@Autowired |
65 | 71 |
private IDescriptionService descriptionService; |
72 |
|
|
73 |
@Autowired |
|
74 |
private IOccurrenceService occurrenceService; |
|
66 | 75 |
|
67 | 76 |
/* |
68 | 77 |
* (non-Javadoc) |
... | ... | |
155 | 164 |
// get the descriptions for the taxon |
156 | 165 |
Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null); |
157 | 166 |
|
158 |
Pager<TaxonDescription> page = descriptionService.getTaxonDescriptions(taxon, null, null, null, null, null); |
|
159 |
List<TaxonDescription> taxonDescriptions = page.getRecords(); |
|
167 |
TaxonBase tb = service.load(uuid); |
|
168 |
|
|
169 |
List<OrderHint> orderHints = new ArrayList<OrderHint>(); |
|
170 |
orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING)); |
|
171 |
|
|
172 |
|
|
173 |
List<SpecimenOrObservationBase> specimensOrObersvations = occurrenceService.listByAnyAssociation( |
|
174 |
null, (Taxon)tb, null, 0, orderHints, null); |
|
160 | 175 |
|
161 |
String uriParams = geoservice.getOccurrenceServiceRequestParameterString(taxonDescriptions, specimenOrObservationTypeColors, doReturnImage, width , height , bbox , backLayer );
|
|
176 |
String uriParams = geoservice.getOccurrenceServiceRequestParameterString(specimensOrObersvations, specimenOrObservationTypeColors, doReturnImage, width , height , bbox , backLayer );
|
|
162 | 177 |
mv.addObject(uriParams); |
163 | 178 |
return mv; |
164 | 179 |
} |
Also available in: Unified diff
getting all SpecimenOrObservationBases for a Taxon