Search in sources :

Example 1 with UpdateTable

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

the class AdminDatasetProcessor method addTable.

/**
 * Add table to Dataset if it doesn't already exist.
 */
@SneakyThrows
public synchronized void addTable(@NonNull Table table, Namespace namespace) {
    Dataset dataset = namespace.getDataset();
    if (table.getDataset() == null) {
        table.setDataset(dataset);
    } else if (!table.getDataset().equals(dataset)) {
        throw new IllegalArgumentException();
    }
    if (namespace.getStorage().getTable(table.getId()) != null) {
        throw new WebApplicationException("Table already exists", Response.Status.CONFLICT);
    }
    ValidatorHelper.failOnError(log, validator.validate(table));
    namespace.getStorage().addTable(table);
    namespace.sendToAll(new UpdateTable(table));
}
Also used : UpdateTable(com.bakdata.conquery.models.messages.namespaces.specific.UpdateTable) WebApplicationException(javax.ws.rs.WebApplicationException) Dataset(com.bakdata.conquery.models.datasets.Dataset) SneakyThrows(lombok.SneakyThrows)

Aggregations

Dataset (com.bakdata.conquery.models.datasets.Dataset)1 UpdateTable (com.bakdata.conquery.models.messages.namespaces.specific.UpdateTable)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 SneakyThrows (lombok.SneakyThrows)1