use of org.ovirt.engine.core.common.action.AttachEntityToTagParameters in project ovirt-engine by oVirt.
the class HostListModel method postOnAssignTags.
@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
TagListModel model = (TagListModel) getWindow();
ArrayList<Guid> hostIds = new ArrayList<>();
for (Object item : getSelectedItems()) {
VDS vds = (VDS) item;
hostIds.add(vds.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> prmsToAttach = new ArrayList<>();
for (Guid tag_id : tagsToAttach) {
prmsToAttach.add(new AttachEntityToTagParameters(tag_id, hostIds));
}
Frontend.getInstance().runMultipleAction(ActionType.AttachVdsToTag, prmsToAttach);
ArrayList<ActionParametersBase> prmsToDetach = new ArrayList<>();
for (Guid tag_id : tagsToDetach) {
prmsToDetach.add(new AttachEntityToTagParameters(tag_id, hostIds));
}
Frontend.getInstance().runMultipleAction(ActionType.DetachVdsFromTag, prmsToDetach);
cancel();
}
use of org.ovirt.engine.core.common.action.AttachEntityToTagParameters 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.core.common.action.AttachEntityToTagParameters in project ovirt-engine by oVirt.
the class VmListModel method postOnAssignTags.
@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
TagListModel model = (TagListModel) getWindow();
ArrayList<Guid> vmIds = new ArrayList<>();
for (Object item : getSelectedItems()) {
VM vm = (VM) item;
vmIds.add(vm.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> parameters = new ArrayList<>();
for (Guid a : tagsToAttach) {
parameters.add(new AttachEntityToTagParameters(a, vmIds));
}
Frontend.getInstance().runMultipleAction(ActionType.AttachVmsToTag, parameters);
parameters = new ArrayList<>();
for (Guid a : tagsToDetach) {
parameters.add(new AttachEntityToTagParameters(a, vmIds));
}
Frontend.getInstance().runMultipleAction(ActionType.DetachVmFromTag, parameters);
cancel();
}
Aggregations