List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:ru.caramel.juniperbot.module.social.service.impl.YouTubeServiceImpl.java
License:Open Source License
@Override @Transactional/* w w w.j av a 2s .c om*/ public void notifyVideo(String channelId, String videoId) { synchronized (videoCache) { if (videoCache.getIfPresent(videoId) != null) { return; // do not notify this video again } videoCache.put(videoId, videoId); } try { Video video = getVideoById(videoId, "id,snippet"); if (video == null) { log.error("No suitable video found for id={}", videoId); return; } if (video.getSnippet() != null && video.getSnippet().getPublishedAt() != null) { var publishedAt = video.getSnippet().getPublishedAt(); LocalDate dateTime = new DateTime(publishedAt.getValue()).toLocalDate(); if (Days.daysBetween(dateTime, LocalDate.now()).getDays() >= 1) { return; } } repository.findActiveConnections(channelId).forEach(e -> notifyConnection(video, e)); } catch (Exception e) { videoCache.invalidate(videoId); throw e; } }
From source file:ru.caramel.juniperbot.module.social.service.impl.YouTubeServiceImpl.java
License:Open Source License
@Override @Transactional/*from w ww .j a v a 2 s. c o m*/ public void subscribe(YouTubeChannel channel) { LocalDate now = LocalDate.now(); LocalDate expiredAt = channel.getExpiresAt() != null ? LocalDate.fromDateFields(channel.getExpiresAt()) : LocalDate.now(); if (now.isBefore(expiredAt)) { return; } HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); map.add("hub.callback", String.format("%s/api/public/youtube/callback/publish?secret=%s&channel=%s", brandingService.getWebHost(), pubSubSecret, CommonUtils.urlEncode(channel.getChannelId()))); map.add("hub.topic", CHANNEL_RSS_ENDPOINT + channel.getChannelId()); map.add("hub.mode", "subscribe"); map.add("hub.verify", "async"); map.add("hub.verify_token", pubSubSecret); HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers); ResponseEntity<String> response = restTemplate.postForEntity(PUSH_ENDPOINT, request, String.class); if (!response.getStatusCode().is2xxSuccessful()) { throw new IllegalStateException("Could not subscribe to " + channel.getChannelId()); } channel.setExpiresAt(DateTime.now().plusDays(7).toDate()); channelRepository.save(channel); }
From source file:ru.codemine.ccms.dao.ActionEventDAOImpl.java
License:Open Source License
@Override public List<ActionEvent> getActiveEvents() { Query query = getSession()// w w w. j ava 2s. co m .createQuery("FROM ActionEvent a " + "WHERE a.startDate <= :now " + "AND a.endDate >= :now"); query.setDate("now", LocalDate.now().toDate()); return query.list(); }
From source file:ru.codemine.ccms.dao.ActionEventDAOImpl.java
License:Open Source License
@Override public List<ActionEvent> getActiveEvents(Shop shop) { Query query = getSession().createQuery("FROM ActionEvent a " + "WHERE a.startDate <= :now " + "AND a.endDate >= :now " + "AND :shop IN ELEMENTS(a.affectedShops)"); query.setDate("now", LocalDate.now().toDate()); query.setParameter("shop", shop); return query.list(); }
From source file:ru.codemine.ccms.dao.ActionEventDAOImpl.java
License:Open Source License
@Override public List<ActionEvent> getCurrentFuture() { Query query = getSession().createQuery("FROM ActionEvent a " + "WHERE a.endDate >= :now"); query.setDate("now", LocalDate.now().toDate()); return query.list(); }
From source file:ru.codemine.ccms.entity.ActionEvent.java
License:Open Source License
public ActionEvent() { this.title = ""; this.description = ""; this.creationTime = DateTime.now(); this.startDate = LocalDate.now(); this.endDate = LocalDate.now(); this.affectedShops = new LinkedHashSet<>(); this.files = new LinkedHashSet<>(); this.comments = new LinkedHashSet<>(); this.notificationSent = false; }
From source file:ru.codemine.ccms.entity.ActionEvent.java
License:Open Source License
public ActionEvent(Employee creator) { this.title = ""; this.description = ""; this.creator = creator; this.creationTime = DateTime.now(); this.startDate = LocalDate.now(); this.endDate = LocalDate.now(); this.affectedShops = new LinkedHashSet<>(); this.files = new LinkedHashSet<>(); this.comments = new LinkedHashSet<>(); this.notificationSent = false; }
From source file:ru.codemine.ccms.entity.ActionEvent.java
License:Open Source License
public boolean isActive() { return (getStartDate().isBefore(LocalDate.now()) && getEndDate().isAfter(LocalDate.now())); }
From source file:ru.codemine.ccms.entity.SalesMeta.java
License:Open Source License
public SalesMeta() { this.plan = 0.0; this.description = ""; this.startDate = LocalDate.now().withDayOfMonth(1); this.endDate = LocalDate.now().dayOfMonth().withMaximumValue(); this.passabilityTotal = 0; this.chequeCountTotal = 0; this.valueTotal = 0.0; this.cashbackTotal = 0.0; this.salesTotal = 0.0; this.expencesTotal = 0.0; this.expences = new TreeMap<>(); this.sales = new TreeSet<>(); }
From source file:ru.codemine.ccms.entity.SalesMeta.java
License:Open Source License
public SalesMeta(Shop shop) { this.shop = shop; this.description = ""; this.startDate = LocalDate.now().withDayOfMonth(1); this.endDate = LocalDate.now().dayOfMonth().withMaximumValue(); this.plan = 0.0; this.passabilityTotal = 0; this.chequeCountTotal = 0; this.valueTotal = 0.0; this.cashbackTotal = 0.0; this.salesTotal = 0.0; this.expencesTotal = 0.0; this.expences = new TreeMap<>(); this.sales = new TreeSet<>(); for (int i = 1; i <= LocalDate.now().dayOfMonth().getMaximumValue(); i++) { this.sales.add(new Sales(shop, LocalDate.now().withDayOfMonth(i))); }/*from ww w.java 2 s .c o m*/ }