|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package com.cloud.vm.snapshot; |
| 19 | + |
| 20 | +import java.util.Date; |
| 21 | +import java.util.UUID; |
| 22 | + |
| 23 | +import javax.persistence.Column; |
| 24 | +import javax.persistence.Entity; |
| 25 | +import javax.persistence.EnumType; |
| 26 | +import javax.persistence.Enumerated; |
| 27 | +import javax.persistence.GeneratedValue; |
| 28 | +import javax.persistence.GenerationType; |
| 29 | +import javax.persistence.Id; |
| 30 | +import javax.persistence.Table; |
| 31 | +import javax.persistence.TableGenerator; |
| 32 | +import javax.persistence.Temporal; |
| 33 | +import javax.persistence.TemporalType; |
| 34 | + |
| 35 | +import com.cloud.utils.db.GenericDao; |
| 36 | + |
| 37 | +@Entity |
| 38 | +@Table(name = "vm_snapshots") |
| 39 | +public class VMSnapshotVO implements VMSnapshot { |
| 40 | + @Id |
| 41 | + @TableGenerator(name = "vm_snapshots_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "vm_snapshots_seq", allocationSize = 1) |
| 42 | + @GeneratedValue(strategy = GenerationType.TABLE) |
| 43 | + @Column(name = "id") |
| 44 | + long id; |
| 45 | + |
| 46 | + @Column(name = "uuid") |
| 47 | + String uuid = UUID.randomUUID().toString(); |
| 48 | + |
| 49 | + @Column(name = "name") |
| 50 | + String name; |
| 51 | + |
| 52 | + @Column(name = "display_name") |
| 53 | + String displayName; |
| 54 | + |
| 55 | + @Column(name = "description") |
| 56 | + String description; |
| 57 | + |
| 58 | + @Column(name = "vm_id") |
| 59 | + long vmId; |
| 60 | + |
| 61 | + @Column(name = "account_id") |
| 62 | + long accountId; |
| 63 | + |
| 64 | + @Column(name = "domain_id") |
| 65 | + long domainId; |
| 66 | + |
| 67 | + @Column(name = "vm_snapshot_type") |
| 68 | + @Enumerated(EnumType.STRING) |
| 69 | + VMSnapshot.Type type; |
| 70 | + |
| 71 | + @Column(name = "state", updatable = true, nullable = false) |
| 72 | + @Enumerated(value = EnumType.STRING) |
| 73 | + private State state; |
| 74 | + |
| 75 | + @Column(name = GenericDao.CREATED_COLUMN) |
| 76 | + Date created; |
| 77 | + |
| 78 | + @Column(name = GenericDao.REMOVED_COLUMN) |
| 79 | + Date removed; |
| 80 | + |
| 81 | + @Column(name = "current") |
| 82 | + Boolean current; |
| 83 | + |
| 84 | + @Column(name = "parent") |
| 85 | + Long parent; |
| 86 | + |
| 87 | + @Column(name = "updated") |
| 88 | + @Temporal(value = TemporalType.TIMESTAMP) |
| 89 | + Date updated; |
| 90 | + |
| 91 | + @Column(name="update_count", updatable = true, nullable=false) |
| 92 | + protected long updatedCount; |
| 93 | + |
| 94 | + public Long getParent() { |
| 95 | + return parent; |
| 96 | + } |
| 97 | + |
| 98 | + public void setParent(Long parent) { |
| 99 | + this.parent = parent; |
| 100 | + } |
| 101 | + |
| 102 | + public VMSnapshotVO() { |
| 103 | + |
| 104 | + } |
| 105 | + |
| 106 | + public Date getRemoved() { |
| 107 | + return removed; |
| 108 | + } |
| 109 | + |
| 110 | + public VMSnapshotVO(Long accountId, Long domainId, Long vmId, |
| 111 | + String description, String vmSnapshotName, String vsDisplayName, |
| 112 | + Long serviceOfferingId, Type type, Boolean current) { |
| 113 | + this.accountId = accountId; |
| 114 | + this.domainId = domainId; |
| 115 | + this.vmId = vmId; |
| 116 | + this.state = State.Allocated; |
| 117 | + this.description = description; |
| 118 | + this.name = vmSnapshotName; |
| 119 | + this.displayName = vsDisplayName; |
| 120 | + this.type = type; |
| 121 | + this.current = current; |
| 122 | + } |
| 123 | + |
| 124 | + public String getDescription() { |
| 125 | + return description; |
| 126 | + } |
| 127 | + |
| 128 | + @Override |
| 129 | + public Date getCreated() { |
| 130 | + return created; |
| 131 | + } |
| 132 | + |
| 133 | + public void setCreated(Date created) { |
| 134 | + this.created = created; |
| 135 | + } |
| 136 | + |
| 137 | + @Override |
| 138 | + public long getId() { |
| 139 | + return id; |
| 140 | + } |
| 141 | + |
| 142 | + @Override |
| 143 | + public Long getVmId() { |
| 144 | + return vmId; |
| 145 | + } |
| 146 | + |
| 147 | + public void setVmId(Long vmId) { |
| 148 | + this.vmId = vmId; |
| 149 | + } |
| 150 | + |
| 151 | + @Override |
| 152 | + public String getName() { |
| 153 | + return name; |
| 154 | + } |
| 155 | + |
| 156 | + public void setName(String name) { |
| 157 | + this.name = name; |
| 158 | + } |
| 159 | + |
| 160 | + @Override |
| 161 | + public State getState() { |
| 162 | + return state; |
| 163 | + } |
| 164 | + |
| 165 | + public void setState(State state) { |
| 166 | + this.state = state; |
| 167 | + } |
| 168 | + |
| 169 | + @Override |
| 170 | + public String getUuid() { |
| 171 | + return uuid; |
| 172 | + } |
| 173 | + |
| 174 | + @Override |
| 175 | + public long getAccountId() { |
| 176 | + return accountId; |
| 177 | + } |
| 178 | + |
| 179 | + @Override |
| 180 | + public long getDomainId() { |
| 181 | + return domainId; |
| 182 | + } |
| 183 | + |
| 184 | + @Override |
| 185 | + public String getDisplayName() { |
| 186 | + return displayName; |
| 187 | + } |
| 188 | + |
| 189 | + public void setDisplayName(String displayName) { |
| 190 | + this.displayName = displayName; |
| 191 | + } |
| 192 | + |
| 193 | + public Boolean getCurrent() { |
| 194 | + return current; |
| 195 | + } |
| 196 | + |
| 197 | + public void setCurrent(Boolean current) { |
| 198 | + this.current = current; |
| 199 | + } |
| 200 | + |
| 201 | + @Override |
| 202 | + public long getUpdatedCount() { |
| 203 | + return updatedCount; |
| 204 | + } |
| 205 | + |
| 206 | + @Override |
| 207 | + public void incrUpdatedCount() { |
| 208 | + this.updatedCount++; |
| 209 | + } |
| 210 | + |
| 211 | + @Override |
| 212 | + public Date getUpdated() { |
| 213 | + return updated; |
| 214 | + } |
| 215 | + |
| 216 | + @Override |
| 217 | + public Type getType() { |
| 218 | + return type; |
| 219 | + } |
| 220 | + |
| 221 | + public void setRemoved(Date removed) { |
| 222 | + this.removed = removed; |
| 223 | + } |
| 224 | +} |
0 commit comments