use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup 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.DbGroup in project ovirt-engine by oVirt.
the class GetDbGroupByIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
final Guid id = getParameters().getId();
final DbGroup group = dao.get(id);
getQueryReturnValue().setReturnValue(group);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class GroupMapper method map.
@Mapping(from = DbGroup.class, to = Group.class)
public static Group map(DbGroup entity, Group template) {
Group model = template != null ? template : new Group();
model.setName(entity.getName());
model.setId(entity.getId().toString());
if (!StringUtils.isEmpty(entity.getDomain())) {
Domain dom = new Domain();
dom.setName(entity.getDomain());
dom.setId(DirectoryEntryIdUtils.encode(dom.getName()));
model.setDomain(dom);
}
model.setDomainEntryId(DirectoryEntryIdUtils.encode(entity.getExternalId()));
model.setNamespace(entity.getNamespace());
return model;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DetachUserGroupFromTagCommand method executeCommand.
@Override
protected void executeCommand() {
if (getTagId() != null) {
for (Guid groupGuid : getGroupList()) {
DbGroup group = dbGroupDao.get(groupGuid);
if (tagDao.getTagUserGroupByGroupIdAndByTagId(getTagId(), groupGuid) != null) {
if (group != null) {
appendCustomCommaSeparatedValue("DetachGroupsNames", group.getName());
}
tagDao.detachUserGroupFromTag(getTagId(), groupGuid);
noActionDone = false;
setSucceeded(true);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DbGroupDaoTest method testGet.
/**
* Ensures that, if the id is valid, then retrieving a group works as expected.
*/
@Test
public void testGet() {
DbGroup result = dao.get(existingGroup.getId());
assertNotNull(result);
assertEquals(existingGroup, result);
}
Aggregations