Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. ------
  2.     @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  3.     @ResponseBody
  4.     public PersonRestRepresentation getPerson(@PathVariable("id") final String id, final HttpServletRequest servletRequest) {
  5.  
  6.         final UUID faceId = UUID.fromString(id);
  7.  
  8.         final Recognizeable person = faceLibraryService.findOne(faceId).get();
  9.  
  10.         if (person != null) {
  11.  
  12.             final List<RecognizeableReference> faces = faceLibraryService.getImagesForFaceId(person.getId());
  13.  
  14.             final PersonRestRepresentation restRepresentation = new PersonRestRepresentation();
  15.  
  16.             restRepresentation.setName(person.getName());
  17.             restRepresentation.setId(id);
  18.  
  19.             final List<PersonImageRestRepresentation> images = fromRecognizeableReferences(person, faces, servletRequest);
  20.  
  21.             restRepresentation.setImages(images);
  22.  
  23.             return restRepresentation;
  24.         }
  25.  
  26.         //Return empty
  27.         return new PersonRestRepresentation();
  28.     }
  29.  
  30. ----
  31.  
  32. private List<PersonImageRestRepresentation> fromRecognizeableReferences(final Recognizeable face, final List<RecognizeableReference> recognizeableReferences, final HttpServletRequest servletRequest) {
  33.  
  34.         return Utils.asSeq(recognizeableReferences)
  35.                 .map(recognizeableReference -> RecognizeableReferenceRequestEnricher.enrichRecognizeableReference(servletRequest, recognizeableReference))
  36.                 .map(imageTransformer::toModel)
  37.                 .map(personImageRestRepresentation -> {
  38.  
  39.                     personImageRestRepresentation.setPersonId(face.getId().getValue().toString());
  40.                     personImageRestRepresentation.setCreatedAt("date1");
  41.                     personImageRestRepresentation.setUpdatedAt("date2");
  42.  
  43.                     return personImageRestRepresentation;
  44.  
  45.                 }).asJava();
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement