Add isProfileLatestVersion on DatasetListingModel

This commit is contained in:
George Kalampokis 2020-06-30 18:29:06 +03:00
parent f821938542
commit 64078eb283
2 changed files with 23 additions and 2 deletions

View File

@ -186,7 +186,7 @@ public class DatasetManager {
CompletableFuture<List<DatasetListingModel>> itemsFuture = pagedItems.
selectAsync(item -> new DatasetListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> {
selectAsync(this::mapModel).whenComplete((resultList, throwable) -> {
dataTable.setData(resultList);
});
@ -240,7 +240,7 @@ public class DatasetManager {
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
CompletableFuture<List<DatasetListingModel>> itemsFuture = pagedItems.
selectAsync(item -> new DatasetListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> {
selectAsync(this::mapModel).whenComplete((resultList, throwable) -> {
dataTable.setData(resultList);
});
@ -1024,4 +1024,16 @@ public class DatasetManager {
dstTags.add(tag);
}
}
private DatasetListingModel mapModel(Dataset item) {
DatasetListingModel listingModel = new DatasetListingModel().fromDataModel(item);
DatasetProfileCriteria criteria = new DatasetProfileCriteria();
criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
List<DatasetProfile> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false;
profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId());
listingModel.setProfileLatestVersion(islast);
return listingModel;
}
}

View File

@ -33,6 +33,7 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
private int version;
private List<UserInfoListingModel> users;
private Boolean isPublic;
private Boolean isProfileLatestVersion;
public String getId() {
return id;
@ -176,6 +177,14 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
isPublic = aPublic;
}
public Boolean getProfileLatestVersion() {
return isProfileLatestVersion;
}
public void setProfileLatestVersion(Boolean profileLatestVersion) {
isProfileLatestVersion = profileLatestVersion;
}
@Override
public DatasetListingModel fromDataModel(Dataset entity) {
this.id = entity.getId() != null ? entity.getId().toString() : "";