Search in sources :

Example 6 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class HostListModel method onAssignTags.

public void onAssignTags() {
    TagListModel model = (TagListModel) getWindow();
    getAttachedTagsToSelectedHosts(model);
}
Also used : TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Example 7 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class HostListModel method getAttachedTagsToSelectedHosts.

private void getAttachedTagsToSelectedHosts(final TagListModel model) {
    ArrayList<Guid> hostIds = new ArrayList<>();
    for (VDS vds : getSelectedItems()) {
        hostIds.add(vds.getId());
    }
    attachedTagsToEntities = new HashMap<>();
    allAttachedTags = new ArrayList<>();
    selectedItemsCounter = 0;
    for (Guid hostId : hostIds) {
        AsyncDataProvider.getInstance().getAttachedTagsToHost(new AsyncQuery<>(returnValue -> {
            allAttachedTags.addAll(returnValue);
            selectedItemsCounter++;
            if (selectedItemsCounter == getSelectedItems().size()) {
                postGetAttachedTags(model);
            }
        }), hostId);
    }
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) RpmVersion(org.ovirt.engine.core.compat.RpmVersion) Arrays(java.util.Arrays) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) SetHaMaintenanceParameters(org.ovirt.engine.core.common.action.SetHaMaintenanceParameters) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) Event(org.ovirt.engine.ui.uicompat.Event) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) RoleType(org.ovirt.engine.core.common.businessentities.RoleType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VdsPowerDownParameters(org.ovirt.engine.core.common.action.VdsPowerDownParameters) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) StringHelper(org.ovirt.engine.core.compat.StringHelper) FrontendUrlUtils(org.ovirt.engine.ui.frontend.utils.FrontendUrlUtils) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) HostGeneralModel.createUpgradeModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostGeneralModel.createUpgradeModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) HostErrataCountModel(org.ovirt.engine.ui.uicommonweb.models.HostErrataCountModel) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) Uri(org.ovirt.engine.ui.uicommonweb.Uri) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) HostedEngineDeployConfiguration(org.ovirt.engine.core.common.businessentities.HostedEngineDeployConfiguration) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) QueryType(org.ovirt.engine.core.common.queries.QueryType) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Guid(org.ovirt.engine.core.compat.Guid) HostGlusterSwiftListModel(org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterSwiftListModel) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ExternalDiscoveredHost(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) HostGlusterStorageDevicesListModel(org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterStorageDevicesListModel) HashSet(java.util.HashSet) FenceVdsManualyParameters(org.ovirt.engine.core.common.action.FenceVdsManualyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) HostMaintenanceConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.HostMaintenanceConfirmationModel) NumaSupportModel(org.ovirt.engine.ui.uicommonweb.models.hosts.numa.NumaSupportModel) Permission(org.ovirt.engine.core.common.businessentities.Permission) Window(com.google.gwt.user.client.Window) ForceSelectSPMParameters(org.ovirt.engine.core.common.action.ForceSelectSPMParameters) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) ReversibleFlow(org.ovirt.engine.ui.uicompat.ReversibleFlow) RemoveVdsParameters(org.ovirt.engine.core.common.action.RemoveVdsParameters) ExternalComputeResource(org.ovirt.engine.core.common.businessentities.ExternalComputeResource) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Linq(org.ovirt.engine.ui.uicommonweb.Linq) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) HaMaintenanceMode(org.ovirt.engine.core.common.businessentities.HaMaintenanceMode) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) TaskListModel(org.ovirt.engine.ui.uicommonweb.models.events.TaskListModel) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) FenceProxySourceTypeHelper(org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) HostAffinityLabelListModel(org.ovirt.engine.ui.uicommonweb.models.configure.labels.list.HostAffinityLabelListModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) HostDeviceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.HostDeviceListModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) Comparator(java.util.Comparator) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) MaintenanceNumberOfVdssParameters(org.ovirt.engine.core.common.action.MaintenanceNumberOfVdssParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class UserListModel method getAttachedTagsToSelectedUsers.

private void getAttachedTagsToSelectedUsers(final TagListModel model) {
    ArrayList<Guid> userIds = new ArrayList<>();
    ArrayList<Guid> grpIds = new ArrayList<>();
    attachedTagsToEntities = new HashMap<>();
    allAttachedTags = new ArrayList<>();
    selectedItemsCounter = 0;
    for (Object item : getSelectedItems()) {
        DbUser user = (DbUser) item;
        if (!user.isGroup()) {
            userIds.add(user.getId());
        } else {
            grpIds.add(user.getId());
        }
    }
    for (Guid userId : userIds) {
        AsyncDataProvider.getInstance().getAttachedTagsToUser(new AsyncQuery<>(returnValue -> {
            allAttachedTags.addAll(returnValue);
            selectedItemsCounter++;
            if (selectedItemsCounter == getSelectedItems().size()) {
                postGetAttachedTags(model);
            }
        }), userId);
    }
    for (Guid grpId : grpIds) {
        AsyncDataProvider.getInstance().getAttachedTagsToUserGroup(new AsyncQuery<>(returnValue -> {
            allAttachedTags.addAll(returnValue);
            selectedItemsCounter++;
            if (selectedItemsCounter == getSelectedItems().size()) {
                postGetAttachedTags(model);
            }
        }), grpId);
    }
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) QueryType(org.ovirt.engine.core.common.queries.QueryType) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) UserOrGroup(org.ovirt.engine.core.searchbackend.VdcUserConditionFieldAutoCompleter.UserOrGroup) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) IdParameters(org.ovirt.engine.core.common.action.IdParameters) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 9 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class UserListModel method postOnAssignTags.

@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
    TagListModel model = (TagListModel) getWindow();
    ArrayList<Guid> userIds = new ArrayList<>();
    ArrayList<Guid> grpIds = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        DbUser user = (DbUser) item;
        if (user.isGroup()) {
            grpIds.add(user.getId());
        } else {
            userIds.add(user.getId());
        }
    }
    // prepare attach/detach lists
    ArrayList<Guid> tagsToAttach = new ArrayList<>();
    ArrayList<Guid> tagsToDetach = new ArrayList<>();
    if (model.getItems() != null && model.getItems().size() > 0) {
        ArrayList<TagModel> tags = (ArrayList<TagModel>) model.getItems();
        TagModel rootTag = tags.get(0);
        TagModel.recursiveEditAttachDetachLists(rootTag, attachedTags, tagsToAttach, tagsToDetach);
    }
    ArrayList<ActionParametersBase> usersToAttach = new ArrayList<>();
    ArrayList<ActionParametersBase> grpsToAttach = new ArrayList<>();
    for (Guid tag_id : tagsToAttach) {
        if (userIds.size() > 0) {
            usersToAttach.add(new AttachEntityToTagParameters(tag_id, userIds));
        }
        if (grpIds.size() > 0) {
            grpsToAttach.add(new AttachEntityToTagParameters(tag_id, grpIds));
        }
    }
    if (usersToAttach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.AttachUserToTag, usersToAttach);
    }
    if (grpsToAttach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.AttachUserGroupToTag, grpsToAttach);
    }
    ArrayList<ActionParametersBase> usersToDetach = new ArrayList<>();
    ArrayList<ActionParametersBase> grpsToDetach = new ArrayList<>();
    for (Guid tag_id : tagsToDetach) {
        if (userIds.size() > 0) {
            usersToDetach.add(new AttachEntityToTagParameters(tag_id, userIds));
        }
        if (grpIds.size() > 0) {
            grpsToDetach.add(new AttachEntityToTagParameters(tag_id, grpIds));
        }
    }
    if (usersToDetach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.DetachUserFromTag, usersToDetach);
    }
    if (grpsToDetach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.DetachUserGroupFromTag, grpsToDetach);
    }
    cancel();
}
Also used : ArrayList(java.util.ArrayList) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) Guid(org.ovirt.engine.core.compat.Guid) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 10 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class UserListModel method onAssignTags.

private void onAssignTags() {
    TagListModel model = (TagListModel) getWindow();
    getAttachedTagsToSelectedUsers(model);
}
Also used : TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Aggregations

TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)13 ArrayList (java.util.ArrayList)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)6 Guid (org.ovirt.engine.core.compat.Guid)6 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)6 TagModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)6 Inject (com.google.inject.Inject)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ActionUtils (org.ovirt.engine.core.common.ActionUtils)3 ActionType (org.ovirt.engine.core.common.action.ActionType)3 Tags (org.ovirt.engine.core.common.businessentities.Tags)3 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)3 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)3 SearchObjects (org.ovirt.engine.core.searchbackend.SearchObjects)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3