Skip to content
Snippets Groups Projects
Commit 69d668c0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

rest api returns better parsed publication list

parent a7990136
No related branches found
No related tags found
1 merge request!5Frontend refactor
......@@ -77,7 +77,8 @@ public class ProjectController extends BaseController {
@RequestMapping(value = "/getPublications", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public Map<String, Object> getPublications(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "token") String token,
@RequestParam(value = "start", defaultValue = "0") String start, @RequestParam(value = "length", defaultValue = "10") Integer length) throws QueryException, SecurityException {
@RequestParam(value = "start", defaultValue = "0") String start, @RequestParam(value = "length", defaultValue = "10") Integer length)
throws QueryException, SecurityException {
return projectController.getPublications(projectId, token, start, length);
}
......
......@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import lcsb.mapviewer.annotation.services.PubmedParser;
import lcsb.mapviewer.api.QueryException;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.model.Project;
......@@ -67,6 +68,9 @@ public class ProjectRestImpl {
@Autowired
AnnotationViewFactory annotationViewFactory;
@Autowired
private PubmedParser pubmedParser;
@Autowired
private OverviewImageViewFactory factory;
......@@ -498,23 +502,28 @@ public class ProjectRestImpl {
for (Map.Entry<MiriamData, List<AnnotatedObject>> entry : publications.entrySet()) {
if (index >= start && index < start + length) {
List<Object> elements = new ArrayList<>();
for (AnnotatedObject object: entry.getValue()) {
if (object instanceof Element) {
elements.add(preparedElement((Element) object, columns));
} else if (object instanceof Reaction) {
elements.add(preparedReaction((Reaction) object, columns));
}
for (AnnotatedObject object : entry.getValue()) {
elements.add(createMinifiedSearchResult(object));
}
Map<String, Object> row = new HashMap<>();
row.put("elements", elements);
row.put("publication", annotationViewFactory.create(entry.getKey()));
if (entry.getKey().getDataType().equals(MiriamType.PUBMED)) {
try {
row.put("publication", pubmedParser.getPubmedArticleById(Integer.valueOf(entry.getKey().getResource())));
} catch (Exception e) {
logger.error(e, e);
row.put("publication", annotationViewFactory.create(entry.getKey()));
}
} else {
row.put("publication", annotationViewFactory.create(entry.getKey()));
}
resultList.add(row);
}
index++;
}
Map<String, Object> result = new HashMap<>();
result.put("data", resultList);
result.put("totalSize", publications.size());
......@@ -523,4 +532,21 @@ public class ProjectRestImpl {
return result;
}
/**
* @return the pubmedParser
* @see #pubmedParser
*/
public PubmedParser getPubmedParser() {
return pubmedParser;
}
/**
* @param pubmedParser
* the pubmedParser to set
* @see #pubmedParser
*/
public void setPubmedParser(PubmedParser pubmedParser) {
this.pubmedParser = pubmedParser;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment