@Override protected void addUsersToModel(VdcQueryReturnValue returnValue, Set<String> excludeUsers) { Iterable<DbUser> filteredUsers = Linq.where( (ArrayList<DbUser>) returnValue.getReturnValue(), new Linq.DbUserPredicate(getTargetDbUser())); for (DbUser dbUser : filteredUsers) { if (!excludeUsers.contains(dbUser.getExternalId())) { EntityModel tempVar2 = new EntityModel(); tempVar2.setEntity(dbUser); getusers().add(tempVar2); } } }
public void postUpdateHost(Collection<VDS> hosts) { // Filter hosts hosts = Linq.where(hosts, new Linq.HostStatusPredicate(VDSStatus.Up)); // Allow only hosts with version above 2.2 for export storage. ArrayList<VDS> list = new ArrayList<VDS>(); if (getCurrentStorageItem() != null && getCurrentStorageItem().getRole() == StorageDomainType.ImportExport) { for (VDS host : hosts) { if (host.getVdsGroupCompatibilityVersion().compareTo(new Version("2.2")) >= 0) { //$NON-NLS-1$ list.add(host); } } hosts = list; } VDS oldSelectedItem = getHost().getSelectedItem(); VDS selectedItem = null; // On Edit of active storage - only SPM is available. In edit of storage in maintenance, // any host can perform the operation, thus no need to filter to use just the SPM if (getStorage() != null && getStorage().getStatus() != StorageDomainStatus.Maintenance) { VDS spm = getSPM(hosts); hosts = spm != null ? Collections.singletonList(spm) : Collections.<VDS>emptyList(); } // Try to select previously selected host. if (oldSelectedItem != null) { selectedItem = Linq.firstOrDefault(hosts, new Linq.HostPredicate(oldSelectedItem.getId())); } // Select a default - if there's a SPM choose it, otherwise choose the first host in the list. if (selectedItem == null) { VDS spm = getSPM(hosts); selectedItem = spm == null ? Linq.firstOrDefault(hosts) : spm; } getHost().setItems(hosts, selectedItem); }
@Override protected void addGroupsToModel(VdcQueryReturnValue returnValue, Set<String> excludeUsers) { Iterable<DbGroup> filteredGroups = Linq.where( (ArrayList<DbGroup>) returnValue.getReturnValue(), new Linq.DbGroupPredicate(getTargetDbGroup())); for (DbGroup group : filteredGroups) { if (!excludeUsers.contains(group.getId().toString())) { DbUser dbUser = new DbUser(); dbUser.setExternalId(group.getExternalId()); dbUser.setFirstName(group.getName()); dbUser.setLastName(""); // $NON-NLS-1$ dbUser.setLoginName(""); // $NON-NLS-1$ dbUser.setDomain(group.getDomain()); dbUser.setNamespace(group.getNamespace()); EntityModel entity = new EntityModel(); entity.setEntity(dbUser); getgroups().add(entity); } } }