use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class ConverterUtil method toTableDto.
/**
* Converts from TableInfo to TableDto.
*
* @param tableInfo connector table info
* @return table dto
*/
public TableDto toTableDto(final TableInfo tableInfo) {
final TableDto result = this.mapper.map(tableInfo, TableDto.class);
//TODO: Add this logic in the mapping
final List<FieldDto> fields = result.getFields();
if (fields != null) {
int index = 0;
for (final FieldDto field : fields) {
field.setPos(index++);
}
}
return result;
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class TagV1Resource method removeTableTags.
/**
* {@inheritDoc}
*/
@Override
public void removeTableTags(final String catalogName, final String databaseName, final String tableName, final Boolean deleteAll, final Set<String> tags) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
requestWrapper.processRequest(name, "TagV1Resource.removeTableTags", () -> {
if (!tableService.exists(name)) {
// Delete tags if exists
tagService.delete(name, false);
throw new TableNotFoundException(name);
}
final TableDto oldTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
tagService.removeTableTags(name, deleteAll, tags, true);
final TableDto currentTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
eventBus.postAsync(new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, oldTable, currentTable));
return null;
});
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class TagV1Resource method setTableTags.
/**
* {@inheritDoc}
*/
@Override
public Set<String> setTableTags(final String catalogName, final String databaseName, final String tableName, final Set<String> tags) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
return requestWrapper.processRequest(name, "TagV1Resource.setTableTags", () -> {
if (!tableService.exists(name)) {
throw new TableNotFoundException(name);
}
final TableDto oldTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
final Set<String> result = tagService.setTableTags(name, tags, true);
final TableDto currentTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
eventBus.postAsync(new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, oldTable, currentTable));
return result;
});
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class PartitionV1Resource method savePartitions.
/**
* {@inheritDoc}
*/
@Override
public PartitionsSaveResponseDto savePartitions(final String catalogName, final String databaseName, final String tableName, final String viewName, final PartitionsSaveRequestDto partitionsSaveRequestDto) {
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofView(catalogName, databaseName, tableName, viewName));
return requestWrapper.processRequest(name, "saveMViewPartition", () -> {
final PartitionsSaveResponseDto result;
if (partitionsSaveRequestDto == null || partitionsSaveRequestDto.getPartitions() == null || partitionsSaveRequestDto.getPartitions().isEmpty()) {
result = new PartitionsSaveResponseDto();
} else {
result = mViewService.savePartitions(name, partitionsSaveRequestDto, true);
// This metadata is actually for the view, if it is present update that
if (partitionsSaveRequestDto.getDefinitionMetadata() != null || partitionsSaveRequestDto.getDataMetadata() != null) {
final TableDto dto = v1.getMView(catalogName, databaseName, tableName, viewName);
dto.setDefinitionMetadata(partitionsSaveRequestDto.getDefinitionMetadata());
dto.setDataMetadata(partitionsSaveRequestDto.getDataMetadata());
v1.updateMView(catalogName, databaseName, tableName, viewName, dto);
}
}
return result;
});
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class MetacatElasticSearchEventHandlers method metacatUpdateTablePostEventHandler.
/**
* Subscriber.
*
* @param event event
*/
@EventListener
public void metacatUpdateTablePostEventHandler(final MetacatUpdateTablePostEvent event) {
log.debug("Received UpdateTableEvent {}", event);
registry.counter(Metrics.CounterElasticSearchTableUpdate.name()).increment();
final TableDto dto = event.getCurrentTable();
final ElasticSearchDoc doc = new ElasticSearchDoc(dto.getName().toString(), dto, event.getRequestContext().getUserName(), false);
final ElasticSearchDoc oldDoc = es.get(ElasticSearchDoc.Type.table.name(), doc.getId());
es.save(ElasticSearchDoc.Type.table.name(), doc.getId(), doc.toJsonString());
if (oldDoc == null || oldDoc.getDto() == null || !Objects.equals(((TableDto) oldDoc.getDto()).getDataMetadata(), dto.getDataMetadata())) {
updateEntitiesWithSameUri(ElasticSearchDoc.Type.table.name(), dto, event.getRequestContext());
}
}
Aggregations