Example usage for org.joda.time LocalDateTime LocalDateTime

List of usage examples for org.joda.time LocalDateTime LocalDateTime

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime LocalDateTime.

Prototype

public LocalDateTime() 

Source Link

Document

Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.

Usage

From source file:se.inera.intyg.intygstjanst.web.service.impl.CertificateServiceImpl.java

License:Open Source License

@Override
@Transactional/*from w  w  w .ja v a  2 s. c om*/
public void certificateReceived(CertificateHolder certificateHolder)
        throws CertificateAlreadyExistsException, InvalidCertificateException {
    LOG.debug("Certificate received {}", certificateHolder.getId());
    Certificate certificate = storeCertificate(certificateHolder);
    LOG.debug("Certificate stored {}", certificateHolder.getId());
    monitoringLogService.logCertificateRegistered(certificate.getId(), certificate.getType(),
            certificate.getCareUnitId());

    if (certificateHolder.isWireTapped()) {
        Personnummer personnummer = certificateHolder.getCivicRegistrationNumber();
        String certificateId = certificateHolder.getId();
        final String recipient = "FK";
        setCertificateState(personnummer, certificateId, recipient, CertificateState.SENT, new LocalDateTime());
        monitoringLogService.logCertificateSentAndNotifiedByWiretapping(certificate.getId(),
                certificate.getType(), certificate.getCareUnitId(), recipient);
    }

    statisticsService.created(certificate);

    /**
     * TODO INTYG-2042: This code below should be uncommented and used immediately when the statistics service has
     * been updated accordingly.
     * String transformedXml = certificateReceivedForStatistics(certificateHolder);
     * statisticsService.created(transformedXml, certificate.getId(), certificate.getType(),
     * certificate.getCareUnitId());
     **/

    sjukfallCertificateService.created(certificate);

}

From source file:se.inera.intyg.intygstjanst.web.service.impl.CertificateServiceImpl.java

License:Open Source License

/**
 * TODO INTYG-2042: This code should be uncommented and used immediately when the statistics service has been
 * updated accordingly.//from w w w .j ava2 s.  co  m
 * private String certificateReceivedForStatistics(CertificateHolder certificateHolder)
 * throws CertificateAlreadyExistsException, InvalidCertificateException {
 * try {
 * ModuleApi moduleApi = moduleRegistry.getModuleApi(certificateHolder.getType());
 * String resultXml = moduleApi.transformToStatisticsService(certificateHolder.getOriginalCertificate());
 * return resultXml;
 * } catch (ModuleNotFoundException | ModuleException e) {
 * LOG.error("Module not found for certificate of type {}", certificateHolder.getType());
 * throw Throwables.propagate(e);
 * }
 * }
 **/

@VisibleForTesting
Certificate storeCertificate(CertificateHolder certificateHolder)
        throws CertificateAlreadyExistsException, InvalidCertificateException {
    Certificate certificate = ConverterUtil.toCertificate(certificateHolder);

    // ensure that certificate does not exist yet
    try {
        checkForExistingCertificate(certificate.getId(), certificate.getCivicRegistrationNumber());
    } catch (PersistenceException e) {
        throw new InvalidCertificateException(certificate.getId(), certificate.getCivicRegistrationNumber());
    }

    // add initial RECEIVED state using current time as receiving timestamp
    CertificateStateHistoryEntry state = new CertificateStateHistoryEntry(HVTARGET, CertificateState.RECEIVED,
            new LocalDateTime());
    certificate.addState(state);
    certificateDao.store(certificate);
    storeOriginalCertificate(certificateHolder.getOriginalCertificate(), certificate);
    return certificate;
}

From source file:todolist.ui.controllers.SettingsController.java

/**
 * isWithinWeek/*from  ww w  . j av a  2 s  .c o m*/
 * 
 * @param startOfWeek
 * @param endOfWeek
 * @param endTime
 * @return boolean
 */
private boolean isWithinWeek(LocalDateTime startOfWeek, LocalDateTime endOfWeek,
        java.time.LocalDateTime endTime) {

    int millis = 0;
    int seconds = endTime.getSecond();
    int minutes = endTime.getMinute();
    int hours = endTime.getHour();
    int day = endTime.getDayOfMonth();
    int month = endTime.getMonthValue();
    int year = endTime.getYear();

    LocalDateTime endTimeFormatted = new LocalDateTime();
    endTimeFormatted = endTimeFormatted.withDate(year, month, day);
    endTimeFormatted = endTimeFormatted.withTime(hours, minutes, seconds, millis);

    return endTimeFormatted.isAfter(startOfWeek) && endTimeFormatted.isBefore(endOfWeek);
}

From source file:uk.co.onehp.trickle.controller.domain.DomainControllerImpl.java

License:Open Source License

private List<Bet> betsFromTodayOrLater(List<Bet> bets) {
    List<Bet> filteredBets;
    filteredBets = Lists.newArrayList(Iterables.filter(bets, new Predicate<Bet>() {
        @Override/*from   www. j a  v  a2s.  c o  m*/
        public boolean apply(Bet bet) {
            return bet.getHorse().getRace().getStartTime()
                    .isAfter(new LocalDateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0));
        }
    }));
    return filteredBets;
}

From source file:uk.co.onehp.trickle.dao.HibernateBetDao.java

License:Open Source License

@Override
public List<Bet> getBetsToPlace() {
    List<Bet> bets = incompleteBets();
    List<Bet> filteredBets;
    filteredBets = Lists.newArrayList(Iterables.filter(bets, new Predicate<Bet>() {
        @Override// w w  w. j  a  v  a 2 s .c o  m
        public boolean apply(Bet bet) {
            return new LocalDateTime().isAfter(bet.getHorse().getRace().getStartTime()
                    .minusSeconds(DateUtil.getMostSeconds(bet.getUnprocessedTimings())));
        }
    }));
    return filteredBets;
}

From source file:uk.co.onehp.trickle.dao.HibernateBetDao.java

License:Open Source License

@Override
public List<Bet> getUpcomingBetsToPlace() {
    List<Bet> bets = incompleteBets();
    List<Bet> filteredBets;
    filteredBets = Lists.newArrayList(Iterables.filter(bets, new Predicate<Bet>() {
        @Override//from  w  w w . j  a v  a  2  s .c o m
        public boolean apply(Bet bet) {
            return new LocalDateTime().isAfter(bet.getHorse().getRace().getStartTime()
                    .minusSeconds(DateUtil.getMostSeconds(bet.getUnprocessedTimings())
                            + HibernateBetDao.this.upcomingBetsSeconds));
        }
    }));
    return filteredBets;
}

From source file:uk.co.onehp.trickle.dao.HibernateMarketDaoCustomT.java

License:Open Source License

@Ignore
public static void main(final String[] args) {
    final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "classpath:/spring-trickle.xml");
    final MarketDao marketDao = (MarketDao) applicationContext.getBean("marketDao");
    final HorseDao horseDao = (HorseDao) applicationContext.getBean("horseDao");

    final Market market = new Market(7483, "Market");
    final Meeting meeting = new Meeting(234, "Meeting");
    final Race race = new Race(867, "Race", new LocalDateTime(), "meeting");
    final Horse horse = new Horse();
    final Pricing pricing = new Pricing(new BigDecimal("3.45"), new BigDecimal("3090.96"), BettingAspect.BACK);

    horse.setRunnerId(441);//from  w w  w.  j  a v a 2s.  c o m
    horse.setRaceId(867);
    horse.setRace(race);
    horse.setPrices(Lists.newArrayList(pricing));

    race.addHorse(horse);

    meeting.addRace(race);

    market.addMeeting(meeting);

    marketDao.saveOrUpdate(market);
    System.out.println(marketDao.getMarket(7483));
}

From source file:uk.co.onehp.trickle.dao.HibernateSessionTokenDaoCustomT.java

License:Open Source License

@Ignore
public static void main(final String[] args) {
    final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "classpath:/spring-trickle.xml");
    final SessionTokenDao dao = (SessionTokenDao) applicationContext.getBean("sessionTokenDao");

    final SessionToken token = new SessionToken();
    token.setSessionType(SessionType.GLOBAL);
    token.setToken("kjngshjgsdlhkjn");
    token.setUpdatedDateTime(new LocalDateTime());

    dao.saveOrUpdate(token);//from   w ww  . j a va  2s .c  om

    final SessionToken result = dao.getSessionToken(SessionType.GLOBAL);
    System.out.println(result);

    result.setToken("sdgnsdlgsgdsag");
    result.setUpdatedDateTime(new LocalDateTime());

    dao.saveOrUpdate(result);

    final SessionToken result2 = dao.getSessionToken(SessionType.GLOBAL);
    System.out.println(result2);
}

From source file:uk.co.onehp.trickle.domain.SessionToken.java

License:Open Source License

public void updateToken(String token) {
    this.token = token;
    updatedDateTime = new LocalDateTime();
}

From source file:uk.co.onehp.trickle.services.betfair.BetfairServiceImpl.java

License:Open Source License

private PlaceBets createLimitedSPBet(Bet bet, BigDecimal liability) {
    BigDecimal price = (bet.getStrategy().getAspect() == BettingAspect.BACK ? bet.getStrategy().getMinOdds()
            : bet.getStrategy().getMaxOdds());
    bet.addLog(new BetLog(new LocalDateTime(), liability, price, BetType.LIMITED_SP));
    this.domainService.updateBet(bet);
    PlaceBets placeBets = new PlaceBets();
    placeBets.setBetType(bet.getStrategy().getAspect() == BettingAspect.BACK ? BetTypeEnum.B : BetTypeEnum.L);
    placeBets.setBetCategoryType(BetCategoryTypeEnum.L);
    placeBets.setBetPersistenceType(BetPersistenceTypeEnum.NONE);
    placeBets.setMarketId(bet.getHorse().getRaceId());
    placeBets.setSelectionId(bet.getHorse().getRunnerId());
    placeBets.setBspLiability(liability.doubleValue());
    placeBets.setSize(bet.getStrategy().getAspect() == BettingAspect.BACK ? liability.doubleValue()
            : BettingUtil.libilityToStake(liability, price).doubleValue());
    placeBets.setPrice(price.doubleValue());
    return placeBets;
}