Example usage for org.joda.time DateTime getDayOfMonth

List of usage examples for org.joda.time DateTime getDayOfMonth

Introduction

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

Prototype

public int getDayOfMonth() 

Source Link

Document

Get the day of month field value.

Usage

From source file:com.hmsinc.epicenter.webapp.remoting.ForecastingService.java

License:Open Source License

@Secured("ROLE_USER")
@Transactional(readOnly = true)//from w  ww . j ava  2 s. com
@RemoteMethod
public String getSeasonalTrendChart(final AnalysisParametersDTO paramsDTO) {

    final AnalysisParameters params = convertParameters(paramsDTO);

    // 60 day window
    final DateTime windowStart = params.getEndDate().minusDays(59);

    // Set the start date back 1 year + 60 days
    params.setStartDate(windowStart.minusYears(1).minusDays(59));

    final TimeSeriesChart chart = new TimeSeriesChart();

    final TimeSeries ts = queryService.queryForTimeSeries(params, paramsDTO.getAlgorithmName(), null);

    if (ts != null) {

        final TimeSeries forecast = waveletSeasonalTrendForecaster.process(ts.after(windowStart),
                ts.before(windowStart.minusDays(1)), null);
        final TimeSeries known = forecast.before(params.getEndDate());
        final TimeSeries predicted = forecast.after(params.getEndDate().plusDays(1));

        chart.addBand("70% Confidence Prediction", predicted, ResultType.LOWER_BOUND_70,
                ResultType.UPPER_BOUND_70, new Color(0x0072bf), new Color(0x0072bf));
        chart.addBand("80% Confidence Prediction", predicted, ResultType.LOWER_BOUND_80,
                ResultType.UPPER_BOUND_80, new Color(0x0099ff), new Color(0x0099ff));
        chart.addBand("90% Confidence Prediction", predicted, ResultType.LOWER_BOUND_90,
                ResultType.UPPER_BOUND_90, new Color(0x3fb2ff), new Color(0x3fb2ff));
        chart.addBand("95% Confidence Prediction", predicted, ResultType.LOWER_BOUND_95,
                ResultType.UPPER_BOUND_95, new Color(0xbfe5ff), new Color(0xbfe5ff));

        chart.add("Actual Value", known, ChartColor.VALUE.getColor(), LineStyle.DOTTED);
        chart.add("Actual Trend", known, ResultType.TREND, ChartColor.VALUE.getColor(), LineStyle.THICK);

        final DateTime knownFirst = known.first().getTime();
        final DateTime predictedFirst = predicted.first().getTime();

        final Marker marker = new IntervalMarker(
                new Day(knownFirst.getDayOfMonth(), knownFirst.getMonthOfYear(), knownFirst.getYear())
                        .getFirstMillisecond(),
                new Day(predictedFirst.getDayOfMonth(), predictedFirst.getMonthOfYear(),
                        predictedFirst.getYear()).getFirstMillisecond(),
                Color.LIGHT_GRAY, new BasicStroke(2.0f), null, null, 1.0f);
        marker.setAlpha(0.3f);
        chart.getMarkers().add(marker);
        chart.setYLabel(params.getDataRepresentation().getDisplayName());
        chart.setAlwaysScaleFromZero(false);
    }

    return chartService.getChartURL(chart);

}

From source file:com.huang.rp.blog.access.service.AccessService.java

License:Apache License

/**
 * ?/*from w  w  w .  j  a va  2s . c  o m*/
 * @return
 */
public Map<String, Map<String, List<BlogPostsWithBLOBs>>> getTimelineList(HttpServletRequest request,
        AccessFilter filter) {
    if (filter == null)
        filter = new AccessFilter();
    filter.setRows(Integer.MAX_VALUE - 1);
    filter.setSord("desc");
    filter.setSidx("id");
    CookieVO cookieVO = parseCookie(request);
    filter.setSearchStr(cookieVO.getSearch());
    filter.setTagId(cookieVO.getTag());
    filter.setUserId(cookieVO.getUserId());
    filter.setHighLight(true);
    List<BlogPostsWithBLOBs> excerptList = getArticleExcerptListByFilter(request, filter);
    Map<String, Map<String, List<BlogPostsWithBLOBs>>> timeline = Maps.newLinkedHashMap();
    for (BlogPostsWithBLOBs spost : excerptList) {
        Date postDate = spost.getPostDate();
        DateTime dt = new DateTime(postDate.getTime());
        String yearMonthKey = dt.monthOfYear().getAsText(Locale.ENGLISH) + "," + dt.getYearOfEra();////key May,2015?
        Map<String, List<BlogPostsWithBLOBs>> yearMonthPostMap = timeline.get(yearMonthKey);
        if (yearMonthPostMap == null) {
            yearMonthPostMap = Maps.newLinkedHashMap();
            timeline.put(yearMonthKey, yearMonthPostMap);
        }
        String dayKey = "Day" + dt.getDayOfMonth();
        List<BlogPostsWithBLOBs> dayPostList = yearMonthPostMap.get(dayKey);
        if (dayPostList == null) {
            dayPostList = Lists.newArrayList();
            yearMonthPostMap.put(dayKey, dayPostList);
        }
        dayPostList.add(spost);

    }
    return timeline;
}

From source file:com.huang.rp.common.utils.TimeUtils.java

License:Apache License

/**
 * ?//from  w  ww .j  a  v  a 2  s.  co m
 * @return
 */
public static String getYYMMDDStr() {
    DateTime dt = new DateTime();
    StringBuilder sb = new StringBuilder();
    sb.append(dt.getYear()).append(dt.getMonthOfYear()).append(dt.getDayOfMonth());
    return sb.toString();
}

From source file:com.inkubator.hrm.util.KodefikasiUtil.java

public static String getKodefikasi(int maxNumerData, String pattern) {
    String afterString = StringUtils.substringAfter(pattern, "[");
    String beforeString = StringUtils.substringBefore(pattern, "[");
    String removeParenties1 = StringUtils.remove(afterString, "[");
    String removeParenties2 = StringUtils.remove(removeParenties1, "]");
    int numberOfYear = StringUtils.countMatches(removeParenties2, "Y");
    int numberofN = StringUtils.countMatches(removeParenties2, "N");

    int currentNumber = maxNumerData + 1;
    int numberofNEx = String.valueOf(currentNumber).length();

    int selisih = numberofN - numberofNEx;

    String montInString = null;// w  w  w .  j a v a2 s.c o  m
    String yearInString = null;
    String dayInString = null;
    String numberInString = null;
    if (selisih == 0) {
        numberInString = String.valueOf(currentNumber);
    } else {
        numberInString = StringUtils.leftPad(String.valueOf(currentNumber), numberofN, "0");
    }
    DateTime jodaTime = new DateTime();
    int year = jodaTime.getYear();
    int month = jodaTime.getMonthOfYear();
    int day = jodaTime.getDayOfMonth();

    if (month < 10) {
        montInString = "0" + month;
    } else {
        montInString = String.valueOf(month);
    }
    if (numberOfYear == 2) {
        year = Integer.parseInt(new SimpleDateFormat("YY").format(new Date()));
        if (year < 10) {
            yearInString = "0" + year;
        } else {
            yearInString = String.valueOf(year);
        }
    } else {
        yearInString = String.valueOf(year);
    }

    if (day < 10) {
        dayInString = "0" + day;
    } else {
        dayInString = String.valueOf(day);
    }
    String output1 = StringUtils.replaceOnce(removeParenties2, "Y", yearInString);
    String output2 = StringUtils.remove(output1, "Y");
    String output3 = StringUtils.replaceOnce(output2, "M", montInString);
    String output4 = StringUtils.remove(output3, "M");
    String output5 = StringUtils.replaceOnce(output4, "D", dayInString);
    String output6 = StringUtils.remove(output5, "D");
    String output7 = StringUtils.replaceOnce(output6, "N", numberInString);
    String output8 = StringUtils.remove(output7, "N");
    return beforeString + output8;

}

From source file:com.inkubator.hrm.util.KodefikasiUtil.java

public static String getKodefikasiOnlyPattern(String pattern) {
    String afterString = StringUtils.substringAfter(pattern, "[");
    String beforeString = StringUtils.substringBefore(pattern, "[");
    String removeParenties1 = StringUtils.remove(afterString, "[");
    String removeParenties2 = StringUtils.remove(removeParenties1, "]");
    int numberOfYear = StringUtils.countMatches(removeParenties2, "Y");
    int numberofN = StringUtils.countMatches(removeParenties2, "N");

    //        int currentNumber = maxNumerData + 1;
    //        int numberofNEx = String.valueOf(currentNumber).length();

    //        int selisih = numberofN - numberofNEx;

    String montInString = null;/*from   w  ww  .j  av  a  2s  . c  o m*/
    String yearInString = null;
    String dayInString = null;
    String numberInString = null;
    //        if (selisih == 0) {
    //            numberInString = String.valueOf(currentNumber);
    //        } else {
    ////            numberInString = StringsUtils.leftPad(String.valueOf(currentNumber), numberofN, "0");
    //        }
    DateTime jodaTime = new DateTime();
    int year = jodaTime.getYear();
    int month = jodaTime.getMonthOfYear();
    int day = jodaTime.getDayOfMonth();

    if (month < 10) {
        montInString = "0" + month;
    } else {
        montInString = String.valueOf(month);
    }
    if (numberOfYear == 2) {
        year = Integer.parseInt(new SimpleDateFormat("YY").format(new Date()));
        if (year < 10) {
            yearInString = "0" + year;
        } else {
            yearInString = String.valueOf(year);
        }
    } else {
        yearInString = String.valueOf(year);
    }

    if (day < 10) {
        dayInString = "0" + day;
    } else {
        dayInString = String.valueOf(day);
    }
    String output1 = StringUtils.replaceOnce(removeParenties2, "Y", yearInString);
    String output2 = StringUtils.remove(output1, "Y");
    String output3 = StringUtils.replaceOnce(output2, "M", montInString);
    String output4 = StringUtils.remove(output3, "M");
    String output5 = StringUtils.replaceOnce(output4, "D", dayInString);
    String output6 = StringUtils.remove(output5, "D");
    //        String output7 = StringsUtils.replaceOnce(output6, "N", numberInString);
    //        String output8 = StringsUtils.remove(output7, "N");
    return beforeString + output6;
}

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

@PostConstruct
@Override//from w ww.j a  va  2  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.inspireVeiN.iPlayed.iPlayedPlayerListener.java

License:Open Source License

private void login(Player p) {
    String player = p.getName();/*w  w  w  . j  a  v  a2 s  .com*/
    Arguments entry = null;
    if (plugin.timesdb.hasIndex(player))
        entry = plugin.timesdb.getArguments(player);
    else {
        entry = new Arguments(player);
        entry.setValue("playtime", "0");
        plugin.timesdb.addIndex(player, entry);
        plugin.timesdb.update();
    }
    DateTime dt = new DateTime();
    plugin.timesdb.setArgument(player, "lastlogin",
            dt.getMonthOfYear() + "/" + dt.getDayOfMonth() + "/" + dt.getYear(), true);
    plugin.timesdb.setArgument(player, "startTime", Integer.toString(dt.getMinuteOfDay()), true);
}

From source file:com.iukonline.amule.android.amuleremote.partfile.PartFileDetailsFragment.java

License:Open Source License

private void refreshView() {

    View v = getView();//from  w w w . j  ava2  s  .c  o m

    if (mPartFile != null) {

        mFileNameText.setText(mPartFile.getFileName());

        String textCat = getResources().getString(R.string.partfile_details_cat_unknown);
        int backgroundColorCat = 0;
        int textColorCat = getResources().getColor(R.color.secondary_text);
        long cat = mPartFile.getCat();
        if (cat == 0) {
            textCat = getResources().getString(R.string.partfile_details_cat_nocat);

        } else {
            ECCategory[] catList = mApp.mECHelper.getCategories();
            if (catList != null) {
                for (int i = 0; i < catList.length; i++) {
                    if (catList[i].getId() == cat) {
                        textCat = catList[i].getTitle();

                        backgroundColorCat = 0xff000000 | (int) catList[i].getColor();
                        textColorCat = 0xff000000 | GUIUtils.chooseFontColor((int) catList[i].getColor());

                        break;
                    }
                }
            }
        }
        mCategoryText.setText(textCat);
        ((GradientDrawable) mCategoryText.getBackground()).setColor(backgroundColorCat);
        mCategoryText.setTextColor(textColorCat);

        mLinkText.setText(mPartFile.getEd2kLink());
        mDoneText.setText(GUIUtils.longToBytesFormatted(mPartFile.getSizeDone()));
        mSizeText.setText(GUIUtils.longToBytesFormatted(mPartFile.getSizeFull()));
        mRemainingText.setText(GUIUtils.getETA(getActivity(), mPartFile.getSizeFull() - mPartFile.getSizeDone(),
                mPartFile.getSpeed()));

        Date lastSeenComplateDate = mPartFile.getLastSeenComp();
        DateTime lastSeenComplateDateTime = new DateTime(lastSeenComplateDate);
        DateTime now = new DateTime();
        if (lastSeenComplateDate == null || lastSeenComplateDate.getTime() == 0L) {
            mLastSeenText.setText(getResources().getString(R.string.partfile_last_seen_never));
        } else {
            long lastSeenSeconds = (System.currentTimeMillis() - mPartFile.getLastSeenComp().getTime()) / 1000L;

            if (lastSeenSeconds <= 60L) {
                mLastSeenText.setText(getResources().getString(R.string.partfile_last_seen_now));
            } else if (lastSeenSeconds <= 3600L) {
                mLastSeenText.setText(getResources().getQuantityString(R.plurals.partfile_last_seen_mins,
                        (int) (lastSeenSeconds / 60L), lastSeenSeconds / 60L));
            } else if (lastSeenSeconds <= 86400L) {
                int lastSeenHours = (int) (lastSeenSeconds / 3600);
                if (lastSeenHours < 12 || lastSeenComplateDateTime.getDayOfMonth() == now.getDayOfMonth()) {
                    mLastSeenText.setText(getResources().getQuantityString(R.plurals.partfile_last_seen_hours,
                            lastSeenHours, lastSeenHours));
                } else {
                    mLastSeenText.setText(getResources().getString(R.string.partfile_last_seen_yesterday));
                }
            } else {
                int diffDays = Days.daysBetween(lastSeenComplateDateTime, now).getDays();
                if (diffDays <= 31) {
                    mLastSeenText.setText(getResources().getQuantityString(R.plurals.partfile_last_seen_days,
                            diffDays, diffDays));
                } else if (diffDays <= 180) {
                    int diffMonths = Months.monthsBetween(lastSeenComplateDateTime, now).getMonths();
                    mLastSeenText.setText(getResources().getQuantityString(R.plurals.partfile_last_seen_months,
                            diffMonths, diffMonths));
                } else {
                    mLastSeenText.setText(getResources().getString(R.string.partfile_last_seen_date,
                            lastSeenComplateDateTime.toString(DateTimeFormat.forStyle("L-")
                                    .withLocale(getResources().getConfiguration().locale))));
                }
            }
        }

        mSourcesAvailableText
                .setText(Integer.toString(mPartFile.getSourceCount() - mPartFile.getSourceNotCurrent()));
        mSourcesActiveText.setText(Integer.toString(mPartFile.getSourceXfer()));
        mSourcesA4AFText.setText(Integer.toString(mPartFile.getSourceA4AF()));
        mSourcesNotCurrentText.setText(Integer.toString(mPartFile.getSourceNotCurrent()));

        switch (mPartFile.getPrio()) {
        case ECPartFile.PR_LOW:
            mPriorityText.setText(R.string.partfile_prio_low);
            break;
        case ECPartFile.PR_NORMAL:
            mPriorityText.setText(R.string.partfile_prio_normal);
            break;
        case ECPartFile.PR_HIGH:
            mPriorityText.setText(R.string.partfile_prio_high);
            break;
        case ECPartFile.PR_AUTO_LOW:
            mPriorityText.setText(R.string.partfile_prio_auto_low);
            break;
        case ECPartFile.PR_AUTO_NORMAL:
            mPriorityText.setText(R.string.partfile_prio_auto_normal);
            break;
        case ECPartFile.PR_AUTO_HIGH:
            mPriorityText.setText(R.string.partfile_prio_auto_high);
            break;
        default:
            mPriorityText.setText(R.string.partfile_prio_unknown);
            break;
        }

        int statusColor = R.color.progressWaitingMid;

        switch (mPartFile.getStatus()) {

        case ECPartFile.PS_ALLOCATING:
            mStatusText.setText(R.string.partfile_status_allocating);
            break;
        case ECPartFile.PS_COMPLETE:
            mStatusText.setText(R.string.partfile_status_complete);
            statusColor = R.color.progressRunningMid;
            break;
        case ECPartFile.PS_COMPLETING:
            mStatusText.setText(R.string.partfile_status_completing);
            statusColor = R.color.progressRunningMid;
            break;
        case ECPartFile.PS_EMPTY:
            mStatusText.setText(R.string.partfile_status_empty);
            statusColor = R.color.progressBlockedMid;
            break;
        case ECPartFile.PS_ERROR:
            mStatusText.setText(R.string.partfile_status_error);
            statusColor = R.color.progressBlockedMid;
            break;
        case ECPartFile.PS_WAITINGFORHASH:
        case ECPartFile.PS_HASHING:
            mStatusText.setText(R.string.partfile_status_hashing);
            break;
        case ECPartFile.PS_INSUFFICIENT:
            mStatusText.setText(R.string.partfile_status_insuffcient);
            statusColor = R.color.progressBlockedMid;
            break;
        case ECPartFile.PS_PAUSED:
            mStatusText.setText(R.string.partfile_status_paused);
            break;
        case ECPartFile.PS_READY:
            if (mPartFile.getSourceXfer() > 0) {
                mStatusText.setText(R.string.partfile_status_downloading);
                mStatusText.append(" " + GUIUtils.longToBytesFormatted(mPartFile.getSpeed()) + "/s");
                statusColor = R.color.progressRunningMid;
            } else {
                mStatusText.setText(R.string.partfile_status_waiting);
                statusColor = R.color.progressWaitingMid;
            }
            break;
        case ECPartFile.PS_UNKNOWN:
            mStatusText.setText(R.string.partfile_status_unknown);
            statusColor = R.color.progressStoppedMid;
            break;
        default:
            mStatusText.setText("UNKNOWN-" + mPartFile.getStatus());
            break;
        }
        mStatusText.setTextColor(getResources().getColor(statusColor));
    }
}

From source file:com.linkedin.cubert.utils.FileSystemUtils.java

License:Open Source License

public static List<Path> getDurationPaths(FileSystem fs, Path root, DateTime startDate, DateTime endDate,
        boolean isDaily, int hourStep, boolean errorOnMissing, boolean useHourlyForMissingDaily)
        throws IOException {
    List<Path> paths = new ArrayList<Path>();
    while (endDate.compareTo(startDate) >= 0) {
        Path loc;/*from www .  j  a  v a 2  s  . com*/
        if (isDaily)
            loc = generateDatedPath(root, endDate.getYear(), endDate.getMonthOfYear(), endDate.getDayOfMonth());
        else
            loc = generateDatedPath(root, endDate.getYear(), endDate.getMonthOfYear(), endDate.getDayOfMonth(),
                    endDate.getHourOfDay());

        // Check that directory exists, and contains avro files.
        if (fs.exists(loc) && fs.globStatus(new Path(loc, "*" + "avro")).length > 0) {
            paths.add(loc);
        }

        else {

            loc = generateDatedPath(new Path(root.getParent(), "hourly"), endDate.getYear(),
                    endDate.getMonthOfYear(), endDate.getDayOfMonth());
            if (isDaily && useHourlyForMissingDaily && fs.exists(loc)) {
                for (FileStatus hour : fs.listStatus(loc)) {
                    paths.add(hour.getPath());
                }
            }

            else if (errorOnMissing) {
                throw new RuntimeException("Missing directory " + loc.toString());
            }

        }
        if (hourStep == 24)
            endDate = endDate.minusDays(1);
        else
            endDate = endDate.minusHours(hourStep);
    }
    return paths;
}

From source file:com.marand.thinkmed.medications.business.impl.DefaultMedicationsBo.java

License:Open Source License

@Override
public List<TherapySurgeryReportElementDto> getTherapySurgeryReportElements(@Nonnull final String patientId,
        final Double patientHeight, @Nonnull final DateTime searchStart,
        @Nonnull final RoundsIntervalDto roundsIntervalDto, @Nonnull final Locale locale,
        @Nonnull final DateTime when) {
    Preconditions.checkNotNull(patientId, "patientId");
    Preconditions.checkNotNull(searchStart, "searchStart");
    Preconditions.checkNotNull(roundsIntervalDto, "roundsIntervalDto");
    Preconditions.checkNotNull(locale, "locale");
    Preconditions.checkNotNull(when, "when");

    final DateTime roundsStart = new DateTime(searchStart.getYear(), searchStart.getMonthOfYear(),
            searchStart.getDayOfMonth(), roundsIntervalDto.getStartHour(), roundsIntervalDto.getStartMinute());

    final List<Pair<MedicationOrderComposition, MedicationInstructionInstruction>> instructionsList = medicationsOpenEhrDao
            .findMedicationInstructions(patientId, Intervals.infiniteFrom(roundsStart), null);

    final Double referenceWeight = medicationsOpenEhrDao.getPatientLastReferenceWeight(patientId,
            Intervals.infiniteTo(searchStart));

    final List<TherapySurgeryReportElementDto> elements = new ArrayList<>();
    final Map<Long, MedicationDataForTherapyDto> medicationsMap = getMedicationDataForTherapies(
            instructionsList, null);//from  w  ww.  jav  a  2 s.  co m

    for (final Pair<MedicationOrderComposition, MedicationInstructionInstruction> instructionPair : instructionsList) {
        final MedicationOrderComposition composition = instructionPair.getFirst();
        final MedicationInstructionInstruction instruction = instructionPair.getSecond();

        final MedicationTimingCluster medicationTiming = instruction.getOrder().get(0).getMedicationTiming();
        final Interval instructionInterval = MedicationsEhrUtils.getInstructionInterval(medicationTiming);
        final boolean onlyOnce = isOnlyOnceThenEx(medicationTiming);
        if (instructionInterval.overlaps(Intervals.infiniteFrom(searchStart))
                || onlyOnce && instructionInterval.getStart().isAfter(searchStart.minusHours(1))) {
            final List<MedicationActionAction> actions = MedicationsEhrUtils.getInstructionActions(composition,
                    instruction);
            if (!isTherapyCanceledAbortedOrSuspended(actions)) {
                final TherapyDto therapy = getTherapyFromMedicationInstruction(composition, instruction,
                        referenceWeight, patientHeight, when);

                therapyDisplayProvider.fillDisplayValues(therapy, false, true, false, locale, true);

                final boolean containsAntibiotics = getMedicationIds(
                        MedicationsEhrUtils.getRepresentingOrderActivity(instruction)).stream().anyMatch(
                                id -> medicationsMap.containsKey(id) && medicationsMap.get(id).isAntibiotic());

                if (containsAntibiotics) {
                    final int consecutiveDays = getTherapyConsecutiveDay(
                            getOriginalTherapyStart(patientId, composition), when, when,
                            therapy.getPastDaysOfTherapy());

                    elements.add(new TherapySurgeryReportElementDto(therapy.getFormattedTherapyDisplay(),
                            consecutiveDays));
                } else {
                    elements.add(new TherapySurgeryReportElementDto(therapy.getFormattedTherapyDisplay()));
                }
            }
        }
    }
    return elements;
}