class LibraryServiceImpl implements LibraryService {

	@Override
	@SuppressWarnings("unchecked")
	public List<LibInfoRecord> getLibInfo(String user, String project, String exploratoryName) {
		Document document = libraryDAO.findAllLibraries(user, project, exploratoryName);

		Map<LibKey, List<LibraryStatus>> model = new TreeMap<>(Comparator.comparing(LibKey::getName)
				.thenComparing(LibKey::getVersion)
				.thenComparing(LibKey::getGroup));

		if (document.get(ExploratoryLibDAO.EXPLORATORY_LIBS) != null) {
			List<Document> exploratoryLibs = (List<Document>) document.get(ExploratoryLibDAO.EXPLORATORY_LIBS);
			exploratoryLibs.forEach(e -> populateModel(exploratoryName, e, model, "notebook"));

		}

		if (document.get(ExploratoryLibDAO.COMPUTATIONAL_LIBS) != null) {
			Document computationalLibs = getLibsOfActiveComputationalResources(document);
			populateComputational(computationalLibs, model, "cluster");
		}

		List<LibInfoRecord> libInfoRecords = new ArrayList<>();

		for (Map.Entry<LibKey, List<LibraryStatus>> entry : model.entrySet()) {
			libInfoRecords.add(new LibInfoRecord(entry.getKey(), entry.getValue()));

		}

		return libInfoRecords;
	}

}