protected void addGroupsToModel(QueryReturnValue returnValue, Set<String> excludeUsers) { for (Queryable item : (Collection<Queryable>) returnValue.getReturnValue()) { DirectoryGroup a = (DirectoryGroup) item; if (!excludeUsers.contains(a.getId())) { // TODO: This is a hack, we should either use DbGroup or reimplement user/group representation in GWT DbUser group = new DbUser(); group.setExternalId(a.getId()); group.setFirstName(a.getName()); group.setLastName(""); //$NON-NLS-1$ // TODO: Due to group -> DbUser mapping hack we have to use note to represent display name of group group.setNote(a.getDisplayName()); group.setDomain(a.getDirectoryName()); group.setNamespace(a.getNamespace()); EntityModel<DbUser> groupEntity = new EntityModel<>(); groupEntity.setEntity(group); getgroups().add(groupEntity); } } } protected Set<String> getExcludeUsers() {
currentUser.setLastName(USER); currentUser.setDomain(DOMAIN); currentUser.setNamespace(NAMESPACE); currentUser.setId(GUIDS[0]);
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); vm = FixturesTool.VM_RHEL5_POOL_50; existingUser = dao .get(new Guid("9bf7c640-b620-456f-a550-0348f366544a")); deletableUser = dao.get(new Guid("9bf7c640-b620-456f-a550-0348f366544b")); newUser = new DbUser(); newUser.setExternalId("0"); newUser.setId(Guid.newGuid()); newUser.setFirstName("Bob"); newUser.setLastName("Milqtoste"); newUser.setLoginName("newuser"); newUser.setEmail("newuser@redhat.com"); newUser.setDomain("domain"); newUser.setGroupNames(new LinkedList<>(Collections.singletonList("groups"))); newUser.setNamespace("*"); }
@Mapping(from = User.class, to = DbUser.class) public static DbUser map(User model, DbUser template) { DbUser entity = template != null? template: new DbUser(); if (model.isSetPrincipal()) { entity.setLoginName(model.getPrincipal()); } else if (model.isSetName()) { entity.setLoginName(model.getName()); } if (model.isSetId()) { String id = model.getId(); entity.setId(GuidUtils.asGuid(id)); } if (model.isSetDomain()) { Domain domain = model.getDomain(); if (domain.isSetName()) { entity.setDomain(domain.getName()); } } if (model.isSetDomainEntryId()) { entity.setExternalId(DirectoryEntryIdUtils.decode(model.getDomainEntryId())); } if (model.isSetNamespace()) { entity.setNamespace(model.getNamespace()); } return entity; }