Search in sources :

Example 1 with SecondaryIdDescription

use of com.bakdata.conquery.models.datasets.SecondaryIdDescription in project conquery by bakdata.

the class RequiredColumn method toColumn.

public Column toColumn(Table table, CentralRegistry storage) {
    Column col = new Column();
    col.setName(name);
    col.setType(type);
    col.setSharedDictionary(sharedDictionary);
    col.setTable(table);
    if (!Strings.isNullOrEmpty(secondaryId)) {
        final SecondaryIdDescription description = storage.resolve(new SecondaryIdDescriptionId(table.getDataset().getId(), secondaryId));
        col.setSecondaryId(description);
    }
    return col;
}
Also used : SecondaryIdDescriptionId(com.bakdata.conquery.models.identifiable.ids.specific.SecondaryIdDescriptionId) Column(com.bakdata.conquery.models.datasets.Column) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription)

Example 2 with SecondaryIdDescription

use of com.bakdata.conquery.models.datasets.SecondaryIdDescription in project conquery by bakdata.

the class RequiredSecondaryId method toSecondaryId.

public SecondaryIdDescription toSecondaryId() {
    final SecondaryIdDescription desc = new SecondaryIdDescription();
    desc.setName(getName());
    desc.setDescription(getDescription());
    desc.setLabel(getLabel());
    return desc;
}
Also used : SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription)

Example 3 with SecondaryIdDescription

use of com.bakdata.conquery.models.datasets.SecondaryIdDescription in project conquery by bakdata.

the class StoredQueriesProcessorTest method mockManagedSecondaryIdQueryFrontEnd.

private static ManagedQuery mockManagedSecondaryIdQueryFrontEnd(User user, ManagedExecutionId id, ExecutionState execState, CQElement root, Dataset dataset) {
    final SecondaryIdQuery sid = new SecondaryIdQuery();
    sid.setSecondaryId(new SecondaryIdDescription() {

        {
            setDataset(DATASET_0);
            setName("sid");
        }
    });
    sid.setRoot(root);
    return mockManagedQuery(sid, user, id, execState, dataset);
}
Also used : SecondaryIdQuery(com.bakdata.conquery.apiv1.query.SecondaryIdQuery) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription)

Example 4 with SecondaryIdDescription

use of com.bakdata.conquery.models.datasets.SecondaryIdDescription in project conquery by bakdata.

the class TableExportQuery method resolve.

@Override
public void resolve(QueryResolveContext context) {
    query.resolve(context);
    // First is dates
    AtomicInteger currentPosition = new AtomicInteger(1);
    positions = new HashMap<>();
    Map<SecondaryIdDescription, Integer> secondaryIdPositions = new HashMap<>();
    // SecondaryIds are pulled to the front and grouped over all tables
    tables.stream().map(cqUnfilteredTable -> cqUnfilteredTable.getTable().getTable().getColumns()).flatMap(Arrays::stream).map(Column::getSecondaryId).filter(Objects::nonNull).distinct().sorted(Comparator.comparing(SecondaryIdDescription::getLabel)).forEach(secondaryId -> secondaryIdPositions.put(secondaryId, currentPosition.getAndIncrement()));
    for (CQUnfilteredTable table : tables) {
        Connector connector = table.getTable();
        final Column validityDateColumn = findValidityDateColumn(connector, table.getDateColumn());
        if (validityDateColumn != null) {
            positions.putIfAbsent(validityDateColumn, 0);
        }
        // Set column positions, set SecondaryId positions to precomputed ones.
        for (Column column : connector.getTable().getColumns()) {
            positions.computeIfAbsent(column, col -> col.getSecondaryId() != null ? secondaryIdPositions.get(col.getSecondaryId()) : currentPosition.getAndIncrement());
        }
    }
    resultInfos = createResultInfos(currentPosition.get(), secondaryIdPositions, positions);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) CQUnfilteredTable(com.bakdata.conquery.apiv1.query.concept.filter.CQUnfilteredTable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) Column(com.bakdata.conquery.models.datasets.Column) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription)

Example 5 with SecondaryIdDescription

use of com.bakdata.conquery.models.datasets.SecondaryIdDescription in project conquery by bakdata.

the class TableExportQuery method createResultInfos.

private static List<ResultInfo> createResultInfos(int size, Map<SecondaryIdDescription, Integer> secondaryIdPositions, Map<Column, Integer> positions) {
    ResultInfo[] infos = new ResultInfo[size];
    infos[0] = ConqueryConstants.DATES_INFO;
    for (Map.Entry<SecondaryIdDescription, Integer> e : secondaryIdPositions.entrySet()) {
        SecondaryIdDescription desc = e.getKey();
        Integer pos = e.getValue();
        infos[pos] = new SimpleResultInfo(desc.getLabel(), ResultType.IdT.INSTANCE);
    }
    for (Map.Entry<Column, Integer> entry : positions.entrySet()) {
        // 0 Position is date, already covered
        final int position = entry.getValue();
        // SecondaryIds are pulled to the front, already covered.
        final Column column = entry.getKey();
        if (position == 0 || column.getSecondaryId() != null) {
            continue;
        }
        infos[position] = new SimpleResultInfo(column.getTable().getLabel() + " " + column.getLabel(), ResultType.resolveResultType(column.getType()));
    }
    return List.of(infos);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleResultInfo(com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo) Column(com.bakdata.conquery.models.datasets.Column) SimpleResultInfo(com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo) ResultInfo(com.bakdata.conquery.models.query.resultinfo.ResultInfo) HashMap(java.util.HashMap) Map(java.util.Map) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription)

Aggregations

SecondaryIdDescription (com.bakdata.conquery.models.datasets.SecondaryIdDescription)9 Column (com.bakdata.conquery.models.datasets.Column)4 SecondaryIdQuery (com.bakdata.conquery.apiv1.query.SecondaryIdQuery)2 Jackson (com.bakdata.conquery.io.jackson.Jackson)2 Connector (com.bakdata.conquery.models.datasets.concepts.Connector)2 SecondaryIdDescriptionId (com.bakdata.conquery.models.identifiable.ids.specific.SecondaryIdDescriptionId)2 TableId (com.bakdata.conquery.models.identifiable.ids.specific.TableId)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Response (javax.ws.rs.core.Response)2 Slf4j (lombok.extern.slf4j.Slf4j)2 FilterSearch (com.bakdata.conquery.apiv1.FilterSearch)1 FESecondaryId (com.bakdata.conquery.apiv1.frontend.FESecondaryId)1 CQUnfilteredTable (com.bakdata.conquery.apiv1.query.concept.filter.CQUnfilteredTable)1 IntegrationTest (com.bakdata.conquery.integration.IntegrationTest)1 InternalOnly (com.bakdata.conquery.io.jackson.InternalOnly)1 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)1 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)1 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)1