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

42 lines
1.0 KiB
Java

package dao.entities;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.hibernate.query.Query;
import dao.JpaDao;
import entities.DMPProfile;
import entities.responses.IDLabelPair;
public class DMPProfileDaoImpl extends JpaDao<DMPProfile, UUID> implements DMPProfileDao {
public DMPProfile loadDetails(DMPProfile t) {
return null;
}
@Override
public List<UUID> listAllIDs() {
String queryString = "SELECT dmpProfile.id FROM DMPProfile dmpProfile";
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
return typedQuery.getResultList();
}
@Override
public List<IDLabelPair> listAllIDsLabels() {
String queryString = "SELECT dmpProfile.id, dmpProfile.label FROM DMPProfile dmpProfile";
Query query = (Query) entityManager.createQuery(queryString);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {
return new IDLabelPair(row[0].toString(), row[1].toString());
})
.collect(Collectors.toList());
}
}