argos/dmp-backend/src/main/java/dao/entities/DatasetProfileDaoImpl.java

43 lines
1.1 KiB
Java
Raw Normal View History

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