@Override public void initSelectedProfile(ListModel<VnicProfileView> profileList, VmNetworkInterface networkInterface) { if (networkInterface.getVnicProfileId() != null) { Collection<VnicProfileView> profiles = Optional.ofNullable(profileList.getItems()).orElse(Collections.emptyList()); profileList.setSelectedItem(profiles.stream() .filter(profile -> Objects.equals(profile.getId(), networkInterface.getVnicProfileId())) .findAny() .orElse(VnicProfileView.EMPTY)); } else { profileList.setSelectedItem(VnicProfileView.EMPTY); } }
} else { vnicsEncountered.add(vnicName); Guid existingProfileId = existingVnic.getVnicProfileId(); Guid editedProfileId = editedVnic.getVnicProfileId();
@Mapping(from = VmNetworkInterface.class, to = Nic.class) public static Nic map(VmNetworkInterface entity, Nic template) { Nic model = template != null ? template : new Nic(); if (entity.getVmId() != null) { model.setVm(new Vm()); model.getVm().setId(entity.getVmId().toString()); } if (entity.getId() != null) { model.setId(entity.getId().toString()); } if (entity.getName() != null) { model.setName(entity.getName()); } if (entity.getMacAddress() != null) { model.setMac(new Mac()); model.getMac().setAddress(entity.getMacAddress()); } model.setLinked(entity.isLinked()); model.setInterface(map(entity.getType())); model.setPlugged(entity.isPlugged()); if (entity.getVnicProfileId() != null) { model.setVnicProfile(new VnicProfile()); model.getVnicProfile().setId(entity.getVnicProfileId().toString()); } return model; }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", getId()) .append("name", getName()) .append("networkName", getNetworkName()) .append("vnicProfileName", getVnicProfileName()) .append("vnicProfileId", getVnicProfileId()) .append("speed", getSpeed()) .append("type", getType()) .append("macAddress", getMacAddress()) .append("active", isPlugged()) .append("linked", isLinked()) .append("portMirroring", isPortMirroring()) .append("vmId", getVmId()) .append("vmName", getVmName()) .append("vmTemplateId", getVmTemplateId()) .append("QoSName", getQosName()) .append("remoteNetworkName", getRemoteNetworkName()) .build(); }