List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:com.xpn.xwiki.doc.XWikiDocument.java
public void setContentUpdateDate(Date date) { if ((date != null) && (!date.equals(this.contentUpdateDate))) { setMetaDataDirty(true);/*from ww w.j av a2s. c om*/ } // Make sure we drop milliseconds for consistency with the database if (date != null) { date.setTime((date.getTime() / 1000) * 1000); } this.contentUpdateDate = date; }
From source file:org.ofbiz.order.order.OrderServices.java
@SuppressWarnings("unchecked") public static Map<String, Object> cancelFlaggedSalesOrders(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); //Locale locale = (Locale) context.get("locale"); List<GenericValue> ordersToCheck = null; // create the query expressions List<EntityExpr> exprs = UtilMisc.toList( EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED")); EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(exprs, EntityOperator.AND); // get the orders try {/*from www . j av a 2 s . co m*/ ordersToCheck = delegator.findList("OrderHeader", ecl, null, UtilMisc.toList("orderDate"), null, false); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting order headers", module); } if (UtilValidate.isEmpty(ordersToCheck)) { Debug.logInfo("No orders to check, finished", module); return ServiceUtil.returnSuccess(); } Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); Iterator<GenericValue> i = ordersToCheck.iterator(); while (i.hasNext()) { GenericValue orderHeader = i.next(); String orderId = orderHeader.getString("orderId"); String orderStatus = orderHeader.getString("statusId"); if (orderStatus.equals("ORDER_CREATED")) { // first check for un-paid orders Timestamp orderDate = orderHeader.getTimestamp("entryDate"); // need the store for the order GenericValue productStore = null; try { productStore = orderHeader.getRelatedOne("ProductStore"); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductStore from OrderHeader", module); } // default days to cancel int daysTillCancel = 30; // get the value from the store if (productStore != null && productStore.get("daysToCancelNonPay") != null) { daysTillCancel = productStore.getLong("daysToCancelNonPay").intValue(); } if (daysTillCancel > 0) { // 0 days means do not auto-cancel Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(orderDate.getTime()); cal.add(Calendar.DAY_OF_YEAR, daysTillCancel); Date cancelDate = cal.getTime(); Date nowDate = new Date(); //Debug.log("Cancel Date : " + cancelDate, module); //Debug.log("Current Date : " + nowDate, module); if (cancelDate.equals(nowDate) || nowDate.after(cancelDate)) { // cancel the order item(s) Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "statusId", "ITEM_CANCELLED", "userLogin", userLogin); try { // TODO: looks like result is ignored here, but we should be looking for errors dispatcher.runSync("changeOrderItemStatus", svcCtx); } catch (GenericServiceException e) { Debug.logError(e, "Problem calling change item status service : " + svcCtx, module); } } } } else { // check for auto-cancel items List itemsExprs = new ArrayList(); // create the query expressions itemsExprs.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderId)); itemsExprs.add(EntityCondition.makeCondition( UtilMisc.toList( EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_CREATED"), EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_APPROVED")), EntityOperator.OR)); itemsExprs.add(EntityCondition.makeCondition("dontCancelSetUserLogin", EntityOperator.EQUALS, GenericEntity.NULL_FIELD)); itemsExprs.add(EntityCondition.makeCondition("dontCancelSetDate", EntityOperator.EQUALS, GenericEntity.NULL_FIELD)); itemsExprs.add(EntityCondition.makeCondition("autoCancelDate", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD)); ecl = EntityCondition.makeCondition(itemsExprs); List<GenericValue> orderItems = null; try { orderItems = delegator.findList("OrderItem", ecl, null, null, null, false); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting order item records", module); } if (UtilValidate.isNotEmpty(orderItems)) { Iterator<GenericValue> oii = orderItems.iterator(); while (oii.hasNext()) { GenericValue orderItem = oii.next(); String orderItemSeqId = orderItem.getString("orderItemSeqId"); Timestamp autoCancelDate = orderItem.getTimestamp("autoCancelDate"); if (autoCancelDate != null) { if (nowTimestamp.equals(autoCancelDate) || nowTimestamp.after(autoCancelDate)) { // cancel the order item Map<String, Object> svcCtx = UtilMisc.<String, Object>toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "statusId", "ITEM_CANCELLED", "userLogin", userLogin); try { // TODO: check service result for an error return dispatcher.runSync("changeOrderItemStatus", svcCtx); } catch (GenericServiceException e) { Debug.logError(e, "Problem calling change item status service : " + svcCtx, module); } } } } } } } return ServiceUtil.returnSuccess(); }
From source file:com.globalsight.everest.workflowmanager.WorkflowManagerLocal.java
private DefaultPathTasks updateDefaultPathTasks(int p_actionType, Date p_baseDate, List p_wfTaskInfos, Workflow p_wfClone, long p_completedTaskId, boolean p_isActiveTaskReassigned, Date p_originalBaseDate, Session p_session) throws Exception { int size = p_wfTaskInfos.size(); Hashtable ht = p_wfClone.getTasks(); FluxCalendar defaultCalendar = ServerProxy.getCalendarManager() .findDefaultCalendar(String.valueOf(p_wfClone.getCompanyId())); UserFluxCalendar userCalendar = null; DefaultPathTasks dpt = new DefaultPathTasks(); Date estimatedDate = p_isActiveTaskReassigned ? p_baseDate : p_originalBaseDate; boolean found = p_completedTaskId <= 0; // loop thru the tasks following the given start task for updating // the estimated dates for the tasks and possibly workflow. boolean firstTime = true; boolean activeTaskAccepted = false; for (int i = 0; i < size; i++) { WfTaskInfo wfTaskInfo = (WfTaskInfo) p_wfTaskInfos.get(i); if (!found) { found = p_completedTaskId == wfTaskInfo.getId(); } else {/* ww w . ja v a2 s . c o m*/ TaskImpl task = (TaskImpl) ht.get(new Long(wfTaskInfo.getId())); if (task != null) { Date acceptBy = ServerProxy.getEventScheduler().determineDate(estimatedDate, defaultCalendar, wfTaskInfo.getAcceptanceDuration()); task.setEstimatedAcceptanceDate(acceptBy); long duration = wfTaskInfo.getTotalDuration(); if (firstTime) { firstTime = false; if (activeTaskAccepted = (task.getAcceptor() != null && task.getAcceptedDate().compareTo(p_originalBaseDate) >= 0)) { removeReservedTime(task.getId(), task.getAcceptor()); userCalendar = ServerProxy.getCalendarManager() .findUserCalendarByOwner(task.getAcceptor()); if (p_isActiveTaskReassigned) { // reset acceptor and acceptance date task.setAcceptor(null); task.setAcceptedDate(null); task.setState(TaskImpl.STATE_ACTIVE); } else { estimatedDate = task.getAcceptedDate(); duration = wfTaskInfo.getCompletionDuration(); } } // possibly create proposed type reserved times createProposedReservedTimes(p_actionType, estimatedDate, wfTaskInfo, task, ReservedTime.TYPE_PROPOSED, p_isActiveTaskReassigned, p_session); } Date completeBy = ServerProxy.getEventScheduler().determineDate(estimatedDate, userCalendar == null ? (BaseFluxCalendar) defaultCalendar : (BaseFluxCalendar) userCalendar, duration); task.setEstimatedCompletionDate(completeBy); if (activeTaskAccepted && !p_isActiveTaskReassigned) { addReservedTimeToUserCalendar(userCalendar, buildReservedTimeName(wfTaskInfo.getName(), task), ReservedTime.TYPE_ACTIVITY, task.getAcceptedDate(), completeBy, task.getIdAsLong(), p_session); } estimatedDate = completeBy; activeTaskAccepted = false; // reset it TaskInfo ti = new TaskInfo(task.getId(), task.getTaskName(), task.getState(), acceptBy, completeBy, null, null, task.getType()); if (wfTaskInfo.getOverdueToPM() != 0) { ti.setOverdueToPM(wfTaskInfo.getOverdueToPM()); } if (wfTaskInfo.getOverdueToUser() != 0) { ti.setOverdueToUser(wfTaskInfo.getOverdueToUser()); } dpt.addTaskInfo(ti); p_session.saveOrUpdate(task); } } // There's an edge case where all nodes could go thru on common // decision node. Therefore, let's start from the START node... if (i == (size - 1) && dpt.size() == 0 && !wfTaskInfo.followedByExitNode()) { i = -1; found = true; } } // For sla report issue. // No need to set estimated completion date for a workflow if // the advanced task happens to be the last one. // User can override the estimatedCompletionDate. if ((!estimatedDate.equals(p_baseDate)) && (!p_wfClone.isEstimatedCompletionDateOverrided())) { p_wfClone.setEstimatedCompletionDate(estimatedDate); sendNotification(p_wfClone); } // For sla report issue. p_wfClone.updateTranslationCompletedDates(); return dpt; }
From source file:com.globalsight.webservices.Ambassador.java
private boolean checkCreatetionDate(Date creationDate, Date startDate, Date endDate) { if (startDate != null && endDate == null) { if (!creationDate.after(startDate) && !creationDate.equals(startDate)) { return false; }//from www.j a va2 s .co m } else if (startDate == null && endDate != null) { if (!creationDate.before(endDate) && creationDate.equals(endDate)) { return false; } } else if (startDate != null && endDate != null) { if ((!creationDate.after(startDate) && !creationDate.equals(startDate)) || (!creationDate.before(endDate) && !creationDate.equals(endDate))) { return false; } } return true; }