Daniel Erez has uploaded a new change for review.

Change subject: core: DiskConditionField - extract verbs to constants
......................................................................

core: DiskConditionField - extract verbs to constants

DiskConditionFieldAutoCompleter:
extract verbs to constants - needed for column sorting support in the UI.

Change-Id: I7d0aa6d38799e7e922d4f5ddf5fca56c76598136
Signed-off-by: Daniel Erez <de...@redhat.com>
---
M 
backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/DiskConditionFieldAutoCompleter.java
1 file changed, 66 insertions(+), 51 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/74/29374/1

diff --git 
a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/DiskConditionFieldAutoCompleter.java
 
b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/DiskConditionFieldAutoCompleter.java
index bd68aaa..ccab731 100644
--- 
a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/DiskConditionFieldAutoCompleter.java
+++ 
b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/DiskConditionFieldAutoCompleter.java
@@ -10,57 +10,72 @@
 import org.ovirt.engine.core.compat.StringHelper;
 
 public class DiskConditionFieldAutoCompleter extends 
BaseConditionFieldAutoCompleter {
+    public static final String ALIAS = "ALIAS";
+    public static final String DESCRIPTION = "DESCRIPTION";
+    public static final String PROVISIONED_SIZE = "PROVISIONED_SIZE";
+    public static final String SIZE = "SIZE";
+    public static final String ACTUAL_SIZE = "ACTUAL_SIZE";
+    public static final String CREATION_DATE = "CREATION_DATE";
+    public static final String BOOTABLE = "BOOTABLE";
+    public static final String SHAREABLE = "SHAREABLE";
+    public static final String STATUS = "STATUS";
+    public static final String DISK_TYPE = "DISK_TYPE";
+    public static final String NUMBER_OF_VMS = "NUMBER_OF_VMS";
+    public static final String VM_NAMES = "VM_NAMES";
+    public static final String QUOTA = "QUOTA";
+    public static final String ID = "ID";
+
     public DiskConditionFieldAutoCompleter() {
         // Building the basic verbs set.
-        mVerbs.add("ALIAS");
-        mVerbs.add("DESCRIPTION");
-        mVerbs.add("PROVISIONED_SIZE");
-        mVerbs.add("SIZE");
-        mVerbs.add("ACTUAL_SIZE");
-        mVerbs.add("CREATION_DATE");
-        mVerbs.add("BOOTABLE");
-        mVerbs.add("SHAREABLE");
-        mVerbs.add("STATUS");
-        mVerbs.add("DISK_TYPE");
-        mVerbs.add("NUMBER_OF_VMS");
-        mVerbs.add("VM_NAMES");
-        mVerbs.add("QUOTA");
-        mVerbs.add("ID");
+        mVerbs.add(ALIAS);
+        mVerbs.add(DESCRIPTION);
+        mVerbs.add(PROVISIONED_SIZE);
+        mVerbs.add(SIZE);
+        mVerbs.add(ACTUAL_SIZE);
+        mVerbs.add(CREATION_DATE);
+        mVerbs.add(BOOTABLE);
+        mVerbs.add(SHAREABLE);
+        mVerbs.add(STATUS);
+        mVerbs.add(DISK_TYPE);
+        mVerbs.add(NUMBER_OF_VMS);
+        mVerbs.add(VM_NAMES);
+        mVerbs.add(QUOTA);
+        mVerbs.add(ID);
 
         // Building the autoCompletion dict.
         buildCompletions();
 
         // Building the types dict.
-        getTypeDictionary().put("ALIAS", String.class);
-        getTypeDictionary().put("DESCRIPTION", String.class);
-        getTypeDictionary().put("PROVISIONED_SIZE", Long.class);
-        getTypeDictionary().put("SIZE", Long.class);
-        getTypeDictionary().put("ACTUAL_SIZE", Long.class);
-        getTypeDictionary().put("CREATION_DATE", Date.class);
-        getTypeDictionary().put("BOOTABLE", Boolean.class);
-        getTypeDictionary().put("SHAREABLE", Boolean.class);
-        getTypeDictionary().put("STATUS", ImageStatus.class);
-        getTypeDictionary().put("DISK_TYPE", DiskStorageType.class);
-        getTypeDictionary().put("NUMBER_OF_VMS", Integer.class);
-        getTypeDictionary().put("VM_NAMES", String.class);
-        getTypeDictionary().put("QUOTA", String.class);
-        getTypeDictionary().put("ID", UUID.class);
+        getTypeDictionary().put(ALIAS, String.class);
+        getTypeDictionary().put(DESCRIPTION, String.class);
+        getTypeDictionary().put(PROVISIONED_SIZE, Long.class);
+        getTypeDictionary().put(SIZE, Long.class);
+        getTypeDictionary().put(ACTUAL_SIZE, Long.class);
+        getTypeDictionary().put(CREATION_DATE, Date.class);
+        getTypeDictionary().put(BOOTABLE, Boolean.class);
+        getTypeDictionary().put(SHAREABLE, Boolean.class);
+        getTypeDictionary().put(STATUS, ImageStatus.class);
+        getTypeDictionary().put(DISK_TYPE, DiskStorageType.class);
+        getTypeDictionary().put(NUMBER_OF_VMS, Integer.class);
+        getTypeDictionary().put(VM_NAMES, String.class);
+        getTypeDictionary().put(QUOTA, String.class);
+        getTypeDictionary().put(ID, UUID.class);
 
         // building the ColumnName dict. - the name of the column in db
-        columnNameDict.put("ALIAS", "disk_alias");
-        columnNameDict.put("DESCRIPTION", "disk_description");
-        columnNameDict.put("PROVISIONED_SIZE", "size");
-        columnNameDict.put("SIZE", "size");
-        columnNameDict.put("ACTUAL_SIZE", "actual_size");
-        columnNameDict.put("CREATION_DATE", "creation_date");
-        columnNameDict.put("BOOTABLE", "boot");
-        columnNameDict.put("SHAREABLE", "shareable");
-        columnNameDict.put("STATUS", "imageStatus");
-        columnNameDict.put("DISK_TYPE", "disk_storage_type");
-        columnNameDict.put("NUMBER_OF_VMS", "number_of_vms");
-        columnNameDict.put("VM_NAMES", "vm_names");
-        columnNameDict.put("QUOTA", "quota_name");
-        columnNameDict.put("ID", "disk_id");
+        columnNameDict.put(ALIAS, "disk_alias");
+        columnNameDict.put(DESCRIPTION, "disk_description");
+        columnNameDict.put(PROVISIONED_SIZE, "size");
+        columnNameDict.put(SIZE, "size");
+        columnNameDict.put(ACTUAL_SIZE, "actual_size");
+        columnNameDict.put(CREATION_DATE, "creation_date");
+        columnNameDict.put(BOOTABLE, "boot");
+        columnNameDict.put(SHAREABLE, "shareable");
+        columnNameDict.put(STATUS, "imageStatus");
+        columnNameDict.put(DISK_TYPE, "disk_storage_type");
+        columnNameDict.put(NUMBER_OF_VMS, "number_of_vms");
+        columnNameDict.put(VM_NAMES, "vm_names");
+        columnNameDict.put(QUOTA, "quota_name");
+        columnNameDict.put(ID, "disk_id");
 
         // Building the validation dict.
         buildBasicValidationTable();
@@ -68,12 +83,12 @@
 
     @Override
     public IAutoCompleter getFieldRelationshipAutoCompleter(String fieldName) {
-        if ("CREATION_DATE".equals(fieldName) || "SIZE".equals(fieldName)
-                || "ACTUAL_SIZE".equals(fieldName)
-                || "PROVISIONED_SIZE".equals(fieldName)) {
+        if (CREATION_DATE.equals(fieldName) || SIZE.equals(fieldName)
+                || ACTUAL_SIZE.equals(fieldName)
+                || PROVISIONED_SIZE.equals(fieldName)) {
             return BiggerOrSmallerRelationAutoCompleter.INSTANCE;
         }
-        else if ("NUMBER_OF_VMS".equals(fieldName)) {
+        else if (NUMBER_OF_VMS.equals(fieldName)) {
             return NumericConditionRelationAutoCompleter.INSTANCE;
         } else {
             return StringConditionRelationAutoCompleter.INSTANCE;
@@ -82,12 +97,12 @@
 
     @Override
     public IConditionValueAutoCompleter getFieldValueAutoCompleter(String 
fieldName) {
-        if ("STATUS".equals(fieldName)) {
+        if (STATUS.equals(fieldName)) {
             return new EnumValueAutoCompleter(ImageStatus.class);
-        } else if ("DISK_TYPE".equals(fieldName)) {
+        } else if (DISK_TYPE.equals(fieldName)) {
             return new EnumValueAutoCompleter(DiskStorageType.class);
-        } else if ("BOOTABLE".equals(fieldName) ||
-                "SHAREABLE".equals(fieldName)) {
+        } else if (BOOTABLE.equals(fieldName) ||
+                SHAREABLE.equals(fieldName)) {
             return new BitValueAutoCompleter();
         }
         return null;
@@ -95,7 +110,7 @@
 
     @Override
     public void formatValue(String fieldName, Pair<String, String> pair, 
boolean caseSensitive) {
-        if ("CREATION_DATE".equals(fieldName)) {
+        if (CREATION_DATE.equals(fieldName)) {
             Date tmp = new Date(Date.parse(StringHelper.trim(pair.getSecond(), 
'\'')));
             pair.setSecond(StringFormat.format("'%1$s'", tmp));
         } else {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d0aa6d38799e7e922d4f5ddf5fca56c76598136
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <de...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to