Search in sources :

Example 1 with UpdateConcept

use of com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept in project conquery by bakdata.

the class AdminDatasetProcessor method addConcept.

/**
 * Add the concept to the dataset if it does not exist yet
 */
public synchronized void addConcept(@NonNull Dataset dataset, @NonNull Concept<?> concept) {
    concept.setDataset(dataset);
    ValidatorHelper.failOnError(log, validator.validate(concept));
    if (datasetRegistry.get(dataset.getId()).getStorage().hasConcept(concept.getId())) {
        throw new WebApplicationException("Can't replace already existing concept " + concept.getId(), Response.Status.CONFLICT);
    }
    final Namespace namespace = datasetRegistry.get(concept.getDataset().getId());
    // Register the Concept in the ManagerNode and Workers
    datasetRegistry.get(dataset.getId()).getStorage().updateConcept(concept);
    getJobManager().addSlowJob(new SimpleJob(String.format("sendToAll : Add %s ", concept.getId()), () -> namespace.sendToAll(new UpdateConcept(concept))));
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) UpdateConcept(com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept) Namespace(com.bakdata.conquery.models.worker.Namespace)

Aggregations

SimpleJob (com.bakdata.conquery.models.jobs.SimpleJob)1 UpdateConcept (com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept)1 Namespace (com.bakdata.conquery.models.worker.Namespace)1 WebApplicationException (javax.ws.rs.WebApplicationException)1