Java Code Examples for java.sql.Timestamp#before()

The following examples show how to use java.sql.Timestamp#before() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TravelAuthorizationServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
private  boolean matchReimbursements(List<TravelReimbursementDocument> travelReimbursementDocuments, Date tripBeginBufferDate, Date tripEndBufferDate) {
    Timestamp earliestTripBeginDate = null;
    Timestamp greatestTripEndDate = null;

    for (TravelReimbursementDocument document : travelReimbursementDocuments) {
        Timestamp tripBegin = document.getTripBegin();
        Timestamp tripEnd = document.getTripEnd();
        if (ObjectUtils.isNull(earliestTripBeginDate) && ObjectUtils.isNull(greatestTripEndDate)) {
            earliestTripBeginDate = tripBegin;
            greatestTripEndDate = tripEnd;
        }
        else {
            earliestTripBeginDate = tripBegin.before(earliestTripBeginDate) ? tripBegin :earliestTripBeginDate;
            greatestTripEndDate = tripEnd.after(greatestTripEndDate)? tripEnd : greatestTripEndDate;

            }
     }

   if(doesDatesOverlap(tripBeginBufferDate, tripEndBufferDate, convertToSqlDate(earliestTripBeginDate), convertToSqlDate(greatestTripEndDate))) {
       return true;
   }


    return false;
}
 
Example 2
Source File: InvoiceRecurrenceDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.ar.document.service.InvoiceRecurrenceService#isValidRecurrenceEndDate(Date)
 */
@Override
public boolean isValidRecurrenceEndDate(Date beginDate, Date endDate) {
    boolean isSuccess = true;
    if (ObjectUtils.isNull(beginDate) ||
        ObjectUtils.isNull(endDate)) {
        return isSuccess;
    }
    Timestamp beginDateTimestamp = new Timestamp(beginDate.getTime());
    Timestamp endDateTimestamp = new Timestamp(endDate.getTime());
    if ((ObjectUtils.isNotNull(endDateTimestamp)) &&
        (endDateTimestamp.before(beginDateTimestamp) || endDateTimestamp.equals(beginDateTimestamp))) {
        return false;
    }
    return isSuccess;
}
 
Example 3
Source File: ServiceUtil.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
public static Map<String, Object> genericDateCondition(DispatchContext dctx, Map<String, ? extends Object> context) {
    Timestamp fromDate = (Timestamp) context.get("fromDate");
    Timestamp thruDate = (Timestamp) context.get("thruDate");
    Timestamp now = UtilDateTime.nowTimestamp();
    boolean reply = true;

    if (fromDate != null && fromDate.after(now)) {
        reply = false;
    }
    if (thruDate != null && thruDate.before(now)) {
        reply = false;
    }

    Map<String, Object> result = ServiceUtil.returnSuccess();
    result.put("conditionReply", reply);
    return result;
}
 
Example 4
Source File: TechDataServices.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
/** Used to to request the remain capacity available for dateFrom in a TechDataCalenda,
 * If the dateFrom (param in) is not  in an available TechDataCalendar period, the return value is zero.
 *
 * @param techDataCalendar        The TechDataCalendar cover
 * @param dateFrom                        the date
 * @return  long capacityRemaining
 */
public static long capacityRemaining(GenericValue techDataCalendar,  Timestamp  dateFrom) {
    GenericValue techDataCalendarWeek = null;
    // TODO read TechDataCalendarExcWeek to manage execption week (maybe it's needed to refactor the entity definition
    try {
        techDataCalendarWeek = techDataCalendar.getRelatedOne("TechDataCalendarWeek", true);
    } catch (GenericEntityException e) {
        Debug.logError("Pb reading Calendar Week associated with calendar"+e.getMessage(), module);
        return 0;
    }
    // TODO read TechDataCalendarExcDay to manage execption day
    Calendar cDateTrav =  Calendar.getInstance();
    cDateTrav.setTime(dateFrom);
    Map<String, Object> position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
    int moveDay = (Integer) position.get("moveDay");
    if (moveDay != 0) return 0;
    Time startTime = (Time) position.get("startTime");
    Double capacity = (Double) position.get("capacity");
    Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
    if (dateFrom.before(startAvailablePeriod)) return 0;
    Timestamp endAvailablePeriod = new Timestamp(startAvailablePeriod.getTime()+capacity.longValue());
    if (dateFrom.after(endAvailablePeriod)) return 0;
    return  endAvailablePeriod.getTime() - dateFrom.getTime();
}
 
Example 5
Source File: UtilValidate.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static boolean isDateBeforeNow(Timestamp  date) {
    Timestamp now = UtilDateTime.nowTimestamp();
    if (date != null) {
        return date.before(now);
    }
    return false;
}
 
Example 6
Source File: InvoiceRecurrenceDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.kuali.kfs.module.ar.document.service.InvoiceRecurrenceService#isValidRecurrenceBeginDate(Date)
 */
@Override
public boolean isValidRecurrenceBeginDate(Date beginDate) {
    boolean isSuccess = true;
    if (ObjectUtils.isNull(beginDate)) {
        return isSuccess;
    }
    Timestamp currentDate = new Timestamp(dateTimeService.getCurrentDate().getTime());
    Timestamp beginDateTimestamp = new Timestamp(beginDate.getTime());
    if (beginDateTimestamp.before(currentDate) || beginDateTimestamp.equals(currentDate)) {
        return false;
    }
    return isSuccess;
}
 
Example 7
Source File: CriteriaUtil.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static org.hibernate.criterion.Criterion getStopOpenIntervalCriterion(Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or, String startPropertyName,
		String stopPropertyName) {
	if (from != null && to != null) {
		if (to.before(from)) {
			throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
		}
		return applyOr(
				Restrictions.or(
						Restrictions.or( // partial interval overlappings:
								Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from),
										getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to)),
								Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from),
										getRestrictionCriterion(RestrictionCriterionTypes.LE, stopPropertyName, to))),
						Restrictions.or( // total inclusions:
								Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, from),
										getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, to)),
								Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, from),
										getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, stopPropertyName)))),
				or);
	} else if (from != null && to == null) {
		return applyOr(
				Restrictions.or(
						Restrictions.or( // partial interval overlappings:
								getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from),
								getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from)),
						Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, from),
								getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, stopPropertyName))),
				or);
	} else if (from == null && to != null) {
		return applyOr(getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to), or);
	}
	return null;
}
 
Example 8
Source File: StoryForest.java    From StoryForest with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Filter docs outside the time section.
 * @param t Threshold time.
 */
public void filterStoryTreesByTime(Timestamp t) {
    for (Iterator<StoryTree> iter = storyTrees.iterator(); iter.hasNext(); ) {
        StoryTree st = iter.next();
        Timestamp storyEndTime = new Timestamp(st.endTimestamp);
        if (storyEndTime.before(t)) {
            iter.remove();
        }
    }
}
 
Example 9
Source File: TimestampTimeModel.java    From envelope with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(Row first, Row second) {
  Timestamp ts1 = first.getAs(field.name());
  Timestamp ts2 = second.getAs(field.name());
  
  if (ts1.before(ts2)) {
    return -1;
  } else if (ts1.after(ts2)) {
    return 1;
  } else {
    return 0;
  }
}
 
Example 10
Source File: AsOfAttribute.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public boolean asOfDateMatchesRange(Timestamp asOfDate, Timestamp from, Timestamp to)
{
    if (asOfDate.equals(this.getInfinityDate()))
    {
        return to.equals(this.getInfinityDate());
    }
    else
    {
        if (to.after(asOfDate) || (this.isToIsInclusive() && to.equals(asOfDate)))
        {
            return from.before(asOfDate) || (!this.isToIsInclusive() && from.equals(asOfDate));
        }
    }
    return false;
}
 
Example 11
Source File: CriteriaUtil.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static org.hibernate.criterion.Criterion getStopOptionalIntervalCriterion(Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or, boolean includeStop,
		String startPropertyName, String stopPropertyName) {
	if (from != null && to != null) {
		if (to.before(from)) {
			throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
		}
		return applyOr(Restrictions.or(
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, stopPropertyName),
						Restrictions.and(
								getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from),
								includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, to)
										: getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to))),
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NOT_NULL, stopPropertyName),
						Restrictions.or(
								// partial interval overlappings:
								Restrictions.or(
										Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from),
												includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, to)
														: getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to)),
										Restrictions.and(
												includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, from)
														: getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from),
												getRestrictionCriterion(RestrictionCriterionTypes.LE, stopPropertyName, to))),
								// total inclusions:
								Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, from),
										getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, to))))),
				or);
	} else if (from != null && to == null) {
		return applyOr(Restrictions.or(
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, stopPropertyName),
						getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from)),
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NOT_NULL, stopPropertyName),
						Restrictions.or(
								getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from),
								includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, from)
										: getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from)))),
				or);
	} else if (from == null && to != null) {
		return applyOr(Restrictions.or(
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, stopPropertyName),
						includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, to)
								: getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to)),
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NOT_NULL, stopPropertyName),
						Restrictions.or(
								includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, to)
										: getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to),
								getRestrictionCriterion(RestrictionCriterionTypes.LE, stopPropertyName, to)))),
				or);
	}
	return null;
}
 
Example 12
Source File: CriteriaUtil.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static org.hibernate.criterion.Criterion getStartOptionalIntervalCriterion(Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or, boolean includeStop,
		String startPropertyName, String stopPropertyName) {
	if (from != null && to != null) {
		if (to.before(from)) {
			throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
		}
		return applyOr(Restrictions.or(
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, startPropertyName),
						Restrictions.and(
								includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, from)
										: getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from),
								getRestrictionCriterion(RestrictionCriterionTypes.LE, stopPropertyName, to))),
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NOT_NULL, startPropertyName),
						Restrictions.or(
								// partial interval overlappings:
								Restrictions.or(
										Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from),
												includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, to)
														: getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to)),
										Restrictions.and(
												includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, from)
														: getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from),
												getRestrictionCriterion(RestrictionCriterionTypes.LE, stopPropertyName, to))),
								// total inclusions:
								Restrictions.and(getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, from),
										getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, to))))),
				or);
	} else if (from != null && to == null) {
		return applyOr(Restrictions.or(
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, startPropertyName),
						includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, from)
								: getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from)),
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NOT_NULL, startPropertyName),
						Restrictions.or(
								getRestrictionCriterion(RestrictionCriterionTypes.GE, startPropertyName, from),
								includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.GE, stopPropertyName, from)
										: getRestrictionCriterion(RestrictionCriterionTypes.GT, stopPropertyName, from)))),
				or);
	} else if (from == null && to != null) {
		return applyOr(Restrictions.or(
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NULL, startPropertyName),
						getRestrictionCriterion(RestrictionCriterionTypes.LE, stopPropertyName, to)),
				Restrictions.and(
						getRestrictionCriterion(RestrictionCriterionTypes.IS_NOT_NULL, startPropertyName),
						Restrictions.or(
								includeStop ? getRestrictionCriterion(RestrictionCriterionTypes.LE, startPropertyName, to)
										: getRestrictionCriterion(RestrictionCriterionTypes.LT, startPropertyName, to),
								getRestrictionCriterion(RestrictionCriterionTypes.LE, stopPropertyName, to)))),
				or);
	}
	return null;
}
 
Example 13
Source File: TemProfileAddressLookupableHelperServiceImpl.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @see org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResults(java.util.Map)
 */
@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {

    List<TemProfileAddress> searchResults = new ArrayList<TemProfileAddress>();

    if (fieldValues.containsKey(TemPropertyConstants.TemProfileProperties.PRINCIPAL_ID) && !StringUtils.isEmpty(fieldValues.get(TemPropertyConstants.TemProfileProperties.PRINCIPAL_ID))) {
    	final Map<String, String> kimFieldsForLookup = this.getPersonFieldValues(fieldValues);
    	kimFieldsForLookup.put(KFSPropertyConstants.KUALI_USER_PERSON_ACTIVE_INDICATOR, KFSConstants.ACTIVE_INDICATOR);

        List<EntityAddressBo> addresses = (List<EntityAddressBo>) getLookupService().findCollectionBySearchHelper(EntityAddressBo.class, kimFieldsForLookup, false);

    	for (EntityAddressBo address : addresses) {
    		TemProfileAddress temAddress = getTravelerService().convertToTemProfileAddressFromKimAddress(address);
    		temAddress.setPrincipalId(fieldValues.get(TemPropertyConstants.TemProfileProperties.PRINCIPAL_ID));
            searchResults.add(temAddress);
        }
    }

    if (searchResults.isEmpty() && fieldValues.containsKey(TemPropertyConstants.TemProfileProperties.CUSTOMER_NUMBER) && !StringUtils.isEmpty(fieldValues.get(TemPropertyConstants.TemProfileProperties.CUSTOMER_NUMBER))) {
    	final Map<String, String> customerFieldsForLookup = this.getCustomerFieldValues(fieldValues);

        LOG.debug("Using fieldsForLookup "+ customerFieldsForLookup);

        Collection<AccountsReceivableCustomerAddress> customerAddresses = getAccountsReceivableModuleService().searchForCustomerAddresses(customerFieldsForLookup);

    	boolean active;
        for (AccountsReceivableCustomerAddress customerAddress : customerAddresses) {
        	active = true;
        	if (ObjectUtils.isNotNull(customerAddress)) {
                if (ObjectUtils.isNotNull(customerAddress.getCustomerAddressEndDate())) {
                    Timestamp currentDateTimestamp = new Timestamp(SpringContext.getBean(DateTimeService.class).getCurrentDate().getTime());
                    Timestamp addressEndDateTimestamp = new Timestamp(customerAddress.getCustomerAddressEndDate().getTime());
                    if (addressEndDateTimestamp.before(currentDateTimestamp)) {
                    	active = false;
                    }
                }
            }

        	if(active) {
        		searchResults.add(getTravelerService().convertToTemProfileAddressFromCustomer(customerAddress));
        	}
        }
    }

    CollectionIncomplete results = new CollectionIncomplete(searchResults, Long.valueOf(searchResults.size()));

    // sort list if default sort column given
    List<String> defaultSortColumns = getDefaultSortColumns();
    if (defaultSortColumns.size() > 0) {
        Collections.sort(results, new BeanPropertyComparator(defaultSortColumns, true));
    }

    return results;
}
 
Example 14
Source File: TimestampTests.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = NullPointerException.class)
public void test17() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
    ts1.before(null);
}
 
Example 15
Source File: TimestampTests.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = NullPointerException.class)
public void test17() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
    ts1.before(null);
}
 
Example 16
Source File: TimestampTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = NullPointerException.class)
public void test17() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
    ts1.before(null);
}
 
Example 17
Source File: TimestampTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compares two Timestamps with the expected result.
 *
 * @param ts1 the first Timestamp
 * @param ts2 the second Timestamp
 * @param expect the expected relation between ts1 and ts2; 0 if
 * ts1 equals to ts2, or 1 if ts1 is after ts2, or -1 if ts1 is
 * before ts2.
 */
private void compareTimestamps(Timestamp ts1, Timestamp ts2, int expected) {
    boolean expectedResult = expected > 0;
    boolean result = ts1.after(ts2);
    if (result != expectedResult) {
        errln("ts1.after(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    expectedResult = expected < 0;
    result = ts1.before(ts2);
    if (result != expectedResult) {
        errln("ts1.before(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    expectedResult = expected == 0;
    result = ts1.equals(ts2);
    if (result != expectedResult) {
        errln("ts1.equals(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    int x = ts1.compareTo(ts2);
    int y = (x > 0) ? 1 : (x < 0) ? -1 : 0;
    if (y != expected) {
        errln("ts1.compareTo(ts2) returned " + x + ", expected "
              + relation(expected, "") + "0"
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }
    long t1 = ts1.getTime();
    long t2 = ts2.getTime();
    int z = (t1 > t2) ? 1 : (t1 < t2) ? -1 : 0;
    if (z == 0) {
        int n1 = ts1.getNanos();
        int n2 = ts2.getNanos();
        z = (n1 > n2) ? 1 : (n1 < n2) ? -1 : 0;
    }
    if (z != expected) {
        errln("ts1.getTime() " + relation(z, "==") + " ts2.getTime(), expected "
              + relation(expected, "==")
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }
}
 
Example 18
Source File: TimestampTests.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = NullPointerException.class)
public void test17() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
    ts1.before(null);
}
 
Example 19
Source File: XPLAINDistPropsDescriptor.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public final void processMemberReplyMessages(
    // never hold the reply messages list locally here.
    final List<GfxdFunctionReplyMessage> replyMsgs) {
  
  if(replyMsgs == null) {
    return;
  }

  Timestamp begin_receive_time = null;

  if (memberReplyMappedDesc == Collections.EMPTY_LIST) {
    memberReplyMappedDesc = new ArrayList<XPLAINDistPropsDescriptor>();
  }

  final GemFireCacheImpl c = Misc.getGemFireCacheNoThrow();
  for (GfxdFunctionReplyMessage r : replyMsgs) {

    XPLAINDistPropsDescriptor msg = cloneMe();

    // find the first reply.
    Timestamp ct = r.getConstructTime();
    if (begin_receive_time == null || begin_receive_time.before(ct)) {
      begin_receive_time = ct;
    }

    // record individual message details.
    msg.flipdirection();
    if (msg.dist_direction == XPLAINUtil.DIRECTION.IN) {
      msg.dist_object_type = XPLAINUtil.OP_RESULT_RECEIVE;
      msg.originator = r.getSender().toString();
      msg.target_member = c.getDistributedSystem().getDistributedMember();
    }
    else {
      msg.dist_object_type = XPLAINUtil.OP_RESULT_SEND;
      msg.originator = c.getDistributedSystem().getDistributedMember()
          .toString();
      msg.target_member = msg.getRecipients(r, false)[0];
    }

    msg.dist_object_name = r.getClass().getSimpleName();
    msg.construct_time = r.getConstructTime();
    msg.ser_deser_time = r.getSerializeDeSerializeTime();
    msg.process_time = r.getProcessTime();
    msg.throttle_time = 0;
    msg.replySingleResult = r.getSingleResult();
    msg.replySingleResultStatistics = r.getSingleResultStatistics();

    // in case the clock doesn't ticks
    if(msg.construct_time != null && msg.process_time == 0 && msg.ser_deser_time == 0 && msg.throttle_time == 0) {
      msg.process_time = 1;
    }
    memberReplyMappedDesc.add(msg);
  }

  setBeginReceiveTime(begin_receive_time);
}
 
Example 20
Source File: TimestampTests.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions = NullPointerException.class)
public void test17() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
    ts1.before(null);
}