Search in sources :

Example 11 with VmNicFilterParameter

use of org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter in project ovirt-engine by oVirt.

the class VmNicFilterParameterDaoImpl method getAllForVmNic.

@Override
public List<VmNicFilterParameter> getAllForVmNic(Guid vmInterfaceId, Guid userId, boolean filtered) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_interface_id", vmInterfaceId).addValue("user_id", userId).addValue("is_filtered", filtered);
    List<VmNicFilterParameter> results = getCallsHandler().executeReadList("GetVmInterfaceFilterParametersByVmInterfaceId", VmNicFilterParameterRowMapper.INSTANCE, parameterSource);
    return results;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Example 12 with VmNicFilterParameter

use of org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter in project ovirt-engine by oVirt.

the class AddVmInterfaceCommand method saveNetworkFilterParameters.

protected void saveNetworkFilterParameters() {
    if (getParameters().getFilterParameters() != null) {
        for (VmNicFilterParameter parameter : getParameters().getFilterParameters()) {
            parameter.setVmInterfaceId(getInterface().getId());
            runInternalAction(ActionType.AddVmNicFilterParameter, new VmNicFilterParameterParameters(getParameters().getVmId(), parameter));
        }
    }
}
Also used : VmNicFilterParameterParameters(org.ovirt.engine.core.common.action.VmNicFilterParameterParameters) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Example 13 with VmNicFilterParameter

use of org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter in project ovirt-engine by oVirt.

the class UpdateVmInterfaceCommand method saveNetworkFilterParameters.

protected void saveNetworkFilterParameters() {
    List<VmNicFilterParameter> newParameters = getParameters().getFilterParameters();
    if (newParameters != null) {
        List<VmNicFilterParameter> savedParameters = runInternalQuery(QueryType.GetVmInterfaceFilterParametersByVmInterfaceId, new IdQueryParameters(getInterface().getId())).getReturnValue();
        for (VmNicFilterParameter parameter : newParameters) {
            boolean toUpdate = savedParameters.stream().anyMatch(saved -> Objects.equals(parameter.getId(), saved.getId()));
            if (toUpdate) {
                runInternalAction(ActionType.UpdateVmNicFilterParameter, new VmNicFilterParameterParameters(getParameters().getVmId(), parameter));
            } else {
                parameter.setVmInterfaceId(getInterface().getId());
                runInternalAction(ActionType.AddVmNicFilterParameter, new VmNicFilterParameterParameters(getParameters().getVmId(), parameter));
            }
        }
        for (VmNicFilterParameter parameter : savedParameters) {
            if (newParameters.stream().noneMatch(newParameter -> Objects.equals(parameter.getId(), newParameter.getId()))) {
                runInternalAction(ActionType.RemoveVmNicFilterParameter, new RemoveVmNicFilterParameterParameters(getParameters().getVmId(), parameter.getId()));
            }
        }
    }
}
Also used : VmNicFilterParameterParameters(org.ovirt.engine.core.common.action.VmNicFilterParameterParameters) RemoveVmNicFilterParameterParameters(org.ovirt.engine.core.common.action.RemoveVmNicFilterParameterParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) RemoveVmNicFilterParameterParameters(org.ovirt.engine.core.common.action.RemoveVmNicFilterParameterParameters) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Example 14 with VmNicFilterParameter

use of org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter in project ovirt-engine by oVirt.

the class VmInterfaceListModel method updateNetworkFilterParameterMap.

private void updateNetworkFilterParameterMap(List<VmNetworkInterface> vmInterfaces) {
    List<QueryType> queryTypes = new ArrayList<>();
    List<QueryParametersBase> queryParametersBases = new ArrayList<>();
    vmInterfaces.stream().forEach(iface -> {
        queryTypes.add(QueryType.GetVmInterfaceFilterParametersByVmInterfaceId);
        queryParametersBases.add(new IdQueryParameters(iface.getId()));
    });
    final IFrontendMultipleQueryAsyncCallback callback = multiResult -> {
        Map<Guid, List<VmNicFilterParameter>> networkFilterMap = new HashMap<>(vmInterfaces.size());
        for (int i = 0; i < multiResult.getReturnValues().size(); i++) {
            List<VmNicFilterParameter> params = multiResult.getReturnValues().get(i).getReturnValue();
            networkFilterMap.put(vmInterfaces.get(i).getId(), params);
        }
        setMapNicFilterParameter(networkFilterMap);
        setItems(vmInterfaces);
    };
    if (vmInterfaces.isEmpty()) {
        setItems(vmInterfaces);
    }
    Frontend.getInstance().runMultipleQueries(queryTypes, queryParametersBases, callback);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ActionUtils(org.ovirt.engine.core.common.ActionUtils) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Objects(java.util.Objects) VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) IFrontendMultipleQueryAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleQueryAsyncCallback) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) IFrontendMultipleQueryAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleQueryAsyncCallback) ArrayList(java.util.ArrayList) List(java.util.List) QueryType(org.ovirt.engine.core.common.queries.QueryType) HashMap(java.util.HashMap) Map(java.util.Map) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Aggregations

VmNicFilterParameter (org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)14 ArrayList (java.util.ArrayList)3 VmNicFilterParameterParameters (org.ovirt.engine.core.common.action.VmNicFilterParameterParameters)3 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)3 List (java.util.List)2 Test (org.junit.Test)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)2 Scheduler (com.google.gwt.core.client.Scheduler)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ConstraintViolation (javax.validation.ConstraintViolation)1 Before (org.junit.Before)1 NetworkFilterParameter (org.ovirt.engine.api.model.NetworkFilterParameter)1 NetworkFilterParameters (org.ovirt.engine.api.model.NetworkFilterParameters)1 ActionUtils (org.ovirt.engine.core.common.ActionUtils)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 RemoveVmNicFilterParameterParameters (org.ovirt.engine.core.common.action.RemoveVmNicFilterParameterParameters)1