Search in sources :

Example 1 with ConceptTreeChildId

use of com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId in project conquery by bakdata.

the class FrontEndConceptBuilder method createCTRoot.

private static FENode createCTRoot(Concept<?> c, StructureNode[] structureNodes) {
    MatchingStats matchingStats = c.getMatchingStats();
    StructureNodeId structureParent = Arrays.stream(structureNodes).filter(sn -> sn.getContainedRoots().contains(c.getId())).findAny().map(StructureNode::getId).orElse(null);
    FENode n = FENode.builder().active(true).description(c.getDescription()).label(c.getLabel()).additionalInfos(c.getAdditionalInfos()).matchingEntries(matchingStats.countEvents()).matchingEntities(matchingStats.countEntities()).dateRange(matchingStats.spanEvents() != null ? matchingStats.spanEvents().toSimpleRange() : null).detailsAvailable(Boolean.TRUE).codeListResolvable(c.countElements() > 1).parent(structureParent).selects(c.getSelects().stream().map(FrontEndConceptBuilder::createSelect).collect(Collectors.toList())).tables(c.getConnectors().stream().map(FrontEndConceptBuilder::createTable).collect(Collectors.toList())).build();
    if (c instanceof ConceptTreeNode) {
        ConceptTreeNode<?> tree = (ConceptTreeNode<?>) c;
        if (tree.getChildren() != null) {
            n.setChildren(tree.getChildren().stream().map(ConceptTreeChild::getId).toArray(ConceptTreeChildId[]::new));
        }
    }
    return n;
}
Also used : ConceptTreeChild(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeChild) Arrays(java.util.Arrays) IdentifiableImpl(com.bakdata.conquery.models.identifiable.IdentifiableImpl) Subject(com.bakdata.conquery.models.auth.entities.Subject) ArrayUtils(org.apache.commons.lang3.ArrayUtils) ConceptTreeNode(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeNode) IId(com.bakdata.conquery.models.identifiable.ids.IId) ArrayList(java.util.ArrayList) FEValidityDate(com.bakdata.conquery.apiv1.frontend.FEValidityDate) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage) Select(com.bakdata.conquery.models.datasets.concepts.select.Select) FERoot(com.bakdata.conquery.apiv1.frontend.FERoot) StructureNodeId(com.bakdata.conquery.models.identifiable.ids.specific.StructureNodeId) Map(java.util.Map) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) Nullable(javax.annotation.Nullable) Identifiable(com.bakdata.conquery.models.identifiable.Identifiable) ConceptConfigurationException(com.bakdata.conquery.models.exceptions.ConceptConfigurationException) FEValue(com.bakdata.conquery.apiv1.frontend.FEValue) FESecondaryId(com.bakdata.conquery.apiv1.frontend.FESecondaryId) Collectors(java.util.stream.Collectors) FEList(com.bakdata.conquery.apiv1.frontend.FEList) Objects(java.util.Objects) List(java.util.List) Filter(com.bakdata.conquery.models.datasets.concepts.filters.Filter) Slf4j(lombok.extern.slf4j.Slf4j) FETable(com.bakdata.conquery.apiv1.frontend.FETable) FENode(com.bakdata.conquery.apiv1.frontend.FENode) Ability(com.bakdata.conquery.models.auth.permissions.Ability) FEFilter(com.bakdata.conquery.apiv1.frontend.FEFilter) ConceptTreeChildId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId) AllArgsConstructor(lombok.AllArgsConstructor) FESelect(com.bakdata.conquery.apiv1.frontend.FESelect) Column(com.bakdata.conquery.models.datasets.Column) ConceptTreeNode(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeNode) FENode(com.bakdata.conquery.apiv1.frontend.FENode) ConceptTreeChild(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeChild) ConceptTreeChildId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId) StructureNodeId(com.bakdata.conquery.models.identifiable.ids.specific.StructureNodeId)

Example 2 with ConceptTreeChildId

use of com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId in project conquery by bakdata.

the class IdTests method testInterning.

@Test
public void testInterning() throws JsonParseException, JsonMappingException, JsonProcessingException, IOException {
    String raw = "1.concepts.2.3.4";
    ConceptTreeChildId id1 = ConceptTreeChildId.Parser.INSTANCE.parse(raw);
    ConceptTreeChildId id2 = ConceptTreeChildId.Parser.INSTANCE.parse(raw);
    assertThat(id1).isSameAs(id2);
    assertThat(id1.getParent()).isSameAs(id2.getParent());
    assertThat(id1.findConcept()).isSameAs(id2.findConcept());
    assertThat(id1.findConcept().getDataset()).isSameAs(id2.findConcept().getDataset());
}
Also used : ConceptTreeChildId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with ConceptTreeChildId

use of com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId in project conquery by bakdata.

the class IdTests method testEquals.

@Test
public void testEquals() {
    ConceptTreeChildId idA = new ConceptTreeChildId(new ConceptTreeChildId(new ConceptId(new DatasetId("1"), "2"), "3"), "4");
    ConceptTreeChildId idB = new ConceptTreeChildId(new ConceptTreeChildId(new ConceptId(new DatasetId("1"), "2"), "3"), "4");
    assertThat(idA).isEqualTo(idB);
    assertThat(idA).hasSameHashCodeAs(idB);
    assertThat(idA.toString()).isEqualTo(idB.toString());
}
Also used : ConceptTreeChildId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ConceptTreeChildId

use of com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId in project conquery by bakdata.

the class IdTests method testJacksonBinarySerialization.

@Test
public void testJacksonBinarySerialization() throws JsonParseException, JsonMappingException, JsonProcessingException, IOException {
    ConceptTreeChildId id = new ConceptTreeChildId(new ConceptTreeChildId(new ConceptId(new DatasetId("1"), "2"), "3"), "4");
    ObjectMapper mapper = Jackson.BINARY_MAPPER;
    ConceptTreeChildId copy = mapper.readValue(mapper.writeValueAsBytes(id), ConceptTreeChildId.class);
    assertThat(copy).isEqualTo(id);
    assertThat(copy).hasSameHashCodeAs(id);
    assertThat(copy.toString()).isEqualTo(id.toString());
}
Also used : ConceptTreeChildId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ConceptTreeChildId

use of com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId in project conquery by bakdata.

the class IdTests method testJacksonSerialization.

@Test
public void testJacksonSerialization() throws JsonParseException, JsonMappingException, JsonProcessingException, IOException {
    ConceptTreeChildId id = new ConceptTreeChildId(new ConceptTreeChildId(new ConceptId(new DatasetId("1"), "2"), "3"), "4");
    ObjectMapper mapper = Jackson.MAPPER;
    ConceptTreeChildId copy = mapper.readValue(mapper.writeValueAsBytes(id), ConceptTreeChildId.class);
    assertThat(copy).isEqualTo(id);
    assertThat(copy).hasSameHashCodeAs(id);
    assertThat(copy.toString()).isEqualTo(id.toString());
}
Also used : ConceptTreeChildId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ConceptTreeChildId (com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId)7 ConceptId (com.bakdata.conquery.models.identifiable.ids.specific.ConceptId)5 Test (org.junit.jupiter.api.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)4 FENode (com.bakdata.conquery.apiv1.frontend.FENode)2 ConceptTreeNode (com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeNode)2 IdentifiableImpl (com.bakdata.conquery.models.identifiable.IdentifiableImpl)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 FEFilter (com.bakdata.conquery.apiv1.frontend.FEFilter)1 FEList (com.bakdata.conquery.apiv1.frontend.FEList)1 FERoot (com.bakdata.conquery.apiv1.frontend.FERoot)1 FESecondaryId (com.bakdata.conquery.apiv1.frontend.FESecondaryId)1 FESelect (com.bakdata.conquery.apiv1.frontend.FESelect)1 FETable (com.bakdata.conquery.apiv1.frontend.FETable)1 FEValidityDate (com.bakdata.conquery.apiv1.frontend.FEValidityDate)1 FEValue (com.bakdata.conquery.apiv1.frontend.FEValue)1 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)1 Subject (com.bakdata.conquery.models.auth.entities.Subject)1 Ability (com.bakdata.conquery.models.auth.permissions.Ability)1