Calculating doied datasets and used description templates query
This commit is contained in:
parent
2e083df185
commit
1b156ca78e
|
@ -9,6 +9,7 @@ import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.model.DescriptionTemplate;
|
import eu.eudat.model.DescriptionTemplate;
|
||||||
import eu.eudat.query.utils.BuildSubQueryInput;
|
import eu.eudat.query.utils.BuildSubQueryInput;
|
||||||
import eu.eudat.query.utils.QueryUtilsService;
|
import eu.eudat.query.utils.QueryUtilsService;
|
||||||
|
@ -53,6 +54,8 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
|
|
||||||
private Instant after;
|
private Instant after;
|
||||||
|
|
||||||
|
private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery;
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
public DescriptionTemplateQuery like(String value) {
|
public DescriptionTemplateQuery like(String value) {
|
||||||
|
@ -200,6 +203,11 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DescriptionTemplateQuery dmpDescriptionTemplateSubQuery(DmpDescriptionTemplateQuery value) {
|
||||||
|
this.dmpDescriptionTemplateQuery = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DescriptionTemplateQuery authorize(EnumSet<AuthorizationFlags> values) {
|
public DescriptionTemplateQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
|
@ -327,6 +335,11 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
predicates.add(afterClause);
|
predicates.add(afterClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.dmpDescriptionTemplateQuery != null) {
|
||||||
|
QueryContext<DmpDescriptionTemplateEntity, UUID> subQuery = this.applySubQuery(this.dmpDescriptionTemplateQuery, queryContext, UUID.class, dmpDescriptionTemplateEntityRoot -> dmpDescriptionTemplateEntityRoot.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId));
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateEntity._groupId)).value(subQuery.Query));
|
||||||
|
}
|
||||||
|
|
||||||
if (!predicates.isEmpty()) {
|
if (!predicates.isEmpty()) {
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
|
|
@ -279,7 +279,15 @@ public class MetricsServiceImpl implements MetricsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateDoiedDatasets(boolean forNexus) {
|
private double calculateDoiedDatasets(boolean forNexus) {
|
||||||
return 0;
|
DescriptionQuery descriptionQuery = this.queryFactory.query(DescriptionQuery.class).statuses(DescriptionStatus.Finalized).isActive(IsActive.Active);
|
||||||
|
if (forNexus)
|
||||||
|
descriptionQuery.createdAfter(_config.getNexusDate());
|
||||||
|
DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active);
|
||||||
|
EntityDoiQuery entityDoiQuery = this.queryFactory.query(EntityDoiQuery.class).types(EntityType.DMP).isActive(IsActive.Active);
|
||||||
|
dmpQuery.entityDoiSubQuery(entityDoiQuery);
|
||||||
|
descriptionQuery.dmpSubQuery(dmpQuery);
|
||||||
|
descriptionQuery.setDistinct(true);
|
||||||
|
return descriptionQuery.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateDraftTemplates(boolean forNexus) {
|
private double calculateDraftTemplates(boolean forNexus) {
|
||||||
|
@ -297,11 +305,13 @@ public class MetricsServiceImpl implements MetricsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateUsedTemplates(boolean forNexus) {
|
private double calculateUsedTemplates(boolean forNexus) {
|
||||||
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active);
|
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active);
|
||||||
dmpDescriptionTemplateQuery.setDistinct(true);
|
descriptionTemplateQuery.setDistinct(true);
|
||||||
if (forNexus)
|
if (forNexus)
|
||||||
dmpDescriptionTemplateQuery.after(_config.getNexusDate());
|
descriptionTemplateQuery.after(_config.getNexusDate());
|
||||||
return dmpDescriptionTemplateQuery.count();
|
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class);
|
||||||
|
descriptionTemplateQuery.dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery);
|
||||||
|
return descriptionTemplateQuery.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateActiveUsers() {
|
private double calculateActiveUsers() {
|
||||||
|
|
Loading…
Reference in New Issue