Search in sources :

Example 1 with Identifiable

use of com.bakdata.conquery.models.identifiable.Identifiable in project conquery by bakdata.

the class AdminDatasetProcessor method deleteSecondaryId.

/**
 * Delete SecondaryId if it does not have any dependents.
 */
public synchronized void deleteSecondaryId(@NonNull SecondaryIdDescription secondaryId) {
    final Namespace namespace = datasetRegistry.get(secondaryId.getDataset().getId());
    // Before we commit this deletion, we check if this SecondaryId still has dependent Columns.
    final List<Column> dependents = namespace.getStorage().getTables().stream().map(Table::getColumns).flatMap(Arrays::stream).filter(column -> secondaryId.equals(column.getSecondaryId())).collect(Collectors.toList());
    if (!dependents.isEmpty()) {
        final Set<TableId> tables = dependents.stream().map(Column::getTable).map(Identifiable::getId).collect(Collectors.toSet());
        log.error("SecondaryId[{}] still present on {}", secondaryId, tables);
        throw new ForbiddenException(String.format("SecondaryId still has dependencies. %s", tables));
    }
    log.info("Deleting SecondaryId[{}]", secondaryId);
    namespace.getStorage().removeSecondaryId(secondaryId.getId());
    namespace.sendToAll(new RemoveSecondaryId(secondaryId));
}
Also used : Arrays(java.util.Arrays) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) SneakyThrows(lombok.SneakyThrows) RequiredArgsConstructor(lombok.RequiredArgsConstructor) EntityIdMap(com.bakdata.conquery.models.identifiable.mapping.EntityIdMap) Import(com.bakdata.conquery.models.datasets.Import) DictionaryId(com.bakdata.conquery.models.identifiable.ids.specific.DictionaryId) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) InternalOnly(com.bakdata.conquery.io.jackson.InternalOnly) RemoveImportJob(com.bakdata.conquery.models.messages.namespaces.specific.RemoveImportJob) NonNull(lombok.NonNull) Table(com.bakdata.conquery.models.datasets.Table) Concept(com.bakdata.conquery.models.datasets.concepts.Concept) RemoveConcept(com.bakdata.conquery.models.messages.namespaces.specific.RemoveConcept) Set(java.util.Set) Validator(javax.validation.Validator) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) RemoveSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.RemoveSecondaryId) Dataset(com.bakdata.conquery.models.datasets.Dataset) Objects(java.util.Objects) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription) JobManager(com.bakdata.conquery.models.jobs.JobManager) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) Jackson(com.bakdata.conquery.io.jackson.Jackson) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) Column(com.bakdata.conquery.models.datasets.Column) Namespace(com.bakdata.conquery.models.worker.Namespace) RemoveTable(com.bakdata.conquery.models.messages.namespaces.specific.RemoveTable) Getter(lombok.Getter) AddWorker(com.bakdata.conquery.models.messages.network.specific.AddWorker) UpdateTable(com.bakdata.conquery.models.messages.namespaces.specific.UpdateTable) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) UpdateSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.UpdateSecondaryId) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage) IdMutex(com.bakdata.conquery.models.identifiable.IdMutex) TableId(com.bakdata.conquery.models.identifiable.ids.specific.TableId) CsvParser(com.univocity.parsers.csv.CsvParser) UpdateMatchingStatsMessage(com.bakdata.conquery.models.messages.namespaces.specific.UpdateMatchingStatsMessage) Identifiable(com.bakdata.conquery.models.identifiable.Identifiable) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) ForbiddenException(javax.ws.rs.ForbiddenException) ImportJob(com.bakdata.conquery.models.jobs.ImportJob) IOException(java.io.IOException) ValidatorHelper(com.bakdata.conquery.models.exceptions.ValidatorHelper) UpdateConcept(com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept) ShardNodeInformation(com.bakdata.conquery.models.worker.ShardNodeInformation) StructureNode(com.bakdata.conquery.models.datasets.concepts.StructureNode) FilterSearch(com.bakdata.conquery.apiv1.FilterSearch) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) Collections(java.util.Collections) InputStream(java.io.InputStream) TableId(com.bakdata.conquery.models.identifiable.ids.specific.TableId) ForbiddenException(javax.ws.rs.ForbiddenException) RemoveSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.RemoveSecondaryId) Column(com.bakdata.conquery.models.datasets.Column) Arrays(java.util.Arrays) Namespace(com.bakdata.conquery.models.worker.Namespace)

Aggregations

FilterSearch (com.bakdata.conquery.apiv1.FilterSearch)1 InternalOnly (com.bakdata.conquery.io.jackson.InternalOnly)1 Jackson (com.bakdata.conquery.io.jackson.Jackson)1 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)1 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)1 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)1 Column (com.bakdata.conquery.models.datasets.Column)1 Dataset (com.bakdata.conquery.models.datasets.Dataset)1 Import (com.bakdata.conquery.models.datasets.Import)1 SecondaryIdDescription (com.bakdata.conquery.models.datasets.SecondaryIdDescription)1 Table (com.bakdata.conquery.models.datasets.Table)1 Concept (com.bakdata.conquery.models.datasets.concepts.Concept)1 Connector (com.bakdata.conquery.models.datasets.concepts.Connector)1 StructureNode (com.bakdata.conquery.models.datasets.concepts.StructureNode)1 ValidatorHelper (com.bakdata.conquery.models.exceptions.ValidatorHelper)1 IdMutex (com.bakdata.conquery.models.identifiable.IdMutex)1 Identifiable (com.bakdata.conquery.models.identifiable.Identifiable)1 ConceptId (com.bakdata.conquery.models.identifiable.ids.specific.ConceptId)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 DictionaryId (com.bakdata.conquery.models.identifiable.ids.specific.DictionaryId)1