Add Last Public Version on Dataset Index
This commit is contained in:
parent
5ec02a89de
commit
a21afab48a
|
@ -54,6 +54,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
private UUID grant;
|
||||
private List<Collaborator> collaborators;
|
||||
private Boolean lastVersion;
|
||||
private Boolean lastPublicVersion;
|
||||
private List<Organization> organizations;
|
||||
private Boolean isPublic;
|
||||
private Short grantStatus;
|
||||
|
@ -146,6 +147,14 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
this.lastVersion = lastVersion;
|
||||
}
|
||||
|
||||
public Boolean getLastPublicVersion() {
|
||||
return lastPublicVersion;
|
||||
}
|
||||
|
||||
public void setLastPublicVersion(Boolean lastPublicVersion) {
|
||||
this.lastPublicVersion = lastPublicVersion;
|
||||
}
|
||||
|
||||
public List<Organization> getOrganizations() {
|
||||
return organizations;
|
||||
}
|
||||
|
@ -196,6 +205,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
builder.endArray();
|
||||
}
|
||||
builder.field("lastVersion", this.lastVersion.toString());
|
||||
builder.field("lastPublicVersion", this.lastPublicVersion.toString());
|
||||
if (organizations != null) {
|
||||
builder.startArray("organizations");
|
||||
this.organizations.forEach(x -> {
|
||||
|
@ -247,6 +257,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
this.collaborators = ((List<HashMap>) fields.get("collaborators")).stream().map(hashMap -> new Collaborator().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
||||
}
|
||||
this.lastVersion = Boolean.parseBoolean((String) fields.get("lastVersion"));
|
||||
this.lastPublicVersion = Boolean.parseBoolean((String) fields.get("lastPublicVersion"));
|
||||
if (fields.get("organizations") != null) {
|
||||
this.organizations = ((List<HashMap>) fields.get("organizations")).stream().map(hashMap -> new Organization().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
|
||||
if (criteria.isPublic()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("public.keyword", "true"));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("status.keyword", Dataset.Status.FINALISED.getValue()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("lastPublicVersion.keyword", "true"));
|
||||
}
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) {
|
||||
boolQuery = boolQuery.should(QueryBuilders.queryStringQuery("*" + criteria.getLike() + "*").fields(Stream.of(new Object[][] {
|
||||
|
|
|
@ -941,6 +941,7 @@ public class DataManagementPlanManager {
|
|||
}).collect(Collectors.toList()));
|
||||
}
|
||||
datasetElastic.setLastVersion(true);
|
||||
datasetElastic.setLastPublicVersion(false);
|
||||
if (dataset1.getDmp().getOrganisations() != null) {
|
||||
datasetElastic.setOrganizations(dataset1.getDmp().getOrganisations().stream().map(org -> {
|
||||
Organization organization = new Organization();
|
||||
|
@ -1316,12 +1317,17 @@ public class DataManagementPlanManager {
|
|||
throw new Exception("DMP is not finalized");
|
||||
dmp.setPublic(true);
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
|
||||
dmp.getDataset().forEach(dataset -> {
|
||||
try {
|
||||
datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset));
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
||||
criteria.setGroupIds(Collections.singletonList(dmp.getGroupId()));
|
||||
criteria.setAllVersions(true);
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).toList().stream().forEach(dmp1 -> {
|
||||
dmp1.getDataset().forEach(dataset -> {
|
||||
try {
|
||||
datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset));
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
});
|
||||
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
sendNotification(dmp, user, NotificationType.DMP_PUBLISH);
|
||||
|
|
|
@ -609,9 +609,14 @@ public class DatasetManager {
|
|||
dmpCriteria.setGroupIds(Collections.singletonList(datasetWizardModel.getDmp().getGroupId()));
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream()
|
||||
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> dataset.setLastVersion(dmp.getId().equals(datasetWizardModel.getDmp().getId())));
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream().filter(DMP::isPublic)
|
||||
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> dataset.setLastPublicVersion(dmp.getId().equals(datasetWizardModel.getDmp().getId())));
|
||||
if (dataset.getLastVersion() == null) {
|
||||
dataset.setLastVersion(true);
|
||||
}
|
||||
if (dataset.getLastPublicVersion() == null) {
|
||||
dataset.setLastPublicVersion(false);
|
||||
}
|
||||
if (datasetWizardModel.getDmp().getOrganisations() != null) {
|
||||
dataset.setOrganizations(datasetWizardModel.getDmp().getOrganisations().stream().map(org -> {
|
||||
Organization organization = new Organization();
|
||||
|
|
|
@ -6,7 +6,7 @@ export class DatasetCriteria extends BaseCriteria {
|
|||
public status?: Number;
|
||||
public dmpIds?: string[] = [];
|
||||
public tags?: ExternalSourceItemModel[] = [];
|
||||
public allVersions?: boolean = true;
|
||||
public allVersions?: boolean = false;
|
||||
public role?: number;
|
||||
public organisations?: string[] = [];
|
||||
public collaborators?: string[] = [];
|
||||
|
|
Loading…
Reference in New Issue