package eu.eudat.dao.entities; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; import javax.persistence.Query; import javax.persistence.TypedQuery; import eu.eudat.dao.JpaDao; import eu.eudat.entities.DatasetProfile; import eu.eudat.entities.responses.IDLabelPair; import org.springframework.stereotype.Component; @Component("datasetProfileDao") public class DatasetProfileDaoImpl extends JpaDao implements DatasetProfileDao { public DatasetProfile loadDetails(DatasetProfile t) { // TODO Auto-generated method stub return null; } @Override public List listAllIDs() { String queryString = "SELECT dp.id FROM DatasetProfile dp"; TypedQuery typedQuery = entityManager.createQuery(queryString, UUID.class); return typedQuery.getResultList(); } @Override public List listAllIDsLabels() { String queryString = "SELECT dp.id, dp.label FROM DatasetProfile dp"; Query query = (Query) entityManager.createQuery(queryString); List rows = query.getResultList(); return rows.stream().map(row -> { return new IDLabelPair(row[0].toString(), row[1].toString()); }) .collect(Collectors.toList()); } }