Example usage for org.joda.time Interval getStart

List of usage examples for org.joda.time Interval getStart

Introduction

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

Prototype

public DateTime getStart() 

Source Link

Document

Gets the start of this time interval, which is inclusive, as a DateTime.

Usage

From source file:com.nfsdb.journal.Journal.java

License:Apache License

public TempPartition<T> createTempPartition(String name) throws JournalException {
    int lag = getMetadata().getLag();
    if (lag <= 0) {
        throw new JournalRuntimeException("Journal doesn't support temp partitions: %s", this);
    }//from  www  .j a v a2s.co  m

    Interval interval = null;
    if (getMetadata().getPartitionType() != PartitionType.NONE) {
        if (nonLagPartitionCount() > 0) {
            Interval lastPartitionInterval = partitions.get(nonLagPartitionCount() - 1).getInterval();
            interval = new Interval(lastPartitionInterval.getStart(),
                    lastPartitionInterval.getEnd().plusHours(lag));
        } else {
            interval = Dates.intervalForDate(System.currentTimeMillis(), getMetadata().getPartitionType());
        }
    }
    return new TempPartition<>(this, interval, nonLagPartitionCount(), name);
}

From source file:com.nfsdb.journal.utils.Dates.java

License:Apache License

public static String dirNameForIntervalStart(Interval interval, PartitionType partitionType) {
    switch (partitionType) {
    case YEAR:/*from   w w  w .  j  a  v a2 s.c  o m*/
        return interval.getStart().toString("YYYY");
    case MONTH:
        return interval.getStart().toString("YYYY-MM");
    case DAY:
        return interval.getStart().toString("YYYY-MM-dd");
    case NONE:
        return "default";
    }
    return "";
}

From source file:com.peertopark.java.dates.Intervals.java

License:Apache License

/**
 * Get a list of DateTime with the days of week in a datetime interval
 * @param interval//from   ww w. java  2 s .co m
 * @param dayOfWeek
 * @return List of DateTime
 */
public static List<DateTime> daysOfWeek(Interval interval, int dayOfWeek) {
    return Dates.daysOfWeekInDateInterval(interval.getStart(), interval.getEnd(), dayOfWeek);
}

From source file:com.peertopark.java.dates.iterators.DayOfWeekIterator.java

License:Apache License

public DayOfWeekIterator(Interval interval, int dayOfWeekToIterate) {
    this(interval.getStart(), interval.getEnd(), dayOfWeekToIterate);
}

From source file:com.pinterest.deployservice.handler.DeployHandler.java

License:Apache License

public List<DeployBean> getDeployCandidates(String envId, Interval interval, int size, boolean onlyGoodBuilds)
        throws Exception {
    LOG.info("Search Deploy candidates between {} and {} for environment {}",
            interval.getStart().toString(ISODateTimeFormat.dateTime()),
            interval.getEnd().toString(ISODateTimeFormat.dateTime()), envId);
    List<DeployBean> taggedGoodDeploys = new ArrayList<DeployBean>();

    List<DeployBean> availableDeploys = deployDAO.getAcceptedDeploys(envId, interval, size);

    if (!onlyGoodBuilds) {
        return availableDeploys;
    }// w ww  .j av  a2  s .  c  om

    if (!availableDeploys.isEmpty()) {
        Map<String, DeployBean> buildId2DeployBean = new HashMap<String, DeployBean>();
        for (DeployBean deployBean : availableDeploys) {
            String buildId = deployBean.getBuild_id();
            if (StringUtils.isNotEmpty(buildId)) {
                buildId2DeployBean.put(buildId, deployBean);
            }
        }
        List<BuildBean> availableBuilds = buildDAO.getBuildsFromIds(buildId2DeployBean.keySet());
        List<BuildTagBean> buildTagBeanList = buildTagsManager.getEffectiveTagsWithBuilds(availableBuilds);
        for (BuildTagBean buildTagBean : buildTagBeanList) {
            if (buildTagBean.getTag() != null && buildTagBean.getTag().getValue() == TagValue.BAD_BUILD) {
                // bad build,  do not include
                LOG.info("Env {} Build {} is tagged as BAD_BUILD, ignore", envId, buildTagBean.getBuild());
            } else {
                String buildId = buildTagBean.getBuild().getBuild_id();
                taggedGoodDeploys.add(buildId2DeployBean.get(buildId));
            }
        }
    }
    // should order deploy bean by start date desc
    if (taggedGoodDeploys.size() > 0) {
        Collections.sort(taggedGoodDeploys, new Comparator<DeployBean>() {
            @Override
            public int compare(final DeployBean d1, final DeployBean d2) {
                return Long.compare(d2.getStart_date(), d1.getStart_date());
            }
        });
        LOG.info("Env {} the first deploy candidate is {}", envId, taggedGoodDeploys.get(0).getBuild_id());
    }
    return taggedGoodDeploys;
}

From source file:com.pinterest.teletraan.worker.AutoPromoter.java

License:Apache License

/**
 * get a list of available builds, and filter out the BAD_BUILD builds
 * @param envBean/*from   w  w  w . ja v a2  s .c  o m*/
 * @param interval
 * @param size
 * @return
 * @throws Exception
 */
List<BuildBean> getBuildCandidates(EnvironBean envBean, Interval interval, int size) throws Exception {
    // By default, buildName is the same as envName
    String buildName = envBean.getBuild_name();
    String scmBranch = envBean.getBranch();
    List<BuildBean> taggedGoodBuilds = new ArrayList<BuildBean>();

    List<BuildBean> availableBuilds = buildDAO.getAcceptedBuilds(buildName, scmBranch, interval, size);
    LOG.info("Env {} stage {} has {} accepted builds with name {} branch {} between {} and {}",
            envBean.getEnv_name(), envBean.getStage_name(), availableBuilds.size(), buildName, scmBranch,
            interval.getStart().toString(), interval.getEnd().toString());
    if (!availableBuilds.isEmpty()) {
        List<BuildTagBean> buildTagBeanList = buildTagsManager.getEffectiveTagsWithBuilds(availableBuilds);
        for (BuildTagBean buildTagBean : buildTagBeanList) {
            if (buildTagBean.getTag() != null && buildTagBean.getTag().getValue() == TagValue.BAD_BUILD) {
                // bad build,  do not include
                LOG.info("Env {} Build {} is tagged as BAD_BUILD, ignore", envBean.getEnv_id(),
                        buildTagBean.getBuild());
            } else {
                taggedGoodBuilds.add(buildTagBean.getBuild());
            }
        }
    }
    // should order build bean ORDER BY publish_date DESC
    if (taggedGoodBuilds.size() > 0) {
        Collections.sort(taggedGoodBuilds, new Comparator<BuildBean>() {
            @Override
            public int compare(final BuildBean d1, final BuildBean d2) {
                return Long.compare(d2.getPublish_date(), d1.getPublish_date());
            }
        });
        LOG.info("Env {} the first build candidate is {}", envBean.getEnv_id(),
                taggedGoodBuilds.get(0).getBuild_id());
    }
    return taggedGoodBuilds;
}

From source file:com.qcadoo.mes.deviationCausesReporting.dataProvider.DeviationWithOccurrencesDataProvider.java

License:Open Source License

private List<Entity> getMatchingOccurrencesProjection(final DeviationsReportCriteria criteria) {
    SearchQueryBuilder sqb = getDictionaryItemDD().find(ALL_PROBLEM_OCCURRENCES_QUERY);
    Interval searchInterval = criteria.getSearchInterval();
    sqb.setTimestamp(L_DATE_FROM, searchInterval.getStart().toDate());
    sqb.setTimestamp(L_DATE_TO, searchInterval.getEnd().toDate());
    sqb.setParameterList(L_EXCLUDED_ORDER_STATES, criteria.getExcludedOrderStates());
    return sqb.list().getEntities();
}

From source file:com.qcadoo.mes.deviationCausesReporting.print.DeviationsProtocolPdf.java

License:Open Source License

private PdfPTable createHeaderTable(final Interval searchDatesRange, final Locale locale) {
    PdfPTable headerTable = pdfHelper.createPanelTable(2);
    headerTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    pdfHelper.addTableCellAsTwoColumnsTable(headerTable,
            translate("deviationCausesReporting.report.header.dateFrom.label", locale),
            DateUtils.toDateString(searchDatesRange.getStart().toDate()));
    pdfHelper.addTableCellAsTwoColumnsTable(headerTable,
            translate("deviationCausesReporting.report.header.dateTo.label", locale),
            DateUtils.toDateString(searchDatesRange.getEnd().toDate()));
    return headerTable;
}

From source file:com.qcadoo.mes.productionPerShift.DateTimeRange.java

License:Open Source License

public DateTimeRange unionWith(DateTimeRange other) {
    Interval otherInterval = other.interval;
    DateTime start = interval.getStart().isBefore(otherInterval.getStart()) ? interval.getStart()
            : otherInterval.getStart();/*from  ww w. ja va2 s.  c om*/
    DateTime end = interval.getEnd().isAfter(otherInterval.getEnd()) ? interval.getEnd()
            : otherInterval.getEnd();
    Interval unionInterval = new Interval(start, end);

    return new DateTimeRange(unionInterval);
}

From source file:com.qcadoo.mes.productionPerShift.DateTimeRange.java

License:Open Source License

public Collection<? extends DateTimeRange> remove(final DateTimeRange range) {
    Interval other = range.interval;
    if (interval.contains(other)) {
        return Lists.newArrayList(new DateTimeRange(interval.getStart(), other.getStart()),
                new DateTimeRange(other.getEnd(), interval.getEnd()));
    } else if (other.contains(interval)) {
        return Collections.EMPTY_LIST;
    } else if (interval.overlaps(other)) {
        if (interval.getStart().isBefore(other.getStart())) {
            return Lists.newArrayList(new DateTimeRange(interval.getStart(), other.getStart()));
        } else {//w  w w.j a  va2s  .c  o m
            return Lists.newArrayList(new DateTimeRange(other.getEnd(), interval.getEnd()));
        }
    }
    return Lists.newArrayList(this);
}