List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:eu.itesla_project.histodb.client.impl.OfflineDbImpl.java
License:Mozilla Public License
@Override public OfflineWorkflowCreationParameters getParameters(String workflowId) { Matcher m = ID_PATTERN.matcher(workflowId); if (!m.matches()) { throw new IllegalArgumentException("Unexpected workflow id"); }/*w w w. ja v a2 s .c om*/ return new OfflineWorkflowCreationParameters(EnumSet.of(Country.FR), new DateTime(Long.parseLong(m.group(1))), new Interval(new DateTime(Long.parseLong(m.group(2))), new DateTime(Long.parseLong(m.group(3)))), false, false); }
From source file:eu.itesla_project.modules.test.InMemoryOfflineDb.java
License:Mozilla Public License
@Override public OfflineWorkflowCreationParameters getParameters(String workflowId) { return new OfflineWorkflowCreationParameters(EnumSet.of(Country.FR), DateTime.now(), new Interval(DateTime.now(), DateTime.now().plus(1)), false, false); }
From source file:eu.itesla_project.offline.server.OfflineApplicationMock.java
License:Mozilla Public License
@Override public Map<String, OfflineWorkflowStatus> listWorkflows() { Map<String, OfflineWorkflowStatus> statuses = new HashMap<>(); for (OfflineWorkflowMock workflow : workflows.values()) { statuses.put(workflow.id,/* www . j a va2s . c o m*/ new OfflineWorkflowStatus(workflow.id, OfflineWorkflowStep.SAMPLING, new OfflineWorkflowCreationParameters(new HashSet(), new DateTime(), new Interval(0, 100000), false, false))); } return statuses; }
From source file:eu.itesla_project.offline.server.OfflineApplicationResource.java
License:Mozilla Public License
@POST @Path("workflow/create") @Produces(MediaType.TEXT_PLAIN)//from ww w. j a v a2 s. c o m public Response createWorkflow(JsonObject paramsObj) { LOGGER.debug("createWorkflow()"); String workflowId = paramsObj.getString("id", null); //DateTime parsing... DateTime baseCaseDate = DateTime.parse(paramsObj.getJsonString("baseCaseDate").getString()); DateTime histoIntervalStart = DateTime .parse(paramsObj.getJsonObject("histoInterval").getJsonString("start").getString()); DateTime histoIntervalEnd = DateTime .parse(paramsObj.getJsonObject("histoInterval").getJsonString("end").getString()); List<JsonString> countryCodes = paramsObj.getJsonArray("countries").getValuesAs(JsonString.class); Set<Country> countries = new HashSet<>(countryCodes.size()); for (JsonString countryCode : countryCodes) { countries.add(Country.valueOf(countryCode.getString())); } OfflineWorkflowCreationParameters parameters = new OfflineWorkflowCreationParameters(countries, baseCaseDate, new Interval(histoIntervalStart.getMillis(), histoIntervalEnd.getMillis()), false, // TODO false); try { return Response.status(200).entity(bean.getApplication().createWorkflow(workflowId, parameters)) .build(); } catch (Exception e) { LOGGER.error(e.toString(), e); return Response.status(500).entity(e.getMessage()).build(); } }
From source file:fi.hsl.parkandride.core.domain.HasInterval.java
License:EUPL
default Interval getInterval() { return new Interval(getStart(), getEnd()); }
From source file:fi.hsl.parkandride.core.service.FacilityHistoryService.java
License:EUPL
private static Interval windowForDate(LocalDate date) { return new Interval(date.toDateTime(WINDOW_START), date.toDateTime(WINDOW_END)); }
From source file:fr.cls.atoll.motu.library.misc.data.DatasetFtp.java
License:Open Source License
/** * Select data file.//from ww w.j a va 2 s. c om * * @return the list< data file> */ protected List<DataFile> selectDataFile() { ExtractCriteriaDatetime extractCriteriaDatetime = findCriteriaDatetime(); if (extractCriteriaDatetime == null) { return product.getDataFiles(); } List<DataFile> selected = new ArrayList<DataFile>(); Date start = extractCriteriaDatetime.getFrom(); Date end = extractCriteriaDatetime.getTo(); Interval datePeriod = new Interval(start.getTime(), end.getTime()); // files are sorted by date (ascending) List<DataFile> dataFiles = product.getDataFiles(); for (DataFile dataFile : dataFiles) { Date fileStart = dataFile.getStartCoverageDate().toDate(); // file start date is greater than criteria end date --> end if (fileStart.compareTo(end) > 0) { break; } Date fileEnd = dataFile.getEndCoverageDate().toDate(); Interval filePeriod = new Interval(fileStart.getTime(), fileEnd.getTime()); if (DateUtils.intersects(filePeriod, datePeriod)) { selected.add(dataFile); } } return selected; }
From source file:google.registry.model.domain.DomainResource.java
License:Open Source License
/** * The logic in this method, which handles implicit server approval of transfers, very closely * parallels the logic in {@code DomainTransferApproveFlow} which handles explicit client * approvals./*w w w . j a v a 2 s. com*/ */ @Override public DomainResource cloneProjectedAtTime(final DateTime now) { TransferData transferData = getTransferData(); DateTime transferExpirationTime = transferData.getPendingTransferExpirationTime(); // If there's a pending transfer that has expired, handle it. if (TransferStatus.PENDING.equals(transferData.getTransferStatus()) && isBeforeOrAt(transferExpirationTime, now)) { // Project until just before the transfer time. This will handle the case of an autorenew // before the transfer was even requested or during the request period. // If the transfer time is precisely the moment that the domain expires, there will not be an // autorenew billing event (since we end the recurrence at transfer time and recurrences are // exclusive of their ending), and we can just proceed with the transfer. DomainResource domainAtTransferTime = cloneProjectedAtTime(transferExpirationTime.minusMillis(1)); // If we are within an autorenew grace period, the transfer will subsume the autorenew. There // will already be a cancellation written in advance by the transfer request flow, so we don't // need to worry about billing, but we do need to reduce the number of years added to the // expiration time by one to account for the year added by the autorenew. int extraYears = transferData.getExtendedRegistrationYears(); if (domainAtTransferTime.getGracePeriodStatuses().contains(GracePeriodStatus.AUTO_RENEW)) { extraYears--; } // Set the expiration, autorenew events, and grace period for the transfer. (Transfer ends // all other graces). Builder builder = domainAtTransferTime.asBuilder() // Extend the registration by the correct number of years from the expiration time that // was current on the domain right before the transfer, capped at 10 years from the // moment of the transfer. .setRegistrationExpirationTime(extendRegistrationWithCap(transferExpirationTime, domainAtTransferTime.getRegistrationExpirationTime(), extraYears)) // Set the speculatively-written new autorenew events as the domain's autorenew events. .setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent()) .setAutorenewPollMessage(transferData.getServerApproveAutorenewPollMessage()) // Set the grace period using a key to the prescheduled transfer billing event. Not using // GracePeriod.forBillingEvent() here in order to avoid the actual datastore fetch. .setGracePeriods(ImmutableSet.of(GracePeriod.create(GracePeriodStatus.TRANSFER, transferExpirationTime.plus(Registry.get(getTld()).getTransferGracePeriodLength()), transferData.getGainingClientId(), transferData.getServerApproveBillingEvent()))); // Set all remaining transfer properties. setAutomaticTransferSuccessProperties(builder, transferData); // Finish projecting to now. return builder.build().cloneProjectedAtTime(now); } // There is no transfer. Do any necessary autorenews. Builder builder = asBuilder(); if (isBeforeOrAt(registrationExpirationTime, now)) { // Autorenew by the number of years between the old expiration time and now. DateTime lastAutorenewTime = leapSafeAddYears(registrationExpirationTime, new Interval(registrationExpirationTime, now).toPeriod().getYears()); DateTime newExpirationTime = lastAutorenewTime.plusYears(1); builder.setRegistrationExpirationTime(newExpirationTime) .addGracePeriod(GracePeriod.createForRecurring(GracePeriodStatus.AUTO_RENEW, lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()), getCurrentSponsorClientId(), autorenewBillingEvent)); } // Remove any grace periods that have expired. DomainResource almostBuilt = builder.build(); builder = almostBuilt.asBuilder(); for (GracePeriod gracePeriod : almostBuilt.getGracePeriods()) { if (isBeforeOrAt(gracePeriod.getExpirationTime(), now)) { builder.removeGracePeriod(gracePeriod); } } // Handle common properties like setting or unsetting linked status. This also handles the // general case of pending transfers for other resource types, but since we've always handled // a pending transfer by this point that's a no-op for domains. projectResourceOntoBuilderAtTime(almostBuilt, builder, now); return builder.build(); }
From source file:google.registry.model.EppResourceUtils.java
License:Open Source License
/** * The lifetime of a resource is from its creation time, inclusive, through its deletion time, * exclusive, which happily maps to the behavior of Interval. *//*from ww w . j a v a 2s. c om*/ private static Interval getLifetime(EppResource resource) { return new Interval(resource.getCreationTime(), resource.getDeletionTime()); }
From source file:google.registry.model.registry.Registry.java
License:Open Source License
public Interval getLrpPeriod() { return (lrpPeriodStart == null && lrpPeriodEnd == null) ? new Interval(START_OF_TIME, Duration.ZERO) // An empty duration. : new Interval(lrpPeriodStart, lrpPeriodEnd); }