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