当前位置: 首页>>代码示例>>Java>>正文


Java Period.getEnd方法代码示例

本文整理汇总了Java中nl.strohalm.cyclos.utils.Period.getEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Period.getEnd方法的具体用法?Java Period.getEnd怎么用?Java Period.getEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nl.strohalm.cyclos.utils.Period的用法示例。


在下文中一共展示了Period.getEnd方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEndParameter

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
/**
 * Returns the end date of the given period, handling null
 */
public static QueryParameter getEndParameter(final Period period) {
    if (period == null) {
        return null;
    }
    Calendar end = period.getEnd();
    if (end == null) {
        return null;
    }
    // We must consider the time when explicitly set
    if (!period.isUseTime()) {
        // Truncate the end date and set the next day
        end = DateHelper.getDayEnd(end);
    }
    String operator = period.isInclusiveEnd() ? "<=" : "<";
    return new QueryParameter(end, operator);
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:20,代码来源:HibernateHelper.java

示例2: nullSafeSet

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SessionImplementor session) throws HibernateException, SQLException {
    final Period period = (Period) value;
    Timestamp begin = null;
    Timestamp end = null;
    if (period != null && period.getBegin() != null) {
        begin = new Timestamp(period.getBegin().getTimeInMillis());
    }
    if (period != null && period.getEnd() != null) {
        end = new Timestamp(period.getEnd().getTimeInMillis());
    }
    st.setTimestamp(index + BEGIN, begin);
    st.setTimestamp(index + END, end);
    if (getLog().isDebugEnabled()) {
        getLog().debug("Binding " + begin + " to parameter: " + (index + BEGIN));
        getLog().debug("Binding " + end + " to parameter: " + (index + END));
    }
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:18,代码来源:BasePeriodType.java

示例3: getByPeriod

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
@Override
public List<R> getByPeriod(final Currency currency, final Period period) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("currency", currency);
    StringBuilder hql = new StringBuilder();
    hql.append(" from ").append(getEntityType().getName()).append(" r ");
    hql.append(" where r.currency = :currency ");
    // don't use HibernateHelper.addPeriodParameterToQuery, because that tests if the stored enabledSince date falls in the period.
    // In stead, we want to get a list of all entities with the period between enabledSince and DisabledSince overlapping the period.
    // So that includes entities with enabledSince BEFORE the period.
    if (period != null && period.getBegin() != null) {
        params.put("startDate", period.getBegin());
        hql.append(" and (r.disabledSince is null or (r.disabledSince is not null and r.disabledSince > :startDate)) ");
    }
    if (period != null && period.getEnd() != null) {
        params.put("endDate", period.getEnd());
        hql.append(" and (r.enabledSince <= :endDate)) ");
    }
    hql.append(" order by r.enabledSince desc");
    return list(hql.toString(), params);
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:22,代码来源:RateParametersDAOImpl.java

示例4: resolveMembersForTransactionsReport

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Iterator<Member> resolveMembersForTransactionsReport(final MembersTransactionsReportParameters params) {
    final Collection<MemberGroup> groups = params.getMemberGroups();
    final Period period = params.getPeriod();
    final MemberQuery query = new MemberQuery();
    query.setPageParameters(params.getPageParameters());
    if (params.isFetchBroker()) {
        query.fetch(Member.Relationships.BROKER);
    }
    query.setGroups(groups);
    if (period != null && period.getEnd() != null) {
        query.setActivationPeriod(Period.endingAt(period.getEnd()));
    }
    query.setResultType(ResultType.ITERATOR);
    final List<Member> members = (List<Member>) elementService.search(query);
    final Iterator<Member> membersIterator = members.iterator();
    return membersIterator;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:19,代码来源:AccountServiceImpl.java

示例5: validate

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
public ValidationError validate(final Object object, final Object property, final Object value) {
    final Period period = (Period) value;
    if (period == null) {
        return new RequiredError();
    } else {
        if (isBeginRequired(validationType) && period.getBegin() == null) {
            return new ValidationError("errors.periodBeginRequired", property);
        } else if (isEndRequired(validationType) && period.getEnd() == null) {
            return new ValidationError("errors.periodEndRequired", property);
        } else if (ValidationType.BOTH_REQUIRED == validationType || ValidationType.BOTH_REQUIRED_AND_NOT_EXPIRED == validationType) {
            if (period.getBegin().after(period.getEnd())) {
                return new ValidationError("errors.periodInvalidBounds", property);
            } else if (ValidationType.BOTH_REQUIRED_AND_NOT_EXPIRED == validationType && hasExpired(period)) {
                return new ValidationError("errors.periodExpired", property);
            } else {
                return null;
            }
        } else if (validationType == ValidationType.VALIDATE_RANGE) {
            if (period.getBegin() != null && period.getEnd() != null && period.getBegin().after(period.getEnd())) {
                return new ValidationError("errors.periodInvalidBounds", property);
            }
            if (period.getEnd() != null && hasExpired(period)) {
                return new ValidationError("errors.periodExpired", property);
            }
            return null;
        } else {
            return null;
        }
    }
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:31,代码来源:PeriodValidation.java

示例6: getPropertyValue

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
public Object getPropertyValue(final Object component, final int property) throws HibernateException {
    final Period period = (Period) component;
    switch (property) {
        case BEGIN:
            return period.getBegin();
        case END:
            return period.getEnd();
    }
    return null;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:11,代码来源:BasePeriodType.java

示例7: toVO

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
/**
 * Convert an advertisement to VO, filling the given ad and owner custom fields
 */
public <VO extends AdVO> VO toVO(final Class<VO> voType, final Ad ad, final List<AdCustomField> adFields, final List<MemberCustomField> memberFields) {
    if (ad == null) {
        return null;
    }
    final LocalSettings localSettings = settingsService.getLocalSettings();

    final VO vo;
    try {
        vo = voType.newInstance();
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
    vo.setId(ad.getId());
    vo.setCategory(toVO(ad.getCategory()));
    vo.setTitle(ad.getTitle());
    vo.setDescription(ad.getDescription());
    final Currency currency = ad.getCurrency();
    vo.setCurrency(currencyHelper.toVO(currency));
    vo.setPrice(ad.getPrice());
    if (currency == null) {
        vo.setFormattedPrice(localSettings.getNumberConverter().toString(ad.getPrice()));
    } else {
        vo.setFormattedPrice(localSettings.getUnitsConverter(currency.getPattern()).toString(ad.getPrice()));
    }
    vo.setPermanent(ad.isPermanent());
    vo.setSearching(ad.getTradeType() == Ad.TradeType.SEARCH);
    vo.setHtml(ad.isHtml());
    final Period publicationPeriod = ad.getPublicationPeriod();
    if (publicationPeriod != null) {
        final Calendar begin = publicationPeriod.getBegin();
        final Calendar end = publicationPeriod.getEnd();
        vo.setPublicationStart(begin);
        vo.setFormattedPublicationStart(localSettings.getRawDateConverter().toString(begin));
        vo.setPublicationEnd(end);
        vo.setFormattedPublicationEnd(localSettings.getRawDateConverter().toString(end));
    }
    vo.setOwner(memberHelper.toVO(ad.getOwner(), memberFields, false));
    vo.setImages(imageHelper.toVOs(ad.getImages()));
    if (adFields != null) {
        List<AdCustomField> visibleAdFields = new ArrayList<AdCustomField>();
        List<Visibility> allowedVisibilities = Arrays.asList(AdCustomField.Visibility.WEB_SERVICE, AdCustomField.Visibility.MEMBER);
        // filter by visibility
        for (AdCustomField adCustomField : adFields) {
            if (allowedVisibilities.contains(adCustomField.getVisibility())) {
                visibleAdFields.add(adCustomField);
            }
        }
        vo.setFields(fieldHelper.toList(visibleAdFields, null, ad.getCustomValues()));
    }
    return vo;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:55,代码来源:AdHelper.java

示例8: getNumberOfMembersInGroupsInPeriod

import nl.strohalm.cyclos.utils.Period; //导入方法依赖的package包/类
/**
 * gets the number of members which were in the specified group at any moment during the specified period. Used by Activity Stats: gross Product,
 * number of transactions and % not trading for compare periods, Histogram, Single Period, and by Key Dev Stats number of members
 * 
 * @param groups the set of groups in which the members must be counted.
 * @param period the period in which they should be part of any of the groups
 * @return an int indicating the number of members during that period in that set of groups
 * 
 */
@Override
public int getNumberOfMembersInGroupsInPeriod(final Collection<? extends Group> groups, final Period period) {
    final StringBuilder hql = new StringBuilder(" select count(m.id) from Member m where 1=1 ");

    final Map<String, Object> namedParameters = new HashMap<String, Object>();

    if (CollectionUtils.isEmpty(groups) && period != null && period.getEnd() != null) {
        namedParameters.put("endDate", period.getEnd());
        hql.append(" and m.creationDate <= :endDate ");

    } else if (!CollectionUtils.isEmpty(groups) && period != null && period.getEnd() != null && period.getBegin() != null) {
        namedParameters.put("beginDate", period.getBegin());
        namedParameters.put("endDate", period.getEnd());
        namedParameters.put("groups", groups);

        // First condition: it has been in one of the selected groups
        hql.append(" and ( (m.group in (:groups) and m.creationDate < :endDate and not exists ");
        hql.append(" (select gr1.id from GroupRemark gr1 where gr1.subject = m)) or ");

        // Second: Changed the member's group inside the period.
        hql.append(" (m.creationDate < :endDate and exists (select gr.id from GroupRemark gr where gr.subject=m and (gr.oldGroup in ");
        hql.append(" (:groups) or gr.newGroup in (:groups)) and gr.date > :beginDate and gr.date <= :endDate)) or ");

        // Third condition: the group remark right before the period put the member in one
        // of the selected groups
        hql.append(" exists (select gr2.id from GroupRemark gr2 where gr2.subject=m and ");
        hql.append(" gr2.newGroup in (:groups) and gr2.date=(select max(gr3.date) from GroupRemark ");
        hql.append(" gr3 where gr3.subject=m and gr3.date < :beginDate)) or ");

        // Fourth condition: the group remark right after the begin period: the member was created
        // then the group was changed in the period, we must use oldGroup.
        hql.append(" (m.creationDate <= :endDate and exists (select gr2.id from GroupRemark gr2 where ");
        hql.append(" gr2.subject=m and gr2.oldGroup in (:groups) and gr2.date = (select min(gr3.date) ");
        hql.append(" from GroupRemark gr3 where gr3.subject=m and gr3.date > :endDate))) ");
        hql.append(" ) ");
    } else if (!CollectionUtils.isEmpty(groups)) {
        hql.append(" and m.group in (:groups) ");
        namedParameters.put("groups", groups);
    }
    final Number count = uniqueResult(hql.toString(), namedParameters);
    return count.intValue();
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:52,代码来源:ElementDAOImpl.java


注:本文中的nl.strohalm.cyclos.utils.Period.getEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。