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);
}
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);
}
}
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);
}
}
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();
}
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);
}
Aggregations