mirror of https://github.com/apache/cloudstack.git
quota: remove include column from tariff, fix list tariff api to accept start date
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
355b2e6330
commit
0e0df49d3e
|
|
@ -31,6 +31,7 @@ import org.apache.log4j.Logger;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@APICommand(name = "quotaTariffList", responseObject = QuotaTariffResponse.class, description = "Lists all quota tariff plans", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
|
|
@ -44,6 +45,9 @@ public class QuotaTariffListCmd extends BaseListCmd {
|
|||
@Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, required = false, description = "Usage type of the resource")
|
||||
private Integer usageType;
|
||||
|
||||
@Parameter(name = ApiConstants.START_DATE, type = CommandType.DATE, required = false, description = "The effective start date on/after which the quota tariff is effective and older tariffs are no longer used for the usage type. Use yyyy-MM-dd as the date format, e.g. startDate=2009-06-03.")
|
||||
private Date startDate;
|
||||
|
||||
public QuotaTariffListCmd() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -74,6 +78,10 @@ public class QuotaTariffListCmd extends BaseListCmd {
|
|||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public Integer getUsageType() {
|
||||
return usageType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
response.setUsageUnit(tariff.getUsageUnit());
|
||||
response.setUsageDiscriminator(tariff.getUsageDiscriminator());
|
||||
response.setTariffValue(tariff.getCurrencyValue());
|
||||
response.setInclude(tariff.getInclude());
|
||||
response.setEffectiveOn(tariff.getEffectiveOn());
|
||||
response.setDescription(tariff.getDescription());
|
||||
return response;
|
||||
|
|
@ -215,7 +214,10 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
@Override
|
||||
public List<QuotaTariffVO> listQuotaTariffPlans(final QuotaTariffListCmd cmd) {
|
||||
List<QuotaTariffVO> result = new ArrayList<QuotaTariffVO>();
|
||||
Date now = _quotaService.computeAdjustedTime(new Date());
|
||||
Date now = cmd.getStartDate();
|
||||
if (now == null) {
|
||||
now = _quotaService.computeAdjustedTime(new Date());
|
||||
}
|
||||
s_logger.info("Now=" + now.toGMTString() + " quotatype=" + cmd.getUsageType());
|
||||
if (cmd.getUsageType() != null) {
|
||||
QuotaTariffVO tariffPlan = _quotaTariffDao.findTariffPlanByUsageType(cmd.getUsageType(), now);
|
||||
|
|
|
|||
|
|
@ -50,10 +50,6 @@ public class QuotaTariffResponse extends BaseResponse {
|
|||
@Param(description = "the date on/after which this quota value will be effective")
|
||||
private Date effectiveOn = null;
|
||||
|
||||
@SerializedName("include")
|
||||
@Param(description = "include")
|
||||
private int include;
|
||||
|
||||
@SerializedName("description")
|
||||
@Param(description = "description")
|
||||
private String description;
|
||||
|
|
@ -108,14 +104,6 @@ public class QuotaTariffResponse extends BaseResponse {
|
|||
this.tariffValue = tariffValue;
|
||||
}
|
||||
|
||||
public int getInclude() {
|
||||
return include;
|
||||
}
|
||||
|
||||
public void setInclude(int include) {
|
||||
this.include = include;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ public class QuotaTariffDaoImpl extends GenericDaoBase<QuotaTariffVO, Long> impl
|
|||
searchUsageType.done();
|
||||
|
||||
listAllIncludedUsageType = createSearchBuilder();
|
||||
listAllIncludedUsageType.and("include", listAllIncludedUsageType.entity().getInclude(), SearchCriteria.Op.EQ);
|
||||
listAllIncludedUsageType.and("onorbeforedate", listAllIncludedUsageType.entity().getEffectiveOn(), SearchCriteria.Op.LTEQ);
|
||||
listAllIncludedUsageType.and("quotatype", listAllIncludedUsageType.entity().getUsageType(), SearchCriteria.Op.EQ);
|
||||
listAllIncludedUsageType.done();
|
||||
|
|
@ -62,7 +61,6 @@ public class QuotaTariffDaoImpl extends GenericDaoBase<QuotaTariffVO, Long> impl
|
|||
try {
|
||||
final Filter filter = new Filter(QuotaTariffVO.class, "effectiveOn", false, 0L, 1L);
|
||||
final SearchCriteria<QuotaTariffVO> sc = listAllIncludedUsageType.create();
|
||||
sc.setParameters("include", 1);
|
||||
sc.setParameters("onorbeforedate", onOrBeforeDate);
|
||||
sc.setParameters("quotatype", quotaType);
|
||||
result = search(sc, filter);
|
||||
|
|
@ -88,7 +86,6 @@ public class QuotaTariffDaoImpl extends GenericDaoBase<QuotaTariffVO, Long> impl
|
|||
try {
|
||||
final Filter filter = new Filter(QuotaTariffVO.class, "effectiveOn", false, 0L, 1L);
|
||||
final SearchCriteria<QuotaTariffVO> sc = listAllIncludedUsageType.create();
|
||||
sc.setParameters("include", 1);
|
||||
sc.setParameters("onorbeforedate", onOrBeforeDate);
|
||||
for (Integer quotaType : QuotaTypes.listQuotaTypes().keySet()) {
|
||||
sc.setParameters("quotatype", quotaType);
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@ public class QuotaTariffVO implements InternalIdentity {
|
|||
@Column(name = "currency_value")
|
||||
private BigDecimal currencyValue;
|
||||
|
||||
@Column(name = "include")
|
||||
private int include;
|
||||
|
||||
@Column(name = "effective_on")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
private Date effectiveOn = null;
|
||||
|
|
@ -73,14 +70,13 @@ public class QuotaTariffVO implements InternalIdentity {
|
|||
public QuotaTariffVO() {
|
||||
}
|
||||
|
||||
public QuotaTariffVO(final int usagetype, final String usagename, final String usageunit, final String usagediscriminator, final BigDecimal currencyvalue, final int include,
|
||||
public QuotaTariffVO(final int usagetype, final String usagename, final String usageunit, final String usagediscriminator, final BigDecimal currencyvalue,
|
||||
final Date effectiveOn, final Date updatedOn, final long updatedBy) {
|
||||
this.usageType = usagetype;
|
||||
this.usageName = usagename;
|
||||
this.usageUnit = usageunit;
|
||||
this.usageDiscriminator = usagediscriminator;
|
||||
this.currencyValue = currencyvalue;
|
||||
this.include = include;
|
||||
this.effectiveOn = effectiveOn;
|
||||
this.updatedOn = updatedOn;
|
||||
this.updatedBy = updatedBy;
|
||||
|
|
@ -155,14 +151,6 @@ public class QuotaTariffVO implements InternalIdentity {
|
|||
this.currencyValue = currencyValue;
|
||||
}
|
||||
|
||||
public int getInclude() {
|
||||
return include;
|
||||
}
|
||||
|
||||
public void setInclude(int include) {
|
||||
this.include = include;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return QuotaTypes.getDescription(usageType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ CREATE TABLE IF NOT EXISTS `cloud_usage`.`quota_tariff` (
|
|||
`usage_unit` varchar(255) NOT NULL COMMENT 'usage type',
|
||||
`usage_discriminator` varchar(255) NOT NULL COMMENT 'usage type',
|
||||
`currency_value` decimal(15,2) NOT NULL COMMENT 'usage type',
|
||||
`include` tinyint(1) NOT NULL COMMENT 'usage type',
|
||||
`effective_on` datetime NOT NULL COMMENT 'date time on which this quota values will become effective',
|
||||
`updated_on` datetime NOT NULL COMMENT 'date this entry was updated on',
|
||||
`updated_by` bigint unsigned NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue