@Override public JsonArray getParamsByHostId(int id) { List<Hostparam> params = hostParamDAO.getParametersByAdressId(id); List<ParametersJson> realParams = new ArrayList<ParametersJson>(); for (Hostparam hp : params) { List<Harddrives> hards = new ArrayList<Harddrives>(); ParametersJson current = new ParametersJson(); current.setIdcomp(hp.getId()); current.setIpadress(hp.getIp()); current.setHostname(hp.getHostname()); current.setIndex(hp.getIndex()); current.setMotherBoard(hp.getMboard()); current.setProcessor(hp.getProc()); current.setMemory(hp.getMemory()); current.setVidCard(hp.getVidcard()); for (Joinhardparam hd : hp.getJoinhardparamCollection()) { Harddrives currentHd = new Harddrives(); currentHd.setId(hd.getIdHard().getId()); currentHd.setVendor(hd.getIdHard().getVendor()); currentHd.setVolume(hd.getIdHard().getVolume()); hards.add(currentHd); } current.setHdrives(hards); current.setIdAdress(hp.getIdadress().getId()); realParams.add(current); } JsonArray paramsJson = (JsonArray) new Gson().toJsonTree(realParams, new TypeToken<List<Hostparam>>() {}.getType()); return paramsJson; }
@Override public List<Hostparam> getAll() { return hostParamDAO.getAll(); }