Gilad Chaplik has uploaded a new change for review.

Change subject: common: Introduce profiles package & Disk Profile
......................................................................

common: Introduce profiles package & Disk Profile

- Introduce ProfileBase abstract class
- Introduce ProfileType
- Introduce DiskProfile (implements ProfileBase)

For more information see http://www.ovirt.org/Features/aggregate_QoS

Change-Id: I1a9af22277b50554531511002f19046c0051d8ff
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitiesDefinitions.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/DiskProfile.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileBase.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileType.java
M 
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
5 files changed, 247 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/31807/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitiesDefinitions.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitiesDefinitions.java
index ff6d14d..1902702 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitiesDefinitions.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitiesDefinitions.java
@@ -44,6 +44,9 @@
     public static final String BOND_NAME_PREFIX = "bond";
     public static final String BOND_NAME_PATTERN = "^" + BOND_NAME_PREFIX + 
"\\d+$";
 
+    // Profiles
+    public static final int PROFILE_NAME_SIZE = 50;
+
     // Bookmark (bookmarks)
     public static final int BOOKMARK_NAME_SIZE = 40;
     public static final int BOOKMARK_VALUE_SIZE = 300;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/DiskProfile.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/DiskProfile.java
new file mode 100644
index 0000000..769a08f
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/DiskProfile.java
@@ -0,0 +1,59 @@
+package org.ovirt.engine.core.common.businessentities.profiles;
+
+import java.io.Serializable;
+
+import javax.validation.constraints.NotNull;
+
+import org.ovirt.engine.core.common.validation.group.CreateEntity;
+import org.ovirt.engine.core.common.validation.group.UpdateEntity;
+import org.ovirt.engine.core.compat.Guid;
+
+public class DiskProfile extends ProfileBase implements Serializable {
+    private static final long serialVersionUID = -7873671967250939737L;
+
+    @NotNull(groups = { CreateEntity.class, UpdateEntity.class })
+    private Guid storageDomainId;
+
+    public DiskProfile() {
+        super(ProfileType.DISK);
+    }
+
+    public Guid getStorageDomainId() {
+        return storageDomainId;
+    }
+
+    public void setStorageDomainId(Guid storageDomainId) {
+        this.storageDomainId = storageDomainId;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((storageDomainId == null) ? 0 : 
storageDomainId.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        DiskProfile other = (DiskProfile) obj;
+        if (storageDomainId == null) {
+            if (other.storageDomainId != null)
+                return false;
+        } else if (!storageDomainId.equals(other.storageDomainId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + ", storage domain id=" + 
getStorageDomainId() + "}";
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileBase.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileBase.java
new file mode 100644
index 0000000..24870a8
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileBase.java
@@ -0,0 +1,148 @@
+package org.ovirt.engine.core.common.businessentities.profiles;
+
+import java.io.Serializable;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import 
org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions;
+import org.ovirt.engine.core.common.businessentities.BusinessEntity;
+import org.ovirt.engine.core.common.businessentities.IVdcQueryable;
+import org.ovirt.engine.core.common.businessentities.Nameable;
+import org.ovirt.engine.core.common.validation.annotation.ValidName;
+import org.ovirt.engine.core.common.validation.group.CreateEntity;
+import org.ovirt.engine.core.common.validation.group.RemoveEntity;
+import org.ovirt.engine.core.common.validation.group.UpdateEntity;
+import org.ovirt.engine.core.compat.Guid;
+
+public abstract class ProfileBase extends IVdcQueryable implements 
BusinessEntity<Guid>, Nameable, Serializable {
+    private static final long serialVersionUID = 1055016330475623255L;
+
+    @NotNull(groups = { UpdateEntity.class, RemoveEntity.class })
+    private Guid id;
+    @Size(min = 1, max = BusinessEntitiesDefinitions.PROFILE_NAME_SIZE, groups 
= { CreateEntity.class,
+            UpdateEntity.class })
+    @ValidName(message = "VALIDATION_NAME_INVALID", groups = { 
CreateEntity.class, UpdateEntity.class })
+    private String name;
+    private Guid qosId;
+    private String description;
+    private ProfileType profileType;
+
+    @SuppressWarnings("unused")
+    private ProfileBase() {
+    }
+
+    public ProfileBase(ProfileType profileType) {
+        this.setProfileType(profileType);
+    }
+
+    @Override
+    public Guid getId() {
+        return id;
+    }
+
+    @Override
+    public void setId(Guid id) {
+        this.id = id;
+    }
+
+    public ProfileType getProfileType() {
+        return profileType;
+    }
+
+    private void setProfileType(ProfileType profileType) {
+        this.profileType = profileType;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Guid getQosId() {
+        return qosId;
+    }
+
+    public void setQosId(Guid qosId) {
+        this.qosId = qosId;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public Object getQueryableId() {
+        return getId();
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 31;
+        result = prime * result + ((description == null) ? 0 : 
description.hashCode());
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((profileType == null) ? 0 : 
profileType.hashCode());
+        result = prime * result + ((qosId == null) ? 0 : qosId.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ProfileBase other = (ProfileBase) obj;
+        if (description == null) {
+            if (other.description != null)
+                return false;
+        } else if (!description.equals(other.description))
+            return false;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (profileType != other.profileType)
+            return false;
+        if (qosId == null) {
+            if (other.qosId != null)
+                return false;
+        } else if (!qosId.equals(other.qosId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append(getName())
+                .append(" {id=")
+                .append(getId())
+                .append(", description=")
+                .append(getDescription())
+                .append(", profile type=")
+                .append(getProfileType().name())
+                .append(", qosId=")
+                .append(getQosId());
+        return builder.toString();
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileType.java
new file mode 100644
index 0000000..f207049
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/profiles/ProfileType.java
@@ -0,0 +1,32 @@
+package org.ovirt.engine.core.common.businessentities.profiles;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ovirt.engine.core.common.businessentities.Identifiable;
+
+public enum ProfileType implements Identifiable {
+    DISK(1);
+
+    private final int value;
+    private static final Map<Integer, ProfileType> valueToStatus = new 
HashMap<Integer, ProfileType>();
+
+    static {
+        for (ProfileType status : values()) {
+            valueToStatus.put(status.getValue(), status);
+        }
+    }
+
+    private ProfileType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static ProfileType forValue(int value) {
+        return valueToStatus.get(value);
+    }
+}
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
index 3f176fd..40ac0f3 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
@@ -195,6 +195,11 @@
         <include name="common/businessentities/VmRngDevice.java" />
                <include name="common/job/*.java" />
 
+               <!-- Profiles -->
+               <include 
name="common/businessentities/profiles/DiskProfile.java" />
+               <include 
name="common/businessentities/profiles/ProfileBase.java" />
+               <include 
name="common/businessentities/profiles/ProfileType.java" />
+
                <!-- Quota -->
                <include name="common/businessentities/Quota.java"/>
                <include 
name="common/businessentities/QuotaEnforcementTypeEnum.java"/>


-- 
To view, visit http://gerrit.ovirt.org/31807
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a9af22277b50554531511002f19046c0051d8ff
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to