use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.
the class StandaloneSupport method preprocessTmp.
public void preprocessTmp(File tmpDir, List<File> descriptions) throws Exception {
final Environment env = testConquery.getDropwizard().getEnvironment();
final net.sourceforge.argparse4j.inf.Namespace namespace = new net.sourceforge.argparse4j.inf.Namespace(Map.of("in", tmpDir, "out", tmpDir, "desc", descriptions));
// We use this to change the visibility of the run method, hence it cannot be instantiated.
new PreprocessorCommand(MoreExecutors.newDirectExecutorService()) {
@Override
public void run(Environment environment, net.sourceforge.argparse4j.inf.Namespace namespace, ConqueryConfig config) throws Exception {
super.run(environment, namespace, config);
}
}.run(env, namespace, config);
}
use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.
the class AdminDatasetProcessor method deleteTable.
/**
* Deletes a table if it has no dependents or not forced to do so.
*/
public synchronized List<ConceptId> deleteTable(Table table, boolean force) {
final Namespace namespace = datasetRegistry.get(table.getDataset().getId());
final List<Concept<?>> dependentConcepts = namespace.getStorage().getAllConcepts().stream().flatMap(c -> c.getConnectors().stream()).filter(con -> con.getTable().equals(table)).map(Connector::getConcept).collect(Collectors.toList());
if (force || dependentConcepts.isEmpty()) {
for (Concept<?> concept : dependentConcepts) {
deleteConcept(concept);
}
namespace.getStorage().getAllImports().stream().filter(imp -> imp.getTable().equals(table)).forEach(this::deleteImport);
namespace.getStorage().removeTable(table.getId());
namespace.sendToAll(new RemoveTable(table));
}
return dependentConcepts.stream().map(Concept::getId).collect(Collectors.toList());
}
use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.
the class AdminDatasetProcessor method deleteImport.
/**
* Deletes an import.
*/
public synchronized void deleteImport(Import imp) {
final Namespace namespace = datasetRegistry.get(imp.getTable().getDataset().getId());
namespace.getStorage().removeImport(imp.getId());
namespace.sendToAll(new RemoveImportJob(imp));
// Remove bucket assignments for consistency report
namespace.removeBucketAssignmentsForImportFormWorkers(imp);
}
use of com.bakdata.conquery.models.worker.Namespace 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))));
}
use of com.bakdata.conquery.models.worker.Namespace 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));
}
Aggregations