Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/689#discussion_r37583531
  
    --- Diff: 
framework/quota/src/org/apache/cloudstack/quota/dao/QuotaUsageDaoImpl.java ---
    @@ -0,0 +1,106 @@
    +//Licensed to the Apache Software Foundation (ASF) under one
    +//or more contributor license agreements.  See the NOTICE file
    +//distributed with this work for additional information
    +//regarding copyright ownership.  The ASF licenses this file
    +//to you under the Apache License, Version 2.0 (the
    +//"License"); you may not use this file except in compliance
    +//with the License.  You may obtain a copy of the License at
    +//
    +//http://www.apache.org/licenses/LICENSE-2.0
    +//
    +//Unless required by applicable law or agreed to in writing,
    +//software distributed under the License is distributed on an
    +//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +//KIND, either express or implied.  See the License for the
    +//specific language governing permissions and limitations
    +//under the License.
    +package org.apache.cloudstack.quota.dao;
    +
    +import java.math.BigDecimal;
    +import java.util.ArrayList;
    +import java.util.Date;
    +import java.util.List;
    +
    +import javax.ejb.Local;
    +
    +import org.springframework.stereotype.Component;
    +import org.apache.cloudstack.quota.vo.QuotaUsageVO;
    +
    +import com.cloud.utils.Pair;
    +import com.cloud.utils.db.Filter;
    +import com.cloud.utils.db.GenericDaoBase;
    +import com.cloud.utils.db.SearchCriteria;
    +import com.cloud.utils.db.TransactionLegacy;
    +
    +@Component
    +@Local(value = { QuotaUsageDao.class })
    +public class QuotaUsageDaoImpl extends GenericDaoBase<QuotaUsageVO, Long> 
implements QuotaUsageDao {
    +
    +    @Override
    +    public Pair<List<QuotaUsageVO>, Integer> 
searchAndCountAllRecords(SearchCriteria<QuotaUsageVO> sc, Filter filter) {
    +        return listAndCountIncludingRemovedBy(sc, filter);
    +    }
    +
    +    @Override
    +    public void saveQuotaUsage(List<QuotaUsageVO> records) {
    +        for (QuotaUsageVO usageRecord : records) {
    +            persist(usageRecord);
    +        }
    +    }
    +
    +    @Override
    +    public BigDecimal findTotalQuotaUsage(final Long accountId, final Long 
domainId, final Integer usageType, final Date startDate, final Date endDate) {
    +        List<QuotaUsageVO> quotaUsage = findQuotaUsage(accountId, 
domainId, null, startDate, endDate);
    +        BigDecimal total = new BigDecimal(0);
    +        for (final QuotaUsageVO quotaRecord : quotaUsage) {
    +            total = total.add(quotaRecord.getQuotaUsed());
    +        }
    +        return total;
    +    }
    +
    +    @SuppressWarnings("deprecation")
    +    @Override
    +    public List<QuotaUsageVO> findQuotaUsage(final Long accountId, final 
Long domainId, final Integer usageType, final Date startDate, final Date 
endDate) {
    +        final short opendb = 
TransactionLegacy.currentTxn().getDatabaseId();
    +        TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.USAGE_DB);
    +        List<QuotaUsageVO> quotaUsageRecords = null;
    +        try {
    +            // TODO instead of max value query with reasonable number and
    +            // iterate
    +            SearchCriteria<QuotaUsageVO> sc = createSearchCriteria();
    +            if (accountId != null) {
    +                sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
    +            }
    +            /*
    +             * if (isDomainAdmin) { SearchCriteria<DomainVO> sdc =
    +             * _domainDao.createSearchCriteria(); sdc.addOr("path",
    +             * SearchCriteria.Op.LIKE,
    +             * _domainDao.findById(caller.getDomainId()).getPath() + "%");
    +             * List<DomainVO> domains = _domainDao.search(sdc, null); 
List<Long>
    +             * domainIds = new ArrayList<Long>(); for (DomainVO domain :
    +             * domains) domainIds.add(domain.getId()); 
sc.addAnd("domainId",
    +             * SearchCriteria.Op.IN, domainIds.toArray());
    +             * s_logger.debug("Account ID=" + accountId); }
    +             */
    --- End diff --
    
    Please remove commented code as it is cruft that obscures the rest of the 
method. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to