Example usage for org.joda.time LocalDate LocalDate

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

Introduction

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

Prototype

public LocalDate() 

Source Link

Document

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

Usage

From source file:com.gst.portfolio.loanaccount.service.LoanReadPlatformServiceImpl.java

License:Apache License

@Override
public LoanTransactionData retrieveRefundByCashTemplate(Long loanId) {
    // TODO Auto-generated method stub
    this.context.authenticatedUser();

    // TODO - KW - OPTIMIZE - write simple sql query to fetch back date of
    // possible next transaction date.
    final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true);
    final MonetaryCurrency currency = loan.getCurrency();
    final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository
            .findOneWithNotFoundDetection(currency);

    final CurrencyData currencyData = applicationCurrency.toData();

    final LocalDate earliestUnpaidInstallmentDate = new LocalDate();

    final LoanTransactionEnumData transactionType = LoanEnumerations
            .transactionType(LoanTransactionType.REFUND_FOR_ACTIVE_LOAN);
    final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService
            .retrieveAllPaymentTypes();//from www. j a v  a2  s . c o  m
    return new LoanTransactionData(null, null, null, transactionType, null, currencyData,
            earliestUnpaidInstallmentDate, retrieveTotalPaidInAdvance(loan.getId()).getPaidInAdvance(), null,
            null, null, null, null, null, paymentOptions, null, null, null, null, false);
}

From source file:com.gst.portfolio.loanaccount.service.LoanWritePlatformServiceJpaRepositoryImpl.java

License:Apache License

/**
 * create standing instruction for disbursed loan
 * /*  w  ww.j  av  a  2 s . co m*/
 * @param loan
 *            the disbursed loan
 * @return void
 **/
private void createStandingInstruction(Loan loan) {

    if (loan.shouldCreateStandingInstructionAtDisbursement()) {
        AccountAssociations accountAssociations = this.accountAssociationRepository.findByLoanIdAndType(
                loan.getId(), AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue());

        if (accountAssociations != null) {

            SavingsAccount linkedSavingsAccount = accountAssociations.linkedSavingsAccount();

            // name is auto-generated
            final String name = "To loan " + loan.getAccountNumber() + " from savings "
                    + linkedSavingsAccount.getAccountNumber();
            final Office fromOffice = loan.getOffice();
            final Client fromClient = loan.getClient();
            final Office toOffice = loan.getOffice();
            final Client toClient = loan.getClient();
            final Integer priority = StandingInstructionPriority.MEDIUM.getValue();
            final Integer transferType = AccountTransferType.LOAN_REPAYMENT.getValue();
            final Integer instructionType = StandingInstructionType.DUES.getValue();
            final Integer status = StandingInstructionStatus.ACTIVE.getValue();
            final Integer recurrenceType = AccountTransferRecurrenceType.AS_PER_DUES.getValue();
            final LocalDate validFrom = new LocalDate();

            AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToLoanTransfer(
                    fromOffice, fromClient, linkedSavingsAccount, toOffice, toClient, loan, transferType);

            AccountTransferStandingInstruction accountTransferStandingInstruction = AccountTransferStandingInstruction
                    .create(accountTransferDetails, name, priority, instructionType, status, null, validFrom,
                            null, recurrenceType, null, null, null);
            accountTransferDetails.updateAccountTransferStandingInstruction(accountTransferStandingInstruction);

            this.accountTransferDetailRepository.save(accountTransferDetails);
        }
    }
}

From source file:com.gst.portfolio.loanaccount.service.LoanWritePlatformServiceJpaRepositoryImpl.java

License:Apache License

@Override
@CronTarget(jobName = JobName.TRANSFER_FEE_CHARGE_FOR_LOANS)
public void transferFeeCharges() throws JobExecutionException {
    final Collection<LoanChargeData> chargeDatas = this.loanChargeReadPlatformService
            .retrieveLoanChargesForFeePayment(ChargePaymentMode.ACCOUNT_TRANSFER.getValue(),
                    LoanStatus.ACTIVE.getValue());
    final boolean isRegularTransaction = true;
    final StringBuilder sb = new StringBuilder();
    if (chargeDatas != null) {
        for (final LoanChargeData chargeData : chargeDatas) {
            if (chargeData.isInstallmentFee()) {
                final Collection<LoanInstallmentChargeData> chargePerInstallments = this.loanChargeReadPlatformService
                        .retrieveInstallmentLoanCharges(chargeData.getId(), true);
                PortfolioAccountData portfolioAccountData = null;
                for (final LoanInstallmentChargeData installmentChargeData : chargePerInstallments) {
                    if (!installmentChargeData.getDueDate().isAfter(new LocalDate())) {
                        if (portfolioAccountData == null) {
                            portfolioAccountData = this.accountAssociationsReadPlatformService
                                    .retriveLoanLinkedAssociation(chargeData.getLoanId());
                        }/*  ww w  .j a v  a  2 s .c o  m*/
                        final SavingsAccount fromSavingsAccount = null;
                        final boolean isExceptionForBalanceCheck = false;
                        final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(),
                                installmentChargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS,
                                PortfolioAccountType.LOAN, portfolioAccountData.accountId(),
                                chargeData.getLoanId(), "Loan Charge Payment", null, null, null, null,
                                LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId(),
                                installmentChargeData.getInstallmentNumber(),
                                AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null,
                                fromSavingsAccount, isRegularTransaction, isExceptionForBalanceCheck);
                        transferFeeCharge(sb, accountTransferDTO);
                    }
                }
            } else if (chargeData.getDueDate() != null && !chargeData.getDueDate().isAfter(new LocalDate())) {
                final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService
                        .retriveLoanLinkedAssociation(chargeData.getLoanId());
                final SavingsAccount fromSavingsAccount = null;
                final boolean isExceptionForBalanceCheck = false;
                final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(),
                        chargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS,
                        PortfolioAccountType.LOAN, portfolioAccountData.accountId(), chargeData.getLoanId(),
                        "Loan Charge Payment", null, null, null, null,
                        LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId(), null,
                        AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null,
                        fromSavingsAccount, isRegularTransaction, isExceptionForBalanceCheck);
                transferFeeCharge(sb, accountTransferDTO);
            }
        }
    }
    if (sb.length() > 0) {
        throw new JobExecutionException(sb.toString());
    }
}

From source file:com.hmsinc.epicenter.util.DateTimeUtils.java

License:Open Source License

public static boolean isToday(final DateTime date) {
    return new LocalDate().equals(date.toLocalDate());
}

From source file:com.hmsinc.epicenter.webapp.map.MapCacheService.java

License:Open Source License

/**
 * Builds the cache key that is valid for this request.
 * /*from   w w w.  j a  va 2 s.  c o m*/
 * TODO: Refactor this so we don't need to mess around with it if we add new
 * parameters.
 * 
 * @param parameters
 * @param feature
 * @return
 */
private static String getCacheKey(final StyleParameters styleParameters, final Geography feature) {

    final AnalysisParameters parameters = styleParameters.getParameters();

    final StringBuilder builder = new StringBuilder();
    builder.append(feature.getId()).append(":").append(makeKeyFromCollection(parameters.getAttributes()))
            .append(":").append(makeKeyFromCollection(parameters.getClassifications())).append(":")
            .append(parameters.getLocation().ordinal()).append(":")
            .append(parameters.getDataRepresentation().ordinal()).append(":")
            .append(parameters.getDataConditioning().ordinal()).append(":");

    if (new LocalDate().equals(parameters.getEndDate().toLocalDate())) {
        builder.append(TimeSeriesPeriod.HOUR.truncate(parameters.getStartDate()).getMillis()).append(":")
                .append(TimeSeriesPeriod.HOUR.truncate(parameters.getEndDate()).getMillis());
    } else {
        builder.append(parameters.getStartDate().getMillis()).append(":")
                .append(parameters.getEndDate().getMillis());
    }
    return builder.toString();
}

From source file:com.hotwire.test.steps.tools.c3.overcharges.C3OverchargeModel.java

License:Open Source License

private int transformStringDateToDays(String searchPeriod) {
    int dateFrom;
    if ("last week".equalsIgnoreCase(searchPeriod)) {
        dateFrom = 7;//from  w  ww  .  j av  a  2 s .  c om
    } else if ("last 2 weeks".equalsIgnoreCase(searchPeriod)) {
        dateFrom = 14;
    } else if ("last 6 months".equalsIgnoreCase(searchPeriod)) {
        LocalDate date1 = new LocalDate().minusMonths(6);
        LocalDate date2 = new LocalDate();
        dateFrom = Days.daysBetween(date1, date2).getDays();
    } else {
        LocalDate date1 = new LocalDate().minusMonths(12);
        LocalDate date2 = new LocalDate();
        dateFrom = Days.daysBetween(date1, date2).getDays();
    }
    return dateFrom;
}

From source file:com.ideaspymes.arthyweb.ventas.service.impl.GestionComercialService.java

public static String getConsultaCantidadCajasAcum(Integer vendedorId, String bd) {

    LocalDate localDate = new LocalDate();
    int ultimoDia = localDate.dayOfMonth().getMaximumValue();
    int mes = localDate.getMonthOfYear();
    int anio = localDate.getYear();

    return "select sum(x.cant_caja) from \n" + "(SELECT \n"
            + "             FD.[ID Sucursales]                                          as     sucursal_key\n"
            + "             ,FD.[ID Vendedores]                                         as     cod_vendedor --\n"
            + "             ,FD.[ID Comprobantes Ventas]                          as     comprobante\n"
            + "             ,FD.[Numero]                                                as     numero_fac\n"
            + "             ,FD.[ID Linea]                                                     as     linea_fac                               \n"
            + "             ,DATEADD(dd, 0, DATEDIFF(dd, 0, F.[Fecha])) as fecha_key\n"
            + "             ,F.[ID Clientes]                                            as     cod_cliente  --\n"
            + "             ,(SELECT \n"
            + "             --OBTENEMOS LA DESCRIPCION DE LA ZONA EN LA QUE SE EJECUTO LA VENTA\n"
            + "             CASE WHEN [Clasificacion 8] = '1' OR  [Clasificacion 8] IS NULL THEN 'NO DEFINIDO' ELSE [Clasificacion 8] END\n"
            + "             " + bd
            + ".FROM [VTA_Clientes] C WHERE C.[ID Clientes]=F.[ID Clientes] AND  C.[ID Sucursales] = FD.[ID Sucursales]) as zona_desc,\n"
            + "             --OBTENEMOS LA DESCRIPCION EL TERRITORIO EN LA QUE SE EJECUTO LA VENTA\n"
            + "             (SELECT \n"
            + "             CASE WHEN [Clasificacion 2] = '1' OR  [Clasificacion 2] IS NULL THEN 'NO DEFINIDO' ELSE [Clasificacion 2] END\n"
            + "             " + bd
            + ".FROM [VTA_Clientes] C WHERE C.[ID Clientes]=F.[ID Clientes] AND  C.[ID Sucursales] = FD.[ID Sucursales]) as territorio_desc\n"
            + "             ,FD.[ID Productos]                                          as     cod_producto --\n"
            + "             ,FD.[ID Unidades Medidas]                             as     unidad_key\n"
            + "             ,FD.[Cantidad Envase]                                       as     cantidad_envase\n"
            + "             ,FD.[Total Linea ML]                                  as     importe                    \n"
            + "             ,ISNULL (CAST (FD.[Promocion] AS INT),0) as     bonicicacion\n"
            + "             ,ISNULL (FD.[PromoPLM3]           ,0)                                     as       cantidad_promo\n"
            + "             ,(CASE WHEN FD.[PromoId]=0 THEN NULL ELSE FD.[PromoId] END)                                                as     promo_key\n"
            + "             --CALCULOS PARA OBTENER VOLUMENES DE VENTA POR CAJAS,GRUESAS Y CAJETILLAS\n"
            + "             ,CAST (case when U.[ID Unidades Medidas] = 15 then cast (FD.[Cantidad Envase] as numeric(14,3)) / 50 else (case when U.[ID Unidades Medidas] = 25  then cast (FD.[Cantidad Envase] as numeric(14,3)) / calc.cantidad_caje_por_gruesa / 50  else (case when U.[ID Unidades Medidas] <> 16 then 0 else FD.[Cantidad Envase] end) end ) end AS numeric (14,3) )  as cant_caja\n"
            + "\n"
            + "             ,CAST ( case when U.[ID Unidades Medidas] = 16 then cast (FD.[Cantidad Envase] as numeric(14,3)) * 50 else (case when U.[ID Unidades Medidas] = 25  then cast (FD.[Cantidad Envase] as numeric(14,3)) / calc.cantidad_caje_por_gruesa   else (case when U.[ID Unidades Medidas] <> 15 then 0 else FD.[Cantidad Envase] end) end ) end  AS numeric (14,3) )as cant_gruesa\n"
            + "\n"
            + "             ,CAST (case when U.[ID Unidades Medidas] <> 29 then cast (FD.[Cantidad Envase] as numeric(14,3)) * U.[Cantidad] else 0 end AS numeric (14,3) )as cant_cajetilla\n"
            + "             \n" + "FROM " + bd + ".[VTA_D Comprobantes de Ventas] FD WITH (NOLOCK)\n"
            + "INNER JOIN " + bd + ".[VTA_C Comprobantes de Ventas] F WITH (NOLOCK) \n"
            + "                           ON  FD.Origen                           =      F.Origen \n"
            + "                           AND FD.[ID Sucursales]                  =      F.[ID Sucursales] \n"
            + "                           AND FD.[ID Vendedores]                  =      F.[ID Vendedores] \n"
            + "                           AND FD.[ID Comprobantes Ventas] = F.[ID Comprobantes Ventas] \n"
            + "                           AND FD.numero                           =      F.numero\n" + "--\n"
            + "LEFT JOIN " + bd + ".[STK_UM de Productos]  U WITH (NOLOCK)\n"
            + "                           ON  FD.[ID Unidades Medidas]      =      U.[ID Unidades Medidas]\n"
            + "                           AND FD.[ID Productos]                   =      U.[ID Productos]\n"
            + "-- TABLA VIRTUAL PARA OBTENER CANTIDA DE PABILOS POR CAJETILLA\n" + "LEFT JOIN " + bd
            + ".calc_pabilo calc ON FD.[ID Productos] = calc.[ID Productos]\n"
            + "WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, F.[Fecha])) between " + convertFechaSQL(1, mes, anio)
            + " and " + convertFechaSQL(ultimoDia, mes, anio) + " \n" + " AND F.[Status] <> '11' \n"
            + " AND FD.[ID Vendedores] = " + vendedorId + ") x";
}

From source file:com.inkubator.hrm.web.HomeDashboardController.java

@PostConstruct
@Override/*ww  w . j a va2 s.co  m*/
public void initialization() {
    super.initialization();

    distribusiKaryawanPerDepartment = new CartesianChartModel();
    barChartDistribusiByDept = new BarChartModel();
    pieModel = new PieChartModel();
    totalMale = new Long(0);
    totalFemale = new Long(0);
    try {
        /**
         * find All holiday date based on JadwalKaryawan "DEFAULT" which is
         * OFF and public holiday
         */
        LocalDate now = new LocalDate();
        startCalendarDate = now.dayOfMonth().withMinimumValue().toDate();
        endCalendarDate = now.dayOfMonth().withMaximumValue().toDate();
        Set<Date> holidays = wtScheduleShiftService.getAllRegulerOffDaysBetween(startCalendarDate,
                endCalendarDate);
        for (Date holiday : holidays) {
            DateTime dtHoliday = new DateTime(holiday);
            listHolidayDate.add(dtHoliday.getDayOfMonth());
        }

        /**
         * calculate employee distribution based on GENDER
         */
        Map<String, Long> employeesByGender = empDataService.getTotalByGender(HrmUserInfoUtil.getCompanyId());
        totalFemale = employeesByGender.get("male");
        totalMale = employeesByGender.get("female");
        lastUpdateEmpDistByGender = new Date(employeesByGender.get("lastUpdate"));

        /**
         * calculate employee distribution based on DEPARTMENT
         */
        Map<String, Long> employeesByDepartment = empDataService
                .getTotalByDepartment(HrmUserInfoUtil.getCompanyId());
        int i = 0;
        for (Map.Entry<String, Long> entry : employeesByDepartment.entrySet()) {

            /**
             * only 8 department is allowed to show atau jika entry key nya
             * "lastUpdate" berarti itu akhir dari list
             */
            if (i == 8 || StringUtils.equals(entry.getKey(), "lastUpdate")) {
                break;
            }
            i++;

            ChartSeries deptSeries = new ChartSeries();
            deptSeries.setLabel(entry.getKey());
            deptSeries.set("Department", entry.getValue());
            barChartDistribusiByDept.addSeries(deptSeries);

        }
        barChartDistribusiByDept.setLegendPosition("ne");
        barChartDistribusiByDept.setStacked(false);
        barChartDistribusiByDept.setShowDatatip(true);
        barChartDistribusiByDept.setLegendCols(4);
        barChartDistribusiByDept.setLegendRows(2);
        barChartDistribusiByDept.setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc,006666,660066");
        lastUpdateEmpDistByDepartment = new Date(employeesByDepartment.get("lastUpdate"));

        /**
         * calculate employee distribution based on AGE
         */
        Map<String, Long> employeesByAge = empDataService.getTotalByAge(HrmUserInfoUtil.getCompanyId());
        pieModel.set("< 26", employeesByAge.get("lessThan26"));
        pieModel.set("25-30", employeesByAge.get("between26And30"));
        pieModel.set("31-35", employeesByAge.get("between31And35"));
        pieModel.set("36-40", employeesByAge.get("between36And40"));
        pieModel.set("> 40", employeesByAge.get("moreThan40"));
        pieModel.setLegendPosition("e");
        pieModel.setFill(false);
        pieModel.setShowDataLabels(true);
        pieModel.setSliceMargin(4);
        pieModel.setDiameter(120);
        pieModel.setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc");
        lastUpdateEmpDistByAge = new Date(employeesByAge.get("lastUpdate"));

        /**
         * calculate employee resume
         */
        employeeResumeModel = empDataService.getEmployeeResumeOnDashboard(HrmUserInfoUtil.getCompanyId());

        /**
         * calculate attendance statistic
         */
        attendanceModel = tempAttendanceRealizationService.getStatisticEmpAttendaceRealization();
        double totalPresent = Double.parseDouble(String.valueOf(attendanceModel.getTotaldayPresent()));
        double totalSchedule = Double.parseDouble(String.valueOf(attendanceModel.getTotaldaySchedule()));
        totalPersent = (totalPresent / totalSchedule);

        persentasiKehadiranPerWeek = new CartesianChartModel();
        barChartModel = new BarChartModel();
        barChartModel.setStacked(false);
        barChartModel.setLegendPosition("ne");
        barChartModel.setLegendCols(6);
        barChartModel.setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc");
        barChartModel.setShowDatatip(true);
        barChartModel.setShadow(true);
        barChartModel.setShowPointLabels(true);
        Axis yAxis = barChartModel.getAxis(AxisType.Y);
        yAxis.setMax(150);
        yAxis.setMin(0);

        //Get Attendance Percentation per Department on Active Period
        Map<String, List<DepAttendanceRealizationViewModel>> mapResult = empDataService
                .getListDepAttendanceByCompanyId(HrmUserInfoUtil.getCompanyId());

        //Looping and render it
        for (Map.Entry<String, List<DepAttendanceRealizationViewModel>> entry : mapResult.entrySet()) {

            ChartSeries charDepartmentSeries = new ChartSeries();
            charDepartmentSeries.setLabel(entry.getKey());
            List<DepAttendanceRealizationViewModel> listDepartmentModel = Lambda.sort(entry.getValue(),
                    Lambda.on(DepAttendanceRealizationViewModel.class).getWeekNumber());
            for (DepAttendanceRealizationViewModel depAttendanceModel : listDepartmentModel) {
                charDepartmentSeries.set(
                        ResourceBundleUtil.getAsString("global.week") + "  "
                                + depAttendanceModel.getWeekNumber(),
                        depAttendanceModel.getAttendancePercentage().doubleValue() * 100);
            }

            barChartModel.addSeries(charDepartmentSeries);
        }

        /**
         * calculate attendance statistic from 6 days ago until yesterday
         */
        SimpleDateFormat formatter = new SimpleDateFormat("MMMM yyyy", LocaleContextHolder.getLocale());
        int week = Calendar.getInstance().get(Calendar.WEEK_OF_MONTH);
        StringBuffer buff = new StringBuffer();
        buff.append(week);
        if (LocaleContextHolder.getLocale().getLanguage().equals("en")) {
            buff.append(StringUtils.suffixesDayOfMonth[week]);
        }
        Object[] parameters = { buff.toString(), formatter.format(now.toDate()) };
        ResourceBundle bundle = ResourceBundle.getBundle("Messages", LocaleContextHolder.getLocale());
        presentationAttendancePerDayLabel = MessageFormat.format(bundle.getString("home.week_update_data"),
                parameters);
        List<Date> listTanggalWaktuKerja = new ArrayList<>();
        IntStream.range(1, 6).forEach(num -> listTanggalWaktuKerja.add(now.minusDays(num).toDate()));
        List<ChartSeries> listPresentasiAttendance = empDataService
                .getEmployeePresentationAttendanceOnDashboard(HrmUserInfoUtil.getCompanyId(),
                        listTanggalWaktuKerja, "dd MMM yyyy");

        presentationAttendancePerDayBarChartModel = new HorizontalBarChartModel();
        listPresentasiAttendance.forEach(series -> presentationAttendancePerDayBarChartModel.addSeries(series));
        presentationAttendancePerDayBarChartModel.setStacked(true);
        presentationAttendancePerDayBarChartModel.setShowDatatip(true);
        presentationAttendancePerDayBarChartModel.setLegendPosition("se");
        presentationAttendancePerDayBarChartModel
                .setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc,d500d5,ff2a55");
        Axis xAxis = presentationAttendancePerDayBarChartModel.getAxis(AxisType.X);
        xAxis.setMax(300);
        xAxis.setTickInterval("20");
        xAxis.setMin(0);

    } catch (Exception e) {
        LOGGER.error("Error ", e);
    }

}

From source file:com.inkubator.hrm.web.mobile.HomeMobileController.java

@PostConstruct
@Override/* ww  w.  j av a2 s  .  c o m*/
public void initialization() {
    try {
        super.initialization();
        loginHistories = loginHistoryService.getByParam(0, 4, Order.desc("loginDate"));
        barChartDistribusiByDept = new BarChartModel();
        totalRequestHistory = approvalActivityService.getTotalRequestHistory(UserInfoUtil.getUserName());
        totalPendingTask = approvalActivityService.getTotalPendingTask(UserInfoUtil.getUserName());
        totalPendingRequest = approvalActivityService.getTotalPendingRequest(UserInfoUtil.getUserName());
        Long empDataId = HrmUserInfoUtil.getEmpId();
        List<LeaveImplementationDateModel> listLeaveImplementationDateModel = leaveImplementationDateService
                .getAllDataWithTotalTakenLeaveByEmpDataId(empDataId);
        totalLeaveType = listLeaveImplementationDateModel.size();
        pieModel = new PieChartModel();
        Map<String, Long> employeesByAge = empDataService.getTotalByAge(HrmUserInfoUtil.getCompanyId());
        pieModel.set("< 26", employeesByAge.get("lessThan26"));
        pieModel.set("25-30", employeesByAge.get("between26And30"));
        pieModel.set("31-35", employeesByAge.get("between31And35"));
        pieModel.set("36-40", employeesByAge.get("between36And40"));
        pieModel.set("> 40", employeesByAge.get("moreThan40"));
        pieModel.setLegendPosition("e");
        pieModel.setFill(true);
        pieModel.setShowDataLabels(true);
        pieModel.setSliceMargin(4);
        pieModel.setDiameter(150);
        pieModel.setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc");
        lastUpdateEmpDistByAge = new Date(employeesByAge.get("lastUpdate"));
        Map<String, Long> employeesByGender = empDataService.getTotalByGender(HrmUserInfoUtil.getCompanyId());
        totalFemale = employeesByGender.get("male");
        totalMale = employeesByGender.get("female");
        lastUpdateEmpDistByGender = new Date(employeesByGender.get("lastUpdate"));
        LocalDate now = new LocalDate();
        SimpleDateFormat formatter = new SimpleDateFormat("MMMM yyyy", LocaleContextHolder.getLocale());
        int week = Calendar.getInstance().get(Calendar.WEEK_OF_MONTH);
        StringBuffer buff = new StringBuffer();
        buff.append(week);
        if (LocaleContextHolder.getLocale().getLanguage().equals("en")) {
            buff.append(StringUtils.suffixesDayOfMonth[week]);
        }
        Object[] parameters = { buff.toString(), formatter.format(now.toDate()) };
        ResourceBundle bundle = ResourceBundle.getBundle("Messages", LocaleContextHolder.getLocale());
        presentationAttendancePerDayLabel = MessageFormat.format(bundle.getString("home.week_update_data"),
                parameters);
        List<Date> listTanggalWaktuKerja = new ArrayList<>();
        IntStream.range(1, 6).forEach(num -> listTanggalWaktuKerja.add(now.minusDays(num).toDate()));
        List<ChartSeries> listPresentasiAttendance = empDataService
                .getEmployeePresentationAttendanceOnDashboard(HrmUserInfoUtil.getCompanyId(),
                        listTanggalWaktuKerja, "dd");

        presentationAttendancePerDayBarChartModel = new HorizontalBarChartModel();
        listPresentasiAttendance.forEach(series -> presentationAttendancePerDayBarChartModel.addSeries(series));
        presentationAttendancePerDayBarChartModel.setStacked(true);
        presentationAttendancePerDayBarChartModel.setShowDatatip(true);
        presentationAttendancePerDayBarChartModel.setShowPointLabels(true);
        presentationAttendancePerDayBarChartModel.setLegendPosition("se");
        presentationAttendancePerDayBarChartModel
                .setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc,d500d5,ff2a55");
        Axis xAxis = presentationAttendancePerDayBarChartModel.getAxis(AxisType.X);
        xAxis.setMax(100);
        xAxis.setTickInterval("20");
        xAxis.setMin(0);
        Map<String, Long> employeesByDepartment = empDataService
                .getTotalByDepartment(HrmUserInfoUtil.getCompanyId());
        int i = 0;
        for (Map.Entry<String, Long> entry : employeesByDepartment.entrySet()) {

            /**
             * only 8 department is allowed to show atau jika entry key nya
             * "lastUpdate" berarti itu akhir dari list
             */
            if (i == 8 || StringUtils.equals(entry.getKey(), "lastUpdate")) {
                break;
            }
            i++;

            ChartSeries deptSeries = new ChartSeries();
            deptSeries.setLabel(entry.getKey());
            deptSeries.set("Department", entry.getValue());
            barChartDistribusiByDept.addSeries(deptSeries);

        }
        barChartDistribusiByDept.setLegendPosition("ne");
        barChartDistribusiByDept.setStacked(false);
        barChartDistribusiByDept.setShowDatatip(true);
        barChartDistribusiByDept.setShowPointLabels(true);
        barChartDistribusiByDept.setLegendCols(4);
        barChartDistribusiByDept.setLegendRows(2);
        barChartDistribusiByDept.setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc,006666,660066");
        lastUpdateEmpDistByDepartment = new Date(employeesByDepartment.get("lastUpdate"));

        barChartModel = new BarChartModel();
        barChartModel.setStacked(false);
        barChartModel.setLegendPosition("ne");
        barChartModel.setLegendCols(4);
        barChartModel.setLegendRows(2);
        barChartModel.setSeriesColors("66cc00,629de1,003366,990000,cccc00,6600cc");
        barChartModel.setShowDatatip(true);
        barChartModel.setShadow(true);
        barChartModel.setShowPointLabels(true);
        Axis yAxis = barChartModel.getAxis(AxisType.Y);
        yAxis.setMax(150);
        yAxis.setMin(0);

        //Get Attendance Percentation per Department on Active Period
        Map<String, List<DepAttendanceRealizationViewModel>> mapResult = empDataService
                .getListDepAttendanceByCompanyId(HrmUserInfoUtil.getCompanyId());

        //Looping and render it
        for (Map.Entry<String, List<DepAttendanceRealizationViewModel>> entry : mapResult.entrySet()) {

            ChartSeries charDepartmentSeries = new ChartSeries();
            charDepartmentSeries.setLabel(entry.getKey());
            List<DepAttendanceRealizationViewModel> listDepartmentModel = Lambda.sort(entry.getValue(),
                    Lambda.on(DepAttendanceRealizationViewModel.class).getWeekNumber());
            for (DepAttendanceRealizationViewModel depAttendanceModel : listDepartmentModel) {
                charDepartmentSeries.set(depAttendanceModel.getWeekNumber(),
                        depAttendanceModel.getAttendancePercentage().doubleValue() * 100);
            }

            barChartModel.addSeries(charDepartmentSeries);
        }
    } catch (Exception ex) {
        LOGGER.error(ex, ex);
    }
}

From source file:com.ligadata.kamanja.copd.COPDRiskAssessment.java

License:Apache License

private Boolean age40OrOlder() {
    org.joda.time.LocalDate birthdate = new org.joda.time.LocalDate(msg.bene_birth_dt() / 10000,
            (msg.bene_birth_dt() % 1000) / 100, msg.bene_birth_dt() % 100);
    Integer age = Years.yearsBetween(birthdate, new LocalDate()).getYears();
    if (age > 40) {
        return true;
    }/*w w  w .  j  av  a2  s  . c o  m*/
    return false;
}