Add type to the recent activity model
This commit is contained in:
parent
325979a896
commit
f5093a6995
|
@ -16,6 +16,7 @@ public abstract class RecentActivityModel<T> {
|
||||||
private Date finalizedAt;
|
private Date finalizedAt;
|
||||||
private Date publishedAt;
|
private Date publishedAt;
|
||||||
private String profile;
|
private String profile;
|
||||||
|
private RecentActivityType type;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -121,5 +122,39 @@ public abstract class RecentActivityModel<T> {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RecentActivityType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(RecentActivityType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract RecentActivityModel fromEntity(T entity);
|
public abstract RecentActivityModel fromEntity(T entity);
|
||||||
|
|
||||||
|
public enum RecentActivityType {
|
||||||
|
DMP(1), DATASET(2);
|
||||||
|
|
||||||
|
private final int index;
|
||||||
|
|
||||||
|
RecentActivityType(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RecentActivityType fromIndex(int index) {
|
||||||
|
switch (index) {
|
||||||
|
case 1:
|
||||||
|
return DMP;
|
||||||
|
case 2:
|
||||||
|
return DATASET;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Recent Activity Type : \"" + index + "\" is not supported.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.logic.utilities.helpers.LabelBuilder;
|
import eu.eudat.logic.utilities.helpers.LabelBuilder;
|
||||||
import eu.eudat.models.data.dataset.DataRepository;
|
import eu.eudat.models.data.dataset.DataRepository;
|
||||||
import eu.eudat.models.data.dataset.Service;
|
import eu.eudat.models.data.dataset.Service;
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -80,6 +79,7 @@ public class RecentDatasetModel extends RecentActivityModel<Dataset> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecentDatasetModel fromDmpEntity(Dataset entity) {
|
public RecentDatasetModel fromDmpEntity(Dataset entity) {
|
||||||
|
this.setType(RecentActivityType.DATASET);
|
||||||
this.setId(entity.getId().toString());
|
this.setId(entity.getId().toString());
|
||||||
this.setTitle(entity.getLabel());
|
this.setTitle(entity.getLabel());
|
||||||
this.setDescription(entity.getDescription());
|
this.setDescription(entity.getDescription());
|
||||||
|
|
|
@ -90,6 +90,7 @@ public class RecentDmpModel extends RecentActivityModel<DMP> {
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public RecentActivityModel fromEntity(DMP entity) {
|
public RecentActivityModel fromEntity(DMP entity) {
|
||||||
|
this.setType(RecentActivityType.DMP);
|
||||||
this.setId(entity.getId().toString());
|
this.setId(entity.getId().toString());
|
||||||
this.setTitle(entity.getLabel());
|
this.setTitle(entity.getLabel());
|
||||||
this.setDescription(entity.getDescription());
|
this.setDescription(entity.getDescription());
|
||||||
|
|
Loading…
Reference in New Issue