List of usage examples for org.joda.time LocalDate toString
public String toString(String pattern)
From source file:ca.ualberta.physics.cssdp.jaxb.LocalDateAdapter.java
License:Apache License
public String marshal(LocalDate v) throws Exception { return v.toString("yyyy-MM-dd"); }
From source file:com.ajah.spring.jdbc.AbstractAjahDao.java
License:Apache License
Object[] getInsertValues(final T entity) { final Object[] values = new Object[getInsertColumns().size()]; try {//from w w w . j a v a 2 s . c o m final BeanInfo componentBeanInfo = Introspector.getBeanInfo(entity.getClass()); final PropertyDescriptor[] props = componentBeanInfo.getPropertyDescriptors(); for (int i = 0; i < values.length; i++) { final Field field = this.colMap.get(this.insertColumns.get(i)); if (field == null) { throw new IllegalArgumentException("Field " + this.insertColumns.get(i) + " not found"); } if (Modifier.isStatic(field.getModifiers())) { continue; } if (LocalDate.class.isAssignableFrom(field.getType())) { final LocalDate localDate = (LocalDate) ReflectionUtils.propGetSafe(entity, getProp(field, props)); if (localDate != null) { values[i] = localDate.toString(LOCAL_DATE_FORMAT); } else { values[i] = null; } } else { values[i] = ReflectionUtils.propGetSafeAuto(entity, field, getProp(field, props)); } if (sqlLog.isLoggable(Level.FINEST)) { log.finest(field.getName() + " set to " + values[i]); } } } catch (final IntrospectionException e) { log.log(Level.SEVERE, entity.getClass().getName() + ": " + e.getMessage(), e); } return values; }
From source file:com.ajah.spring.jdbc.AbstractAjahDao.java
License:Apache License
private Object[] getUpdateValues(final T entity) { final Object[] values = new Object[getUpdateFieldsList().size() + 1]; try {/*from w ww .ja va2s. c o m*/ final BeanInfo componentBeanInfo = Introspector.getBeanInfo(entity.getClass()); final PropertyDescriptor[] props = componentBeanInfo.getPropertyDescriptors(); for (int i = 0; i < (values.length - 1); i++) { final Field field = this.colMap.get(this.updateFieldsList.get(i)); if (LocalDate.class.isAssignableFrom(field.getType())) { final LocalDate localDate = (LocalDate) ReflectionUtils.propGetSafe(entity, getProp(field, props)); if (localDate != null) { values[i] = localDate.toString(LOCAL_DATE_FORMAT); } else { values[i] = null; } } else { values[i] = ReflectionUtils.propGetSafeAuto(entity, field, getProp(field, props)); } } values[values.length - 1] = entity.getId().toString(); } catch (final IntrospectionException e) { log.log(Level.SEVERE, entity.getClass().getName() + ": " + e.getMessage(), e); } return values; }
From source file:com.axelor.apps.account.service.MoveLineExportService.java
License:Open Source License
/** * Mthode ralisant l'export SI - Agresso des en-ttes pour les journaux de type vente * @param mlr/*from w w w . ja va 2s . co m*/ * @param replay * @throws AxelorException * @throws IOException */ @SuppressWarnings("unchecked") @Transactional(rollbackOn = { AxelorException.class, Exception.class }) public void exportMoveLineTypeSelect6FILE1(MoveLineReport moveLineReport, boolean replay) throws AxelorException, IOException { log.info("In export service Type 6 FILE 1 :"); Company company = moveLineReport.getCompany(); String dateQueryStr = String.format(" WHERE self.company = %s", company.getId()); JournalType journalType = moveLineReportService.getJournalType(moveLineReport); if (moveLineReport.getJournal() != null) { dateQueryStr += String.format(" AND self.journal = %s", moveLineReport.getJournal().getId()); } else { dateQueryStr += String.format(" AND self.journal.type = %s", journalType.getId()); } if (moveLineReport.getPeriod() != null) { dateQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (replay) { dateQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { dateQueryStr += " AND self.accountingOk = false "; } dateQueryStr += " AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false "; dateQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); Query dateQuery = JPA.em().createQuery( "SELECT self.date from Move self" + dateQueryStr + "group by self.date order by self.date"); List<LocalDate> allDates = new ArrayList<LocalDate>(); allDates = dateQuery.getResultList(); log.debug("allDates : {}", allDates); List<String[]> allMoveData = new ArrayList<String[]>(); String companyCode = ""; String reference = ""; String moveQueryStr = ""; String moveLineQueryStr = ""; if (moveLineReport.getRef() != null) { reference = moveLineReport.getRef(); } if (company != null) { companyCode = company.getCode(); moveQueryStr += String.format(" AND self.company = %s", company.getId()); } if (moveLineReport.getPeriod() != null) { moveQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (moveLineReport.getDateFrom() != null) { moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString()); } if (moveLineReport.getDateTo() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString()); } if (moveLineReport.getDate() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString()); } if (replay) { moveQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { moveQueryStr += " AND self.accountingOk = false "; } moveQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); LocalDate interfaceDate = moveLineReport.getDate(); for (LocalDate dt : allDates) { List<Journal> journalList = journalRepo.all() .filter("self.type = ?1 AND self.notExportOk = false", journalType).fetch(); if (moveLineReport.getJournal() != null) { journalList = new ArrayList<Journal>(); journalList.add(moveLineReport.getJournal()); } for (Journal journal : journalList) { List<? extends Move> moveList = moveRepo.all().filter( "self.date = ?1 AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false AND self.journal = ?2" + moveQueryStr, dt, journal).fetch(); String journalCode = journal.getExportCode(); if (moveList.size() > 0) { BigDecimal sumDebit = this.getSumDebit( "self.account.reconcileOk = true AND self.debit != 0.00 AND self.move in ?1 " + moveLineQueryStr, moveList); if (sumDebit.compareTo(BigDecimal.ZERO) == 1) { String exportNumber = this.getSaleExportNumber(company); Move firstMove = moveList.get(0); String periodCode = firstMove.getPeriod().getFromDate().toString("yyyyMM"); this.updateMoveList((List<Move>) moveList, moveLineReport, interfaceDate, exportNumber); String items[] = new String[8]; items[0] = companyCode; items[1] = journalCode; items[2] = exportNumber; items[3] = interfaceDate.toString("dd/MM/yyyy"); items[4] = sumDebit.toString(); items[5] = reference; items[6] = dt.toString("dd/MM/yyyy"); items[7] = periodCode; allMoveData.add(items); } } } } String fileName = "entete" + todayTime.toString("YYYYMMddHHmmss") + "ventes.dat"; String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company)); new File(filePath).mkdirs(); log.debug("Full path to export : {}{}", filePath, fileName); CsvTool.csvWriter(filePath, fileName, '|', null, allMoveData); // Utilis pour le debuggage // CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForHeaderFile(mlr.getTypeSelect()), allMoveData); }
From source file:com.axelor.apps.account.service.MoveLineExportService.java
License:Open Source License
/** * Mthode ralisant l'export SI - Agresso des en-ttes pour les journaux de type avoir * @param mlr// w w w.ja va2 s . c o m * @param replay * @throws AxelorException * @throws IOException */ @SuppressWarnings("unchecked") @Transactional(rollbackOn = { AxelorException.class, Exception.class }) public void exportMoveLineTypeSelect7FILE1(MoveLineReport moveLineReport, boolean replay) throws AxelorException, IOException { log.info("In export service 7 FILE 1:"); Company company = moveLineReport.getCompany(); String dateQueryStr = String.format(" WHERE self.company = %s", company.getId()); JournalType journalType = moveLineReportService.getJournalType(moveLineReport); if (moveLineReport.getJournal() != null) { dateQueryStr += String.format(" AND self.journal = %s", moveLineReport.getJournal().getId()); } else { dateQueryStr += String.format(" AND self.journal.type = %s", journalType.getId()); } if (moveLineReport.getPeriod() != null) { dateQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (replay) { dateQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { dateQueryStr += " AND self.accountingOk = false "; } dateQueryStr += " AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false "; dateQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); Query dateQuery = JPA.em().createQuery( "SELECT self.date from Move self" + dateQueryStr + "group by self.date order by self.date"); List<LocalDate> allDates = new ArrayList<LocalDate>(); allDates = dateQuery.getResultList(); log.debug("allDates : {}", allDates); List<String[]> allMoveData = new ArrayList<String[]>(); String companyCode = ""; String reference = ""; String moveQueryStr = ""; String moveLineQueryStr = ""; if (moveLineReport.getRef() != null) { reference = moveLineReport.getRef(); } if (moveLineReport.getCompany() != null) { companyCode = moveLineReport.getCompany().getCode(); moveQueryStr += String.format(" AND self.company = %s", moveLineReport.getCompany().getId()); } if (moveLineReport.getPeriod() != null) { moveQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (moveLineReport.getDateFrom() != null) { moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString()); } if (moveLineReport.getDateTo() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString()); } if (moveLineReport.getDate() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString()); } if (replay) { moveQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { moveQueryStr += " AND self.accountingOk = false "; } moveQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); LocalDate interfaceDate = moveLineReport.getDate(); for (LocalDate dt : allDates) { List<Journal> journalList = journalRepo.all() .filter("self.type = ?1 AND self.notExportOk = false", journalType).fetch(); if (moveLineReport.getJournal() != null) { journalList = new ArrayList<Journal>(); journalList.add(moveLineReport.getJournal()); } for (Journal journal : journalList) { List<Move> moveList = moveRepo.all().filter( "self.date = ?1 AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false AND self.journal = ?2" + moveQueryStr, dt, journal).fetch(); String journalCode = journal.getExportCode(); if (moveList.size() > 0) { BigDecimal sumCredit = this.getSumCredit( "self.account.reconcileOk = true AND self.credit != 0.00 AND self.move in ?1 " + moveLineQueryStr, moveList); if (sumCredit.compareTo(BigDecimal.ZERO) == 1) { String exportNumber = this.getSaleExportNumber(company); Move firstMove = moveList.get(0); String periodCode = firstMove.getPeriod().getFromDate().toString("yyyyMM"); this.updateMoveList(moveList, moveLineReport, interfaceDate, exportNumber); String items[] = new String[8]; items[0] = companyCode; items[1] = journalCode; items[2] = exportNumber; items[3] = interfaceDate.toString("dd/MM/yyyy"); items[4] = sumCredit.toString(); items[5] = reference; items[6] = dt.toString("dd/MM/yyyy"); items[7] = periodCode; allMoveData.add(items); } } } } String fileName = "entete" + todayTime.toString("YYYYMMddHHmmss") + "avoirs.dat"; String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company)); new File(filePath).mkdirs(); log.debug("Full path to export : {}{}", filePath, fileName); CsvTool.csvWriter(filePath, fileName, '|', null, allMoveData); // Utilis pour le debuggage // CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForHeaderFile(mlr.getTypeSelect()), allMoveData); }
From source file:com.axelor.apps.account.service.MoveLineExportService.java
License:Open Source License
/** * Mthode ralisant l'export SI - Agresso des en-ttes pour les journaux de type trsorerie * @param mlr//from w w w . j a va 2 s. co m * @param replay * @throws AxelorException * @throws IOException */ @SuppressWarnings("unchecked") @Transactional(rollbackOn = { AxelorException.class, Exception.class }) public void exportMoveLineTypeSelect8FILE1(MoveLineReport moveLineReport, boolean replay) throws AxelorException, IOException { log.info("In export service 8 FILE 1:"); Company company = moveLineReport.getCompany(); String dateQueryStr = String.format(" WHERE self.company = %s", company.getId()); JournalType journalType = moveLineReportService.getJournalType(moveLineReport); if (moveLineReport.getJournal() != null) { dateQueryStr += String.format(" AND self.journal = %s", moveLineReport.getJournal().getId()); } else { dateQueryStr += String.format(" AND self.journal.type = %s", journalType.getId()); } if (moveLineReport.getPeriod() != null) { dateQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (replay) { dateQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { dateQueryStr += " AND self.accountingOk = false "; } dateQueryStr += " AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false "; dateQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); Query dateQuery = JPA.em().createQuery( "SELECT self.date from Move self" + dateQueryStr + "group by self.date order by self.date"); List<LocalDate> allDates = new ArrayList<LocalDate>(); allDates = dateQuery.getResultList(); log.debug("allDates : {}", allDates); List<String[]> allMoveData = new ArrayList<String[]>(); String companyCode = ""; String reference = ""; String moveQueryStr = ""; String moveLineQueryStr = ""; if (moveLineReport.getRef() != null) { reference = moveLineReport.getRef(); } if (company != null) { companyCode = moveLineReport.getCompany().getCode(); moveQueryStr += String.format(" AND self.company = %s", company.getId()); } if (moveLineReport.getPeriod() != null) { moveQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (moveLineReport.getDateFrom() != null) { moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString()); } if (moveLineReport.getDateTo() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString()); } if (moveLineReport.getDate() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString()); } if (replay) { moveQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { moveQueryStr += " AND self.accountingOk = false "; } moveQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); LocalDate interfaceDate = moveLineReport.getDate(); for (LocalDate dt : allDates) { List<Journal> journalList = journalRepo.all() .filter("self.type = ?1 AND self.notExportOk = false", journalType).fetch(); if (moveLineReport.getJournal() != null) { journalList = new ArrayList<Journal>(); journalList.add(moveLineReport.getJournal()); } for (Journal journal : journalList) { List<Move> moveList = moveRepo.all().filter( "self.date = ?1 AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false AND self.journal = ?2" + moveQueryStr, dt, journal).fetch(); String journalCode = journal.getExportCode(); if (moveList.size() > 0) { long moveLineListSize = moveLineRepo.all() .filter("self.move in ?1 AND (self.debit > 0 OR self.credit > 0) " + moveLineQueryStr, moveList) .count(); if (moveLineListSize > 0) { String exportNumber = this.getTreasuryExportNumber(company); Move firstMove = moveList.get(0); String periodCode = firstMove.getPeriod().getFromDate().toString("yyyyMM"); this.updateMoveList(moveList, moveLineReport, interfaceDate, exportNumber); String items[] = new String[8]; items[0] = companyCode; items[1] = journalCode; items[2] = exportNumber; items[3] = interfaceDate.toString("dd/MM/yyyy"); items[4] = "0"; items[5] = reference; items[6] = dt.toString("dd/MM/yyyy"); items[7] = periodCode; allMoveData.add(items); } } } } String fileName = "entete" + todayTime.toString("YYYYMMddHHmmss") + "tresorerie.dat"; String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company)); new File(filePath).mkdirs(); log.debug("Full path to export : {}{}", filePath, fileName); CsvTool.csvWriter(filePath, fileName, '|', null, allMoveData); // Utilis pour le debuggage // CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForHeaderFile(mlr.getTypeSelect()), allMoveData); }
From source file:com.axelor.apps.account.service.MoveLineExportService.java
License:Open Source License
/** * Mthode ralisant l'export SI - Agresso des en-ttes pour les journaux de type achat * @param mlr/*from ww w. j ava 2s . c o m*/ * @param replay * @throws AxelorException * @throws IOException */ @SuppressWarnings("unchecked") @Transactional(rollbackOn = { AxelorException.class, Exception.class }) public void exportMoveLineTypeSelect9FILE1(MoveLineReport moveLineReport, boolean replay) throws AxelorException, IOException { log.info("In export service 9 FILE 1:"); Company company = moveLineReport.getCompany(); String dateQueryStr = String.format(" WHERE self.company = %s", company.getId()); JournalType journalType = moveLineReportService.getJournalType(moveLineReport); if (moveLineReport.getJournal() != null) { dateQueryStr += String.format(" AND self.journal = %s", moveLineReport.getJournal().getId()); } else { dateQueryStr += String.format(" AND self.journal.type = %s", journalType.getId()); } if (moveLineReport.getPeriod() != null) { dateQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (replay) { dateQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { dateQueryStr += " AND self.accountingOk = false "; } dateQueryStr += " AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false "; dateQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); Query dateQuery = JPA.em().createQuery( "SELECT self.date from Move self" + dateQueryStr + "group by self.date order by self.date"); List<LocalDate> allDates = new ArrayList<LocalDate>(); allDates = dateQuery.getResultList(); log.debug("allDates : {}", allDates); List<String[]> allMoveData = new ArrayList<String[]>(); String companyCode = ""; String reference = ""; String moveQueryStr = ""; String moveLineQueryStr = ""; if (moveLineReport.getRef() != null) { reference = moveLineReport.getRef(); } if (company != null) { companyCode = company.getCode(); moveQueryStr += String.format(" AND self.company = %s", company.getId()); } if (moveLineReport.getPeriod() != null) { moveQueryStr += String.format(" AND self.period = %s", moveLineReport.getPeriod().getId()); } if (moveLineReport.getDateFrom() != null) { moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString()); } if (moveLineReport.getDateTo() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString()); } if (moveLineReport.getDate() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString()); } if (replay) { moveQueryStr += String.format(" AND self.accountingOk = true AND self.moveLineReport = %s", moveLineReport.getId()); } else { moveQueryStr += " AND self.accountingOk = false "; } moveQueryStr += String.format(" AND self.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); LocalDate interfaceDate = moveLineReport.getDate(); for (LocalDate dt : allDates) { List<Journal> journalList = journalRepo.all() .filter("self.type = ?1 AND self.notExportOk = false", journalType).fetch(); if (moveLineReport.getJournal() != null) { journalList = new ArrayList<Journal>(); journalList.add(moveLineReport.getJournal()); } for (Journal journal : journalList) { List<Move> moveList = moveRepo.all().filter( "self.date = ?1 AND self.ignoreInAccountingOk = false AND self.journal.notExportOk = false AND self.journal = ?2" + moveQueryStr, dt, journal).fetch(); String journalCode = journal.getExportCode(); int moveListSize = moveList.size(); if (moveListSize > 0) { int i = 0; for (Move move : moveList) { List<MoveLine> moveLineList = moveLineRepo.all().filter( "self.account.reconcileOk = true AND self.credit != 0.00 AND self.move in ?1" + moveLineQueryStr, moveList).fetch(); if (moveLineList.size() > 0) { String exportNumber = this.getPurchaseExportNumber(company); String periodCode = move.getPeriod().getFromDate().toString("yyyyMM"); BigDecimal totalCredit = this.getSumCredit(moveLineList); String invoiceId = ""; String dueDate = ""; if (move.getInvoice() != null) { invoiceId = move.getInvoice().getInvoiceId(); dueDate = move.getInvoice().getDueDate().toString(); } MoveLine firstMoveLine = moveLineList.get(0); String items[] = new String[11]; items[0] = companyCode; items[1] = journalCode; items[2] = exportNumber; items[3] = interfaceDate.toString("dd/MM/yyyy"); items[4] = invoiceId; items[5] = dueDate; items[6] = firstMoveLine.getAccount().getCode(); items[7] = totalCredit.toString(); items[8] = reference; items[9] = dt.toString("dd/MM/yyyy"); items[10] = periodCode; allMoveData.add(items); this.updateMove(move, moveLineReport, interfaceDate, exportNumber); if (i % 10 == 0) { JPA.clear(); } if (i++ % 100 == 0) { log.debug("Process : {} / {}", i, moveListSize); } } } } } } String fileName = "entete" + todayTime.toString("YYYYMMddHHmmss") + "achats.dat"; String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company)); new File(filePath).mkdirs(); log.debug("Full path to export : {}{}", filePath, fileName); CsvTool.csvWriter(filePath, fileName, '|', null, allMoveData); // Utilis pour le debuggage // CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForHeaderFile(mlr.getTypeSelect()), allMoveData); }
From source file:com.datastax.brisk.demo.pricer.operations.HistoricalPriceInserter.java
License:Apache License
public void run(Client client) throws IOException { //Create a stock price per day Map<ByteBuffer, Map<String, List<Mutation>>> record = new HashMap<ByteBuffer, Map<String, List<Mutation>>>( tickers.length);//from w w w . j av a 2s. c o m LocalDate histDate = today.minusDays(index); ByteBuffer histDateBuf = ByteBufferUtil.bytes(histDate.toString("yyyy-MM-dd")); for (String stock : tickers) { record.put(ByteBufferUtil.bytes(stock), genDaysPrices(histDateBuf)); } long start = System.currentTimeMillis(); boolean success = false; String exceptionMessage = null; for (int t = 0; t < session.getRetryTimes(); t++) { if (success) break; try { client.batch_mutate(record, session.getConsistencyLevel()); success = true; } catch (Exception e) { exceptionMessage = getExceptionMessage(e); success = false; } } if (!success) { error(String.format("Operation [%d] retried %d times - error inserting key %s %s%n", index, session.getRetryTimes(), histDate, (exceptionMessage == null) ? "" : "(" + exceptionMessage + ")")); } session.operations.getAndIncrement(); session.keys.addAndGet(tickers.length); session.latency.getAndAdd(System.currentTimeMillis() - start); }
From source file:com.excilys.sugadroid.activities.AppointmentsActivity.java
License:Open Source License
private void setDayTextView(LocalDate day) { String dayString;//from w w w . ja v a 2s . co m if (day.equals(new LocalDate())) { dayString = getString(R.string.today) + " " + day.toString(getString(R.string.day_date_format)); } else { dayString = day.toString(getString(R.string.day_date_format)); } currentDayText.setText(dayString); }
From source file:com.github.fauu.natrank.service.RankingServiceImpl.java
License:Open Source License
@Override public DynamicRanking createDynamicForDate(LocalDate date) { // FIXME: These should take LocalDate instead of String String dateStr = date.toString("yyyy-MM-dd"); String dateMinusOneYearStr = date.minusYears(1).toString("yyyy-MM-dd"); List<TeamRating> latestTeamRatingsForTeam = teamRatingRepository.findLatestForTeamsByDate(dateStr); List<TeamRank> latestTeamRanksForTeam = teamRankRepository.findLatestForTeamsByDate(dateStr); List<TeamRank> teamRanksForTeamOneYearBefore = teamRankRepository .findLatestForTeamsByDate(dateMinusOneYearStr); DynamicRanking ranking = new DynamicRanking(); ranking.setFullVariantAvailable(rankingRepository.existsByDate(date)); Map<Integer, DynamicRankingEntry> rankingEntryMap = new HashMap<>(); for (TeamRank teamRank : latestTeamRanksForTeam) { DynamicRankingEntry rankingEntry = new DynamicRankingEntry(); rankingEntry.setTeam(teamRank.getTeam()); rankingEntry.setRanking(ranking); rankingEntry.setRank(teamRank.getValue()); rankingEntryMap.put(teamRank.getTeam().getId(), rankingEntry); }//from w ww.j a v a2 s . co m for (TeamRank teamRankOneYearBefore : teamRanksForTeamOneYearBefore) { if (rankingEntryMap.containsKey(teamRankOneYearBefore.getTeam().getId())) { Integer rankOneYearChange = teamRankOneYearBefore.getValue() - rankingEntryMap.get(teamRankOneYearBefore.getTeam().getId()).getRank(); rankingEntryMap.get(teamRankOneYearBefore.getTeam().getId()) .setRankOneYearChange(rankOneYearChange); } } // Temporary workaround to discard lTRFT duplicates for two matches on the same date // (4 April 1909 bug) Collections.reverse(latestTeamRatingsForTeam); List<Integer> processedTeamIds = new LinkedList<>(); for (TeamRating teamRating : latestTeamRatingsForTeam) { DynamicRankingEntry rankingEntry; // Temporary workaround to discard lTRFT duplicates for two matches on the same date // (4 April 1909 bug) if (!processedTeamIds.contains(teamRating.getTeam().getId())) { processedTeamIds.add(teamRating.getTeam().getId()); if (!rankingEntryMap.containsKey(teamRating.getTeam().getId())) { rankingEntry = new DynamicRankingEntry(); rankingEntry.setTeam(teamRating.getTeam()); rankingEntry.setRanking(ranking); rankingEntry.setRating(0); rankingEntry.setRank(0); rankingEntryMap.put(teamRating.getTeam().getId(), rankingEntry); } else { rankingEntry = rankingEntryMap.get(teamRating.getTeam().getId()); rankingEntry.setRating(teamRating.getValue()); } } } List<DynamicRankingEntry> rankingEntries = new LinkedList<>(rankingEntryMap.values()); Collections.sort(rankingEntries); ranking.setDate(date); ranking.setEntries(rankingEntries); return ranking; }