Further fixes and improvements over recent activity
This commit is contained in:
parent
0b452d2520
commit
d51099cedc
|
@ -29,7 +29,16 @@ import java.util.stream.Collectors;
|
|||
@NamedEntityGraph(
|
||||
name = "dmpRecentActivity",
|
||||
attributeNodes = {
|
||||
@NamedAttributeNode("users"), @NamedAttributeNode("creator")})
|
||||
@NamedAttributeNode("users"), @NamedAttributeNode("creator")}),
|
||||
@NamedEntityGraph(
|
||||
name = "recentDmpModel",
|
||||
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), @NamedAttributeNode("associatedDmps"),
|
||||
@NamedAttributeNode("grant"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode(value = "dataset", subgraph = "dataset")},
|
||||
subgraphs = {
|
||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
||||
@NamedSubgraph(name = "dataset", attributeNodes = {@NamedAttributeNode("id"), @NamedAttributeNode("label")})
|
||||
}
|
||||
)
|
||||
})
|
||||
public class DMP implements DataEntity<DMP, UUID> {
|
||||
|
||||
|
|
|
@ -36,7 +36,17 @@ import java.util.stream.Collectors;
|
|||
@NamedEntityGraph(
|
||||
name = "datasetDataRepositories",
|
||||
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("creator")},
|
||||
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")}))
|
||||
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})),
|
||||
@NamedEntityGraph(
|
||||
name = "recentDatasetModel",
|
||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
|
||||
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
|
||||
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
|
||||
subgraphs = {
|
||||
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
|
||||
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
|
||||
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
|
||||
})
|
||||
})
|
||||
public class Dataset implements DataEntity<Dataset, UUID> {
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ public class DashBoardManager {
|
|||
private static final Logger logger = LoggerFactory.getLogger(DashBoardManager.class);
|
||||
|
||||
private final Map<String, Comparator<RecentActivityModel>> comparators = Stream.of(new Object[][] {
|
||||
{ "modified", Comparator.comparing(o -> ((RecentActivityModel)o).getModified())},
|
||||
{ "created", Comparator.comparing(o -> ((RecentActivityModel)o).getCreated())},
|
||||
{ "modified", Comparator.comparing(o -> ((RecentActivityModel)o).getModified()).reversed()},
|
||||
{ "created", Comparator.comparing(o -> ((RecentActivityModel)o).getCreated()).reversed()},
|
||||
{ "label", Comparator.comparing(o -> ((RecentActivityModel)o).getTitle())},
|
||||
{ "status", Comparator.comparing(o -> ((RecentActivityModel)o).getStatus())}
|
||||
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Comparator<RecentActivityModel>)data[1]));
|
||||
|
@ -220,35 +220,29 @@ public class DashBoardManager {
|
|||
datasetList = datasetRepository.getWithCriteria(datasetCriteria);
|
||||
}
|
||||
|
||||
CompletableFuture<List<RecentActivityModel>> dmps = dmpList
|
||||
.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||
.orderBy((builder, root) -> builder.desc(root.get(tableRequest.getCriteria().getOrder())))
|
||||
.skip(tableRequest.getOffset())
|
||||
.take(tableRequest.getLength())
|
||||
.selectAsync(item -> {
|
||||
return new RecentDmpModel().fromEntity(item);
|
||||
})
|
||||
.whenComplete((dmpActivities, throwable) -> {
|
||||
if (dmpActivities != null) {
|
||||
recentActivityModels.addAll(dmpActivities);
|
||||
}
|
||||
});
|
||||
CompletableFuture future = CompletableFuture.runAsync(() -> {
|
||||
recentActivityModels.addAll(dmpList
|
||||
.withHint(HintedModelFactory.getHint(RecentDmpModel.class))
|
||||
.orderBy((builder, root) -> builder.desc(root.get(tableRequest.getCriteria().getOrder())))
|
||||
.skip(tableRequest.getOffset())
|
||||
.take(tableRequest.getLength())
|
||||
.select(item -> {
|
||||
return new RecentDmpModel().fromEntity(item);
|
||||
}));
|
||||
|
||||
CompletableFuture<List<RecentActivityModel>> datasets = datasetList
|
||||
.withHint(HintedModelFactory.getHint(DatasetListingModel.class))
|
||||
.orderBy((builder, root) -> builder.desc(root.get(tableRequest.getCriteria().getOrder())))
|
||||
.skip(tableRequest.getOffset())
|
||||
.take(tableRequest.getLength())
|
||||
.selectAsync(item -> {
|
||||
return new RecentDatasetModel().fromEntity(item);
|
||||
})
|
||||
.whenComplete((datasetActivities, throwable) -> {
|
||||
if (datasetActivities != null) {
|
||||
recentActivityModels.addAll(datasetActivities);
|
||||
}
|
||||
});
|
||||
recentActivityModels.addAll(datasetList
|
||||
.withHint(HintedModelFactory.getHint(RecentDatasetModel.class))
|
||||
.orderBy((builder, root) -> builder.desc(root.get(tableRequest.getCriteria().getOrder())))
|
||||
.skip(tableRequest.getOffset())
|
||||
.take(tableRequest.getLength())
|
||||
.select(item -> {
|
||||
return new RecentDatasetModel().fromEntity(item);
|
||||
}));
|
||||
});
|
||||
|
||||
CompletableFuture.allOf(dmps, datasets).join();
|
||||
|
||||
CompletableFuture.allOf(future).join();
|
||||
// CompletableFuture.allOf(dmps, datasets).join();
|
||||
|
||||
return recentActivityModels.stream().sorted(this.comparators.get(tableRequest.getCriteria().getOrder())).limit(tableRequest.getLength()).collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package eu.eudat.models.data.dashboard.recent.model;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RecentActivityModel<T> {
|
||||
public abstract class RecentActivityModel<T extends DataEntity, S extends DataModel> implements DataModel<T, S> {
|
||||
private String id;
|
||||
private String title;
|
||||
private String description;
|
||||
|
|
|
@ -9,7 +9,7 @@ import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
|||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RecentDatasetModel extends RecentActivityModel<Dataset> {
|
||||
public class RecentDatasetModel extends RecentActivityModel<Dataset, RecentDatasetModel> {
|
||||
private String dmp;
|
||||
private String dmpId;
|
||||
private String dataRepositories;
|
||||
|
@ -101,4 +101,20 @@ public class RecentDatasetModel extends RecentActivityModel<Dataset> {
|
|||
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RecentDatasetModel fromDataModel(Dataset entity) {
|
||||
return (RecentDatasetModel) this.fromEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset toDataModel() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return "recentDatasetModel";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ import eu.eudat.data.entities.DMP;
|
|||
import eu.eudat.logic.utilities.helpers.LabelBuilder;
|
||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.data.dmp.Organisation;
|
||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.models.data.urls.DatasetUrlListing;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
@ -12,10 +14,10 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RecentDmpModel extends RecentActivityModel<DMP> {
|
||||
public class RecentDmpModel extends RecentActivityModel<DMP, RecentDmpModel> {
|
||||
private String doi;
|
||||
private Map<String, Object> extraProperties;
|
||||
private List<RecentDatasetModel> datasets;
|
||||
private List<DatasetUrlListing> datasets;
|
||||
private List<AssociatedProfile> associatedProfiles;
|
||||
private String organisations;
|
||||
private UUID groupId;
|
||||
|
@ -37,11 +39,11 @@ public class RecentDmpModel extends RecentActivityModel<DMP> {
|
|||
this.extraProperties = extraProperties;
|
||||
}
|
||||
|
||||
public List<RecentDatasetModel> getDatasets() {
|
||||
public List<DatasetUrlListing> getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public void setDatasets(List<RecentDatasetModel> datasets) {
|
||||
public void setDatasets(List<DatasetUrlListing> datasets) {
|
||||
this.datasets = datasets;
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,8 @@ public class RecentDmpModel extends RecentActivityModel<DMP> {
|
|||
this.setModified(entity.getModified());
|
||||
this.setStatus(entity.getStatus());
|
||||
this.setVersion(entity.getVersion());
|
||||
this.datasets = entity.getDataset().stream().map(dataset -> new RecentDatasetModel().fromDmpEntity(dataset)).collect(Collectors.toList());
|
||||
//this.datasets = entity.getDataset().stream().map(dataset -> new RecentDatasetModel().fromDmpEntity(dataset)).collect(Collectors.toList());
|
||||
this.datasets = entity.getDataset().stream().map(dataset -> new DatasetUrlListing().fromDataModel(dataset)).collect(Collectors.toList());
|
||||
this.associatedProfiles = entity.getAssociatedDmps().stream().map(item -> new AssociatedProfile().fromData(item)).collect(Collectors.toList());
|
||||
this.setFinalizedAt(entity.getFinalizedAt());
|
||||
this.setGrant(entity.getGrant().getLabel());
|
||||
|
@ -94,4 +97,19 @@ public class RecentDmpModel extends RecentActivityModel<DMP> {
|
|||
this.setUsers(entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecentDmpModel fromDataModel(DMP entity) {
|
||||
return (RecentDmpModel) this.fromEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMP toDataModel() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHint() {
|
||||
return "recentDmpModel";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { UserInfoListingModel } from '../user/user-info-listing';
|
|||
export class RecentDmpModel extends RecentActivityModel {
|
||||
doi: String;
|
||||
extraProperties: Map<String, any>;
|
||||
datasets: RecentDatasetModel[];
|
||||
datasets: any[];
|
||||
associatedProfiles: DmpAssociatedProfileModel[];
|
||||
organisations: String;
|
||||
groupId: string;
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
</div>
|
||||
<div *ngFor="let dataset of getDatasets(activity); let i = index; let last = last" [ngClass]="{'pb-3': i === activity.datasets.length - 1}">
|
||||
<div *ngIf="i < 3">
|
||||
<div class="col-auto dmp-dataset-descriptions-name" *ngIf="!last && i !== 2">{{dataset.title}},</div>
|
||||
<div class="col-auto dmp-dataset-descriptions-name" *ngIf="last || i == 2">{{dataset.title}}</div>
|
||||
<div class="col-auto dmp-dataset-descriptions-name" *ngIf="!last && i !== 2">{{dataset.label}},</div>
|
||||
<div class="col-auto dmp-dataset-descriptions-name" *ngIf="last || i == 2">{{dataset.label}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="d-flex justify-content-center pb-3 show-more" *ngIf="getDatasets(activity).length > 3" [routerLink]="['../plans/overview/' + activity.id]"><u>{{'GENERAL.ACTIONS.SHOW-MORE' | translate}}</u></a>
|
||||
|
|
|
@ -70,7 +70,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
|
|||
.getRecentAcitvity(allDataTableRequest)
|
||||
.subscribe(response => {
|
||||
this.allRecentActivities = response;
|
||||
this.totalCountRecentEdited.emit(this.pageSize);
|
||||
this.totalCountRecentEdited.emit(this.allRecentActivities.length);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue