no message

This commit is contained in:
annabakouli 2018-01-17 14:20:48 +02:00
parent c8caa8d50a
commit 730db6655d
4 changed files with 17 additions and 18 deletions

View File

@ -45,7 +45,7 @@ public class ExternalDatasets extends BaseController{
} }
} }
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getWithExternal"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/external/datasets"}, consumes = "application/json", produces = "application/json")
public @ResponseBody ResponseItem<List<ExternalDatasetListingModel>> getWithExternal(@RequestBody ExternalDatasetCriteria externalDatasetCriteria, Principal principal) { public @ResponseBody ResponseItem<List<ExternalDatasetListingModel>> getWithExternal(@RequestBody ExternalDatasetCriteria externalDatasetCriteria, Principal principal) {
try { try {
List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), externalDatasetCriteria, this.getApiContext().getRemoteFetcher()); List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), externalDatasetCriteria, this.getApiContext().getRemoteFetcher());

View File

@ -33,14 +33,11 @@ public class DatasetDaoImpl implements DatasetDao {
@Override @Override
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) { public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class, Dataset.getHints()); QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class, Dataset.getHints());
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) if (criteria.getLike() != null && !criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%"));
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); if (criteria.getStatus() != null)query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()));
if (criteria.getStatus() != null) if (criteria.getPeriodEnd() != null)query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())); if (criteria.getPeriodStart() != null) query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
if (criteria.getPeriodEnd() != null) if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty()) query.where((builder, root) -> root.get("dmp.id").in( criteria.getDmpIds()));
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
return query; return query;
} }

View File

@ -38,15 +38,6 @@ public class ExternalDatasetManager {
public List<ExternalDatasetListingModel> getWithExternal(ExternalDatasetDao externalDatasetDao , ExternalDatasetCriteria criteria, RemoteFetcher remoteFetcher) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException { public List<ExternalDatasetListingModel> getWithExternal(ExternalDatasetDao externalDatasetDao , ExternalDatasetCriteria criteria, RemoteFetcher remoteFetcher) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
QueryableList<eu.eudat.entities.ExternalDataset> items = externalDatasetDao.getWithCriteria(criteria); QueryableList<eu.eudat.entities.ExternalDataset> items = externalDatasetDao.getWithCriteria(criteria);
List<ExternalDatasetListingModel> externalDatasets = new DomainModelConverter<eu.eudat.entities.ExternalDataset, ExternalDatasetListingModel>().fromDataModel(items.toList(), ExternalDatasetListingModel.class); List<ExternalDatasetListingModel> externalDatasets = new DomainModelConverter<eu.eudat.entities.ExternalDataset, ExternalDatasetListingModel>().fromDataModel(items.toList(), ExternalDatasetListingModel.class);
List<Map<String, String>> remoteRepos = remoteFetcher.getDatasets(criteria.getLike());
ExternalDatasetModel externalSourcesItemModels = new ExternalDatasetModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : externalSourcesItemModels) {
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel();
externalDatasetListingModel.setReference(externalListingItem.getRemoteId());
externalDatasetListingModel.setLabel(externalListingItem.getName());
externalDatasetListingModel.setAbbreviation(externalListingItem.getAbbreviation());
externalDatasets.add(externalDatasetListingModel);
}
return externalDatasets; return externalDatasets;
} }

View File

@ -3,6 +3,8 @@ package eu.eudat.models.criteria;
import eu.eudat.entities.Dataset; import eu.eudat.entities.Dataset;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID;
/** /**
* Created by ikalyvas on 12/15/2017. * Created by ikalyvas on 12/15/2017.
@ -11,6 +13,7 @@ public class DatasetCriteria extends Criteria<Dataset>{
private Integer status; private Integer status;
private Date periodStart; private Date periodStart;
private Date periodEnd; private Date periodEnd;
private List<UUID> dmpIds;
public Integer getStatus() { public Integer getStatus() {
return status; return status;
@ -35,4 +38,12 @@ public class DatasetCriteria extends Criteria<Dataset>{
public void setPeriodEnd(Date periodEnd) { public void setPeriodEnd(Date periodEnd) {
this.periodEnd = periodEnd; this.periodEnd = periodEnd;
} }
public List<UUID> getDmpIds() {
return dmpIds;
}
public void setDmpIds(List<UUID> dmpIds) {
this.dmpIds = dmpIds;
}
} }