use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class UserGeneralModel method updateProperties.
private void updateProperties() {
DbUser user = getEntity();
setDomain(user.getDomain());
setEmail(user.getEmail());
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser 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.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class UserListModel method onRemove.
public void onRemove() {
List<DbUser> selectedItems = getSelectedItems();
ArrayList<ActionParametersBase> userPrms = new ArrayList<>();
ArrayList<ActionParametersBase> groupPrms = new ArrayList<>();
for (DbUser item : selectedItems) {
if (!item.isGroup()) {
userPrms.add(new IdParameters(item.getId()));
} else {
groupPrms.add(new IdParameters(item.getId()));
}
}
IFrontendMultipleActionAsyncCallback lastCallback = result -> Scheduler.get().scheduleDeferred(() -> {
// Refresh user list.
syncSearch();
cancel();
});
if (getUserOrGroup() == UserOrGroup.User) {
if (userPrms.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.RemoveUser, userPrms, lastCallback);
}
} else if (getUserOrGroup() == UserOrGroup.Group) {
if (groupPrms.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.RemoveGroup, groupPrms, lastCallback);
}
}
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class UserListModel method onAdd.
public void onAdd(final boolean closeWindow) {
AdElementListModel model = (AdElementListModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (model.getSelectedItems() == null) {
cancel();
return;
}
List<EntityModel<DbUser>> selectedItems = new ArrayList<>();
for (EntityModel<DbUser> dbUserEntity : model.getItems()) {
if (dbUserEntity.getIsSelected()) {
selectedItems.add(dbUserEntity);
}
}
List<ActionType> actionsList = new ArrayList<>(selectedItems.size());
List<ActionParametersBase> parametersList = new ArrayList<>(selectedItems.size());
ActionParametersBase parameters = null;
for (EntityModel<DbUser> item : selectedItems) {
if (item.getEntity().isGroup()) {
actionsList.add(ActionType.AddGroup);
DbGroup grp = new DbGroup();
grp.setExternalId(item.getEntity().getExternalId());
grp.setName(item.getEntity().getFirstName());
grp.setNamespace(item.getEntity().getNamespace());
grp.setId(item.getEntity().getId());
grp.setDomain(item.getEntity().getDomain());
parameters = new AddGroupParameters(grp);
} else {
actionsList.add(ActionType.AddUser);
parameters = new AddUserParameters(item.getEntity());
}
parametersList.add(parameters);
}
model.startProgress();
IFrontendActionAsyncCallback lastCallback = result -> {
AdElementListModel localModel = (AdElementListModel) result.getState();
localModel.stopProgress();
// Refresh user list.
syncSearch();
if (closeWindow) {
cancel();
}
};
Collection<EntityModel<DbUser>> currentItems = model.getItems();
List<IFrontendActionAsyncCallback> callbacksList = new ArrayList<>(selectedItems.size());
for (EntityModel<DbUser> user : selectedItems) {
callbacksList.add(nopCallback);
currentItems.remove(user);
}
callbacksList.remove(callbacksList.size() - 1);
callbacksList.add(lastCallback);
// Refresh display
model.setItems(null);
model.setItems(currentItems);
Frontend.getInstance().runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class UserListModel method updateDetailsAvailability.
@Override
protected void updateDetailsAvailability() {
if (getSelectedItem() != null) {
DbUser adUser = getSelectedItem();
groupListModel.setIsAvailable(!adUser.isGroup());
eventNotifierListModel.setIsAvailable(!adUser.isGroup());
}
}
Aggregations