Search in sources :

Example 1 with SimpleResultInfo

use of com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo 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)

Example 2 with SimpleResultInfo

use of com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo in project conquery by bakdata.

the class UniqueNameTest method testNameCollision.

@Test
void testNameCollision() {
    final UniqueNamer uniqueNamer = new UniqueNamer(new PrintSettings(true, Locale.ROOT, null, new ConqueryConfig(), null));
    final SimpleResultInfo info1 = new SimpleResultInfo("test", null);
    final SimpleResultInfo info2 = new SimpleResultInfo("test", null);
    final SimpleResultInfo info3 = new SimpleResultInfo("test_1", null);
    final SimpleResultInfo info4 = new SimpleResultInfo("test", null);
    assertThat(uniqueNamer.getUniqueName(info1)).isEqualTo("test");
    assertThat(uniqueNamer.getUniqueName(info2)).isEqualTo("test_1");
    assertThat(uniqueNamer.getUniqueName(info3)).isEqualTo("test_1_1");
    assertThat(uniqueNamer.getUniqueName(info4)).isEqualTo("test_2");
}
Also used : SimpleResultInfo(com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) UniqueNamer(com.bakdata.conquery.models.query.resultinfo.UniqueNamer) Test(org.junit.jupiter.api.Test)

Example 3 with SimpleResultInfo

use of com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo in project conquery by bakdata.

the class CQExternal method getResultInfos.

@Override
public List<ResultInfo> getResultInfos() {
    if (extra == null) {
        return Collections.emptyList();
    }
    List<ResultInfo> resultInfos = new ArrayList<>();
    for (int col = 0; col < format.size(); col++) {
        if (!format.get(col).equals(FORMAT_EXTRA)) {
            continue;
        }
        String column = values[0][col];
        resultInfos.add(new SimpleResultInfo(column, new ResultType.ListT(ResultType.StringT.INSTANCE)));
    }
    return resultInfos;
}
Also used : SimpleResultInfo(com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo) ArrayList(java.util.ArrayList) SimpleResultInfo(com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo) ResultInfo(com.bakdata.conquery.models.query.resultinfo.ResultInfo)

Example 4 with SimpleResultInfo

use of com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo in project conquery by bakdata.

the class SecondaryIdQuery method getResultInfos.

@Override
public List<ResultInfo> getResultInfos() {
    List<ResultInfo> resultInfos = new ArrayList<>();
    resultInfos.add(new SimpleResultInfo(secondaryId.getName(), ResultType.IdT.INSTANCE));
    resultInfos.addAll(query.getResultInfos());
    return resultInfos;
}
Also used : SimpleResultInfo(com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo) ArrayList(java.util.ArrayList) SimpleResultInfo(com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo) ResultInfo(com.bakdata.conquery.models.query.resultinfo.ResultInfo)

Aggregations

SimpleResultInfo (com.bakdata.conquery.models.query.resultinfo.SimpleResultInfo)4 ResultInfo (com.bakdata.conquery.models.query.resultinfo.ResultInfo)3 ArrayList (java.util.ArrayList)2 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)1 Column (com.bakdata.conquery.models.datasets.Column)1 SecondaryIdDescription (com.bakdata.conquery.models.datasets.SecondaryIdDescription)1 UniqueNamer (com.bakdata.conquery.models.query.resultinfo.UniqueNamer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.jupiter.api.Test)1