Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
c762613509
|
@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.model.DmpDescriptionTemplate;
|
||||
|
@ -41,6 +42,8 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
|
||||
private Instant after;
|
||||
|
||||
private DescriptionTemplateQuery descriptionTemplateQuery;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
public DmpDescriptionTemplateQuery ids(UUID value) {
|
||||
|
@ -138,6 +141,11 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
return this;
|
||||
}
|
||||
|
||||
public DmpDescriptionTemplateQuery descriptionTemplateSubQuery(DescriptionTemplateQuery value) {
|
||||
this.descriptionTemplateQuery = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DmpDescriptionTemplateQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
|
@ -229,9 +237,13 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
predicates.add(inClause);
|
||||
}
|
||||
if (this.after != null) {
|
||||
Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpEntity._createdAt), this.after);
|
||||
Predicate afterClause = queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(DmpDescriptionTemplateEntity._createdAt), this.after);
|
||||
predicates.add(afterClause);
|
||||
}
|
||||
if (this.descriptionTemplateQuery != null) {
|
||||
QueryContext<DescriptionTemplateEntity, UUID> subQuery = this.applySubQuery(this.descriptionTemplateQuery, queryContext, UUID.class, descriptionTemplateEntityRoot -> descriptionTemplateEntityRoot.get(DescriptionTemplateEntity._groupId));
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)).value(subQuery.Query));
|
||||
}
|
||||
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
|
|
|
@ -3,11 +3,13 @@ package eu.eudat.service.metrics;
|
|||
import eu.eudat.commons.enums.*;
|
||||
import eu.eudat.commons.metrics.MetricLabels;
|
||||
import eu.eudat.commons.metrics.MetricNames;
|
||||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||
import eu.eudat.data.TenantEntityManager;
|
||||
import eu.eudat.query.*;
|
||||
import eu.eudat.service.keycloak.MyKeycloakAdminRestApi;
|
||||
import gr.cite.commons.web.keycloak.api.configuration.KeycloakClientProperties;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||
import io.prometheus.client.Gauge;
|
||||
|
@ -298,20 +300,20 @@ public class MetricsServiceImpl implements MetricsService {
|
|||
}
|
||||
|
||||
private double calculateFinalizedTemplates(boolean forNexus) {
|
||||
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).statuses(DescriptionTemplateStatus.Finalized).isActive(IsActive.Active);
|
||||
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).statuses(DescriptionTemplateStatus.Finalized).versionStatuses(DescriptionTemplateVersionStatus.Current).isActive(IsActive.Active);
|
||||
if (forNexus)
|
||||
descriptionTemplateQuery.after(_config.getNexusDate());
|
||||
return descriptionTemplateQuery.count();
|
||||
}
|
||||
|
||||
private double calculateUsedTemplates(boolean forNexus) {
|
||||
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active);
|
||||
descriptionTemplateQuery.setDistinct(true);
|
||||
if (forNexus)
|
||||
descriptionTemplateQuery.after(_config.getNexusDate());
|
||||
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class);
|
||||
descriptionTemplateQuery.dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery);
|
||||
return descriptionTemplateQuery.count();
|
||||
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active);
|
||||
dmpDescriptionTemplateQuery.setDistinct(true);
|
||||
if (forNexus) {
|
||||
DescriptionTemplateQuery descriptionTemplateQuery = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).after(_config.getNexusDate());
|
||||
dmpDescriptionTemplateQuery.descriptionTemplateSubQuery(descriptionTemplateQuery);
|
||||
}
|
||||
return dmpDescriptionTemplateQuery.collectAs(new BaseFieldSet().ensure(DmpDescriptionTemplateEntity._descriptionTemplateGroupId)).size();
|
||||
}
|
||||
|
||||
private double calculateActiveUsers() {
|
||||
|
|
Loading…
Reference in New Issue