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