Revision f2babe22
Added by Andreas Kohlbecker almost 8 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationController.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.remote.controller; |
11 | 11 |
|
12 |
import io.swagger.annotations.Api; |
|
13 |
|
|
12 | 14 |
import java.io.IOException; |
13 | 15 |
import java.util.Arrays; |
14 | 16 |
import java.util.List; |
15 | 17 |
import java.util.UUID; |
16 | 18 |
|
19 |
import javax.servlet.http.HttpServletRequest; |
|
17 | 20 |
import javax.servlet.http.HttpServletResponse; |
18 | 21 |
|
19 | 22 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
35 | 38 |
import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor; |
36 | 39 |
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor; |
37 | 40 |
import eu.etaxonomy.cdm.remote.editor.UuidList; |
38 |
import io.swagger.annotations.Api; |
|
39 | 41 |
|
40 | 42 |
/** |
41 | 43 |
* @author a.kohlbecker |
... | ... | |
80 | 82 |
* @param response |
81 | 83 |
* @return |
82 | 84 |
* @throws IOException |
85 |
* |
|
83 | 86 |
*/ |
84 | 87 |
@RequestMapping( |
85 | 88 |
value = {"childNodes"}, |
86 | 89 |
method = RequestMethod.GET) |
87 | 90 |
public List<TaxonNode> getChildNodes( |
88 | 91 |
@PathVariable("uuid") UUID classificationUuid, |
92 |
HttpServletRequest request, |
|
89 | 93 |
HttpServletResponse response |
90 | 94 |
) throws IOException { |
91 | 95 |
|
92 |
return getChildNodesAtRank(classificationUuid, null, response); |
|
96 |
return getChildNodesAtRank(classificationUuid, null, request, response);
|
|
93 | 97 |
} |
94 | 98 |
|
95 | 99 |
@RequestMapping( |
... | ... | |
98 | 102 |
public List<TaxonNode> getChildNodesAtRank( |
99 | 103 |
@PathVariable("uuid") UUID classificationUuid, |
100 | 104 |
@PathVariable("rankUuid") UUID rankUuid, |
105 |
HttpServletRequest request, |
|
101 | 106 |
HttpServletResponse response |
102 | 107 |
) throws IOException { |
103 | 108 |
|
104 |
logger.info("getChildNodesAtRank()"); |
|
105 |
Classification tree = null; |
|
106 |
Rank rank = null; |
|
107 |
if(classificationUuid != null){ // FIXME this never should happen!!!! |
|
108 |
// get view and rank |
|
109 |
tree = service.find(classificationUuid); |
|
109 |
logger.info("getChildNodesAtRank() - " + request.getRequestURI()); |
|
110 | 110 |
|
111 |
if(tree == null) { |
|
112 |
response.sendError(404 , "Classification not found using " + classificationUuid ); |
|
113 |
return null; |
|
114 |
} |
|
111 |
Classification classification = service.find(classificationUuid); |
|
112 |
|
|
113 |
if(classification == null) { |
|
114 |
response.sendError(404 , "Classification not found using " + classificationUuid ); |
|
115 |
return null; |
|
115 | 116 |
} |
116 |
rank = findRank(rankUuid); |
|
117 |
Rank rank = findRank(rankUuid);
|
|
117 | 118 |
|
118 | 119 |
// long start = System.currentTimeMillis(); |
119 |
List<TaxonNode> rootNodes = service.listRankSpecificRootNodes(tree, rank, null, null, NODE_INIT_STRATEGY());
|
|
120 |
List<TaxonNode> rootNodes = service.listRankSpecificRootNodes(classification, rank, null, null, NODE_INIT_STRATEGY());
|
|
120 | 121 |
// System.err.println("service.listRankSpecificRootNodes() " + (System.currentTimeMillis() - start)); |
121 | 122 |
|
122 | 123 |
return rootNodes; |
... | ... | |
149 | 150 |
@RequestParam(value = "taxonUuids", required = true) UuidList taxonUuids, |
150 | 151 |
@RequestParam(value = "minRankUuid", required = false) UUID minRankUuid, |
151 | 152 |
@RequestParam(value = "maxRankUuid", required = false) UUID maxRankUuid, |
153 |
HttpServletRequest request, |
|
152 | 154 |
HttpServletResponse response |
153 | 155 |
) throws IOException { |
154 | 156 |
|
155 |
logger.info("getGroupedTaxaByHigherTaxon()"); |
|
156 |
Classification classification = null; |
|
157 |
|
|
158 |
if(classificationUuid != null){ // FIXME this never should happen!!!! |
|
159 |
// get view and rank |
|
160 |
classification = service.find(classificationUuid); |
|
157 |
logger.info("getGroupedTaxaByHigherTaxon() - " + request.getRequestURI()); |
|
161 | 158 |
|
162 |
if(classification == null) {
|
|
163 |
response.sendError(404 , "Classification not found using " + classificationUuid );
|
|
164 |
return null;
|
|
165 |
}
|
|
159 |
Classification classification = service.find(classificationUuid);
|
|
160 |
if(classification == null) {
|
|
161 |
response.sendError(404 , "Classification not found using " + classificationUuid );
|
|
162 |
return null;
|
|
166 | 163 |
} |
167 | 164 |
|
165 |
|
|
168 | 166 |
Rank minRank = findRank(minRankUuid); |
169 | 167 |
Rank maxRank = findRank(maxRankUuid); |
170 | 168 |
|
Also available in: Unified diff
cleaning up and hamonizing contoller code