Search in sources :

Example 1 with ExecutionStatus

use of com.bakdata.conquery.apiv1.ExecutionStatus in project conquery by bakdata.

the class ManagedExecution method setAdditionalFieldsForStatusWithSource.

/**
 * Sets additional fields of an {@link ExecutionStatus} when a more specific status is requested.
 */
protected void setAdditionalFieldsForStatusWithSource(Subject subject, FullExecutionStatus status) {
    QueryDescription query = getSubmitted();
    NamespacedIdentifiableCollector namespacesIdCollector = new NamespacedIdentifiableCollector();
    query.visit(namespacesIdCollector);
    final Set<Concept> concepts = namespacesIdCollector.getIdentifiables().stream().filter(ConceptElement.class::isInstance).map(ConceptElement.class::cast).map(ConceptElement::getConcept).collect(Collectors.toSet());
    boolean canExpand = subject.isPermittedAll(concepts, Ability.READ);
    status.setCanExpand(canExpand);
    status.setQuery(canExpand ? getSubmitted() : null);
}
Also used : Concept(com.bakdata.conquery.models.datasets.concepts.Concept) NamespacedIdentifiableCollector(com.bakdata.conquery.util.QueryUtils.NamespacedIdentifiableCollector) ConceptElement(com.bakdata.conquery.models.datasets.concepts.ConceptElement) QueryDescription(com.bakdata.conquery.apiv1.query.QueryDescription)

Example 2 with ExecutionStatus

use of com.bakdata.conquery.apiv1.ExecutionStatus in project conquery by bakdata.

the class StoredQueriesProcessorTest method makeState.

@SneakyThrows
private static ExecutionStatus makeState(ManagedExecutionId id, User owner, User callingUser, ExecutionState state, String typeLabel, SecondaryIdDescriptionId secondaryId) {
    OverviewExecutionStatus status = new OverviewExecutionStatus();
    final ManagedQuery execMock = new ManagedQuery() {

        {
            setDataset(DATASET_0);
            setQueryId(id.getExecution());
        }
    };
    status.setTags(new String[0]);
    status.setLabel(id.getExecution().toString());
    status.setPristineLabel(true);
    status.setCreatedAt(LocalDateTime.MIN.atZone(ZoneId.systemDefault()));
    status.setOwner(owner.getId());
    status.setShared(false);
    status.setOwn(owner.equals(callingUser));
    status.setId(id);
    status.setStatus(state);
    status.setQueryType(typeLabel);
    // This is probably not interesting on the overview (only if there is an filter for the search)
    status.setSecondaryId(secondaryId);
    if (state.equals(DONE)) {
        status.setResultUrls(List.of(ResultExcelResource.getDownloadURL(URI_BUILDER.clone(), execMock), ResultCsvResource.getDownloadURL(URI_BUILDER.clone(), execMock), ResultArrowFileResource.getDownloadURL(URI_BUILDER.clone(), execMock), ResultArrowStreamResource.getDownloadURL(URI_BUILDER.clone(), execMock)));
    }
    return status;
}
Also used : ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) OverviewExecutionStatus(com.bakdata.conquery.apiv1.OverviewExecutionStatus) SneakyThrows(lombok.SneakyThrows)

Aggregations

OverviewExecutionStatus (com.bakdata.conquery.apiv1.OverviewExecutionStatus)1 QueryDescription (com.bakdata.conquery.apiv1.query.QueryDescription)1 Concept (com.bakdata.conquery.models.datasets.concepts.Concept)1 ConceptElement (com.bakdata.conquery.models.datasets.concepts.ConceptElement)1 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)1 NamespacedIdentifiableCollector (com.bakdata.conquery.util.QueryUtils.NamespacedIdentifiableCollector)1 SneakyThrows (lombok.SneakyThrows)1