2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.dao.entities;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2017-10-23 18:06:24 +02:00
|
|
|
import java.util.List;
|
2017-09-14 12:37:36 +02:00
|
|
|
import java.util.UUID;
|
2017-10-23 18:06:24 +02:00
|
|
|
import java.util.stream.Collectors;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2017-10-23 18:06:24 +02:00
|
|
|
import javax.persistence.Query;
|
|
|
|
import javax.persistence.TypedQuery;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
import eu.eudat.dao.JpaDao;
|
|
|
|
import eu.eudat.entities.DatasetProfile;
|
|
|
|
import eu.eudat.entities.responses.IDLabelPair;
|
|
|
|
import org.springframework.stereotype.Component;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
@Component("datasetProfileDao")
|
2017-09-14 12:37:36 +02:00
|
|
|
public class DatasetProfileDaoImpl extends JpaDao<DatasetProfile, UUID> implements DatasetProfileDao {
|
|
|
|
|
|
|
|
|
|
|
|
public DatasetProfile loadDetails(DatasetProfile t) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
2017-10-23 18:06:24 +02:00
|
|
|
|
|
|
|
@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());
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
}
|