Search in sources :

Example 16 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyDaoTest method createDummyPolicy.

private void createDummyPolicy() {
    dummyPolicy = new ClusterPolicy();
    dummyPolicy.setId(Guid.newGuid());
    dummyPolicy.setName("Dummy policy");
    dummyPolicy.setDescription("Dummy policy description");
    dummyPolicy.setLocked(false);
    ArrayList<Guid> filters = new ArrayList<>();
    filters.add(FixturesTool.POLICY_UNIT_MIGRATION);
    dummyPolicy.setFilters(filters);
    HashMap<Guid, Integer> filterPositionMap = new HashMap<>();
    filterPositionMap.put(FixturesTool.POLICY_UNIT_MIGRATION, 1);
    dummyPolicy.setFilterPositionMap(filterPositionMap);
    dummyPolicy.setParameterMap(new LinkedHashMap<>());
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 17 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyDaoTest method testGet.

@Test
public void testGet() {
    ClusterPolicy result = dao.get(existingPolicy.getId(), Collections.emptyMap());
    assertEquals(result, existingPolicy);
}
Also used : ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) Test(org.junit.Test)

Example 18 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyDaoImpl method get.

@Override
public ClusterPolicy get(Guid id, @NotNull Map<Guid, PolicyUnitType> internalUnitTypes) {
    ClusterPolicy clusterPolicy = super.get(id);
    if (clusterPolicy == null) {
        return null;
    }
    List<ClusterPolicyUnit> clusterPolicyUnits = getCallsHandler().executeReadList("GetClusterPolicyUnitsByClusterPolicyId", createClusterPolicyUnitRowMapper(), createIdParameterMapper(id));
    Map<Guid, ClusterPolicy> map = new HashMap<>();
    map.put(clusterPolicy.getId(), clusterPolicy);
    fillClusterPolicy(map, clusterPolicyUnits, Collections.unmodifiableMap(internalUnitTypes));
    return clusterPolicy;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 19 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyDaoImpl method getAll.

@Override
public List<ClusterPolicy> getAll(@NotNull Map<Guid, PolicyUnitType> internalUnitTypes) {
    List<ClusterPolicy> clusterPolicies = super.getAll();
    Map<Guid, ClusterPolicy> map = new HashMap<>();
    for (ClusterPolicy clusterPolicy : clusterPolicies) {
        map.put(clusterPolicy.getId(), clusterPolicy);
    }
    List<ClusterPolicyUnit> clusterPolicyUnits = getCallsHandler().executeReadList("GetAllFromClusterPolicyUnits", createClusterPolicyUnitRowMapper(), getCustomMapSqlParameterSource());
    fillClusterPolicy(map, clusterPolicyUnits, Collections.unmodifiableMap(internalUnitTypes));
    return clusterPolicies;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Guid(org.ovirt.engine.core.compat.Guid) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 20 with ClusterPolicy

use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.

the class ClusterPolicyListModel method onRemove.

public void onRemove() {
    for (Object item : getSelectedItems()) {
        ClusterPolicy clusterPolicy = (ClusterPolicy) item;
        Frontend.getInstance().runAction(ActionType.RemoveClusterPolicy, new ClusterPolicyCRUDParameters(clusterPolicy.getId(), clusterPolicy));
    }
    setWindow(null);
    // Execute search to keep list updated.
    getSearchCommand().execute();
}
Also used : ClusterPolicyCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Aggregations

ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)37 Guid (org.ovirt.engine.core.compat.Guid)20 HashMap (java.util.HashMap)10 LinkedHashMap (java.util.LinkedHashMap)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 ClusterPolicyCRUDParameters (org.ovirt.engine.core.common.scheduling.parameters.ClusterPolicyCRUDParameters)7 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)2 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 ValidationError (org.ovirt.engine.core.common.utils.customprop.ValidationError)2 Arrays (java.util.Arrays)1