private void filterCpuTypeByArchitecture() { final ArchitectureType selectedArchitecture = getArchitecture().getSelectedItem(); final FilteredListModel.Filter<ServerCpu> filter = selectedArchitecture == null || selectedArchitecture.equals(ArchitectureType.undefined) ? cpu -> cpu == null || cpu.getLevel() > 0 : cpu -> cpu != null && selectedArchitecture.equals(cpu.getArchitecture()) && cpu.getLevel() > 0; getCPU().filterItems(filter); }
@Mapping(from = ServerCpu.class, to = Cpu.class) public static Cpu map(ServerCpu entity, Cpu template) { Cpu model = template != null ? template : new Cpu(); model.setName(entity.getCpuName()); model.setLevel(entity.getLevel()); model.setArchitecture(map(entity.getArchitecture(), null)); return model; }
public ClusterLevel makeClusterLevel(String version) { ClusterLevel level = new ClusterLevel(); level.setId(version); // Not exposing CPU list filtered queries: if (!isFiltered()) { CpuTypes cpuTypes = new CpuTypes(); for (ServerCpu serverCpu : getServerCpuList(version)) { CpuType cpuType = new CpuType(); cpuType.setName(serverCpu.getCpuName()); cpuType.setLevel(serverCpu.getLevel()); cpuType.setArchitecture(CPUMapper.map(serverCpu.getArchitecture(), null)); cpuTypes.getCpuTypes().add(cpuType); } level.setCpuTypes(cpuTypes); } // Add permits: Permits permits = new Permits(); for (ActionGroup actionGroup : getActionGroups()) { Permit permit = PermitMapper.map(actionGroup, null); permits.getPermits().add(permit); } level.setPermits(permits); return LinkHelper.addLinks(level); }