@Transactional
  public ArrayList<Point> getTrackById(long id) {
    ArrayList<Point> list = new ArrayList<Point>();
    if (postsRepo.findOne(id) != null) {
      list = postsRepo.findOne(id).getTrack();
    }

    return list;
  }
  @Transactional
  public ArrayList<Post> getPosts() {
    ArrayList<Post> list = new ArrayList<Post>();
    if (postsRepo.findAll() != null) {
      for (Post e : postsRepo.findAll()) {
        list.add(e);
      }
    }

    return list;
  }
 @Transactional
 public void addPost(
     String title, String text, Long partners, Long days, Date mdate, ArrayList<Point> track) {
   User currentUser = usersRepo.findOne(User.getCurrentUserId());
   // Post p = new Post(currentUser, title, text, partners, days, mdate, new Date()));
   Post p = new Post(currentUser, title, text, partners, days, new Date(), new Date(), track);
   postsRepo.save(p);
 }
 @Transactional
 public HashMap<Long, MarkerData> getTracks() {
   HashMap<Long, MarkerData> list = new HashMap<>();
   for (Post e : postsRepo.findAll()) {
     Calendar c = Calendar.getInstance();
     c.setTime(e.getMdate());
     c.add(Calendar.DATE, toIntExact(e.getDays())); // number of days to add
     if (e != null && c.getTime().after(e.getMdate())) {
       MarkerData data = new MarkerData(e.getTrack().get(e.getTrack().size() - 1), "ava1.jpg");
       list.put(e.getId(), data);
     }
   }
   return list;
 }
 @Transactional
 public ArrayList<Point> getLinesById(Long id) {
   ArrayList<Point> list = new ArrayList<>();
   Post post = postsRepo.findOne(id);
   if (post != null) {
     return post.getTrack();
   }
   /*	for(Post e: postsRepo.findAll()) {
   	Calendar c = Calendar.getInstance();
   	c.setTime(e.getMdate());
   	c.add(Calendar.DATE, toIntExact(e.getDays()));  // number of days to add
   	if(e != null && c.getTime().after(e.getMdate())) {
   		list.put(e.getId(), e.getTrack().get(e.getTrack().size() - 1));
   	}
   }*/
   return list;
 }
  @Transactional
  public ArrayList<Post> getSort() {

    return (ArrayList<Post>)
        postsRepo.findAll(new Sort(Sort.Direction.DESC, "id")); // spring рахує сторінки з нуля
  }
  @Transactional
  public Page<Post> getPosts(int page, int pageSize) {

    return postsRepo.findAll(new PageRequest(page - 1, pageSize)); // spring рахує сторінки з нуля
  }
 @Transactional
 public ArrayList<Post> findPosts(long id) {
   return postsRepo.findPosts(id);
 }
 @Transactional
 public Post getPostById(Long Id) {
   return postsRepo.findOne(Id);
 }