public boolean demoteLE(LearningElementDto le) throws UnknownHostException, Exception { boolean ok = false; LearningElement model = dao.getLE(le.getId()); if (model != null) { model.setStatus(0); dao.demoteLE(model); ok = true; } else throw new Exception("LearningElement does not exist. "); return ok; }
public List<LearningElementDto> searchLearningElements(String keyword) throws UnknownHostException { List<LearningElement> LOList; LOList = dao.searchLE(keyword); List<LearningElementDto> objects = new ArrayList<>(); for (LearningElement model : LOList) { LearningElementDto dto = new LearningElementDto(); dto.setId(model.getId()); dto.setRating(model.getRating()); dto.setTitle(model.getTitle()); dto.setDescription(model.getDescription()); dto.setSubject(model.getSubject()); dto.setDownloads(model.getDownloads()); dto.setUploadDate(model.getUploadDate()); dto.setUploadedBy(model.getUploadedBy()); dto.setComments(model.getComments()); dto.setRev(model.getRev()); dto.setStatus(model.getStatus()); objects.add(dto); } return objects; }
public LearningElementDto getSpecificLearningElement(String id) throws UnknownHostException { LearningElement leModel = dao.getSpecificLearningElement(id); LearningElementDto dto = new LearningElementDto(); if (leModel != null) { dto.setId(leModel.getId()); dto.setTitle(leModel.getTitle()); dto.setDescription(leModel.getDescription()); dto.setSubject(leModel.getSubject()); dto.setUploadDate(leModel.getUploadDate()); dto.setDownloads(leModel.getDownloads()); dto.setRating(leModel.getRating()); dto.setRev(leModel.getRev()); dto.setStatus(leModel.getStatus()); dto.setComments(leModel.getComments()); dto.setUploadedBy(leModel.getUploadedBy()); dto.setFilePath(leModel.getFilePath()); } return dto; }
public boolean reviewLE(LearningElementDto le) throws UnknownHostException { LearningElement obj = dao.getSpecificLearningElementById(le.getId()); obj.setComments(le.getComments()); obj.setRating(le.getRating()); return dao.saveLE(obj); }