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);
}
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;
}
Aggregations