List of usage examples for org.apache.commons.lang.time DateUtils addDays
public static Date addDays(Date date, int amount)
From source file:org.camunda.bpm.engine.test.history.CleanableHistoricCaseInstanceReportTest.java
private void prepareCaseInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount) { // update time to live List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key) .list();//from w ww . j a v a 2 s . c o m assertEquals(1, caseDefinitions.size()); repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitions.get(0).getId(), historyTimeToLive); Date oldCurrentTime = ClockUtil.getCurrentTime(); ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, daysInThePast)); for (int i = 0; i < instanceCount; i++) { CaseInstance caseInstance = caseService.createCaseInstanceByKey(key); caseService.terminateCaseExecution(caseInstance.getId()); caseService.closeCaseInstance(caseInstance.getId()); } ClockUtil.setCurrentTime(oldCurrentTime); }
From source file:org.camunda.bpm.engine.test.history.CleanableHistoricProcessInstanceReportTest.java
protected void prepareProcessInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount) { List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(key).list(); assertEquals(1, processDefinitions.size()); repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinitions.get(0).getId(), historyTimeToLive);//www . j av a2 s.c o m Date oldCurrentTime = ClockUtil.getCurrentTime(); ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, daysInThePast)); List<String> processInstanceIds = new ArrayList<String>(); for (int i = 0; i < instanceCount; i++) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(key); processInstanceIds.add(processInstance.getId()); } runtimeService.deleteProcessInstances(processInstanceIds, null, true, true); ClockUtil.setCurrentTime(oldCurrentTime); }
From source file:org.camunda.bpm.engine.test.history.HistoricBatchManagerBatchesForCleanupTest.java
@SuppressWarnings("unchecked") @Test/* w w w .j av a2 s .c o m*/ public void testFindHistoricBatchIdsForCleanup() { // given String batchType = prepareHistoricBatches(2); final Map<String, Integer> batchOperationsMap = new HashedMap(); batchOperationsMap.put(batchType, historicBatchHistoryTTL); engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new Command<Object>() { @Override public Object execute(CommandContext commandContext) { // when List<String> historicBatchIdsForCleanup = commandContext.getHistoricBatchManager() .findHistoricBatchIdsForCleanup(batchSize, batchOperationsMap); // then assertEquals(resultCount, historicBatchIdsForCleanup.size()); if (resultCount > 0) { List<HistoricBatch> historicBatches = historyService.createHistoricBatchQuery().list(); for (HistoricBatch historicBatch : historicBatches) { historicBatch.getEndTime() .before(DateUtils.addDays(ClockUtil.getCurrentTime(), historicBatchHistoryTTL)); } } return null; } }); }
From source file:org.camunda.bpm.engine.test.history.HistoricBatchManagerBatchesForCleanupTest.java
private String prepareHistoricBatches(int batchesCount) { Date startDate = ClockUtil.getCurrentTime(); ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast)); List<Batch> list = new ArrayList<Batch>(); for (int i = 0; i < batchesCount; i++) { list.add(helper.migrateProcessInstancesAsync(1)); }/*from w w w.j av a 2s . c om*/ Batch batch1 = list.get(0); String batchType = batch1.getType(); helper.executeSeedJob(batch1); helper.executeJobs(batch1); ClockUtil.setCurrentTime(DateUtils.addDays(startDate, batch1EndTime)); helper.executeMonitorJob(batch1); Batch batch2 = list.get(1); helper.executeSeedJob(batch2); helper.executeJobs(batch2); ClockUtil.setCurrentTime(DateUtils.addDays(startDate, batch2EndTime)); helper.executeMonitorJob(batch2); ClockUtil.setCurrentTime(new Date()); return batchType; }
From source file:org.camunda.bpm.engine.test.history.HistoricProcessInstanceTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" }) public void testHistoricProcessInstanceStartDate() { runtimeService.startProcessInstanceByKey("oneTaskProcess"); Date date = new Date(); assertEquals(1, historyService.createHistoricProcessInstanceQuery().startDateOn(date).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().startDateBy(date).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().startDateBy(DateUtils.addDays(date, -1)) .count());//from ww w . ja va2 s. c o m assertEquals(0, historyService.createHistoricProcessInstanceQuery().startDateBy(DateUtils.addDays(date, 1)) .count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().startDateOn(DateUtils.addDays(date, -1)) .count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().startDateOn(DateUtils.addDays(date, 1)) .count()); }
From source file:org.camunda.bpm.engine.test.history.HistoricProcessInstanceTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" }) public void testHistoricProcessInstanceFinishDateUnfinished() { runtimeService.startProcessInstanceByKey("oneTaskProcess"); Date date = new Date(); assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishDateOn(date).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishDateBy(date).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishDateBy(DateUtils.addDays(date, 1)) .count());/*from www . j a va2s . co m*/ assertEquals(0, historyService.createHistoricProcessInstanceQuery() .finishDateBy(DateUtils.addDays(date, -1)).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery() .finishDateOn(DateUtils.addDays(date, -1)).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishDateOn(DateUtils.addDays(date, 1)) .count()); }
From source file:org.camunda.bpm.engine.test.history.HistoricProcessInstanceTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneTaskProcess.bpmn20.xml" }) public void testHistoricProcessInstanceFinishDateFinished() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Date date = new Date(); runtimeService.deleteProcessInstance(pi.getId(), "cancel"); assertEquals(1, historyService.createHistoricProcessInstanceQuery().finishDateOn(date).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().finishDateBy(date).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().finishDateBy(DateUtils.addDays(date, 1)) .count());//from w w w .ja v a2s.c o m assertEquals(0, historyService.createHistoricProcessInstanceQuery() .finishDateBy(DateUtils.addDays(date, -1)).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery() .finishDateOn(DateUtils.addDays(date, -1)).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishDateOn(DateUtils.addDays(date, 1)) .count()); }
From source file:org.carewebframework.vista.ui.vitals.DisplayController.java
private void chartData() { Date dateHigh = null;/* ww w .j a v a2 s. com*/ Date dateLow = null; int row = selectedRow; boolean useAge = chkAge.isVisible() && chkAge.isChecked(); chart.clear(); int colcount = hdrVitals.getChildren().size() - 1; if (row < 0 || row >= lstVitals.getItemCount() || colcount < 0) { return; } boolean hasData = false; String testname = getValue(0, row); String testid = (String) getObject(0, row); boolean isBP = StringUtils.containsIgnoreCase(testname, "pressure"); chart.getYAxis().title.text = (String) getObject(colcount, row); chart.getXAxis().title.text = useAge ? "age (months)" : null; chart.getXAxis().type = useAge ? "linear" : "datetime"; for (int col = 1; col < colcount; col++) { Listheader hdr = (Listheader) hdrVitals.getChildren().get(col); FMDate date = (FMDate) hdr.getValue(); if (date != null) { double xVal = useAge ? dateToAge(date) : date.getTime(); String vals[] = StrUtil.split(getValue(col, row), ";"); boolean newData = false; for (String val : vals) { if (isBP) { String pcs[] = StrUtil.split(val, "/"); if (pcs.length > 0) { newData |= plotData(xVal, pcs[0], "Systolic", testname) != null; } if (pcs.length > 2) { newData |= plotData(xVal, pcs[1], "Mean", testname) != null; newData |= plotData(xVal, pcs[2], "Diastolic", testname) != null; } else { newData |= plotData(xVal, pcs[1], "Diastolic", testname) != null; } } else { newData |= plotData(xVal, val, testname, testname) != null; } } if (newData) { hasData = true; dateLow = dateLow == null ? date : date.getTime() < dateLow.getTime() ? date : dateLow; dateHigh = dateHigh == null ? date : date.getTime() > dateHigh.getTime() ? date : dateHigh; } } } if (hasData) { double xLow = useAge ? dateToAge(dateLow) : dateLow.getTime(); double xHigh = useAge ? dateToAge(dateHigh) : dateHigh.getTime(); plotRange(xLow, xHigh, StrUtil.piece(getValue(colcount, row), " ")); String pctileRPC = percentiles.get(testid); if (pctileRPC != null && chkPercentiles.isChecked()) { List<String> pctiles = broker.callRPCList(pctileRPC, null, testid, patient.getId().getIdPart(), DateUtils.addDays(dateLow, -3000), DateUtils.addDays(dateHigh, 3000), getDefaultUnits()); for (String pctile : pctiles) { String pcs[] = StrUtil.split(pctile, StrUtil.U, 3); FMDate date = new FMDate(pcs[1]); plotPercentile(useAge ? dateToAge(date) : date.getTime(), pcs[2], pcs[0]); } } chart.run(); } }
From source file:org.cleverbus.admin.web.msg.MessageReportController.java
/** * Method generates a date object base on the daysShift param. * * @param daysShift 0 means now, 7 means (now, -7 days) * @return date object// ww w . ja v a 2 s . c o m */ private Date getDateForQuery(int daysShift) { Date queryDate = new Date(); if (daysShift > 0) { queryDate = DateUtils.addDays(queryDate, -daysShift); } return queryDate; }
From source file:org.cleverbus.core.common.asynch.RepairProcessingMsgServiceDbTest.java
@Before public void prepareData() { Date currDate = DateUtils.addDays(new Date(), -1); msg = new Message(); msg.setState(MsgStateEnum.NEW);// ww w .j a v a 2s . c om msg.setMsgTimestamp(currDate); msg.setReceiveTimestamp(currDate); msg.setSourceSystem(ExternalSystemTestEnum.CRM); msg.setCorrelationId("123-456"); msg.setService(ServiceTestEnum.CUSTOMER); msg.setOperationName("setCustomer"); msg.setPayload("xml"); msg.setLastUpdateTimestamp(currDate); }