List of usage examples for java.util Date after
public boolean after(Date when)
From source file:com.collabnet.ccf.pi.sfee.v44.SFEEAttachmentHandler.java
/** * This method retrieves all the attachments for all the artifacts present * in the artifactRows Set and encoded them into GenericArtifact attachment * format.//w ww .j ava 2 s. co m * * @param sessionId * @param lastModifiedDate * @param username * artifacts from this user will be filtered out * @param resyncUsername * artifacts from this user will be filtered out * @param artifactRows * @param sourceForgeSoap * @param maxAttachmentSizePerArtifact * @param artifactData * @return * @throws RemoteException */ public List<GenericArtifact> listAttachments(String sessionId, Date lastModifiedDate, String username, String resyncUsername, List<String> artifactIds, ISourceForgeSoap sourceForgeSoap, long maxAttachmentSizePerArtifact, boolean shouldShipAttachmentsWithArtifact, GenericArtifact artifactData) throws RemoteException { List<GenericArtifact> attachmentGAs = new ArrayList<GenericArtifact>(); for (String artifactId : artifactIds) { // String folderId = artifact.getFolderId(); AttachmentSoapList attachmentsList = sourceForgeSoap.listAttachments(sessionId, artifactId); AttachmentSoapRow[] attachmentRows = attachmentsList.getDataRows(); for (AttachmentSoapRow row : attachmentRows) { String fileName = row.getFileName(); String attachmentSizeStr = row.getFileSize(); // String attachmentId = row.getStoredFileId(); long attachmentSize = Long.parseLong(attachmentSizeStr); if (fileName.startsWith(username + "_")) { continue; } if (resyncUsername != null && fileName.startsWith(resyncUsername + "_")) { continue; } if (attachmentSize > maxAttachmentSizePerArtifact) { log.warn("attachment size is more than the configured maxAttachmentSizePerArtifact " + attachmentSizeStr); continue; } Date createdDate = row.getDateCreated(); if (createdDate.after(lastModifiedDate)) { GenericArtifact ga = new GenericArtifact(); ga.setIncludesFieldMetaData(GenericArtifact.IncludesFieldMetaDataValue.FALSE); ga.setArtifactAction(GenericArtifact.ArtifactActionValue.CREATE); ga.setArtifactMode(GenericArtifact.ArtifactModeValue.CHANGEDFIELDSONLY); ga.setArtifactType(GenericArtifact.ArtifactTypeValue.ATTACHMENT); ga.setDepParentSourceArtifactId(artifactId); ga.setSourceArtifactId(row.getAttachmentId()); if (artifactData != null) { ga.setSourceArtifactVersion(artifactData.getSourceArtifactVersion()); ga.setSourceArtifactLastModifiedDate(artifactData.getSourceArtifactLastModifiedDate()); } else { ga.setSourceArtifactVersion("1"); ga.setSourceArtifactLastModifiedDate(DateUtil.format(createdDate)); } GenericArtifactField contentTypeField = ga.addNewField(AttachmentMetaData.ATTACHMENT_TYPE, GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD); contentTypeField.setFieldValue(AttachmentMetaData.AttachmentType.DATA); contentTypeField.setFieldAction(GenericArtifactField.FieldActionValue.REPLACE); contentTypeField.setFieldValueType(GenericArtifactField.FieldValueTypeValue.STRING); GenericArtifactField sourceURLField = ga.addNewField(AttachmentMetaData.ATTACHMENT_SOURCE_URL, GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD); sourceURLField.setFieldValue(AttachmentMetaData.AttachmentType.LINK); sourceURLField.setFieldAction(GenericArtifactField.FieldActionValue.REPLACE); sourceURLField.setFieldValueType(GenericArtifactField.FieldValueTypeValue.STRING); //gaAttachment.setAttachmentAction(GenericArtifactAttachment // .AttachmentActionValue.CREATE); GenericArtifactField nameField = ga.addNewField(AttachmentMetaData.ATTACHMENT_NAME, GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD); nameField.setFieldValue(row.getFileName()); nameField.setFieldAction(GenericArtifactField.FieldActionValue.REPLACE); nameField.setFieldValueType(GenericArtifactField.FieldValueTypeValue.STRING); // gaAttachment.setAttachmentDescription(row.getFileName()); GenericArtifactField sizeField = ga.addNewField(AttachmentMetaData.ATTACHMENT_SIZE, GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD); sizeField.setFieldValue(Long.parseLong(row.getFileSize())); sizeField.setFieldAction(GenericArtifactField.FieldActionValue.REPLACE); sizeField.setFieldValueType(GenericArtifactField.FieldValueTypeValue.STRING); // gaAttachment.setAttachmentType(); GenericArtifactField mimeTypeField = ga.addNewField(AttachmentMetaData.ATTACHMENT_MIME_TYPE, GenericArtifactField.VALUE_FIELD_TYPE_FLEX_FIELD); mimeTypeField.setFieldValue(row.getMimetype()); mimeTypeField.setFieldAction(GenericArtifactField.FieldActionValue.REPLACE); mimeTypeField.setFieldValueType(GenericArtifactField.FieldValueTypeValue.STRING); byte[] attachmentData = null; attachmentData = this.getAttachmentData(sessionId, row.getRawFileId(), Long.parseLong(row.getFileSize()), artifactId, shouldShipAttachmentsWithArtifact, ga); if (shouldShipAttachmentsWithArtifact) { if (attachmentData != null) { ga.setRawAttachmentData(attachmentData); } } attachmentGAs.add(ga); } } } return attachmentGAs; }
From source file:org.openmrs.module.kenyaemr.fragment.controller.form.EnterHtmlFormFragmentController.java
/** * Custom server-side validation/*from w ww. j a va2 s . c om*/ * @param formEncounter the encounter being edited/created * @param formDescriptor the form descriptor * @param visit the associated visit * @return any validation errors */ protected List<FormSubmissionError> extraValidation(Encounter formEncounter, FormDescriptor formDescriptor, Visit visit) { List<FormSubmissionError> validationErrors = new ArrayList<FormSubmissionError>(); EncounterWrapper wrapped = new EncounterWrapper(formEncounter); if (wrapped.getProvider() == null) { validationErrors.add(new FormSubmissionError("general-form-error", "Current user is not a provider and no other provider was specified")); } if (formDescriptor.getAutoCreateVisitTypeUuid() != null) { // Don't do validation against the visit because the encounter can be moved } else if (visit != null) { // If encounter is for a specific visit then check encounter date is valid for that visit. The visit handler // will ensure that the encounter is actually saved into that visit Date formEncounterDateTime = formEncounter.getEncounterDatetime(); if (formEncounterDateTime.before(visit.getStartDatetime())) { validationErrors.add(new FormSubmissionError("general-form-error", "Encounter datetime should be after the visit start date")); } if (visit.getStopDatetime() != null && formEncounterDateTime.after(visit.getStopDatetime())) { validationErrors.add(new FormSubmissionError("general-form-error", "Encounter datetime should be before the visit stop date")); } } return validationErrors; }
From source file:org.phenotips.data.internal.MonarchPatientScorerTest.java
@Test public void getSpecificityWithNoFeaturesReturns0() throws ComponentLookupException { Mockito.doReturn(Collections.emptySet()).when(this.patient).getFeatures(); CapturingMatcher<PatientSpecificity> specCapture = new CapturingMatcher<>(); Mockito.doNothing().when(this.cache).set(Matchers.eq(""), Matchers.argThat(specCapture)); Date d1 = new Date(); this.mocker.getComponentUnderTest().getSpecificity(this.patient); Date d2 = new Date(); PatientSpecificity spec = specCapture.getLastValue(); Assert.assertEquals(0.0, spec.getScore(), 0.0); Assert.assertEquals("monarchinitiative.org", spec.getComputingMethod()); Assert.assertFalse(d1.after(spec.getComputationDate())); Assert.assertFalse(d2.before(spec.getComputationDate())); }
From source file:com.otway.picasasync.syncutil.AlbumSync.java
public Date localChangeDate() { Date localDate = FileUtilities.getLatestDatefromDir(localFolder); if (albumEntry != null) { DateTime updateDate = albumEntry.getUpdated(); if (updateDate != null) { Date remoteDate = new Date(updateDate.getValue()); // TODO: More exists calls // If the remote date is more recent, use that, otherwise use the localdate if (!localFolder.exists() || remoteDate.after(localDate)) return remoteDate; }/*from w ww . j a va 2s .c o m*/ } return localDate; }
From source file:de.iteratec.iteraplan.presentation.dialog.GraphicalReporting.Line.JFreeChartLineGraphicCreator.java
private int getIndexLastElementBeforeFromDate(List<TimeseriesEntry> entries) { int idx = -1; for (TimeseriesEntry entry : entries) { Date date = entry.getDate(); if (date.before(fromDate)) { int idxDate = entries.indexOf(entry); if (idx < 0) { idx = idxDate;//from w w w . j a va 2s. c om } else { if (date.after(entries.get(idx).getDate())) { idx = idxDate; } } } } return idx; }
From source file:com.dattasmoon.pebble.plugin.FireReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { if (com.twofortyfouram.locale.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) { // fetch this for later, we may need it in case we change things // around and we need to know what version of the code they were // running when they saved the action int bundleVersionCode = intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_VERSION_CODE, 1); Type type = Type.values()[intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_TYPE, Type.NOTIFICATION.ordinal())]; PowerManager pm;/*from w w w . j a va2s . c o m*/ switch (type) { case NOTIFICATION: SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); // handle screen DND boolean notifScreenOn = sharedPref.getBoolean(Constants.PREFERENCE_NOTIF_SCREEN_ON, true); pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "FireReceiver.onReceive: notifScreenOn=" + notifScreenOn + " screen=" + pm.isScreenOn()); } if (!notifScreenOn && pm.isScreenOn()) { break; } //handle quiet hours DND boolean quiet_hours = sharedPref.getBoolean(Constants.PREFERENCE_QUIET_HOURS, false); //we only need to pull this if quiet hours are enabled. Save the cycles for the cpu! (haha) if (quiet_hours) { String[] pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_BEFORE, "00:00") .split(":"); Date quiet_hours_before = new Date(0, 0, 0, Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1])); pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_AFTER, "23:59").split(":"); Date quiet_hours_after = new Date(0, 0, 0, Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1])); Calendar c = Calendar.getInstance(); Date now = new Date(0, 0, 0, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Checking quiet hours. Now: " + now.toString() + " vs " + quiet_hours_before.toString() + " and " + quiet_hours_after.toString()); } if (now.before(quiet_hours_before) || now.after(quiet_hours_after)) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Time is before or after the quiet hours time. Returning."); } break; } } String title = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_TITLE); String body = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_BODY); sendAlertToPebble(context, bundleVersionCode, title, body); break; case SETTINGS: Mode mode = Mode.values()[intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_MODE, Mode.OFF.ordinal())]; String packageList = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_PACKAGE_LIST); setNotificationSettings(context, bundleVersionCode, mode, packageList); break; } } }
From source file:com.inmobi.databus.readers.DatabusStreamWaitingReader.java
private void setDeltaCheckpoint(Date from, Date to) { Calendar cal = Calendar.getInstance(); cal.setTime(from);/*w ww. j ava2 s.c o m*/ while (cal.getTime().before(to)) { Integer currentMinute = cal.get(Calendar.MINUTE); if (partitionMinList.contains(currentMinute)) { // create a checkpoint for that minute only if it does not have // checkpoint or checkpoint file time stamp is older than // current file time stamp Date checkpointedTimeStamp = pChkpoints.get(currentMinute).timeStamp; if (checkpointedTimeStamp == null || !(checkpointedTimeStamp.after(cal.getTime()))) { deltaCheckpoint.put(currentMinute, new PartitionCheckpoint(getStreamFile(cal.getTime()), -1)); pChkpoints.get(currentMinute).processed = true; } } cal.add(Calendar.MINUTE, 1); } }
From source file:com.hp.mqm.atrf.core.configuration.FetchConfiguration.java
public void validateProperties() { //MUST PARAMETERS validateMustParameter(ALM_USER_PARAM); validateMustParameter(ALM_PROJECT_PARAM); validateMustParameter(ALM_DOMAIN_PARAM); validateMustParameter(ALM_SERVER_URL_PARAM); if (StringUtils.isEmpty(getOutputFile())) { //MUST//from ww w .j a v a 2 s . com validateMustParameter(OCTANE_USER_PARAM); validateMustParameter(OCTANE_WORKSPACE_ID_PARAM); validateMustParameter(OCTANE_SHAREDSPACE_ID_PARAM); validateMustParameter(OCTANE_SERVER_URL_PARAM); //INTEGER validateIntegerParameter(OCTANE_WORKSPACE_ID_PARAM); validateIntegerParameter(OCTANE_SHAREDSPACE_ID_PARAM); } //INTEGER validateIntegerParameter(SYNC_BULK_SIZE_PARAM); validateIntegerParameter(SYNC_SLEEP_BETWEEN_POSTS_PARAM); validateIntegerParameter(PROXY_PORT_PARAM); //CUSTOM VALIDATIONS //ALM_RUN_FILTER_START_FROM_ID String startFromIdValue = getAlmRunFilterStartFromId(); if (StringUtils.isNotEmpty(startFromIdValue)) { boolean isValid = false; if (ALM_RUN_FILTER_START_FROM_ID_LAST_SENT.equalsIgnoreCase(startFromIdValue)) { isValid = true; } else { try { Integer.parseInt(startFromIdValue); isValid = true; } catch (NumberFormatException e) { isValid = false; } } if (!isValid) { throw new RuntimeException(String.format( "Configuration parameter '%s' can hold integer value or '%s' string, but contains '%s'", ALM_RUN_FILTER_START_FROM_ID_PARAM, ALM_RUN_FILTER_START_FROM_ID_LAST_SENT, startFromIdValue)); } } //ALM_RUN_FILTER_START_FROM_DATE String startFromDateValue = getAlmRunFilterStartFromDate(); if (StringUtils.isNotEmpty(startFromDateValue)) { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); try { Date d = dateFormat.parse(startFromDateValue); if (d.after(dateFormat.parse("2099-12-31")) || d.before(dateFormat.parse("1900-01-01"))) { throw new RuntimeException( String.format("Configuration parameter '%s' should be in range of 1900-2100", ALM_RUN_FILTER_START_FROM_DATE_PARAM)); } //The date 2017-12-06 is out of <1900-2100> range" } catch (ParseException e) { throw new RuntimeException(String.format( "Configuration parameter '%s' should contain date in the following format '%s'", ALM_RUN_FILTER_START_FROM_DATE_PARAM, DATE_FORMAT)); } } //ALM_RUN_FILTER_RELATED_ENTITY_ENTITY_ID_PARAM String relatedEntityType = getAlmRunFilterRelatedEntityType(); String relatedEntityId = getAlmRunFilterRelatedEntityId(); if (StringUtils.isNotEmpty(relatedEntityType) && StringUtils.isEmpty(relatedEntityId)) { throw new RuntimeException(String.format( "Configuration contains value for parameter '%s', but missing value for parameter '%s'", ALM_RUN_FILTER_RELATED_ENTITY_TYPE_PARAM, ALM_RUN_FILTER_RELATED_ENTITY_ID_PARAM)); } if (StringUtils.isNotEmpty(relatedEntityId) && StringUtils.isEmpty(relatedEntityType)) { throw new RuntimeException(String.format( "Configuration contains value for parameter '%s', but missing value for parameter '%s'", ALM_RUN_FILTER_RELATED_ENTITY_ID_PARAM, ALM_RUN_FILTER_RELATED_ENTITY_TYPE_PARAM)); } if (StringUtils.isNotEmpty(relatedEntityType)) { relatedEntityType = relatedEntityType.toLowerCase(); List<String> allowedEntityTypes = Arrays.asList("test", "testset", "sprint", "release"); if (!allowedEntityTypes.contains(relatedEntityType)) { throw new RuntimeException(String.format( "Configuration contains illegal value for parameter '%s', allowed values are %s", ALM_RUN_FILTER_RELATED_ENTITY_TYPE_PARAM, allowedEntityTypes.toString())); } } //FETCH LIMIT String fetchLimitStr = getProperty(ALM_RUN_FILTER_FETCH_LIMIT_PARAM); int fetchLimit = ALM_RUN_FILTER_FETCH_LIMIT_DEFAULT; if (StringUtils.isNotEmpty(fetchLimitStr)) { try { fetchLimit = Integer.parseInt(fetchLimitStr); } catch (Exception e) { throw new RuntimeException(String.format( "Configuration contains illegal value for parameter '%s', the value should be integer in range of 1-200000", ALM_RUN_FILTER_FETCH_LIMIT_PARAM)); } if (fetchLimit > ALM_RUN_FILTER_FETCH_LIMIT_MAX || fetchLimit < ALM_RUN_FILTER_FETCH_LIMIT_MIN) { throw new RuntimeException(String.format( "Configuration contains illegal value for parameter '%s', the value should be integer in range of 1-200000", ALM_RUN_FILTER_FETCH_LIMIT_PARAM)); } } else { fetchLimit = ALM_RUN_FILTER_FETCH_LIMIT_DEFAULT; } setProperty(ALM_RUN_FILTER_FETCH_LIMIT_PARAM, Integer.toString(fetchLimit)); //BULK SIZE String bulkSizeStr = getProperty(SYNC_BULK_SIZE_PARAM); int bulkSize = SYNC_BULK_SIZE_DEFAULT; if (StringUtils.isNotEmpty(bulkSizeStr)) { try { bulkSize = Integer.parseInt(bulkSizeStr); if (bulkSize < SYNC_BULK_SIZE_MIN || bulkSize > SYNC_BULK_SIZE_MAX) { bulkSize = SYNC_BULK_SIZE_DEFAULT; } } catch (Exception e) { bulkSize = SYNC_BULK_SIZE_DEFAULT; } } setProperty(SYNC_BULK_SIZE_PARAM, Integer.toString(bulkSize)); //SLEEP String sleepBetweenPostsStr = getProperty(SYNC_SLEEP_BETWEEN_POSTS_PARAM); int sleepBetweenPosts = SYNC_SLEEP_BETWEEN_POSTS_DEFAULT; if (StringUtils.isNotEmpty(sleepBetweenPostsStr)) { try { sleepBetweenPosts = Integer.parseInt(sleepBetweenPostsStr); if (sleepBetweenPosts < SYNC_SLEEP_BETWEEN_POSTS_MIN || sleepBetweenPosts > SYNC_SLEEP_BETWEEN_POSTS_MAX) { sleepBetweenPosts = SYNC_SLEEP_BETWEEN_POSTS_DEFAULT; } } catch (Exception e) { sleepBetweenPosts = SYNC_SLEEP_BETWEEN_POSTS_DEFAULT; } } setProperty(SYNC_SLEEP_BETWEEN_POSTS_PARAM, Integer.toString(sleepBetweenPosts)); }
From source file:org.jasig.schedassist.web.visitor.CreateAppointmentFormController.java
/** * Verify the startTime argument is within the window; throws a {@link ScheduleException} if not. * //from ww w . j a v a 2 s . co m * @param window * @param startTime * @throws SchedulingException */ protected void validateChosenStartTime(VisibleWindow window, Date startTime) throws SchedulingException { final Date currentWindowStart = window.calculateCurrentWindowStart(); final Date currentWindowEnd = window.calculateCurrentWindowEnd(); if (startTime.before(currentWindowStart) || startTime.equals(currentWindowEnd) || startTime.after(currentWindowEnd)) { throw new SchedulingException("requested time is no longer within visible window"); } }
From source file:com.liferay.journal.util.impl.JournalContentImpl.java
protected JournalArticleDisplay getArticleDisplay(JournalArticle article, String ddmTemplateKey, String viewMode, String languageId, int page, PortletRequestModel portletRequestModel, ThemeDisplay themeDisplay) {/* w w w .j a v a 2s . co m*/ if (article.getStatus() != WorkflowConstants.STATUS_APPROVED) { return null; } Date now = new Date(); Date displayDate = article.getDisplayDate(); Date expirationDate = article.getExpirationDate(); if (((displayDate != null) && displayDate.after(now)) || ((expirationDate != null) && expirationDate.before(now))) { return null; } try { return _journalArticleLocalService.getArticleDisplay(article, ddmTemplateKey, viewMode, languageId, page, portletRequestModel, themeDisplay); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(StringBundler.concat("Unable to get display for ", article.toString(), StringPool.SPACE, languageId), e); } return null; } }