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


Java Period类代码示例

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


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

示例1: handleDisplay

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
@Override
protected ActionForward handleDisplay(final ActionContext context) throws Exception {
    final HttpServletRequest request = context.getRequest();
    // Set initial values for period
    final MembersTransactionsReportForm form = context.getForm();
    final NamedPeriod period = NamedPeriod.getLastQuarterPeriod();
    final LocalSettings settings = settingsService.getLocalSettings();
    final BeanBinder<Period> periodBinder = DataBinderHelper.periodBinder(settings, "period");
    periodBinder.writeAsString(form.getMembersTransactionsReport(), period);

    // Send member groups to JSP
    AdminGroup adminGroup = context.getGroup();
    adminGroup = groupService.load(adminGroup.getId(), AdminGroup.Relationships.MANAGES_GROUPS);
    final Collection<MemberGroup> groups = new TreeSet<MemberGroup>(adminGroup.getManagesGroups());
    request.setAttribute("memberGroups", groups);

    RequestHelper.storeEnum(request, MembersTransactionsReportDTO.DetailsLevel.class, "detailsLevels");
    return context.getInputForward();
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:20,代码来源:MembersTransactionsReportAction.java

示例2: getBeginParameter

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

示例3: processScheduled

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
@Override
public void processScheduled(final Period period) {
    // Process each transfer
    final TransferQuery query = new TransferQuery();
    query.setResultType(ResultType.ITERATOR);
    query.setPeriod(period);
    query.setStatus(Payment.Status.SCHEDULED);
    query.setUnordered(true);
    CacheCleaner cacheCleaner = new CacheCleaner(fetchService);
    final List<Transfer> transfers = transferDao.search(query);
    try {
        for (final Transfer transfer : transfers) {
            processScheduledTransfer(transfer, true, true, true);
            cacheCleaner.clearCache();
        }
    } finally {
        DataIteratorHelper.close(transfers);
    }
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:20,代码来源:PaymentServiceImpl.java

示例4: processGuaranteeLoans

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
/**
 * Generates a new loan for each guarantee if its status is ACCEPTED and the begin period is before or equals to the time parameter
 * @param time the times used as the current time
 */
@Override
public void processGuaranteeLoans(final Calendar time) {
    final GuaranteeQuery query = new GuaranteeQuery();
    query.fetch(Guarantee.Relationships.GUARANTEE_TYPE, Guarantee.Relationships.SELLER, Guarantee.Relationships.BUYER);
    query.setStatusList(Collections.singletonList(Guarantee.Status.ACCEPTED));
    query.setStartIn(Period.endingAt(time));
    query.setLoanFilter(GuaranteeQuery.LoanFilter.WITHOUT_LOAN);

    final List<Guarantee> guarantees = guaranteeDao.search(query);

    for (final Guarantee guarantee : guarantees) {
        grantLoan(time, guarantee, false);
        save(guarantee, true);
    }
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:20,代码来源:GuaranteeServiceImpl.java

示例5: getOldestTransfer

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
@Override
public Calendar getOldestTransfer(final Currency currency, final Account account, final Period period, final boolean excludeChargebacks) {
    final StringBuilder hql = new StringBuilder();
    final Map<String, Object> namedParameters = new HashMap<String, Object>();
    hql.append(" select min(t.processDate) from Transfer t  ");
    hql.append(" where 1=1 ");
    if (currency != null) {
        namedParameters.put("currency", currency);
        hql.append(" and t.to.type.currency = :currency ");
    }
    if (account != null) {
        namedParameters.put("account", account);
        hql.append(" and (t.from = :account or t.to = :account) ");
    }
    if (excludeChargebacks) {
        hql.append(" and t.chargedBackBy is null and t.chargebackOf is null ");
    }
    HibernateHelper.addPeriodParameterToQuery(hql, namedParameters, "t.processDate", period);
    hql.append(" order by t.processDate, t.id");
    return (Calendar) uniqueResult(hql.toString(), namedParameters);
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:22,代码来源:TransferDAOImpl.java

示例6: getSinglePeriodLoginTimes

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
@Override
public StatisticalResultDTO getSinglePeriodLoginTimes(final StatisticalActivityQuery queryParameters) {
    final Period periodMain = queryParameters.getPeriodMain();
    final LoginTimesPerMemberStats statsMainPeriod = new LoginTimesPerMemberStats(queryParameters, periodMain, loginHistoryDao);
    final List<Number> periodMainLoginTimes = statsMainPeriod.getListLoginTimes();
    final int periodMainNoOfMembers = periodMainLoginTimes.size();
    StatisticalResultDTO result = null;
    final String baseKey = "reports.stats.activity.singlePeriod.loginTimes";
    if (periodMainNoOfMembers >= MINIMUM_NUMBER_OF_VALUES) {
        final StatisticalNumber periodMainMedianLoginTimesPerMember = Median.getMedian(periodMainLoginTimes, StatisticalService.ALPHA);
        final Number[][] tableCells = new Number[1][1];
        tableCells[0][0] = periodMainMedianLoginTimesPerMember;
        result = new StatisticalResultDTO(tableCells);
        result.setBaseKey(baseKey);
        passGroupFilter(result, queryParameters);
        setGeneralsForSinglePeriod(result, queryParameters, 1, false);
        final String[] columnSubHeaders = { "(n=" + periodMainNoOfMembers + ")" };
        result.setColumnSubHeaders(columnSubHeaders);
    } else {
        result = StatisticalResultDTO.noDataAvailable(baseKey);
    }
    return result;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:24,代码来源:StatisticalActivityServiceImpl.java

示例7: getBalanceAtTransfer

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
@Override
public BigDecimal getBalanceAtTransfer(final Account account, final Transfer transfer, final boolean compensateChargebacks, final boolean inclusive) {
    if (transfer.getProcessDate() == null) {
        throw new IllegalArgumentException("transfer must be processed.");
    }
    // Get the last closed balance before the given date
    ClosedAccountBalance closedBalance = closedAccountBalanceDao.get(account, transfer.getProcessDate());
    BigDecimal balance = closedBalance == null ? BigDecimal.ZERO : closedBalance.getBalance();

    Period diffPeriod = Period.begginingAt((closedBalance == null) ? null : closedBalance.getDate());
    diffPeriod.setInclusiveEnd(inclusive);
    BigDecimal diff = transferDao.balanceDiff(account, diffPeriod, transfer);
    balance = balance.add(diff);
    if (compensateChargebacks) {
        BigDecimal chargebackBalance = transferDao.getChargebackBalance(account, transfer, inclusive);
        balance = balance.add(chargebackBalance);
    }
    return balance;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:20,代码来源:AccountServiceImpl.java

示例8: getDisappearedMembersCount

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
private int getDisappearedMembersCount(final Period period, final Collection<? extends Group> groups) {
    final MemberQuery memberQuery = new MemberQuery();
    memberQuery.setDeactivationPeriod(period);
    memberQuery.setGroups(groups);
    memberQuery.setPageForCount();
    return PageHelper.getTotalCount(getElementDao().searchHistoryRemoved(memberQuery));
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:8,代码来源:StatisticalKeyDevelopmentsServiceImpl.java

示例9: getHistogramGrossProduct

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
@Override
public StatisticalResultDTO getHistogramGrossProduct(final StatisticalActivityQuery queryParameters) {
    Period period = queryParameters.getPeriodMain();
    final GrossProductPerMemberStats statsPeriod = new GrossProductPerMemberStats(queryParameters, period, getTransferDao());
    final List<Number> listGrossProductPerAllMembers = statsPeriod.getListVolumePerAllMembers(getNumberOfMembersForPeriod(queryParameters, period));
    final HistogramDTOFactory histoFactory = new HistogramDTOFactory(listGrossProductPerAllMembers, getLocalSettings());
    final String baseKey = "reports.stats.activity.histogram.grossProduct";
    final StatisticalResultDTO result = histoFactory.getResultObject(baseKey);
    result.setColumnKeys(new String[] { "reports.stats.activity.histogram.grossProduct.xAxis" });
    final Currency currency = getCurrency(queryParameters);
    result.setXAxisUnits(currency.getSymbol());
    passGroupFilter(result, queryParameters);
    passPaymentFilter(result, queryParameters);
    return result;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:16,代码来源:StatisticalActivityServiceImpl.java

示例10: periodBinder

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
/**
 * Returns a data binder for periods
 */
public static BeanBinder<Period> periodBinder(final LocalSettings localSettings, final String name) {
    final BeanBinder<Period> binder = BeanBinder.instance(Period.class, name);
    binder.registerBinder("begin", PropertyBinder.instance(Calendar.class, "begin", localSettings.getDateConverter()));
    binder.registerBinder("end", PropertyBinder.instance(Calendar.class, "end", localSettings.getDateConverter()));
    return binder;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:10,代码来源:DataBinderHelper.java

示例11: getTableCellsIncomeThroughTime

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
public Number[][] getTableCellsIncomeThroughTime(final Period[] periods, final Collection<PaymentFilter> aPaymentFilters, final SystemAccountType aSystemAccountFilter) {
    final Number[][] tableCells = new Number[periods.length][aPaymentFilters.size()];
    int i = 0;
    for (final Period period : periods) {
        int j = 0;
        for (final PaymentFilter paymentFilter : aPaymentFilters) {
            tableCells[i][j] = getIncome(period, paymentFilter, aSystemAccountFilter);
            j++;
        }
        i++;
    }
    return tableCells;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:14,代码来源:FinanceStatsThroughTime.java

示例12: getRowHeaders

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
/**
 * Generates the row headers in the table in through time: the names of the months, quarters or years
 * 
 * @param throughTimeRange the type of the range (month, year, etc)
 * @param period one period inside this range. It is called once for every period inside the range.
 * @return a String representing the row header of the table.
 */
protected String getRowHeaders(final ThroughTimeRange throughTimeRange, final Period period) {
    String result = "";
    if (throughTimeRange == ThroughTimeRange.MONTH) {
        result = period.getBegin().get(Calendar.YEAR) + " - " + (period.getBegin().get(Calendar.MONTH) + 1 >= 10 ? period.getBegin().get(Calendar.MONTH) + 1 : "0" + (period.getBegin().get(Calendar.MONTH) + 1));
    } else if (throughTimeRange == ThroughTimeRange.QUARTER) {
        result = period.getBegin().get(Calendar.YEAR) + " - " + period.getBeginQuarter().toStringRepresentation();
    } else {
        result = "" + period.getBegin().get(Calendar.YEAR);
    }
    return result;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:19,代码来源:StatisticalServiceImpl.java

示例13: 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

示例14: getNextExecutionDate

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
public Calendar getNextExecutionDate() {
    if (runMode != RunMode.SCHEDULED || enabledSince == null) {
        return null;
    }
    // Resolve the period
    Period period;
    final AccountFeeLog lastLog = getLastExecution();
    if (lastLog == null) {
        // The account fee has never ran. Get the full period which contains the enabled since date
        period = recurrence.currentPeriod(enabledSince);
    } else {
        // Get the next period, counting from the last execution
        final Calendar begin = DateHelper.truncateNextDay(lastLog.getPeriod().getEnd());
        period = recurrence.periodStartingAt(begin);

        // If the fee was re-enabled long after the last execution, use the enabledSince instead
        if (enabledSince.after(period.getEnd())) {
            period = recurrence.currentPeriod(enabledSince);
        }
    }

    Calendar executionDate = DateHelper.truncateNextDay(period.getEnd());
    if (enabledSince.after(executionDate)) {
        executionDate = DateHelper.truncateNextDay(recurrence.currentPeriod(enabledSince).getEnd());
    }
    switch (recurrence.getField()) {
        case WEEKS:
            while (executionDate.get(Calendar.DAY_OF_WEEK) != day) {
                executionDate.add(Calendar.DAY_OF_MONTH, 1);
            }
            break;
        case MONTHS:
            executionDate.set(Calendar.DAY_OF_MONTH, day);
    }
    if (hour != null) {
        executionDate.set(Calendar.HOUR_OF_DAY, hour);
    }
    return executionDate;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:40,代码来源:AccountFee.java

示例15: listTransfers

import nl.strohalm.cyclos.utils.Period; //导入依赖的package包/类
public static List<Entry> listTransfers(final PaymentService paymentService, final Member owner, final Calendar date) {
    final TransferQuery transferQuery = new TransferQuery();
    transferQuery.setIterateAll();
    transferQuery.setOwner(owner);
    transferQuery.setPeriod(Period.day(date));
    transferQuery.setStatus(Payment.Status.PROCESSED);
    final List<Transfer> transfers = paymentService.search(transferQuery);
    final TransformedIteratorList<Transfer, Entry> transferEntries = new TransformedIteratorList<Transfer, Entry>(new TransformPaymentToEntry<Transfer>(owner), transfers);
    return transferEntries;
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:11,代码来源:SearchTransactionsAction.java


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