Lior Vernia has uploaded a new change for review. Change subject: webadmin: Pass map instead of strings to KeyValueModel ......................................................................
webadmin: Pass map instead of strings to KeyValueModel Instead of converting to and from strings, try to keep the data as a map. Change-Id: Ic57b3157960e829d43073c1614647b25a3b6a139 Signed-off-by: Lior Vernia <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/NewClusterPolicyModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java 8 files changed, 21 insertions(+), 50 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/86/27386/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java index 607a1d1..2b50eda 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/customprop/VmPropertiesUtils.java @@ -121,12 +121,8 @@ return map; } - public Map<Version, String> getAllVmProperties() { - Map<Version, String> allVmPropertiesString = new HashMap<Version, String>(); - for (Map.Entry<Version, Map<String, String>> entry : allVmProperties.entrySet()) { - allVmPropertiesString.put(entry.getKey(), convertProperties(entry.getValue())); - } - return allVmPropertiesString; + public Map<Version, Map<String, String>> getAllVmProperties() { + return allVmProperties; } private void getPredefinedProperties(Version version, VmStatic vmStatic, Map<String, String> propertiesMap) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index 076a9b7..1e4f916 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -215,7 +215,7 @@ private static Map<ArchitectureType, Map<Version, Boolean>> suspendSupport; // cached custom properties - private static Map<Version, List<String>> customPropertiesList; + private static Map<Version, Map<String, String>> customPropertiesList; public static String getDefaultConfigurationVersion() { return _defaultConfigurationVersion; @@ -269,31 +269,15 @@ callback.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object returnValue) { - customPropertiesList = (Map<Version, List<String>>) returnValue; + customPropertiesList = (Map<Version, Map<String, String>>) returnValue; } }; callback.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery _asyncQuery) { - Map<Version, String> map = - source != null ? (HashMap<Version, String>) source : new HashMap<Version, String>(); - Map<Version, ArrayList<String>> retMap = new HashMap<Version, ArrayList<String>>(); - - for (Map.Entry<Version, String> keyValuePair : map.entrySet()) { - String[] split = keyValuePair.getValue().split("[;]", -1); //$NON-NLS-1$ - if (split.length == 1 && (split[0] == null || split[0].isEmpty())) { - retMap.put(keyValuePair.getKey(), - null); - } else { - retMap.put(keyValuePair.getKey(), - new ArrayList<String>()); - for (String s : split) { - retMap.get(keyValuePair.getKey()).add(s); - } - } - } - return retMap; + return (source != null) ? (Map<Version, Map<String, String>>) source + : new HashMap<Version, Map<String, String>>(); } @@ -1699,7 +1683,7 @@ aQuery); } - public static Map<Version, List<String>> getCustomPropertiesList() { + public static Map<Version, Map<String, String>> getCustomPropertiesList() { return customPropertiesList; } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java index aa2960c..33eb8de 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java @@ -1518,7 +1518,7 @@ private void clusterPolicyChanged() { ClusterPolicy clusterPolicy = getClusterPolicy().getSelectedItem(); - ArrayList<String> lines = new ArrayList<String>(); + Map<String, String> policyProperties = new HashMap<String, String>(); Map<Guid, PolicyUnit> allPolicyUnits = new HashMap<Guid, PolicyUnit>(); if (clusterPolicy.getFilters() != null) { for (Guid policyUnitId : clusterPolicy.getFilters()) { @@ -1536,12 +1536,10 @@ for (PolicyUnit policyUnit : allPolicyUnits.values()) { if (policyUnit.getParameterRegExMap() != null) { - for (Map.Entry<String, String> keyValue : policyUnit.getParameterRegExMap().entrySet()) { - lines.add(keyValue.getKey() + '=' + keyValue.getValue()); - } + policyProperties.putAll(policyUnit.getParameterRegExMap()); } } - getCustomPropertySheet().setKeyValueString(lines); + getCustomPropertySheet().setKeyValueMap(policyProperties); if (getIsEdit() && clusterPolicy.getId().equals(getEntity().getClusterPolicyId())) { getCustomPropertySheet().deserialize(KeyValueModel.convertProperties(getEntity().getClusterPolicyProperties())); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/NewClusterPolicyModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/NewClusterPolicyModel.java index aae3274..d7b2d1e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/NewClusterPolicyModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/scheduling/NewClusterPolicyModel.java @@ -83,7 +83,7 @@ if (!customPropertiesInitialized) { return; } - ArrayList<String> lines = new ArrayList<String>(); + Map<String, String> policyProperties = new HashMap<String, String>(); Map<Guid, PolicyUnit> allPolicyUnits = new HashMap<Guid, PolicyUnit>(); for (PolicyUnit policyUnit : getUsedFilters()) { allPolicyUnits.put(policyUnit.getId(), policyUnit); @@ -103,16 +103,14 @@ allPolicyUnits.put(selectedItem.getId(), selectedItem); for (PolicyUnit policyUnit : allPolicyUnits.values()) { if (policyUnit.getParameterRegExMap() != null) { - for (Map.Entry<String, String> keyValue : policyUnit.getParameterRegExMap().entrySet()) { - lines.add(keyValue.getKey() + '=' + keyValue.getValue()); - } + policyProperties.putAll(policyUnit.getParameterRegExMap()); } } Map<String, String> defaultMap = new HashMap<String, String>(getCustomProperties()); if(!reset) { defaultMap.putAll(KeyValueModel.convertProperties(getCustomPropertySheet().serialize())); } - getCustomPropertySheet().setKeyValueString(lines); + getCustomPropertySheet().setKeyValueMap(policyProperties); getCustomPropertySheet().deserialize(KeyValueModel.convertProperties(defaultMap)); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java index 2bfc645..d72fd06 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java @@ -1,6 +1,5 @@ package org.ovirt.engine.ui.uicommonweb.models.profiles; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -266,13 +265,8 @@ Map<String, String> customPropertiesList = ((VdcQueryReturnValue) returnValue).getReturnValue(); - List<String> lines = new ArrayList<String>(); - - for (Map.Entry<String, String> keyValue : customPropertiesList.entrySet()) { - lines.add(keyValue.getKey() + '=' + keyValue.getValue()); - } - getCustomPropertySheet().setKeyValueString(lines); - getCustomPropertySheet().setIsChangable(!lines.isEmpty()); + getCustomPropertySheet().setKeyValueMap(customPropertiesList); + getCustomPropertySheet().setIsChangable(!customPropertiesList.isEmpty()); initCustomProperties(); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java index e9876d6..3411c65 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java @@ -1037,14 +1037,14 @@ this.customPropertySheet = customPropertySheet; } - private Map<Version, List<String>> privateCustomPropertiesKeysList; + private Map<Version, Map<String, String>> privateCustomPropertiesKeysList; - public Map<Version, List<String>> getCustomPropertiesKeysList() + public Map<Version, Map<String, String>> getCustomPropertiesKeysList() { return privateCustomPropertiesKeysList; } - public void setCustomPropertiesKeysList(Map<Version, List<String>> value) + public void setCustomPropertiesKeysList(Map<Version, Map<String, String>> value) { privateCustomPropertiesKeysList = value; } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java index dacfcd0..23ca340 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java @@ -473,7 +473,7 @@ return; } VDSGroup cluster = getModel().getSelectedCluster(); - getModel().getCustomPropertySheet().setKeyValueString(getModel().getCustomPropertiesKeysList() + getModel().getCustomPropertySheet().setKeyValueMap(getModel().getCustomPropertiesKeysList() .get(cluster.getcompatibility_version())); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java index 8b43073..c7b79f3 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java @@ -26,7 +26,8 @@ getIsAutoAssign().setEntity(true); // Custom Properties - getCustomPropertySheet().setKeyValueString(AsyncDataProvider.getCustomPropertiesList().get(vm.getVdsGroupCompatibilityVersion())); + getCustomPropertySheet().setKeyValueMap(AsyncDataProvider.getCustomPropertiesList() + .get(vm.getVdsGroupCompatibilityVersion())); getCustomPropertySheet().deserialize(vm.getCustomProperties()); loadHosts(); -- To view, visit http://gerrit.ovirt.org/27386 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic57b3157960e829d43073c1614647b25a3b6a139 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
