mirror of https://github.com/apache/cloudstack.git
Add java changes
This commit is contained in:
parent
f7b40961af
commit
e9b42a3fb2
|
|
@ -20,6 +20,9 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
|
@ -29,6 +32,12 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
@Entity
|
||||
@Table(name = "usage_ip_address")
|
||||
public class UsageIPAddressVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "account_id")
|
||||
private long accountId;
|
||||
|
||||
|
|
@ -38,8 +47,8 @@ public class UsageIPAddressVO implements InternalIdentity {
|
|||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
@Column(name = "ip_id")
|
||||
private long ipId;
|
||||
|
||||
@Column(name = "public_ip_address")
|
||||
private String address = null;
|
||||
|
|
@ -62,7 +71,7 @@ public class UsageIPAddressVO implements InternalIdentity {
|
|||
}
|
||||
|
||||
public UsageIPAddressVO(long id, long accountId, long domainId, long zoneId, String address, boolean isSourceNat, boolean isSystem, Date assigned, Date released) {
|
||||
this.id = id;
|
||||
this.ipId = id;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.zoneId = zoneId;
|
||||
|
|
@ -120,4 +129,8 @@ public class UsageIPAddressVO implements InternalIdentity {
|
|||
public void setReleased(Date released) {
|
||||
this.released = released;
|
||||
}
|
||||
|
||||
public long getIpId() {
|
||||
return ipId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
|
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
@Table(name = "usage_load_balancer_policy")
|
||||
public class UsageLoadBalancerPolicyVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
||||
|
|
@ -39,8 +47,8 @@ public class UsageLoadBalancerPolicyVO implements InternalIdentity {
|
|||
@Column(name = "domain_id")
|
||||
private long domainId;
|
||||
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
@Column(name = "lb_id")
|
||||
private long lbId;
|
||||
|
||||
@Column(name = "created")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
|
|
@ -57,7 +65,7 @@ public class UsageLoadBalancerPolicyVO implements InternalIdentity {
|
|||
this.zoneId = zoneId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.id = id;
|
||||
this.lbId = id;
|
||||
this.created = created;
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
|
@ -90,4 +98,8 @@ public class UsageLoadBalancerPolicyVO implements InternalIdentity {
|
|||
public void setDeleted(Date deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public long getLbId() {
|
||||
return lbId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,27 @@
|
|||
// under the License.
|
||||
package com.cloud.usage;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@Table(name = "usage_network_offering")
|
||||
public class UsageNetworkOfferingVO {
|
||||
public class UsageNetworkOfferingVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
|
@ -116,4 +126,9 @@ public class UsageNetworkOfferingVO {
|
|||
public void setNicId(Long nicId) {
|
||||
this.nicId = nicId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
|
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
@Table(name = "usage_port_forwarding")
|
||||
public class UsagePortForwardingRuleVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
||||
|
|
@ -39,8 +47,8 @@ public class UsagePortForwardingRuleVO implements InternalIdentity {
|
|||
@Column(name = "domain_id")
|
||||
private long domainId;
|
||||
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
@Column(name = "pf_id")
|
||||
private long pfId;
|
||||
|
||||
@Column(name = "created")
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
|
|
@ -57,7 +65,7 @@ public class UsagePortForwardingRuleVO implements InternalIdentity {
|
|||
this.zoneId = zoneId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.id = id;
|
||||
this.pfId = id;
|
||||
this.created = created;
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
|
@ -90,4 +98,8 @@ public class UsagePortForwardingRuleVO implements InternalIdentity {
|
|||
public void setDeleted(Date deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public long getPfId() {
|
||||
return pfId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,27 @@
|
|||
// under the License.
|
||||
package com.cloud.usage;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@Table(name = "usage_security_group")
|
||||
public class UsageSecurityGroupVO {
|
||||
public class UsageSecurityGroupVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
|
@ -95,4 +105,9 @@ public class UsageSecurityGroupVO {
|
|||
public void setDeleted(Date deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
|
@ -30,9 +33,13 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
@Table(name = "usage_snapshot_on_primary")
|
||||
public class UsageSnapshotOnPrimaryVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
// volumeId
|
||||
private long id;
|
||||
private Long id;
|
||||
|
||||
@Column(name = "volume_id")
|
||||
private long volumeId;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
|
@ -73,7 +80,7 @@ public class UsageSnapshotOnPrimaryVO implements InternalIdentity {
|
|||
}
|
||||
|
||||
public UsageSnapshotOnPrimaryVO(long id, long zoneId, long accountId, long domainId, long vmId, String name, int type, long virtualSize, long physicalSize, Date created, Date deleted) {
|
||||
this.id = id;
|
||||
this.volumeId = id;
|
||||
this.zoneId = zoneId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
|
|
@ -153,4 +160,7 @@ public class UsageSnapshotOnPrimaryVO implements InternalIdentity {
|
|||
+ ", snapshotType=" + snapshotType + ", physicalSize=" + physicalSize + ", created=" + created + ", deleted=" + deleted + ", virtualSize=" + virtualSize + ", vmSnapshotId=" + vmSnapshotId + "]";
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
|
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
@Table(name = "usage_storage")
|
||||
public class UsageStorageVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
||||
|
|
@ -39,8 +47,8 @@ public class UsageStorageVO implements InternalIdentity {
|
|||
@Column(name = "domain_id")
|
||||
private long domainId;
|
||||
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
@Column(name = "entity_id")
|
||||
private long entityId;
|
||||
|
||||
@Column(name = "storage_type")
|
||||
private int storageType;
|
||||
|
|
@ -69,7 +77,7 @@ public class UsageStorageVO implements InternalIdentity {
|
|||
this.zoneId = zoneId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.id = id;
|
||||
this.entityId = id;
|
||||
this.storageType = storageType;
|
||||
this.sourceId = sourceId;
|
||||
this.size = size;
|
||||
|
|
@ -81,7 +89,7 @@ public class UsageStorageVO implements InternalIdentity {
|
|||
this.zoneId = zoneId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.id = id;
|
||||
this.entityId = id;
|
||||
this.storageType = storageType;
|
||||
this.sourceId = sourceId;
|
||||
this.size = size;
|
||||
|
|
@ -134,4 +142,8 @@ public class UsageStorageVO implements InternalIdentity {
|
|||
public void setDeleted(Date deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public long getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,27 @@
|
|||
// under the License.
|
||||
package com.cloud.usage;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@Table(name = "usage_vm_instance")
|
||||
public class UsageVMInstanceVO {
|
||||
public class UsageVMInstanceVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "usage_type")
|
||||
private int usageType;
|
||||
|
|
@ -178,4 +188,9 @@ public class UsageVMInstanceVO {
|
|||
public void setCpuSpeed(Long cpuSpeed) {
|
||||
this.cpuSpeed = cpuSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
|
@ -30,9 +33,13 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
@Table(name = "usage_vmsnapshot")
|
||||
public class UsageVMSnapshotVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
// volumeId
|
||||
private long id;
|
||||
private Long id;
|
||||
|
||||
@Column(name = "volume_id")
|
||||
private long volumeId;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
|
@ -71,7 +78,7 @@ public class UsageVMSnapshotVO implements InternalIdentity {
|
|||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.diskOfferingId = diskOfferingId;
|
||||
this.id = id;
|
||||
this.volumeId = id;
|
||||
this.size = size;
|
||||
this.created = created;
|
||||
this.vmId = vmId;
|
||||
|
|
@ -131,6 +138,10 @@ public class UsageVMSnapshotVO implements InternalIdentity {
|
|||
this.vmSnapshotId = vmSnapshotId;
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UsageVMSnapshotVO [id=" + id + ", zoneId=" + zoneId + ", accountId=" + accountId + ", domainId=" + domainId + ", vmId=" + vmId + ", diskOfferingId="
|
||||
|
|
|
|||
|
|
@ -16,17 +16,27 @@
|
|||
// under the License.
|
||||
package com.cloud.usage;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@Table(name = "usage_vpn_user")
|
||||
public class UsageVPNUserVO {
|
||||
public class UsageVPNUserVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
|
@ -103,4 +113,9 @@ public class UsageVPNUserVO {
|
|||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
|
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
|
|||
@Table(name = "usage_volume")
|
||||
public class UsageVolumeVO implements InternalIdentity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private long zoneId;
|
||||
|
||||
|
|
@ -39,8 +47,8 @@ public class UsageVolumeVO implements InternalIdentity {
|
|||
@Column(name = "domain_id")
|
||||
private long domainId;
|
||||
|
||||
@Column(name = "id")
|
||||
private long id;
|
||||
@Column(name = "volume_id")
|
||||
private long volumeId;
|
||||
|
||||
@Column(name = "disk_offering_id")
|
||||
private Long diskOfferingId;
|
||||
|
|
@ -63,7 +71,7 @@ public class UsageVolumeVO implements InternalIdentity {
|
|||
}
|
||||
|
||||
public UsageVolumeVO(long id, long zoneId, long accountId, long domainId, Long diskOfferingId, Long templateId, long size, Date created, Date deleted) {
|
||||
this.id = id;
|
||||
this.volumeId = id;
|
||||
this.zoneId = zoneId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
|
|
@ -114,4 +122,8 @@ public class UsageVolumeVO implements InternalIdentity {
|
|||
public void setDeleted(Date deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ public class UsageIPAddressDaoImpl extends GenericDaoBase<UsageIPAddressVO, Long
|
|||
|
||||
protected static final String UPDATE_RELEASED = "UPDATE usage_ip_address SET released = ? WHERE account_id = ? AND public_ip_address = ? and released IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT =
|
||||
"SELECT id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released " + "FROM usage_ip_address "
|
||||
"SELECT ip_id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released " + "FROM usage_ip_address "
|
||||
+ "WHERE account_id = ? AND ((released IS NULL AND assigned <= ?) OR (assigned BETWEEN ? AND ?) OR "
|
||||
+ " (released BETWEEN ? AND ?) OR ((assigned <= ?) AND (released >= ?)))";
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN =
|
||||
"SELECT id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released " + "FROM usage_ip_address "
|
||||
"SELECT ip_id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released " + "FROM usage_ip_address "
|
||||
+ "WHERE domain_id = ? AND ((released IS NULL AND assigned <= ?) OR (assigned BETWEEN ? AND ?) OR "
|
||||
+ " (released BETWEEN ? AND ?) OR ((assigned <= ?) AND (released >= ?)))";
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released "
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT ip_id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released "
|
||||
+ "FROM usage_ip_address " + "WHERE (released IS NULL AND assigned <= ?) OR (assigned BETWEEN ? AND ?) OR "
|
||||
+ " (released BETWEEN ? AND ?) OR ((assigned <= ?) AND (released >= ?))";
|
||||
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ import com.cloud.utils.db.TransactionLegacy;
|
|||
public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBalancerPolicyVO, Long> implements UsageLoadBalancerPolicyDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UsageLoadBalancerPolicyDaoImpl.class.getName());
|
||||
|
||||
protected static final String REMOVE_BY_USERID_LBID = "DELETE FROM usage_load_balancer_policy WHERE account_id = ? AND id = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_load_balancer_policy SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
|
||||
protected static final String REMOVE_BY_USERID_LBID = "DELETE FROM usage_load_balancer_policy WHERE account_id = ? AND lb_id = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_load_balancer_policy SET deleted = ? WHERE account_id = ? AND lb_id = ? and deleted IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT lb_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
|
||||
+ "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT lb_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
|
||||
+ "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT lb_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
|
||||
+ "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
|
||||
|
||||
public UsageLoadBalancerPolicyDaoImpl() {
|
||||
|
|
@ -80,7 +80,7 @@ public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBala
|
|||
if (pstmt != null) {
|
||||
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
|
||||
pstmt.setLong(2, usage.getAccountId());
|
||||
pstmt.setLong(3, usage.getId());
|
||||
pstmt.setLong(3, usage.getLbId());
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}catch (SQLException e) {
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ import com.cloud.utils.db.TransactionLegacy;
|
|||
public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForwardingRuleVO, Long> implements UsagePortForwardingRuleDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UsagePortForwardingRuleDaoImpl.class.getName());
|
||||
|
||||
protected static final String REMOVE_BY_USERID_PFID = "DELETE FROM usage_port_forwarding WHERE account_id = ? AND id = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_port_forwarding SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
|
||||
protected static final String REMOVE_BY_USERID_PFID = "DELETE FROM usage_port_forwarding WHERE account_id = ? AND pf_id = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_port_forwarding SET deleted = ? WHERE account_id = ? AND pf_id = ? and deleted IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT pf_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
|
||||
+ "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT pf_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
|
||||
+ "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT pf_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
|
||||
+ "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
|
||||
|
||||
public UsagePortForwardingRuleDaoImpl() {
|
||||
|
|
@ -80,7 +80,7 @@ public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForw
|
|||
if (pstmt != null) {
|
||||
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
|
||||
pstmt.setLong(2, usage.getAccountId());
|
||||
pstmt.setLong(3, usage.getId());
|
||||
pstmt.setLong(3, usage.getPfId());
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}catch (SQLException e) {
|
||||
|
|
|
|||
|
|
@ -40,15 +40,15 @@ import com.cloud.utils.db.TransactionLegacy;
|
|||
public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> implements UsageStorageDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UsageStorageDaoImpl.class.getName());
|
||||
|
||||
protected static final String REMOVE_BY_USERID_STORAGEID = "DELETE FROM usage_storage WHERE account_id = ? AND id = ? AND storage_type = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
|
||||
protected static final String REMOVE_BY_USERID_STORAGEID = "DELETE FROM usage_storage WHERE account_id = ? AND entity_id = ? AND storage_type = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND entity_id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT =
|
||||
"SELECT id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
|
||||
"SELECT entity_id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
|
||||
+ "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN =
|
||||
"SELECT id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
|
||||
"SELECT entity_id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
|
||||
+ "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size "
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT entity_id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size "
|
||||
+ "FROM usage_storage " + "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
|
||||
|
||||
private final SearchBuilder<UsageStorageVO> IdSearch;
|
||||
|
|
@ -57,13 +57,13 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> im
|
|||
public UsageStorageDaoImpl() {
|
||||
IdSearch = createSearchBuilder();
|
||||
IdSearch.and("accountId", IdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
IdSearch.and("id", IdSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
IdSearch.and("id", IdSearch.entity().getEntityId(), SearchCriteria.Op.EQ);
|
||||
IdSearch.and("type", IdSearch.entity().getStorageType(), SearchCriteria.Op.EQ);
|
||||
IdSearch.done();
|
||||
|
||||
IdZoneSearch = createSearchBuilder();
|
||||
IdZoneSearch.and("accountId", IdZoneSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
IdZoneSearch.and("id", IdZoneSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
IdZoneSearch.and("id", IdZoneSearch.entity().getEntityId(), SearchCriteria.Op.EQ);
|
||||
IdZoneSearch.and("type", IdZoneSearch.entity().getStorageType(), SearchCriteria.Op.EQ);
|
||||
IdZoneSearch.and("dcId", IdZoneSearch.entity().getZoneId(), SearchCriteria.Op.EQ);
|
||||
IdZoneSearch.and("deleted", IdZoneSearch.entity().getDeleted(), SearchCriteria.Op.NULL);
|
||||
|
|
@ -124,7 +124,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> im
|
|||
if (pstmt != null) {
|
||||
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
|
||||
pstmt.setLong(2, usage.getAccountId());
|
||||
pstmt.setLong(3, usage.getId());
|
||||
pstmt.setLong(3, usage.getEntityId());
|
||||
pstmt.setInt(4, usage.getStorageType());
|
||||
pstmt.setLong(5, usage.getZoneId());
|
||||
pstmt.executeUpdate();
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ import com.cloud.utils.db.TransactionLegacy;
|
|||
@Component
|
||||
public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Long> implements UsageVMSnapshotDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UsageVMSnapshotDaoImpl.class.getName());
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, vm_id, disk_offering_id, size, created, processed, vm_snapshot_id "
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, vm_id, disk_offering_id, size, created, processed, vm_snapshot_id "
|
||||
+ " FROM usage_vmsnapshot" + " WHERE account_id = ? " + " AND ( (created BETWEEN ? AND ?) OR "
|
||||
+ " (created < ? AND processed is NULL) ) ORDER BY created asc";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_vmsnapshot SET processed = ? WHERE account_id = ? AND id = ? and vm_id = ? and created = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_vmsnapshot SET processed = ? WHERE account_id = ? AND volume_id = ? and vm_id = ? and created = ?";
|
||||
|
||||
protected static final String PREVIOUS_QUERY = "SELECT id, zone_id, account_id, domain_id, vm_id, disk_offering_id,size, created, processed, vm_snapshot_id "
|
||||
+ "FROM usage_vmsnapshot " + "WHERE account_id = ? AND id = ? AND vm_id = ? AND created < ? AND processed IS NULL " + "ORDER BY created desc limit 1";
|
||||
protected static final String PREVIOUS_QUERY = "SELECT volume_id, zone_id, account_id, domain_id, vm_id, disk_offering_id,size, created, processed, vm_snapshot_id "
|
||||
+ "FROM usage_vmsnapshot " + "WHERE account_id = ? AND volume_id = ? AND vm_id = ? AND created < ? AND processed IS NULL " + "ORDER BY created desc limit 1";
|
||||
|
||||
@Override
|
||||
public void update(UsageVMSnapshotVO usage) {
|
||||
|
|
@ -54,7 +54,7 @@ public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Lo
|
|||
pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
|
||||
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getProcessed()));
|
||||
pstmt.setLong(2, usage.getAccountId());
|
||||
pstmt.setLong(3, usage.getId());
|
||||
pstmt.setLong(3, usage.getVolumeId());
|
||||
pstmt.setLong(4, usage.getVmId());
|
||||
pstmt.setString(5, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getCreated()));
|
||||
pstmt.executeUpdate();
|
||||
|
|
@ -134,7 +134,7 @@ public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Lo
|
|||
int i = 1;
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
pstmt.setLong(i++, rec.getAccountId());
|
||||
pstmt.setLong(i++, rec.getId());
|
||||
pstmt.setLong(i++, rec.getVolumeId());
|
||||
pstmt.setLong(i++, rec.getVmId());
|
||||
pstmt.setString(i++, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), rec.getCreated()));
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ import com.cloud.utils.db.TransactionLegacy;
|
|||
@Component
|
||||
public class UsageVMSnapshotOnPrimaryDaoImpl extends GenericDaoBase<UsageSnapshotOnPrimaryVO, Long> implements UsageVMSnapshotOnPrimaryDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UsageVMSnapshotOnPrimaryDaoImpl.class.getName());
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, vm_id, name, type, physicalsize, virtualsize, created, deleted, vm_snapshot_id "
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, vm_id, name, type, physicalsize, virtualsize, created, deleted, vm_snapshot_id "
|
||||
+ " FROM usage_snapshot_on_primary" + " WHERE account_id = ? " + " AND ( (created < ? AND deleted is NULL)"
|
||||
+ " OR ( deleted BETWEEN ? AND ?)) ORDER BY created asc";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_snapshot_on_primary SET deleted = ? WHERE account_id = ? AND id = ? and vm_id = ? and created = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_snapshot_on_primary SET deleted = ? WHERE account_id = ? AND volume_id = ? and vm_id = ? and created = ?";
|
||||
|
||||
@Override
|
||||
public void updateDeleted(UsageSnapshotOnPrimaryVO usage) {
|
||||
|
|
@ -51,7 +51,7 @@ public class UsageVMSnapshotOnPrimaryDaoImpl extends GenericDaoBase<UsageSnapsho
|
|||
pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
|
||||
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
|
||||
pstmt.setLong(2, usage.getAccountId());
|
||||
pstmt.setLong(3, usage.getId());
|
||||
pstmt.setLong(3, usage.getVolumeId());
|
||||
pstmt.setLong(4, usage.getVmId());
|
||||
pstmt.setString(5, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getCreated()));
|
||||
pstmt.executeUpdate();
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@ import com.cloud.utils.db.TransactionLegacy;
|
|||
public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> implements UsageVolumeDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UsageVolumeDaoImpl.class.getName());
|
||||
|
||||
protected static final String REMOVE_BY_USERID_VOLID = "DELETE FROM usage_volume WHERE account_id = ? AND id = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_volume SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
|
||||
protected static final String REMOVE_BY_USERID_VOLID = "DELETE FROM usage_volume WHERE account_id = ? AND volume_id = ?";
|
||||
protected static final String UPDATE_DELETED = "UPDATE usage_volume SET deleted = ? WHERE account_id = ? AND volume_id = ? and deleted IS NULL";
|
||||
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
|
||||
+ "FROM usage_volume " + "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR "
|
||||
+ " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
|
||||
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
|
||||
+ "FROM usage_volume " + "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR "
|
||||
+ " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
|
||||
protected static final String GET_ALL_USAGE_RECORDS = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
|
||||
+ "FROM usage_volume " + "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
|
||||
|
||||
public UsageVolumeDaoImpl() {
|
||||
|
|
@ -85,7 +85,7 @@ public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> impl
|
|||
pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
|
||||
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
|
||||
pstmt.setLong(2, usage.getAccountId());
|
||||
pstmt.setLong(3, usage.getId());
|
||||
pstmt.setLong(3, usage.getVolumeId());
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
txn.commit();
|
||||
|
|
|
|||
|
|
@ -16,10 +16,14 @@
|
|||
// under the License.
|
||||
package com.cloud.user;
|
||||
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
|
|
@ -27,8 +31,12 @@ import javax.persistence.TemporalType;
|
|||
|
||||
@Entity
|
||||
@Table(name = "op_user_stats_log")
|
||||
public class UserStatsLogVO {
|
||||
public class UserStatsLogVO implements InternalIdentity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "user_stats_id")
|
||||
private long userStatsId;
|
||||
|
||||
|
|
@ -129,4 +137,8 @@ public class UserStatsLogVO {
|
|||
this.updatedTime = updatedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class UsageStorageDaoImplTest {
|
|||
|
||||
long id = 21, zoneId = 31, accountId = 41;
|
||||
int storageType = 1;
|
||||
String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
|
||||
String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND entity_id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
|
||||
Date deleted = new Date();
|
||||
|
||||
PowerMockito.mockStatic(TransactionLegacy.class);
|
||||
|
|
@ -68,7 +68,7 @@ public class UsageStorageDaoImplTest {
|
|||
|
||||
when(transactionMock.prepareStatement(contains(UPDATE_DELETED))).thenReturn(preparedStatementMock);
|
||||
when(userStorageVOMock.getAccountId()).thenReturn(accountId);
|
||||
when(userStorageVOMock.getId()).thenReturn(id);
|
||||
when(userStorageVOMock.getEntityId()).thenReturn(id);
|
||||
when(userStorageVOMock.getStorageType()).thenReturn(storageType);
|
||||
when(userStorageVOMock.getZoneId()).thenReturn(zoneId);
|
||||
when(userStorageVOMock.getDeleted()).thenReturn(deleted);
|
||||
|
|
|
|||
Loading…
Reference in New Issue