Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- @ResponseBody
- public PersonRestRepresentation getPerson(@PathVariable("id") final String id, final HttpServletRequest servletRequest) {
- final UUID faceId = UUID.fromString(id);
- final Recognizeable person = faceLibraryService.findOne(faceId).get();
- if (person != null) {
- final List<RecognizeableReference> faces = faceLibraryService.getImagesForFaceId(person.getId());
- final PersonRestRepresentation restRepresentation = new PersonRestRepresentation();
- restRepresentation.setName(person.getName());
- restRepresentation.setId(id);
- final List<PersonImageRestRepresentation> images = fromRecognizeableReferences(person, faces, servletRequest);
- restRepresentation.setImages(images);
- return restRepresentation;
- }
- //Return empty
- return new PersonRestRepresentation();
- }
- ----
- private List<PersonImageRestRepresentation> fromRecognizeableReferences(final Recognizeable face, final List<RecognizeableReference> recognizeableReferences, final HttpServletRequest servletRequest) {
- return Utils.asSeq(recognizeableReferences)
- .map(recognizeableReference -> RecognizeableReferenceRequestEnricher.enrichRecognizeableReference(servletRequest, recognizeableReference))
- .map(imageTransformer::toModel)
- .map(personImageRestRepresentation -> {
- personImageRestRepresentation.setPersonId(face.getId().getValue().toString());
- personImageRestRepresentation.setCreatedAt("date1");
- personImageRestRepresentation.setUpdatedAt("date2");
- return personImageRestRepresentation;
- }).asJava();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement