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