Search in sources :

Example 1 with MutableInjectableValues

use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.

the class FormConfigTest method setupTestClass.

@BeforeAll
public void setupTestClass() throws Exception {
    datasetId = dataset.getId();
    datasetId1 = dataset1.getId();
    // Mock DatasetRegistry for translation
    namespacesMock = Mockito.mock(DatasetRegistry.class);
    doAnswer(invocation -> {
        throw new UnsupportedOperationException("Not yet implemented");
    }).when(namespacesMock).getOptional(any());
    doAnswer(invocation -> {
        final DatasetId id = invocation.getArgument(0);
        Namespace namespaceMock = Mockito.mock(Namespace.class);
        if (id.equals(datasetId)) {
            when(namespaceMock.getDataset()).thenReturn(dataset);
        } else if (id.equals(datasetId1)) {
            when(namespaceMock.getDataset()).thenReturn(dataset1);
        } else {
            throw new IllegalStateException("Unkown dataset id.");
        }
        return namespaceMock;
    }).when(namespacesMock).get(any(DatasetId.class));
    when(namespacesMock.getAllDatasets()).thenReturn(List.of(dataset, dataset1));
    when(namespacesMock.injectIntoNew(any(ObjectMapper.class))).thenCallRealMethod();
    when(namespacesMock.inject(any(MutableInjectableValues.class))).thenCallRealMethod();
    storage = new NonPersistentStoreFactory().createMetaStorage();
    ((MutableInjectableValues) FormConfigProcessor.getMAPPER().getInjectableValues()).add(IdResolveContext.class, namespacesMock);
    processor = new FormConfigProcessor(validator, storage, namespacesMock);
    controller = new AuthorizationController(storage, new DevelopmentAuthorizationConfig());
    controller.start();
}
Also used : AuthorizationController(com.bakdata.conquery.models.auth.AuthorizationController) DevelopmentAuthorizationConfig(com.bakdata.conquery.models.config.auth.DevelopmentAuthorizationConfig) FormConfigProcessor(com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) NonPersistentStoreFactory(com.bakdata.conquery.util.NonPersistentStoreFactory) Namespace(com.bakdata.conquery.models.worker.Namespace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with MutableInjectableValues

use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.

the class SerializationTests method treeConcept.

@Test
public void treeConcept() throws IOException, JSONException {
    Dataset dataset = new Dataset();
    dataset.setName("datasetName");
    TreeConcept concept = new TreeConcept();
    concept.setDataset(dataset);
    concept.setLabel("conceptLabel");
    concept.setName("conceptName");
    Table table = new Table();
    Column column = new Column();
    column.setLabel("colLabel");
    column.setName("colName");
    column.setType(MajorTypeId.STRING);
    column.setTable(table);
    Column dateColumn = new Column();
    dateColumn.setLabel("colLabel2");
    dateColumn.setName("colName2");
    dateColumn.setType(MajorTypeId.DATE);
    dateColumn.setTable(table);
    table.setColumns(new Column[] { column, dateColumn });
    table.setDataset(dataset);
    table.setLabel("tableLabel");
    table.setName("tableName");
    column.setTable(table);
    ConceptTreeConnector connector = new ConceptTreeConnector();
    connector.setConcept(concept);
    connector.setLabel("connLabel");
    connector.setName("connName");
    connector.setColumn(column);
    concept.setConnectors(List.of(connector));
    ValidityDate valDate = new ValidityDate();
    valDate.setColumn(dateColumn);
    valDate.setConnector(connector);
    valDate.setLabel("valLabel");
    valDate.setName("valName");
    connector.setValidityDates(List.of(valDate));
    CentralRegistry registry = new CentralRegistry();
    registry.register(dataset);
    registry.register(concept);
    registry.register(column);
    registry.register(dateColumn);
    registry.register(table);
    registry.register(connector);
    registry.register(valDate);
    final Validator validator = Validators.newValidator();
    concept.setValidator(validator);
    SerializationTestUtil.forType(TreeConcept.class).registry(registry).injectables(new Injectable() {

        @Override
        public MutableInjectableValues inject(MutableInjectableValues values) {
            return values.add(Validator.class, validator);
        }
    }).test(concept);
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) ValidityDate(com.bakdata.conquery.models.datasets.concepts.ValidityDate) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Validator(javax.validation.Validator) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 3 with MutableInjectableValues

use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.

the class SerializationTests method table.

@Test
public void table() throws JSONException, IOException {
    Dataset dataset = new Dataset();
    dataset.setName("datasetName");
    Table table = new Table();
    Column column = new Column();
    column.setLabel("colLabel");
    column.setName("colName");
    column.setType(MajorTypeId.STRING);
    column.setTable(table);
    table.setColumns(new Column[] { column });
    table.setDataset(dataset);
    table.setLabel("tableLabel");
    table.setName("tableName");
    CentralRegistry registry = new CentralRegistry();
    registry.register(dataset);
    registry.register(table);
    registry.register(column);
    final Validator validator = Validators.newValidator();
    SerializationTestUtil.forType(Table.class).registry(registry).injectables(new Injectable() {

        @Override
        public MutableInjectableValues inject(MutableInjectableValues values) {
            return values.add(Validator.class, validator);
        }
    }).test(table);
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) Dataset(com.bakdata.conquery.models.datasets.Dataset) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Validator(javax.validation.Validator) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 4 with MutableInjectableValues

use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.

the class ShardNode method run.

@Override
protected void run(Environment environment, Namespace namespace, ConqueryConfig config) throws Exception {
    this.environment = environment;
    connector = new NioSocketConnector();
    jobManager = new JobManager(getName(), config.isFailOnError());
    synchronized (environment) {
        environment.lifecycle().manage(this);
        validator = environment.getValidator();
        scheduler = environment.lifecycle().scheduledExecutorService("Scheduled Messages").build();
    }
    this.config = config;
    config.initialize(this);
    scheduler.scheduleAtFixedRate(this::reportJobManagerStatus, 30, 1, TimeUnit.SECONDS);
    final ObjectMapper binaryMapper = config.configureObjectMapper(Jackson.copyMapperAndInjectables(Jackson.BINARY_MAPPER));
    ((MutableInjectableValues) binaryMapper.getInjectableValues()).add(Validator.class, environment.getValidator());
    workers = new Workers(getConfig().getQueries().getExecutionPool(), binaryMapper, getConfig().getCluster().getEntityBucketSize());
    final Collection<WorkerStorage> workerStorages = config.getStorage().loadWorkerStorages();
    for (WorkerStorage workerStorage : workerStorages) {
        workers.createWorker(workerStorage, config.isFailOnError());
    }
    log.info("All Worker Storages loaded: {}", workers.getWorkers().size());
}
Also used : NioSocketConnector(org.apache.mina.transport.socket.nio.NioSocketConnector) Workers(com.bakdata.conquery.models.worker.Workers) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) JobManager(com.bakdata.conquery.models.jobs.JobManager) WorkerStorage(com.bakdata.conquery.io.storage.WorkerStorage) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with MutableInjectableValues

use of com.bakdata.conquery.io.jackson.MutableInjectableValues in project conquery by bakdata.

the class SerializationTests method bucketCompoundDateRange.

@Test
public void bucketCompoundDateRange() throws JSONException, IOException {
    Dataset dataset = new Dataset();
    dataset.setName("datasetName");
    Table table = new Table();
    Column startCol = new Column();
    startCol.setName("startCol");
    startCol.setType(MajorTypeId.DATE);
    startCol.setTable(table);
    Column endCol = new Column();
    endCol.setLabel("endLabel");
    endCol.setName("endCol");
    endCol.setType(MajorTypeId.DATE);
    endCol.setTable(table);
    Column compoundCol = new Column();
    compoundCol.setName("compoundCol");
    compoundCol.setType(MajorTypeId.DATE_RANGE);
    compoundCol.setTable(table);
    table.setColumns(new Column[] { startCol, endCol, compoundCol });
    table.setDataset(dataset);
    table.setName("tableName");
    Import imp = new Import(table);
    imp.setName("importTest");
    DateRangeTypeCompound compoundStore = new DateRangeTypeCompound(startCol.getName(), endCol.getName(), new BitSetStore(BitSet.valueOf(new byte[] { 0b1000 }), new BitSet(), 4));
    // 0b1000 is a binary representation of 8 so that the 4th is set to make sure that BitSet length is 4.
    ColumnStore startStore = new IntegerDateStore(new ShortArrayStore(new short[] { 1, 2, 3, 4 }, Short.MIN_VALUE));
    ColumnStore endStore = new IntegerDateStore(new ShortArrayStore(new short[] { 5, 6, 7, 8 }, Short.MIN_VALUE));
    Bucket bucket = new Bucket(0, 1, 4, new ColumnStore[] { startStore, endStore, compoundStore }, Collections.emptySet(), new int[0], new int[0], imp);
    compoundStore.setParent(bucket);
    CentralRegistry registry = new CentralRegistry();
    registry.register(dataset);
    registry.register(startCol);
    registry.register(endCol);
    registry.register(compoundCol);
    registry.register(table);
    registry.register(imp);
    registry.register(bucket);
    final Validator validator = Validators.newValidator();
    SerializationTestUtil.forType(Bucket.class).registry(registry).injectables(new Injectable() {

        @Override
        public MutableInjectableValues inject(MutableInjectableValues values) {
            return values.add(Validator.class, validator);
        }
    }).test(bucket);
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Import(com.bakdata.conquery.models.datasets.Import) BitSetStore(com.bakdata.conquery.models.events.stores.primitive.BitSetStore) Dataset(com.bakdata.conquery.models.datasets.Dataset) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) BitSet(java.util.BitSet) ShortArrayStore(com.bakdata.conquery.models.events.stores.primitive.ShortArrayStore) DateRangeTypeCompound(com.bakdata.conquery.models.events.stores.specific.DateRangeTypeCompound) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) ColumnStore(com.bakdata.conquery.models.events.stores.root.ColumnStore) Column(com.bakdata.conquery.models.datasets.Column) Bucket(com.bakdata.conquery.models.events.Bucket) IntegerDateStore(com.bakdata.conquery.models.events.stores.primitive.IntegerDateStore) Validator(javax.validation.Validator) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Aggregations

MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)8 Injectable (com.bakdata.conquery.io.jackson.Injectable)4 Column (com.bakdata.conquery.models.datasets.Column)4 Dataset (com.bakdata.conquery.models.datasets.Dataset)4 Table (com.bakdata.conquery.models.datasets.Table)4 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)4 Validator (javax.validation.Validator)4 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)3 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Test (org.junit.jupiter.api.Test)3 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 CollectEntitiesCommand (com.bakdata.conquery.commands.CollectEntitiesCommand)1 MigrateCommand (com.bakdata.conquery.commands.MigrateCommand)1 PreprocessorCommand (com.bakdata.conquery.commands.PreprocessorCommand)1 RecodeStoreCommand (com.bakdata.conquery.commands.RecodeStoreCommand)1 ShardNode (com.bakdata.conquery.commands.ShardNode)1 StandaloneCommand (com.bakdata.conquery.commands.StandaloneCommand)1 InternalOnly (com.bakdata.conquery.io.jackson.InternalOnly)1