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

44 lines
1.2 KiB
Java

package eu.eudat.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 eu.eudat.dao.JpaDao;
import eu.eudat.entities.DMPProfile;
import eu.eudat.entities.responses.IDLabelPair;
import org.springframework.stereotype.Component;
@Component("dMPProfileDao")
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());
}
}