Skip to content

Commit 2d7979e

Browse files
author
kishan
committed
bug 7504: UsageEvent dao and related objects
1 parent b12cd70 commit 2d7979e

4 files changed

Lines changed: 407 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.event;
19+
20+
import java.util.Date;
21+
22+
public interface UsageEvent {
23+
long getId();
24+
String getType();
25+
26+
Date getCreateDate();
27+
long getAccountId();
28+
Long getSize();
29+
Long getTemplateId();
30+
Long getOfferingId();
31+
long getResourceId();
32+
long getZoneId();
33+
}
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
19+
package com.cloud.event;
20+
21+
import java.util.Date;
22+
23+
import javax.persistence.Column;
24+
import javax.persistence.Entity;
25+
import javax.persistence.GeneratedValue;
26+
import javax.persistence.GenerationType;
27+
import javax.persistence.Id;
28+
import javax.persistence.PrimaryKeyJoinColumn;
29+
import javax.persistence.SecondaryTable;
30+
import javax.persistence.Table;
31+
32+
import com.cloud.utils.db.GenericDao;
33+
34+
@Entity
35+
@Table(name="usage_event")
36+
@SecondaryTable(name="account",
37+
pkJoinColumns={@PrimaryKeyJoinColumn(name="account_id", referencedColumnName="id")})
38+
public class UsageEventVO implements UsageEvent {
39+
@Id
40+
@GeneratedValue(strategy=GenerationType.IDENTITY)
41+
@Column(name="id")
42+
private long id = -1;
43+
44+
@Column(name="type")
45+
private String type;
46+
47+
@Column(name=GenericDao.CREATED_COLUMN)
48+
private Date createDate;
49+
50+
@Column(name="account_id")
51+
private long accountId;
52+
53+
@Column(name="zone_id")
54+
private long zoneId;
55+
56+
@Column(name="resource_id")
57+
private long resourceId;
58+
59+
@Column(name="resource_name")
60+
private String resourceName;
61+
62+
@Column(name="offering_id")
63+
private Long offeringId;
64+
65+
@Column(name="template_id")
66+
private Long templateId;
67+
68+
@Column(name="size")
69+
private Long size;
70+
71+
72+
public UsageEventVO() {
73+
}
74+
75+
public UsageEventVO(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size) {
76+
this.type = usageType;
77+
this.accountId = accountId;
78+
this.zoneId = zoneId;
79+
this.resourceId = resourceId;
80+
this.resourceName = resourceName;
81+
this.offeringId = offeringId;
82+
this.templateId = templateId;
83+
this.size = size;
84+
}
85+
86+
public UsageEventVO(String usageType, long accountId, long zoneId, long resourceId, String resourceName) {
87+
this.type = usageType;
88+
this.accountId = accountId;
89+
this.zoneId = zoneId;
90+
this.resourceId = resourceId;
91+
this.resourceName = resourceName;
92+
}
93+
94+
public long getId() {
95+
return id;
96+
}
97+
@Override
98+
public String getType() {
99+
return type;
100+
}
101+
public void setType(String type) {
102+
this.type = type;
103+
}
104+
105+
@Override
106+
public Date getCreateDate() {
107+
return createDate;
108+
}
109+
public void setCreatedDate(Date createdDate) {
110+
createDate = createdDate;
111+
}
112+
113+
@Override
114+
public long getAccountId() {
115+
return accountId;
116+
}
117+
public void setAccountId(long accountId) {
118+
this.accountId = accountId;
119+
}
120+
121+
public void setZoneId(long zoneId) {
122+
this.zoneId = zoneId;
123+
}
124+
@Override
125+
public long getZoneId() {
126+
return zoneId;
127+
}
128+
129+
public void setResourceId(long resourceId) {
130+
this.resourceId = resourceId;
131+
}
132+
@Override
133+
public long getResourceId() {
134+
return resourceId;
135+
}
136+
137+
public void setResourceName(String resourceName) {
138+
this.resourceName = resourceName;
139+
}
140+
141+
public String getResourceName() {
142+
return resourceName;
143+
}
144+
145+
public void setOfferingId(long offeringId) {
146+
this.offeringId = offeringId;
147+
}
148+
@Override
149+
public Long getOfferingId() {
150+
return offeringId;
151+
}
152+
153+
public void setTemplateId(long templateId) {
154+
this.templateId = templateId;
155+
}
156+
@Override
157+
public Long getTemplateId() {
158+
return templateId;
159+
}
160+
161+
public void setSize(long size) {
162+
this.size = size;
163+
}
164+
@Override
165+
public Long getSize() {
166+
return size;
167+
}
168+
169+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
19+
package com.cloud.event.dao;
20+
21+
import java.util.Date;
22+
import java.util.List;
23+
24+
import com.cloud.event.UsageEventVO;
25+
import com.cloud.exception.UsageServerException;
26+
import com.cloud.utils.db.Filter;
27+
import com.cloud.utils.db.GenericDao;
28+
import com.cloud.utils.db.SearchCriteria;
29+
30+
public interface UsageEventDao extends GenericDao<UsageEventVO, Long> {
31+
32+
public List<UsageEventVO> searchAllUsageEvents(SearchCriteria<UsageEventVO> sc, Filter filter);
33+
34+
public List<UsageEventVO> listLatestEvents(Date recentEventDate, Date endDate);
35+
36+
public List<UsageEventVO> listAllEvents(Date endDate);
37+
38+
public List<UsageEventVO> getLatestEventDate();
39+
40+
List<UsageEventVO> getRecentEvents(Date endDate) throws UsageServerException;
41+
42+
}

0 commit comments

Comments
 (0)