Search in sources :

Example 1 with IId

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

the class IdDeserializer method createContextual.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    JavaType type = Optional.ofNullable(ctxt.getContextualType()).orElseGet(Optional.ofNullable(property).map(BeanProperty::getType)::get);
    while (type.isContainerType()) {
        type = type.getContentType();
    }
    Class<IId<?>> idClass = (Class<IId<?>>) type.getRawClass();
    Parser<IId<Identifiable<?>>> parser = IId.<IId<Identifiable<?>>>createParser((Class) idClass);
    return new IdDeserializer(idClass, parser, // we only need to check for the dataset prefix if the id requires it
    NamespacedId.class.isAssignableFrom(idClass));
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) NamespacedId(com.bakdata.conquery.models.identifiable.ids.NamespacedId) IId(com.bakdata.conquery.models.identifiable.ids.IId) BeanProperty(com.fasterxml.jackson.databind.BeanProperty)

Example 2 with IId

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

the class XodusStoreFactory method createDictionaryStore.

@Override
public IdentifiableStore<Dictionary> createDictionaryStore(CentralRegistry centralRegistry, String pathName) {
    final Environment environment = findEnvironment(pathName);
    final BigStore<IId<Dictionary>, Dictionary> bigStore;
    synchronized (openStoresInEnv) {
        bigStore = new BigStore<>(this, validator, environment, DICTIONARIES.storeInfo(), this::closeStore, this::removeStore, centralRegistry.injectIntoNew(objectMapper));
        openStoresInEnv.put(bigStore.getDataXodusStore().getEnvironment(), bigStore.getDataXodusStore());
        openStoresInEnv.put(bigStore.getMetaXodusStore().getEnvironment(), bigStore.getMetaXodusStore());
    }
    if (useWeakDictionaryCaching) {
        return StoreMappings.identifiableCachedStore(new WeakCachedStore<>(bigStore, getWeakCacheDuration()), centralRegistry);
    }
    return StoreMappings.identifiable(StoreMappings.cached(bigStore), centralRegistry);
}
Also used : Dictionary(com.bakdata.conquery.models.dictionary.Dictionary) IId(com.bakdata.conquery.models.identifiable.ids.IId) Environment(jetbrains.exodus.env.Environment)

Example 3 with IId

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

the class FrontEndConceptBuilder method createRoot.

public static FERoot createRoot(NamespaceStorage storage, Subject subject) {
    FERoot root = new FERoot();
    Map<IId<?>, FENode> roots = root.getConcepts();
    List<? extends Concept<?>> allConcepts = new ArrayList<>(storage.getAllConcepts());
    // Remove any hidden concepts
    allConcepts.removeIf(Concept::isHidden);
    if (allConcepts.isEmpty()) {
        log.warn("There are no displayable concepts in the dataset {}", storage.getDataset().getId());
    }
    // Submit all permissions to Shiro
    boolean[] isPermitted = subject.isPermitted(allConcepts, Ability.READ);
    for (int i = 0; i < allConcepts.size(); i++) {
        if (isPermitted[i]) {
            roots.put(allConcepts.get(i).getId(), createCTRoot(allConcepts.get(i), storage.getStructure()));
        }
    }
    if (roots.isEmpty()) {
        log.warn("No concepts could be collected for {} on dataset {}. The subject is possibly lacking the permission to use them.", subject.getId(), storage.getDataset().getId());
    } else {
        log.trace("Collected {} concepts for {} on dataset {}.", roots.size(), subject.getId(), storage.getDataset().getId());
    }
    // add the structure tree
    for (StructureNode sn : storage.getStructure()) {
        FENode node = createStructureNode(sn, roots);
        if (node == null) {
            log.trace("Did not create a structure node entry for {}. Contained no concepts.", sn.getId());
            continue;
        }
        roots.put(sn.getId(), node);
    }
    // add all secondary IDs
    root.getSecondaryIds().addAll(storage.getSecondaryIds().stream().map(sid -> new FESecondaryId(sid.getId().toString(), sid.getLabel(), sid.getDescription())).collect(Collectors.toSet()));
    return root;
}
Also used : IId(com.bakdata.conquery.models.identifiable.ids.IId) FENode(com.bakdata.conquery.apiv1.frontend.FENode) FERoot(com.bakdata.conquery.apiv1.frontend.FERoot) ArrayList(java.util.ArrayList) FESecondaryId(com.bakdata.conquery.apiv1.frontend.FESecondaryId)

Example 4 with IId

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

the class ConceptResolutionTest method execute.

@Override
public void execute(StandaloneSupport conquery) throws Exception {
    // read test sepcification
    String testJson = In.resource("/tests/query/SIMPLE_TREECONCEPT_QUERY/SIMPLE_TREECONCEPT_Query.test.json").withUTF8().readAll();
    DatasetId dataset = conquery.getDataset().getId();
    ConqueryTestSpec test = JsonIntegrationTest.readJson(dataset, testJson);
    ValidatorHelper.failOnError(log, conquery.getValidator().validate(test));
    test.importRequiredData(conquery);
    FilterSearch.updateSearch(conquery.getNamespace().getNamespaces(), Collections.singleton(conquery.getNamespace().getDataset()), conquery.getDatasetsProcessor().getJobManager(), conquery.getConfig().getCsv());
    conquery.waitUntilWorkDone();
    ConceptsProcessor processor = new ConceptsProcessor(conquery.getNamespace().getNamespaces());
    TreeConcept concept = (TreeConcept) conquery.getNamespace().getStorage().getAllConcepts().iterator().next();
    ResolvedConceptsResult resolved = processor.resolveConceptElements(concept, List.of("A1", "unknown"));
    // check the resolved values
    assertThat(resolved).isNotNull();
    assertThat(resolved.getResolvedConcepts().stream().map(IId::toString)).containsExactlyInAnyOrder("ConceptResolutionTest.test_tree.test_child1");
    assertThat(resolved.getUnknownCodes()).containsExactlyInAnyOrder("unknown");
}
Also used : IId(com.bakdata.conquery.models.identifiable.ids.IId) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) ConqueryTestSpec(com.bakdata.conquery.integration.json.ConqueryTestSpec) ConceptsProcessor(com.bakdata.conquery.resources.api.ConceptsProcessor) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) ResolvedConceptsResult(com.bakdata.conquery.resources.api.ConceptsProcessor.ResolvedConceptsResult)

Aggregations

IId (com.bakdata.conquery.models.identifiable.ids.IId)4 FENode (com.bakdata.conquery.apiv1.frontend.FENode)1 FERoot (com.bakdata.conquery.apiv1.frontend.FERoot)1 FESecondaryId (com.bakdata.conquery.apiv1.frontend.FESecondaryId)1 ConqueryTestSpec (com.bakdata.conquery.integration.json.ConqueryTestSpec)1 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)1 Dictionary (com.bakdata.conquery.models.dictionary.Dictionary)1 NamespacedId (com.bakdata.conquery.models.identifiable.ids.NamespacedId)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 ConceptsProcessor (com.bakdata.conquery.resources.api.ConceptsProcessor)1 ResolvedConceptsResult (com.bakdata.conquery.resources.api.ConceptsProcessor.ResolvedConceptsResult)1 BeanProperty (com.fasterxml.jackson.databind.BeanProperty)1 JavaType (com.fasterxml.jackson.databind.JavaType)1 ArrayList (java.util.ArrayList)1 Environment (jetbrains.exodus.env.Environment)1